create-pmos 0.484.0 → 0.486.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 -27
- package/payload/AGENTS.md +2 -0
- 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/changelog.json +26 -0
- package/workspace/lib/routes-boards.js +37 -8
- package/workspace/lib/routes-report-structure.js +12 -2
- package/workspace/lib/task-cli.js +6 -5
- package/workspace/lib/task-store.js +173 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/server.js +2 -2
- package/workspace/test-lists/initiative-tasks.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.486.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,32 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.486.0",
|
|
37
|
+
"at": "2026-11-02T03:54:59.832Z",
|
|
38
|
+
"f": 3,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1146,
|
|
42
|
+
"t": "An initiative owns its tasks; the Board reads them (D104, batch 22 item 21)",
|
|
43
|
+
"s": "An initiative owns its tasks; the Board reads them",
|
|
44
|
+
"k": "new"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"v": "0.485.0",
|
|
50
|
+
"at": "2026-11-02T02:54:02.793Z",
|
|
51
|
+
"f": 3,
|
|
52
|
+
"prs": [
|
|
53
|
+
{
|
|
54
|
+
"n": 1145,
|
|
55
|
+
"t": "Task dates read through pmos (item 19); a report draft says why it ended (item 20)",
|
|
56
|
+
"s": "Task dates read through pmos (item 19); a report draft says why it ended (item 20)",
|
|
57
|
+
"k": "fix"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
},
|
|
35
61
|
{
|
|
36
62
|
"v": "0.484.0",
|
|
37
63
|
"at": "2026-11-02T02:00:11.221Z",
|
|
@@ -269,32 +295,6 @@
|
|
|
269
295
|
"k": "x"
|
|
270
296
|
}
|
|
271
297
|
]
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
"v": "0.466.0",
|
|
275
|
-
"at": "2026-10-31T06:47:06.602Z",
|
|
276
|
-
"f": 3,
|
|
277
|
-
"prs": [
|
|
278
|
-
{
|
|
279
|
-
"n": 1118,
|
|
280
|
-
"t": "Board-publish slice 1 — the data pack and the Board's read-only mode",
|
|
281
|
-
"s": "Board-publish slice 1 — the data pack and the Board's read-only mode",
|
|
282
|
-
"k": "new"
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"v": "0.465.0",
|
|
288
|
-
"at": "2026-10-31T03:26:05.595Z",
|
|
289
|
-
"f": 3,
|
|
290
|
-
"prs": [
|
|
291
|
-
{
|
|
292
|
-
"n": 1117,
|
|
293
|
-
"t": "A folder with no profile file and no code is a document repository (D68)",
|
|
294
|
-
"s": "A folder with no profile file and no code is a document repository",
|
|
295
|
-
"k": "new"
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
298
|
}
|
|
299
299
|
]
|
|
300
300
|
}
|
package/payload/AGENTS.md
CHANGED
|
@@ -52,6 +52,8 @@ It refuses frontmatter, fenced and indented code, table rows, headings, delibera
|
|
|
52
52
|
|
|
53
53
|
State files are **append-only**: never rewrite or delete an existing line or initiative record; correct by appending. When a vendored skill names a hosted tool, apply this table — the skill bodies are single-sourced from the PMOS kernel and are not forked for file mode.
|
|
54
54
|
|
|
55
|
+
**Read current state through `pmos`, never from a ledger line.** A `.jsonl` ledger is a log of changes: a later line replaces an earlier one, so its first line for a task can hold dates that were changed long ago. Read an initiative's tasks, with the state and the start and due day the Board timeline shows, with `pmos task list <initiative> --all` (add `--json` for fields). Read the Board with `pmos board`, and initiatives with `pmos initiative list`. Never quote a date, owner or state that you read from `boards.jsonl` or another ledger by hand. When `pmos` cannot answer, say so; do not fall back to the raw file.
|
|
56
|
+
|
|
55
57
|
## Work-type lanes (D56)
|
|
56
58
|
|
|
57
59
|
Every initiative carries a `type` — the lane picks what the gate requires **before** work; the kernel (anchor — a KR **or** `health:<id>` from `planning/okrs/health-budgets.md` (D59) — eval-before-work in lane-appropriate form, human Acceptance, append-only state) holds in every lane. Unknown/missing type = `feature`, the strictest lane. The enum is closed — never invent a lane; a work shape with no lane escalates to the PM.
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-02T03:54:56Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-02T03:54:56Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-02T03:54:56Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.486.0",
|
|
4
|
+
"at": "2026-11-02T03:54:59.832Z",
|
|
5
|
+
"f": 3,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1146,
|
|
9
|
+
"t": "An initiative owns its tasks; the Board reads them (D104, batch 22 item 21)",
|
|
10
|
+
"s": "An initiative owns its tasks; the Board reads them",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.485.0",
|
|
17
|
+
"at": "2026-11-02T02:54:02.793Z",
|
|
18
|
+
"f": 3,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1145,
|
|
22
|
+
"t": "Task dates read through pmos (item 19); a report draft says why it ended (item 20)",
|
|
23
|
+
"s": "Task dates read through pmos (item 19); a report draft says why it ended (item 20)",
|
|
24
|
+
"k": "fix"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.484.0",
|
|
4
30
|
"at": "2026-11-02T02:00:11.221Z",
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
*
|
|
61
61
|
* STATE. <stateDirFor(w)>/boards.jsonl, append-only, one per repository. With no state folder the reads use the
|
|
62
62
|
* defaults and every write answers 409 with the reason (stateDirFor is called without `create`).
|
|
63
|
+
* An initiative's tasks are not the Board's (D104): their lines live in the initiative ledger initiative-tasks.jsonl (lib/task-store.js),
|
|
64
|
+
* and readLedger merges them in, so every fold below reads them as before.
|
|
63
65
|
*
|
|
64
66
|
* ROWS come from lib/initiative-rows.js rowsFor (the cached derivation; never a scan per request) and the Roadmap row
|
|
65
67
|
* of routes-initiatives.js rowOf, mapped to the PRD row and cached per repository by the read signature. Until the first
|
|
@@ -93,6 +95,7 @@ const B = require(repoScript('boards.js'));
|
|
|
93
95
|
const WF = require(repoScript('workflows.js'));
|
|
94
96
|
const WS = require('./workflows-store.js');
|
|
95
97
|
const TI = require('./task-items.js');
|
|
98
|
+
const TS = require('./task-store.js');
|
|
96
99
|
const holdSpans = require('./hold-spans.js');
|
|
97
100
|
const ledgers = require('./plan-ledgers.js');
|
|
98
101
|
const intake = require(repoScript('intake.js'));
|
|
@@ -106,28 +109,54 @@ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
|
106
109
|
const today = () => new Date().toISOString().slice(0, 10);
|
|
107
110
|
|
|
108
111
|
// ── the ledger ────────────────────────────────────────────────────────────────────────────────────
|
|
112
|
+
/* D104 (feedback batch 22 item 21): an initiative's tasks are the initiative's. Their lines live in the initiative ledger
|
|
113
|
+
* (initiative-tasks.jsonl, beside plan-items.jsonl: lib/task-store.js), and boards.jsonl keeps the Board's own lines. readLedger hands every reader both, merged by
|
|
114
|
+
* time, so a fold of the Board sees the initiative's tasks and no list of its own; append sends a task line to the initiative ledger.
|
|
115
|
+
* The first read after the change moves the task lines boards.jsonl still holds (task-store migrate: copied as their exact text, checked,
|
|
116
|
+
* nothing in boards.jsonl changed). */
|
|
117
|
+
const rootOfFile = new Map(); // boards.jsonl path -> the repository root its tasks belong to (set by ledgerFile)
|
|
109
118
|
function ledgerFile(ctx, w) {
|
|
110
119
|
const d = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
111
|
-
|
|
120
|
+
const f = d ? path.join(d, LEDGER) : null;
|
|
121
|
+
if (f && w && w.root) rootOfFile.set(f, w.root);
|
|
122
|
+
return f;
|
|
112
123
|
}
|
|
113
|
-
// The ledger's lines, read again only when its stat changes (a write shows on the next read). The lines are
|
|
114
|
-
// caller folds them into objects of its own, so nothing a caller changes reaches the memo.
|
|
124
|
+
// The ledger's lines, read again only when its stat (or the initiative ledger's) changes (a write shows on the next read). The lines are
|
|
125
|
+
// strings; every caller folds them into objects of its own, so nothing a caller changes reaches the memo.
|
|
115
126
|
const ledgerMemo = new Map(); // file -> { key, lines }
|
|
127
|
+
const warnedMove = new Set(); // a boards.jsonl whose task lines could not be moved, said once per server
|
|
128
|
+
const statKey = (f) => { try { const st = fs.statSync(f); return `${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`; } catch { return '-'; } };
|
|
129
|
+
function readBoardLines(f) {
|
|
130
|
+
try { return fs.readFileSync(f, 'utf8').split('\n').filter(Boolean); } catch { return []; }
|
|
131
|
+
}
|
|
116
132
|
function readLedger(ctx, w) {
|
|
117
133
|
const f = ledgerFile(ctx, w);
|
|
118
134
|
if (!f) return [];
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
const store = TS.storeFor(w && w.root);
|
|
136
|
+
const key = statKey(f) + '|' + (store ? statKey(store.file) : 'none');
|
|
121
137
|
const hit = ledgerMemo.get(f);
|
|
122
138
|
if (hit && hit.key === key) return hit.lines.slice();
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
const board = readBoardLines(f);
|
|
140
|
+
let lines = board;
|
|
141
|
+
if (store) {
|
|
142
|
+
const tasks = TS.readStore(w.root);
|
|
143
|
+
if (tasks) {
|
|
144
|
+
const v = TS.view(board, tasks);
|
|
145
|
+
if (v.pending.length) {
|
|
146
|
+
const m = TS.migrate(w.root, board, B);
|
|
147
|
+
if (!m.ok && !warnedMove.has(f)) { warnedMove.add(f); console.warn(`[boards] ${f}: ${m.error}`); }
|
|
148
|
+
lines = m.lines;
|
|
149
|
+
} else lines = v.lines;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
125
152
|
if (ledgerMemo.size > 100) ledgerMemo.clear();
|
|
126
|
-
ledgerMemo.set(f, { key, lines });
|
|
153
|
+
ledgerMemo.set(f, { key: statKey(f) + '|' + (store ? statKey(store.file) : 'none'), lines });
|
|
127
154
|
return lines.slice();
|
|
128
155
|
}
|
|
129
156
|
function append(file, actor, ev) {
|
|
130
157
|
const line = { at: new Date().toISOString(), by: actor.by, ...ev };
|
|
158
|
+
// a task line is the initiative's (D104): it goes to the initiative ledger; only when that ledger cannot be placed does it stay here
|
|
159
|
+
if (TS.isTaskKind(line.kind) && rootOfFile.has(file) && TS.write(rootOfFile.get(file), line)) return line;
|
|
131
160
|
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
132
161
|
return line;
|
|
133
162
|
}
|
|
@@ -588,6 +588,14 @@ function landedSince(root, id, since) {
|
|
|
588
588
|
return hit ? { slot: hit.f.replace(/\.md$/, ''), path: `${p.rel}/${hit.f}` } : null;
|
|
589
589
|
} catch { return null; }
|
|
590
590
|
}
|
|
591
|
+
/** Why a drafting run ended with no draft, in the PM's words, from the run's outcome (lib/headless.js outcomeOf) when there is one. Pure. */
|
|
592
|
+
function endedWhy(out) {
|
|
593
|
+
const clip = (t) => String(t || '').replace(/\s+/g, ' ').trim().slice(0, 280);
|
|
594
|
+
if (out && Array.isArray(out.denied) && out.denied.length) return `The drafting run was not allowed to use ${out.denied.slice(0, 3).map(clip).join(', ')}, so it wrote no draft. Press Draft it now to try again.`;
|
|
595
|
+
if (out && out.ok === false && out.why) return `The drafting run stopped: ${clip(out.why)}`;
|
|
596
|
+
if (out && out.ok && out.headline) return `The drafting run finished without writing a draft. It said: "${clip(out.headline)}"`;
|
|
597
|
+
return 'The drafting session ended before a draft was written. Press Draft it now to try again.';
|
|
598
|
+
}
|
|
591
599
|
/**
|
|
592
600
|
* What a row shows for a report's draft: null, or { state: 'drafting' | 'held' | 'ended', since, saved, sources?, session?, reason? }.
|
|
593
601
|
* A held draft waits for a Chrome or computer check; an ended one lost its session before a draft landed.
|
|
@@ -607,7 +615,9 @@ function draftState(ctx, w, id) {
|
|
|
607
615
|
if (landedSince(root, id, m.since)) { try { fs.unlinkSync(draftingFile(root, id)); } catch { /* gone */ } return null; }
|
|
608
616
|
const alive = m.session && typeof ctx.sessionAlive === 'function' ? ctx.sessionAlive(m.session) : true;
|
|
609
617
|
if (!alive) {
|
|
610
|
-
|
|
618
|
+
// say why it ended (batch 22 item 20, Wawan: "It never reach draft successful state"): the run's own outcome, not a bare retry
|
|
619
|
+
const out = typeof ctx.sessionOutcome === 'function' ? ctx.sessionOutcome(m.session) : null;
|
|
620
|
+
const o = { ...m, ended: true, reason: endedWhy(out) };
|
|
611
621
|
try { fs.writeFileSync(draftingFile(root, id), JSON.stringify(o) + '\n'); } catch { /* shown again next time */ }
|
|
612
622
|
return { state: 'ended', since: m.since, saved: m.saved, reason: o.reason };
|
|
613
623
|
}
|
|
@@ -806,5 +816,5 @@ async function handle(req, res, url, ctx) {
|
|
|
806
816
|
return send(bad(404, 'no such route'));
|
|
807
817
|
}
|
|
808
818
|
|
|
809
|
-
module.exports = { prefixes: ['/api/report-structure', '/api/charts'], handle, sweep, beforeDraft, draftBlock, draftNow, draftState, markDrafting, startCheck, settleChecks, readHold, savedPlan, computerRule, resultJson, promptFor,
|
|
819
|
+
module.exports = { prefixes: ['/api/report-structure', '/api/charts'], handle, sweep, beforeDraft, draftBlock, draftNow, draftState, endedWhy, markDrafting, startCheck, settleChecks, readHold, savedPlan, computerRule, resultJson, promptFor,
|
|
810
820
|
_jobs: jobs, _checks: checkJobs, _pulls: pullJobs };
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* place tasks under a workflow stage of their initiative, or change their dates, owner or notes, by the same function as the Viewer's
|
|
10
10
|
* edit (lib/routes-boards.js taskEdit, POST /api/boards/tasks/edit). The Tasks section groups tasks by stage (feedback batch 6:
|
|
11
11
|
* an agent asked to group tasks by stage had no command for it).
|
|
12
|
-
* pmos task list <initiative> [--all] its open tasks (To do, In progress); --all adds Done, Won't do and Archived
|
|
12
|
+
* pmos task list <initiative> [--all] its open tasks (To do, In progress); --all adds Done, Won't do and Archived.
|
|
13
|
+
* Each line carries the start and due day the Board timeline shows: the folded ledger, where a later edit replaces an earlier line.
|
|
13
14
|
* pmos task state <task> [<task> …] --to <state> [--why <text>]
|
|
14
15
|
* set each task's state: To do, In progress, Done, Won't do or Archived, by the same function as the Board's press
|
|
15
16
|
* (lib/routes-boards.js taskState, POST /api/boards/tasks/state), with the agent as the writer.
|
|
@@ -43,7 +44,7 @@ const USAGE = [
|
|
|
43
44
|
' --milestone makes a task a milestone: its due date shows as ◇ on the Board and the timeline. Set it only when the PM asks.',
|
|
44
45
|
' --pin shows a milestone on the Board timeline, --no-pin hides it, --pin-default goes back to the rule (the last milestone',
|
|
45
46
|
' shows). Set it only when the PM asks.',
|
|
46
|
-
' pmos task list <initiative> [--all] its open tasks; --all adds Done, Won\'t do and Archived',
|
|
47
|
+
' pmos task list <initiative> [--all] its open tasks, with the start and due day the Board shows; --all adds Done, Won\'t do and Archived',
|
|
47
48
|
' pmos task remove <task> [<task> …] [--why <text>]',
|
|
48
49
|
' Delete a task added by mistake (a placeholder, a duplicate) when the PM asks. It goes from every list; the page\'s Undo brings',
|
|
49
50
|
' it back. Work that stopped is Archived or Won\'t do instead. A breakdown item is not deleted: set it to Won\'t do.',
|
|
@@ -105,7 +106,7 @@ function boardsCtx(root, stateDir) {
|
|
|
105
106
|
const w = { id: driver.wsIdOf(root), name: path.basename(root), root };
|
|
106
107
|
return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') } };
|
|
107
108
|
}
|
|
108
|
-
const line = (t) => `${t.id} · ${t.state} · ${t.title}${t.kind === 'Epic' ? ' (epic)' : ''}${t.milestone ? ' · ◇ milestone' : ''}${t.pinned === true ? ' · pinned' : t.pinned === false ? ' · not pinned' : ''}${t.stage ? ' · under ' + t.stage : ''}${t.due ? ' · due ' + t.due : ''}`;
|
|
109
|
+
const line = (t) => `${t.id} · ${t.state} · ${t.title}${t.kind === 'Epic' ? ' (epic)' : ''}${t.milestone ? ' · ◇ milestone' : ''}${t.pinned === true ? ' · pinned' : t.pinned === false ? ' · not pinned' : ''}${t.stage ? ' · under ' + t.stage : ''}${t.start ? ' · starts ' + String(t.start).slice(0, 10) : ''}${t.due ? ' · due ' + String(t.due).slice(0, 10) : ''}`;
|
|
109
110
|
/** The workflow row of an initiative, deriving the rows when they are still being read. */
|
|
110
111
|
function rowOf(boards, ctx, w, id) {
|
|
111
112
|
let r = boards.initiativeWorkflow(ctx, w, id);
|
|
@@ -151,7 +152,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
151
152
|
const msOf = (tid, own) => (MS.has(tid) ? MS.get(tid) : !!own); // the PM's ◇ flag (feedback batch 11 item 3)
|
|
152
153
|
const stageOf = (tid, from) => (S.has(tid) ? S.get(tid) : (from && from.stage) || ''); // the group the Tasks section shows it under
|
|
153
154
|
const own = [...(F.tasks || new Map()).values()].filter((t) => t.initiative === id).map((t) => ({ ...t, stage: stageOf(t.id, t.from), milestone: msOf(t.id), ...pinOf(t.id) }));
|
|
154
|
-
const items = TI.rowsOf(root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, due: x.end, store: 'item', stage: stageOf(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
|
|
155
|
+
const items = TI.rowsOf(root, new Set([id]), board).map((x) => ({ id: x.uid, board, kind: 'Task', title: x.title, state: x.status, owner: x.owner, start: x.start || null, due: x.end, store: 'item', stage: stageOf(x.uid), milestone: msOf(x.uid, x.milestone), ...pinOf(x.uid) }));
|
|
155
156
|
return own.concat(items);
|
|
156
157
|
};
|
|
157
158
|
|
|
@@ -182,7 +183,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
182
183
|
try { boards.seedInitiative(ctx, w, id); } catch { /* the To finish tasks are made on the next read */ }
|
|
183
184
|
const all = tasksOf(id);
|
|
184
185
|
const shown = flags.all ? all : all.filter((t) => OPEN.has(t.state));
|
|
185
|
-
if (json) { say(JSON.stringify({ ok: true, tasks: shown.map((t) => ({ id: t.id, board: t.board, kind: t.kind, title: t.title, state: t.state, owner: t.owner, due: t.due, stage: t.stage || '', ...(t.milestone ? { milestone: true } : {}), ...(typeof t.pinned === 'boolean' ? { pinned: t.pinned } : {}), ...(t.from ? { from: t.from } : {}) })) })); return 0; }
|
|
186
|
+
if (json) { say(JSON.stringify({ ok: true, tasks: shown.map((t) => ({ id: t.id, board: t.board, kind: t.kind, title: t.title, state: t.state, owner: t.owner, start: t.start || null, due: t.due, stage: t.stage || '', ...(t.milestone ? { milestone: true } : {}), ...(typeof t.pinned === 'boolean' ? { pinned: t.pinned } : {}), ...(t.from ? { from: t.from } : {}) })) })); return 0; }
|
|
186
187
|
if (!shown.length) { say(all.length ? `No open task on ${id}. --all lists the ${all.length} closed.` : `No task on ${id}.`); return 0; }
|
|
187
188
|
for (const t of shown) say(line(t));
|
|
188
189
|
return 0;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* task-store.js — an initiative's tasks belong to the initiative (D104, feedback batch 22 item 21).
|
|
3
|
+
*
|
|
4
|
+
* Wawan (2026-11-02): "the initiative task breakdown should belong to the initiative. If board want to show it, use the original source
|
|
5
|
+
* which is from initiative". Before D104 an initiative's tasks had two homes: Board tasks were lines of boards.jsonl (the Board's own
|
|
6
|
+
* ledger) and breakdown items were lines of the initiative ledger, plan-items.jsonl. Now every task line lives in the initiative ledger,
|
|
7
|
+
* and the Board keeps no task list of its own: it reads the initiative's.
|
|
8
|
+
*
|
|
9
|
+
* LEDGER · TASK_KINDS · isTaskKind(kind) → the file name, and the line kinds that are task lines
|
|
10
|
+
* storeFor(root) → the initiative ledger of a repository, or null when it cannot be resolved (no workflow engine)
|
|
11
|
+
* view(boardLines, storeLines) → { lines, pending }: what the Board folds (its own lines without the tasks that moved, and the
|
|
12
|
+
* initiative's task lines, merged by time) and the task lines still only in boards.jsonl
|
|
13
|
+
* migrate(root, boardLines, B) → { ok, moved, lines } — the one-time move of boards.jsonl's task lines (see MIGRATION)
|
|
14
|
+
* write(root, line) → true when the task line went to the initiative ledger, false when that ledger is unavailable
|
|
15
|
+
* snapshot(folded) → the task part of a scripts/boards.js fold as plain JSON (what the migration compares)
|
|
16
|
+
*
|
|
17
|
+
* MIGRATION. A task line of boards.jsonl is copied, as its exact text, to the initiative ledger. Nothing in boards.jsonl is changed or
|
|
18
|
+
* removed: a Board line counts as moved when the same text is in the initiative ledger (one copy for each), so running the move again
|
|
19
|
+
* copies nothing, and a task line an older PMOS still writes to boards.jsonl moves on the next read. The move is checked before it
|
|
20
|
+
* counts: the tasks, their places, milestones, pins and orders are folded the old way and the new way, and when the two are not the same
|
|
21
|
+
* the copy is cut off the ledger again and the Board keeps reading boards.jsonl (the answer says why). A lock file keeps two servers from
|
|
22
|
+
* copying at once.
|
|
23
|
+
*
|
|
24
|
+
* What stays where: a task's Jira link is task-links.jsonl (keyed by the task id, unchanged); a stage's To finish entries, workflows,
|
|
25
|
+
* moves, asks and every other Board line stay in boards.jsonl. Task ids do not change, so every record that names a task still finds it. */
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const ledgers = require('./plan-ledgers.js');
|
|
29
|
+
|
|
30
|
+
const LEDGER = 'initiative-tasks.jsonl';
|
|
31
|
+
const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order']);
|
|
32
|
+
const KINDS = new Set(TASK_KINDS);
|
|
33
|
+
const isTaskKind = (k) => KINDS.has(k);
|
|
34
|
+
const isTaskLine = (r) => !!r && typeof r === 'object' && !Array.isArray(r) && isTaskKind(r.kind);
|
|
35
|
+
const LOCK_STALE_MS = 60 * 1000;
|
|
36
|
+
|
|
37
|
+
/** The initiative ledger of `root`: { root, file }, or null (no workflow engine to place it). */
|
|
38
|
+
function storeFor(root) {
|
|
39
|
+
if (!root) return null;
|
|
40
|
+
try { return { root, file: path.join(ledgers.runsDir(root), LEDGER) }; } catch { return null; }
|
|
41
|
+
}
|
|
42
|
+
/** The task lines of the initiative ledger as their own text, in file order; [] when there is no file yet; null when it cannot be read. */
|
|
43
|
+
const memo = new Map(); // file -> { key, lines }
|
|
44
|
+
function readStore(root) {
|
|
45
|
+
const s = storeFor(root);
|
|
46
|
+
if (!s) return null;
|
|
47
|
+
let st;
|
|
48
|
+
try { st = fs.statSync(s.file); } catch (e) { return e && e.code === 'ENOENT' ? [] : null; }
|
|
49
|
+
if (!st.isFile()) return null;
|
|
50
|
+
const key = `${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`;
|
|
51
|
+
const hit = memo.get(s.file);
|
|
52
|
+
if (hit && hit.key === key) return hit.lines.slice();
|
|
53
|
+
let text;
|
|
54
|
+
try { text = fs.readFileSync(s.file, 'utf8'); } catch { return null; }
|
|
55
|
+
const lines = [];
|
|
56
|
+
for (const raw0 of text.split('\n')) {
|
|
57
|
+
const raw = raw0.replace(/\r$/, '').trim();
|
|
58
|
+
if (!raw) continue;
|
|
59
|
+
let r;
|
|
60
|
+
try { r = JSON.parse(raw); } catch { continue; } // a torn line has no effect, as in boards.jsonl
|
|
61
|
+
if (isTaskLine(r)) lines.push(raw);
|
|
62
|
+
}
|
|
63
|
+
if (memo.size > 200) memo.clear();
|
|
64
|
+
memo.set(s.file, { key, lines });
|
|
65
|
+
return lines.slice();
|
|
66
|
+
}
|
|
67
|
+
/** Append task lines (objects or their JSON text), in order. Refuses a line that is not a task line. → { file, size } (the size before) */
|
|
68
|
+
function appendLines(root, lines) {
|
|
69
|
+
const s = storeFor(root);
|
|
70
|
+
if (!s) throw new Error('the initiative ledger cannot be placed (no workflow engine)');
|
|
71
|
+
const out = [];
|
|
72
|
+
for (const l of lines || []) {
|
|
73
|
+
const r = typeof l === 'string' ? JSON.parse(l) : l;
|
|
74
|
+
if (!isTaskLine(r)) throw new Error('not a task line: ' + String(r && r.kind).slice(0, 40));
|
|
75
|
+
out.push(typeof l === 'string' ? l.trim() : JSON.stringify(l));
|
|
76
|
+
}
|
|
77
|
+
fs.mkdirSync(path.dirname(s.file), { recursive: true });
|
|
78
|
+
let size = 0;
|
|
79
|
+
try { size = fs.statSync(s.file).size; } catch { size = 0; }
|
|
80
|
+
// a last line with no newline (a torn write) must not swallow the first new line
|
|
81
|
+
let lead = '';
|
|
82
|
+
if (size > 0) { const fd = fs.openSync(s.file, 'r'); try { const b = Buffer.alloc(1); fs.readSync(fd, b, 0, 1, size - 1); if (b[0] !== 10) lead = '\n'; } finally { fs.closeSync(fd); } }
|
|
83
|
+
if (out.length) fs.appendFileSync(s.file, lead + out.join('\n') + '\n');
|
|
84
|
+
return { file: s.file, size };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function parse(raw) {
|
|
88
|
+
try { const r = JSON.parse(raw); return r && typeof r === 'object' && !Array.isArray(r) ? r : null; } catch { return null; }
|
|
89
|
+
}
|
|
90
|
+
const atOf = (r) => (r && typeof r.at === 'string' ? r.at : '');
|
|
91
|
+
|
|
92
|
+
/** Board lines and the initiative's task lines → { lines, pending }. Pure. */
|
|
93
|
+
function view(boardLines, storeLines) {
|
|
94
|
+
const left = new Map(); // text → copies in the initiative ledger not yet matched to a Board line
|
|
95
|
+
for (const raw of storeLines || []) left.set(raw, (left.get(raw) || 0) + 1);
|
|
96
|
+
const board = [], pending = [];
|
|
97
|
+
for (const raw0 of boardLines || []) {
|
|
98
|
+
const raw = String(raw0).trim();
|
|
99
|
+
const r = raw[0] === '{' ? parse(raw) : null;
|
|
100
|
+
if (isTaskLine(r)) {
|
|
101
|
+
const n = left.get(raw) || 0;
|
|
102
|
+
if (n > 0) { left.set(raw, n - 1); continue; } // moved: the initiative ledger holds it
|
|
103
|
+
pending.push(raw);
|
|
104
|
+
}
|
|
105
|
+
board.push({ raw, at: atOf(r) });
|
|
106
|
+
}
|
|
107
|
+
// the initiative's task lines, merged into the Board's lines by time (each list keeps its own order; a tie reads the Board line first)
|
|
108
|
+
const store = (storeLines || []).map((raw) => ({ raw, at: atOf(parse(raw)) }));
|
|
109
|
+
const lines = [];
|
|
110
|
+
let i = 0, j = 0;
|
|
111
|
+
while (i < board.length || j < store.length) {
|
|
112
|
+
if (j >= store.length || (i < board.length && !(store[j].at && board[i].at && store[j].at < board[i].at))) lines.push(board[i++].raw);
|
|
113
|
+
else lines.push(store[j++].raw);
|
|
114
|
+
}
|
|
115
|
+
return { lines, pending };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The task part of a boards fold, as JSON text: equal text = the Board shows the same tasks, dates, places, milestones, pins and orders. */
|
|
119
|
+
function snapshot(f) {
|
|
120
|
+
const m = (x) => (x instanceof Map ? [...x.entries()].sort((a, b) => (String(a[0]) < String(b[0]) ? -1 : String(a[0]) > String(b[0]) ? 1 : 0)) : []);
|
|
121
|
+
return JSON.stringify({ tasks: m(f.tasks), removed: m(f.removed), sections: m(f.sections), milestones: m(f.milestones), pins: m(f.pins), orders: m(f.orders),
|
|
122
|
+
// the last task-remove of a task is what its Undo reads (routes-boards tasks/restore)
|
|
123
|
+
removes: (f.events || []).filter((e) => e.kind === 'task-remove').map((e) => [e.task, e.at || null, e.why || null]) });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function takeLock(file) {
|
|
127
|
+
const lock = file + '.move.lock';
|
|
128
|
+
try { fs.mkdirSync(path.dirname(file), { recursive: true }); } catch { /* the write below says why */ }
|
|
129
|
+
try { fs.writeFileSync(lock, String(process.pid), { flag: 'wx' }); return lock; } catch { /* held */ }
|
|
130
|
+
try { if (Date.now() - fs.statSync(lock).mtimeMs > LOCK_STALE_MS) { fs.unlinkSync(lock); fs.writeFileSync(lock, String(process.pid), { flag: 'wx' }); return lock; } } catch { /* another took it */ }
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Copy the task lines still only in boards.jsonl to the initiative ledger, and check the copy. `B` is scripts/boards.js.
|
|
136
|
+
* → { ok: true, moved, lines } (lines: what the Board folds now) | { ok: false, error, lines } (lines: the old reading, unchanged)
|
|
137
|
+
*/
|
|
138
|
+
function migrate(root, boardLines, B) {
|
|
139
|
+
const store = storeFor(root);
|
|
140
|
+
const before = readStore(root);
|
|
141
|
+
if (!store || !before) return { ok: false, error: 'the initiative ledger could not be read', lines: (boardLines || []).slice() };
|
|
142
|
+
const v0 = view(boardLines, before);
|
|
143
|
+
if (!v0.pending.length) return { ok: true, moved: 0, lines: v0.lines };
|
|
144
|
+
const lock = takeLock(store.file);
|
|
145
|
+
if (!lock) return { ok: false, error: 'another server is moving the tasks', lines: v0.lines };
|
|
146
|
+
let size = null;
|
|
147
|
+
try {
|
|
148
|
+
const want = snapshot(B.fold(v0.lines));
|
|
149
|
+
size = appendLines(root, v0.pending).size;
|
|
150
|
+
const after = readStore(root);
|
|
151
|
+
const v1 = after ? view(boardLines, after) : null;
|
|
152
|
+
if (!v1 || v1.pending.length || snapshot(B.fold(v1.lines)) !== want) {
|
|
153
|
+
fs.truncateSync(store.file, size); size = null;
|
|
154
|
+
return { ok: false, error: 'the moved tasks did not read the same, so they stay in boards.jsonl', lines: v0.lines };
|
|
155
|
+
}
|
|
156
|
+
size = null;
|
|
157
|
+
return { ok: true, moved: v0.pending.length, lines: v1.lines };
|
|
158
|
+
} catch (e) {
|
|
159
|
+
if (size != null) { try { fs.truncateSync(store.file, size); } catch { /* the check on the next read sees it */ } }
|
|
160
|
+
return { ok: false, error: 'the tasks could not be moved: ' + String((e && e.message) || e).slice(0, 160), lines: v0.lines };
|
|
161
|
+
} finally {
|
|
162
|
+
try { fs.unlinkSync(lock); } catch { /* gone */ }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Write one task line (an object with `kind`, `at`, `by`, …) to the initiative ledger. false = unavailable (the caller keeps the old home). */
|
|
167
|
+
function write(root, line) {
|
|
168
|
+
if (!storeFor(root)) return false;
|
|
169
|
+
appendLines(root, [line]);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
module.exports = { LEDGER, TASK_KINDS, isTaskKind, storeFor, readStore, view, migrate, write, snapshot };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.486.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.486.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
package/workspace/server.js
CHANGED
|
@@ -2863,7 +2863,7 @@ try { require('./lib/routes-report-design.js').attach(reportDesignCtx); } catch
|
|
|
2863
2863
|
// The tick collects check answers and starts the drafts that waited for a failing source (4 hours, then without it).
|
|
2864
2864
|
// agent-orchestrator: the checks of a draft the schedule tick fired, and the tick's retries of them, use spawnScheduled (the capacity governor). A press uses spawnSession.
|
|
2865
2865
|
const reportStructureCtx = () => ({ getWs, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, stepFlags: STEP_FLAGS,
|
|
2866
|
-
scheduleStore: { read: readSchedules, write: writeSchedules }, sessionAlive: (id) => { const x = sessions.get(String(id || '')); return !!x && x.state !== 'exited'; },
|
|
2866
|
+
scheduleStore: { read: readSchedules, write: writeSchedules }, sessionAlive: (id) => { const x = sessions.get(String(id || '')); return !!x && x.state !== 'exited'; }, sessionOutcome: (id) => { const x = sessions.get(String(id || '')); return (x && x.outcome) || null; },
|
|
2867
2867
|
spawnSession: (spec) => spawnSession({ ...spec, autoDelete: undefined }),
|
|
2868
2868
|
spawnScheduled: (spec) => orchSpawn.spawn({ ...spec, autoDelete: undefined }),
|
|
2869
2869
|
skillPrompt: (skillId, w) => { const t = taskById(skillId, w ? w.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
|
|
@@ -3137,7 +3137,7 @@ refreshRun = refreshRunLib.create({
|
|
|
3137
3137
|
proactive: () => proSettings(),
|
|
3138
3138
|
schedules: { read: readSchedules, write: writeSchedules },
|
|
3139
3139
|
startSkill: (wsId, skill, name, origin) => startSkillSession(wsId, skill, name, origin),
|
|
3140
|
-
sessionAlive: (id) => { const x = sessions.get(String(id || '')); return !!x && x.state !== 'exited'; },
|
|
3140
|
+
sessionAlive: (id) => { const x = sessions.get(String(id || '')); return !!x && x.state !== 'exited'; }, sessionOutcome: (id) => { const x = sessions.get(String(id || '')); return (x && x.outcome) || null; },
|
|
3141
3141
|
// popup context slice 3b: how many opened popups have no lead newer than the newest stored read
|
|
3142
3142
|
leadsDue: () => require('./lib/popup-leads.js').due(STATE, { readAt: require('./lib/lead-cli.js').newestRead(STATE) }).length,
|
|
3143
3143
|
freshRows: (wsIdArg) => { const w = getWs(wsIdArg || ''); return w ? freshness.sources({ id: w.id, root: w.root, repoStateDir: (() => { try { return stateDirFor(w); } catch { return null; } })() }) : []; },
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "feedback batch 22 item 21 (D104): an initiative's tasks live in initiative-tasks.jsonl; the one-time move from boards.jsonl reads the same tasks and dates, new writes go to the initiative ledger, a late boards.jsonl line moves, a copy that reads differently is cut off.",
|
|
3
|
+
"modules": ["initiative-tasks.test.js"],
|
|
4
|
+
"seconds": { "initiative-tasks.test.js": 3 }
|
|
5
|
+
}
|