create-pmos 0.670.0 → 0.671.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 +22 -22
- 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 +21 -8
- package/workspace/guide/initiatives-and-next-steps.md +12 -2
- package/workspace/guide/settings-and-switches.md +2 -2
- package/workspace/lib/driver-run.js +1 -1
- package/workspace/lib/driver.js +4 -1
- package/workspace/lib/routes-boards.js +115 -4
- package/workspace/lib/tracker-refresh-run.js +162 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-pop-work.js +23 -3
- package/workspace/public/pm/pop-work-model.js +7 -5
- package/workspace/server.js +27 -0
- package/workspace/skills/tracker-refresh.skill +2 -0
- package/workspace/test-lists/direct-plain-actions.json +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.671.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": {
|
|
@@ -34,21 +34,34 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-22T05:
|
|
37
|
+
"v": "0.671.0",
|
|
38
|
+
"at": "2026-11-22T05:13:23.112Z",
|
|
39
39
|
"f": 4,
|
|
40
40
|
"prs": [
|
|
41
|
-
{
|
|
42
|
-
"n": 1457,
|
|
43
|
-
"t": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
44
|
-
"s": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
45
|
-
"k": "new"
|
|
46
|
-
},
|
|
47
41
|
{
|
|
48
42
|
"n": 1463,
|
|
49
43
|
"t": "Settings is built from the design system's blocks",
|
|
50
44
|
"s": "Settings is built from the design system's blocks",
|
|
51
45
|
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1454,
|
|
49
|
+
"t": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
50
|
+
"s": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
51
|
+
"k": "new"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"v": "0.669.0",
|
|
57
|
+
"at": "2026-11-22T04:57:48.469Z",
|
|
58
|
+
"f": 4,
|
|
59
|
+
"prs": [
|
|
60
|
+
{
|
|
61
|
+
"n": 1457,
|
|
62
|
+
"t": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
63
|
+
"s": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
64
|
+
"k": "new"
|
|
52
65
|
}
|
|
53
66
|
]
|
|
54
67
|
},
|
|
@@ -345,19 +358,6 @@
|
|
|
345
358
|
"k": "new"
|
|
346
359
|
}
|
|
347
360
|
]
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"v": "0.637.0",
|
|
351
|
-
"at": "2026-11-20T00:56:06.689Z",
|
|
352
|
-
"f": 4,
|
|
353
|
-
"prs": [
|
|
354
|
-
{
|
|
355
|
-
"n": 1419,
|
|
356
|
-
"t": "The PMOS design system family (brand, charts, ui, documents, slides)",
|
|
357
|
-
"s": "The PMOS design system family (brand, charts, ui, documents, slides)",
|
|
358
|
-
"k": "new"
|
|
359
|
-
}
|
|
360
|
-
]
|
|
361
361
|
}
|
|
362
362
|
]
|
|
363
363
|
}
|
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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:13:19Z"}
|
|
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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:13:19Z"}
|
|
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-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:13:19Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T05:
|
|
3
|
+
"v": "0.671.0",
|
|
4
|
+
"at": "2026-11-22T05:13:23.112Z",
|
|
5
5
|
"f": 4,
|
|
6
6
|
"prs": [
|
|
7
|
-
{
|
|
8
|
-
"n": 1457,
|
|
9
|
-
"t": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
10
|
-
"s": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
11
|
-
"k": "new"
|
|
12
|
-
},
|
|
13
7
|
{
|
|
14
8
|
"n": 1463,
|
|
15
9
|
"t": "Settings is built from the design system's blocks",
|
|
16
10
|
"s": "Settings is built from the design system's blocks",
|
|
17
11
|
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1454,
|
|
15
|
+
"t": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
16
|
+
"s": "Plain ✓ actions write directly, with Undo and no agent turn",
|
|
17
|
+
"k": "new"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"v": "0.669.0",
|
|
23
|
+
"at": "2026-11-22T04:57:48.469Z",
|
|
24
|
+
"f": 4,
|
|
25
|
+
"prs": [
|
|
26
|
+
{
|
|
27
|
+
"n": 1457,
|
|
28
|
+
"t": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
29
|
+
"s": "Create-pmos picks the code profile itself; OKR template the board resolves",
|
|
30
|
+
"k": "new"
|
|
18
31
|
}
|
|
19
32
|
]
|
|
20
33
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Initiatives: the Roadmap, next steps, the Driver and done"
|
|
4
4
|
description: "The ranked list of initiatives, how PMOS works out the next steps, the Initiative Driver, and integrated work."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-22
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Initiatives: the Roadmap, next steps, the Driver and done
|
|
@@ -48,6 +48,16 @@ Each step says what you can do with it. The control sits under the step.
|
|
|
48
48
|
| `gate` | The step is yours alone: accepting the initiative, approving the contract, answering an open item. | Words only. There is no start button. |
|
|
49
49
|
| `lifecycle` | The initiative is stopped. | **reopen** |
|
|
50
50
|
|
|
51
|
+
### Plain suggestions finish at once
|
|
52
|
+
|
|
53
|
+
Three suggestions on the initiative popup change the record directly, with Undo. They send nothing to Ask PMOS and start no agent run:
|
|
54
|
+
|
|
55
|
+
- **Move the plan end.** ✓ moves the due day of the open task that sets the plan end today.
|
|
56
|
+
- **Close them** (a closed initiative with open tasks). All its open PMOS tasks go to Done. Jira tickets stay with Jira.
|
|
57
|
+
- **Reopen.** An initiative in Won't do comes out of Won't do. An initiative in its last stage goes back to the stage it came from.
|
|
58
|
+
|
|
59
|
+
When PMOS cannot do the change by itself (for example, a Done task sets the plan end), it sends the words to Ask PMOS as before.
|
|
60
|
+
|
|
51
61
|
### Prepare, then go
|
|
52
62
|
|
|
53
63
|
**Prepare** shows a plan and starts nothing. The plan names the branch and the folder, says whether the initiative's branch already exists (it is reused) or would be created, lists the sessions already running on the initiative, names the read-only sources the session may use, and shows the budget. It also shows the exact first input the session would receive. Preparing creates no branch, folder or session.
|
|
@@ -214,7 +224,7 @@ The Initiative Driver is a short background agent run for one initiative or one
|
|
|
214
224
|
A run starts for one of four reasons:
|
|
215
225
|
|
|
216
226
|
- **Created.** An initiative is created from the page, from Triage (accept), or with `pmos initiative new`. The run starts within one tick of the server (about one minute).
|
|
217
|
-
- **Moved.**
|
|
227
|
+
- **Moved.** An agent moves the initiative to another stage. A move you press on the board starts no run: the daily sweep still asks for the documents of the new stage.
|
|
218
228
|
- **Answered.** You send a proposal back with a note.
|
|
219
229
|
- **Stuck.** The unblock sweep finds a blocker the agent can work on.
|
|
220
230
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Settings, switches and data freshness"
|
|
4
4
|
description: "What each section of Settings holds, every PMOS_ environment variable, and how the workspace keeps each source up to date."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-22
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Settings, switches and data freshness
|
|
@@ -332,7 +332,7 @@ The calendar-sync skill reads today and the next 14 days, read-only, and saves t
|
|
|
332
332
|
|
|
333
333
|
The events are kept in your own runtime folder on this machine, never in a repository.
|
|
334
334
|
|
|
335
|
-
The tracker-refresh
|
|
335
|
+
The tracker-refresh read is a plain script, not an agent run: the schedule and the Refresh press start no session. It reads tracker items from files already in your repository and moves an item only when a newer file shows a new status, so a read can change nothing. It records that the read finished, even when nothing moved. `pmos tracker status` says when tracker items were last read for this repository.
|
|
336
336
|
|
|
337
337
|
The record is kept in your own runtime folder on this machine, never in a repository. Tracker items show the time of this record, or the time the schedule last started the skill if that is later.
|
|
338
338
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 1. writes the ledger's `epoch` on the first scan, so only events AFTER it wake a run (an old initiative is history);
|
|
8
8
|
* 2. closes runs that were alive when the server stopped (`run-end`, reason "interrupted"): they still count against the day;
|
|
9
9
|
* 3. finds the wakes: a `created` placement line (the page, Triage accept and `pmos initiative new` all write one), a board
|
|
10
|
-
* `move` line, a proposal the PM sent back with a note. Each key wakes once (the ledger's `wake` line makes it idempotent);
|
|
10
|
+
* `move` line (one the PM pressed on the page, `pressed: true`, wakes none: bet 1f), a proposal the PM sent back with a note. Each key wakes once (the ledger's `wake` line makes it idempotent);
|
|
11
11
|
* 4. every 30 minutes inside the day-check window, and outside quiet hours, runs the unblock sweep (no model, lib/driver.js);
|
|
12
12
|
* 5. starts the queued runs the rules allow (mode, pause, 3 at once) through spawnSession with origin `drive:<kind>:<id>`
|
|
13
13
|
* and the skill prompt, which lib/headless.js turns into a `claude -p` run with a fixed tool list.
|
package/workspace/lib/driver.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* plan(state, { now, running }) → { start: [{ target, board, wakes[] }], refused: [{ target, wakes[], reason }] }
|
|
19
19
|
* detect(facts, state, { now, stalledDays }) → the blockers, each { key, target, board, title, code, owner, cat, text }
|
|
20
20
|
* sweepLines(facts, state, { now, stalledDays }) → { blockers, lines } the lines to append (once per blocker per day)
|
|
21
|
-
* wakesFromLedgers({ created, moved }, state, { ws, epoch }) → wake lines for creations and moves not yet woken
|
|
21
|
+
* wakesFromLedgers({ created, moved }, state, { ws, epoch }) → wake lines for creations and moves not yet woken (a move pressed on the page, `pressed: true`, wakes none)
|
|
22
22
|
* answeredWakes(state) → wake lines for proposals the PM sent back with a note
|
|
23
23
|
* localDay(ms) · targetKey(target) · wsIdOf(root)
|
|
24
24
|
*
|
|
@@ -468,6 +468,9 @@ function wakesFromLedgers({ created = [], moved = [] } = {}, state, { ws, epoch,
|
|
|
468
468
|
}
|
|
469
469
|
for (const m of moved) {
|
|
470
470
|
if (!m || m.kind !== 'move' || typeof m.id !== 'string' || !ID_RE.test(m.id) || !after(m.at)) continue;
|
|
471
|
+
// a move the PM pressed on the page (a Board drag, a direct ✓: `pressed: true`) is the PM's own word: it wakes no follow-up run (bet 1f).
|
|
472
|
+
// The daily sweep still asks for the new stage's due documents. A move kept from a driver proposal, or made by an agent, still wakes one.
|
|
473
|
+
if (m.pressed === true) continue;
|
|
471
474
|
const key = `moved:${ws}:${m.id}:${m.at}`;
|
|
472
475
|
if (state.wakeKeys.has(key)) continue;
|
|
473
476
|
lines.push({ ev: 'wake', key, target: { kind: 'initiative', ws, id: m.id }, board: m.board || boardOf(m.id), reason: 'moved' });
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
* POST /api/boards/tasks/order { ws, board, initiative, section, tasks: [id] } → { ok, from } the PM's order inside one stage (a drag in the
|
|
33
33
|
* Tasks list, batch 18 item 16): a task-order line; tasks [] takes the order out; Undo sends `from` back
|
|
34
34
|
* POST /api/boards/tasks/state { ws, board, task, state } → { ok, item }
|
|
35
|
+
* POST /api/boards/ini-plan-end { ws, board, id, to } · ini-close-open { ws, board, id } · ini-reopen { ws, board, id }
|
|
36
|
+
* the popup's direct ✓ presses (bet 1f): see "direct ✓ presses" below; { ask: true } sends the words to Ask PMOS
|
|
35
37
|
* POST /api/boards/tasks/reschedule { ws, board, task, days } → { ok, item }
|
|
36
38
|
* POST /api/boards/tasks/undo-add { ws, board, task } → { ok } takes back a task added in the last 2 minutes, still To do
|
|
37
39
|
* POST /api/boards/tasks/rename { ws, board, task, title } → { ok, from, item } only the title changes
|
|
@@ -1145,7 +1147,7 @@ function moveOnWorkflow(ctx, res, body, g, p, own) {
|
|
|
1145
1147
|
if (!before.anchor) warnings.push('No anchor');
|
|
1146
1148
|
const happened = stageHappened(ctx, res, body, p.fr.folded, p.board.id);
|
|
1147
1149
|
if (happened === false) return;
|
|
1148
|
-
append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.wfStage.key, to: t.key, why: body.why || '', warnings, ...(happened ? { happened } : {}) });
|
|
1150
|
+
append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.wfStage.key, to: t.key, why: body.why || '', warnings, ...(happened ? { happened } : {}), ...(g.pressed ? { pressed: true } : {}) });
|
|
1149
1151
|
const f1 = foldOf(ctx, p.w), row = boardRow(p.board, b0, f1);
|
|
1150
1152
|
const made = stageTasks(p.file, f1, p.board, row, g.actor.by); // the new stage's To finish entries, as tasks
|
|
1151
1153
|
ctx.json(res, { ok: true, row, warnings, ...(made ? { tasksMade: made } : {}) });
|
|
@@ -1266,7 +1268,7 @@ const WRITES = {
|
|
|
1266
1268
|
const warnings = B.moveWarnings(p.board, before, before.stage, body.to, { hasSpec: b0.hasSpec });
|
|
1267
1269
|
const happened = stageHappened(ctx, res, body, p.fr.folded, p.board.id);
|
|
1268
1270
|
if (happened === false) return;
|
|
1269
|
-
append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.stage, to: body.to, why: body.why || '', warnings, ...(happened ? { happened } : {}) });
|
|
1271
|
+
append(p.file, g.actor, { kind: 'move', board: p.board.id, id: body.id, from: before.stage, to: body.to, why: body.why || '', warnings, ...(happened ? { happened } : {}), ...(g.pressed ? { pressed: true } : {}) });
|
|
1270
1272
|
const row = boardRow(p.board, b0, foldOf(ctx, p.w));
|
|
1271
1273
|
ctx.json(res, { ok: true, row, warnings });
|
|
1272
1274
|
},
|
|
@@ -1877,6 +1879,112 @@ const WRITES = {
|
|
|
1877
1879
|
},
|
|
1878
1880
|
};
|
|
1879
1881
|
|
|
1882
|
+
/* ── direct ✓ presses (initiative direct-plain-actions, bet 1f): three suggestions of the initiative popup (public/pm/pop-work-model.js
|
|
1883
|
+
* derivedOf d:plan-end and d:closed-open) used to type a sentence into Ask PMOS, and an agent session made a plain change. Each is now one
|
|
1884
|
+
* press that writes through the task and board routes above (writeAs: the same checks, the same ledger lines) and answers its own Undo.
|
|
1885
|
+
* When the plain reading does not hold, a route writes nothing and answers { ok: false, ask: true, error }: the page sends the old words
|
|
1886
|
+
* to Ask PMOS, as before.
|
|
1887
|
+
*
|
|
1888
|
+
* POST /api/boards/ini-plan-end { ws, board, id, to } → { ok, task, title, from: { due }, to, said } | { ok: true, same: true, said }
|
|
1889
|
+
* The plan end is not stored: it is the latest due day of the initiative's PMOS tasks and breakdown items. The open one that sets it
|
|
1890
|
+
* today gets `to` as its due day. A Done task that sets it, or no dated task at all, is { ask: true }.
|
|
1891
|
+
* POST /api/boards/ini-close-open { ws, board, id } → { ok, closed: [{ task, title, from }], said }
|
|
1892
|
+
* Every open PMOS task and breakdown item goes to Done. A Jira ticket is Jira's and is never written here. Undo: tasks/state with
|
|
1893
|
+
* each `from`.
|
|
1894
|
+
* POST /api/boards/ini-reopen { ws, board, id } → { ok, did: 'wontdo' | 'stage', to, undo: { route, body }, said }
|
|
1895
|
+
* Won't do: out of Won't do, back to the stage it was in. The last stage: back to the stage of the last move into it, else the stage
|
|
1896
|
+
* before it. Anything else is { ask: true }. */
|
|
1897
|
+
const OPEN_STATES = ['To do', 'In progress'];
|
|
1898
|
+
/** The PMOS tasks and breakdown items of one initiative, as { id, store, title, state, due }. Won't do and Archived are left out. */
|
|
1899
|
+
function workOfIni(p, id) {
|
|
1900
|
+
const out = [];
|
|
1901
|
+
for (const t of tasksOfIni(p.fr.folded, id)) {
|
|
1902
|
+
if (!t || t.initiative !== id || t.board !== p.board.id || t.state === "Won't do" || t.state === 'Archived') continue;
|
|
1903
|
+
out.push({ id: t.id, store: 'task', title: t.title, state: t.state, due: t.due ? String(t.due).slice(0, 10) : null });
|
|
1904
|
+
}
|
|
1905
|
+
for (const r of TI.rowsOf(p.w.root, new Set([id]), p.board.id)) out.push({ id: r.uid, store: 'item', title: r.title, state: r.status, due: r.end ? String(r.end).slice(0, 10) : null });
|
|
1906
|
+
return out;
|
|
1907
|
+
}
|
|
1908
|
+
/** The initiative of a direct press on this board: { p, b0, row } or null (the failure is answered). */
|
|
1909
|
+
function directFrame(ctx, res, body) {
|
|
1910
|
+
const p = postFrame(ctx, res, body);
|
|
1911
|
+
if (!p) return null;
|
|
1912
|
+
if (p.board.self) { fail(ctx, res, 409, SELF_REFUSAL); return null; }
|
|
1913
|
+
if (typeof body.id !== 'string' || !body.id) { fail(ctx, res, 400, 'id is required'); return null; }
|
|
1914
|
+
if (!p.file) { fail(ctx, res, 409, NO_STATE); return null; }
|
|
1915
|
+
const base = needRows(ctx, res, p.w);
|
|
1916
|
+
if (!base) return null;
|
|
1917
|
+
const b0 = base.find((r) => r.id === body.id);
|
|
1918
|
+
if (!b0 || boardIdOf(b0, p.fr.boards, p.fr.folded, p.w) !== p.board.id) { fail(ctx, res, 404, `no initiative ${body.id} on this board`); return null; }
|
|
1919
|
+
return { p, b0, row: boardRow(p.board, b0, p.fr.folded) };
|
|
1920
|
+
}
|
|
1921
|
+
const askBack = (ctx, res, error) => ctx.json(res, { ok: false, ask: true, error }, 409);
|
|
1922
|
+
const DAY_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
1923
|
+
Object.assign(WRITES, {
|
|
1924
|
+
'/api/boards/ini-plan-end': (ctx, res, body, g) => {
|
|
1925
|
+
if (typeof body.to !== 'string' || !DAY_ONLY.test(body.to)) return fail(ctx, res, 400, 'to is a day, YYYY-MM-DD');
|
|
1926
|
+
const f = directFrame(ctx, res, body);
|
|
1927
|
+
if (!f) return;
|
|
1928
|
+
const end = f.row.end ? String(f.row.end).slice(0, 10) : null;
|
|
1929
|
+
if (end && end >= body.to) return ctx.json(res, { ok: true, same: true, said: 'The plan already ends on ' + end + '.' });
|
|
1930
|
+
const work = workOfIni(f.p, body.id);
|
|
1931
|
+
const setter = end ? work.find((x) => x.due === end && OPEN_STATES.includes(x.state)) : null;
|
|
1932
|
+
if (!setter) return askBack(ctx, res, end ? 'a task that is done sets the plan end, so PMOS cannot move it by itself' : 'no dated PMOS task sets the plan end');
|
|
1933
|
+
const r = writeAs(ctx, '/api/boards/tasks/edit', { ws: body.ws, board: body.board, task: setter.id, due: body.to }, g);
|
|
1934
|
+
if (!r.body || r.body.ok === false) return ctx.json(res, r.body || { ok: false, error: 'the plan end was not moved' }, r.status);
|
|
1935
|
+
ctx.json(res, { ok: true, task: setter.id, title: setter.title, from: { due: end }, to: body.to, said: 'The plan end moved to ' + body.to + ': ' + setter.title + ' is due then.' });
|
|
1936
|
+
},
|
|
1937
|
+
'/api/boards/ini-close-open': (ctx, res, body, g) => {
|
|
1938
|
+
const f = directFrame(ctx, res, body);
|
|
1939
|
+
if (!f) return;
|
|
1940
|
+
const open = workOfIni(f.p, body.id).filter((x) => OPEN_STATES.includes(x.state));
|
|
1941
|
+
if (!open.length) return askBack(ctx, res, 'it has no open PMOS task: the open ones are Jira tickets, and Jira owns them');
|
|
1942
|
+
const closed = [], failed = [];
|
|
1943
|
+
for (const x of open) {
|
|
1944
|
+
const r = writeAs(ctx, '/api/boards/tasks/state', { ws: body.ws, board: body.board, task: x.id, state: 'Done', why: 'closed with its initiative' }, g);
|
|
1945
|
+
if (r.body && r.body.ok !== false) closed.push({ task: x.id, title: x.title, from: x.state }); else failed.push(x.title);
|
|
1946
|
+
}
|
|
1947
|
+
if (!closed.length) return fail(ctx, res, 500, 'no task was closed: ' + failed.join(', '));
|
|
1948
|
+
ctx.json(res, { ok: true, closed, said: closed.length + (closed.length === 1 ? ' task' : ' tasks') + ' closed.' + (failed.length ? ' Not closed: ' + failed.join(', ') + '.' : '') });
|
|
1949
|
+
},
|
|
1950
|
+
'/api/boards/ini-reopen': (ctx, res, body, g) => {
|
|
1951
|
+
const f = directFrame(ctx, res, body);
|
|
1952
|
+
if (!f) return;
|
|
1953
|
+
const { row } = f, k = B.key(f.p.board.id, body.id), stages = row.wfStages || [];
|
|
1954
|
+
const stageOf = (ref) => stages.find((s) => s.key === ref || s.name === ref) || null;
|
|
1955
|
+
const ended = f.p.fr.folded.ends ? f.p.fr.folded.ends.get(k) : null;
|
|
1956
|
+
const moves = (f.p.fr.folded.moves || []).filter((m) => m.board === f.p.board.id && m.id === body.id && m.via === 'move');
|
|
1957
|
+
if (ended) {
|
|
1958
|
+
const r = writeAs(ctx, '/api/boards/wontdo', { ws: body.ws, board: body.board, id: body.id, back: true }, g);
|
|
1959
|
+
if (!r.body || r.body.ok === false) return ctx.json(res, r.body || { ok: false, error: 'it was not reopened' }, r.status);
|
|
1960
|
+
// back from Won't do lands in Triage (scripts/boards.js): the stage it was in goes back too, by the name of the last move before Won't do
|
|
1961
|
+
const before = [...moves].reverse().find((m) => !ended.at || !m.at || m.at <= ended.at);
|
|
1962
|
+
const want = before ? before.to : (stageOf(ended.stage) || {}).name;
|
|
1963
|
+
let to = (r.body.row && r.body.row.stage) || 'Triage';
|
|
1964
|
+
if (want && want !== to) { const m = writeAs(ctx, '/api/boards/move', { ws: body.ws, board: body.board, id: body.id, to: want, why: 'reopened' }, g); if (m.body && m.body.ok) to = want; }
|
|
1965
|
+
return ctx.json(res, { ok: true, did: 'wontdo', to, undo: { route: '/api/boards/wontdo', body: { id: body.id, reason: ended.reason || 'other', note: ended.note || (ended.reason === 'other' ? 'closed again' : '') } }, said: 'Reopened in ' + to + '.' });
|
|
1966
|
+
}
|
|
1967
|
+
if (!row.closed || !row.wfStage) return askBack(ctx, res, 'it is not in Won\'t do or in its last stage, so PMOS cannot tell where it goes back to');
|
|
1968
|
+
const cur = row.wfStage, here = [row.stage, cur.key, cur.name].filter(Boolean);
|
|
1969
|
+
const into = [...moves].reverse().find((m) => here.includes(m.to));
|
|
1970
|
+
let back = into && into.from && !here.includes(into.from) ? into.from : null;
|
|
1971
|
+
if (!back) {
|
|
1972
|
+
// no move into it (a stage read from Jira or the files): the stage before it on the board's own list, else on the workflow's
|
|
1973
|
+
const cols = (row.workflow || []).map((x) => ({ name: x.name, cat: x.cat }));
|
|
1974
|
+
const list = cols.some((x) => x.name === row.stage) ? cols : stages.map((x) => ({ name: x.name, cat: x.cat, key: x.key }));
|
|
1975
|
+
const i = list.findIndex((x) => here.includes(x.name) || (x.key && here.includes(x.key)));
|
|
1976
|
+
const prev = list.slice(0, Math.max(0, i)).reverse().find((x) => String(x.cat || '').toLowerCase() !== 'done' && !END_RE.test(x.name || ''));
|
|
1977
|
+
back = prev ? prev.name : null;
|
|
1978
|
+
}
|
|
1979
|
+
if (!back) return askBack(ctx, res, 'it has no stage before its last one to go back to');
|
|
1980
|
+
const shut = into ? into.to : row.stage || cur.name;
|
|
1981
|
+
const r = writeAs(ctx, '/api/boards/move', { ws: body.ws, board: body.board, id: body.id, to: back, why: 'reopened' }, g);
|
|
1982
|
+
if (!r.body || r.body.ok === false) return ctx.json(res, r.body || { ok: false, error: 'it was not reopened' }, r.status);
|
|
1983
|
+
const to = (r.body.row && r.body.row.stage) || back;
|
|
1984
|
+
ctx.json(res, { ok: true, did: 'stage', to, undo: { route: '/api/boards/move', body: { id: body.id, to: shut, why: 'closed again' } }, said: 'Reopened in ' + to + '.' });
|
|
1985
|
+
},
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1880
1988
|
async function handle(req, res, url, ctx) {
|
|
1881
1989
|
const p = url.pathname;
|
|
1882
1990
|
if (req.method === 'GET') {
|
|
@@ -1893,8 +2001,11 @@ async function handle(req, res, url, ctx) {
|
|
|
1893
2001
|
if (!got.ok) return fail(ctx, res, 400, 'invalid JSON body');
|
|
1894
2002
|
const body = got.body;
|
|
1895
2003
|
if (!isObj(body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
1896
|
-
const
|
|
1897
|
-
if (!
|
|
2004
|
+
const g0 = guard.requirePagePress(req, body);
|
|
2005
|
+
if (!g0.ok) return fail(ctx, res, g0.status, g0.error);
|
|
2006
|
+
// pressed: the write came straight from a press on the page (not a driver Keep, which calls the same route through writeAs). A stage move
|
|
2007
|
+
// made this way (by the PM, not an agent session sending its header) carries `pressed: true`, and the Driver wakes no follow-up run for it (bet 1f, lib/driver.js wakesFromLedgers).
|
|
2008
|
+
const g = { ...g0, pressed: !!(g0.actor && /^pm:/.test(String(g0.actor.by || ''))) };
|
|
1898
2009
|
fn(ctx, res, body, g);
|
|
1899
2010
|
return true;
|
|
1900
2011
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* tracker-refresh-run.js — the weekly tracker refresh as a plain script, not an agent session (initiative direct-plain-actions, bet 1f B4).
|
|
3
|
+
*
|
|
4
|
+
* refresh(root, { runtimeDir, now }) → { ok, moved: [line], left: [line], notFound: [line], skipped: n, read }
|
|
5
|
+
* line: { item, title, ref, from?, to?, file?, date?, why? }
|
|
6
|
+
*
|
|
7
|
+
* The tracker-refresh skill (skills/tracker-refresh.skill) was an agent run that needed no judgement: find the plan items a tracker owns,
|
|
8
|
+
* find the local file that states each one's status, and move the item to that state with the file as its evidence. This module does the
|
|
9
|
+
* same procedure by code, under the same rules (D71):
|
|
10
|
+
* 1. LOCAL FILES ONLY: no tracker call, no network, no git fetch.
|
|
11
|
+
* 2. READ-ONLY on every source; the only write is a `moved` line in the plan-items ledger with `file:<path>` evidence, by the same writer
|
|
12
|
+
* `pmos item move` uses (lib/plan-items.js), plus the freshness record of the read (lib/tracker-read.js), which is not a ledger line.
|
|
13
|
+
* 3. Evidence for every move: no file, no move.
|
|
14
|
+
* 4. Nothing invented: a file that states more than one status for the reference is not evidence; no file, the item is "not found".
|
|
15
|
+
* 5. Light on content: only the lines that name the reference are read for a status. A file whose name says private, personal,
|
|
16
|
+
* confidential or HR is skipped and counted.
|
|
17
|
+
* 6. Never a Done or Withdrawn item: only items in todo, doing or review are read.
|
|
18
|
+
* 7. A file PMOS writes is never evidence: no `*.jsonl`, nothing under <state>/runs/, <state>/reports/ or <state>/tracker/jira/ (the Jira
|
|
19
|
+
* snapshot belongs to the Jira tickets tab, not to plan items).
|
|
20
|
+
* 8. An old file never undoes a newer move: the file's date (its `timestamp` frontmatter, else its last commit) must be later than the
|
|
21
|
+
* item's last move. A file with neither date is not evidence.
|
|
22
|
+
* Where it looks, in order: <state>/requirements/, the rest of <state>/, then docs/. <state> is pmos/state/ when it exists, else planning/.
|
|
23
|
+
* The newest accepted file wins; when two accepted files disagree, the line says so.
|
|
24
|
+
*/
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
const { execFileSync } = require('child_process');
|
|
28
|
+
const planItems = require('./plan-items.js');
|
|
29
|
+
const TR = require('./tracker-read.js');
|
|
30
|
+
|
|
31
|
+
const OPEN = new Set(['todo', 'doing', 'review']);
|
|
32
|
+
// the skill's table, most specific first so "In Progress" is never read as "Open" or "Done"
|
|
33
|
+
const STATUS = [
|
|
34
|
+
['review', /\b(in review|code review|qa|testing)\b/i],
|
|
35
|
+
['doing', /\b(in progress|doing|started)\b/i],
|
|
36
|
+
['done', /\b(done|closed|resolved|released)\b/i],
|
|
37
|
+
['todo', /\b(to do|todo|open|backlog|ready)\b/i],
|
|
38
|
+
];
|
|
39
|
+
const PRIVATE = /private|personal|confidential|(^|[^a-z])hr([^a-z]|$)/i;
|
|
40
|
+
const TEXT = /\.(md|markdown|txt|csv|tsv|json|ya?ml|html?)$/i;
|
|
41
|
+
const MAX_BYTES = 1 << 20;
|
|
42
|
+
const MAX_FILES = 5000;
|
|
43
|
+
|
|
44
|
+
function stateDirOf(root) {
|
|
45
|
+
const kit = path.join(root, 'pmos', 'state');
|
|
46
|
+
try { if (fs.statSync(kit).isDirectory()) return kit; } catch { /* not a kit layout */ }
|
|
47
|
+
return path.join(root, 'planning');
|
|
48
|
+
}
|
|
49
|
+
const escapeRe = (s) => String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
50
|
+
|
|
51
|
+
/** The text files to search, in the skill's order, with the files PMOS writes left out. → { files: [abs], skipped } */
|
|
52
|
+
function filesOf(root, state) {
|
|
53
|
+
const out = [], seen = new Set();
|
|
54
|
+
let skipped = 0;
|
|
55
|
+
const banned = [path.join(state, 'runs'), path.join(state, 'reports'), path.join(state, 'tracker', 'jira')].map((d) => d + path.sep);
|
|
56
|
+
const walk = (dir) => {
|
|
57
|
+
let names;
|
|
58
|
+
try { names = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
59
|
+
for (const d of names.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
60
|
+
if (out.length >= MAX_FILES) return;
|
|
61
|
+
if (d.name.startsWith('.') || d.name === 'node_modules') continue;
|
|
62
|
+
const p = path.join(dir, d.name);
|
|
63
|
+
if (d.isDirectory()) { if (!banned.some((b) => (p + path.sep).startsWith(b))) walk(p); continue; }
|
|
64
|
+
if (!d.isFile() || seen.has(p) || /\.jsonl$/i.test(d.name) || !TEXT.test(d.name) || banned.some((b) => p.startsWith(b))) continue;
|
|
65
|
+
if (PRIVATE.test(d.name)) { skipped++; seen.add(p); continue; }
|
|
66
|
+
seen.add(p); out.push(p);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
walk(path.join(state, 'requirements'));
|
|
70
|
+
walk(state);
|
|
71
|
+
walk(path.join(root, 'docs'));
|
|
72
|
+
return { files: out, skipped };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The date of a file: its `timestamp` frontmatter, else its last commit, else null. */
|
|
76
|
+
function dateOf(root, abs, text) {
|
|
77
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
78
|
+
const ts = fm && /^timestamp:\s*["']?([0-9]{4}-[0-9]{2}-[0-9]{2}[^"'\s]*)/m.exec(fm[1]);
|
|
79
|
+
if (ts && Number.isFinite(Date.parse(ts[1]))) return new Date(Date.parse(ts[1])).toISOString();
|
|
80
|
+
try {
|
|
81
|
+
const out = execFileSync('git', ['log', '-1', '--format=%cI', '--', path.relative(root, abs)], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 }).trim();
|
|
82
|
+
if (out && Number.isFinite(Date.parse(out))) return new Date(Date.parse(out)).toISOString();
|
|
83
|
+
} catch { /* not a git repository, or not committed */ }
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The status one file states for a reference: { state } | { many: [states] } | null (the file does not name it, or names no status). */
|
|
88
|
+
function statusIn(text, ref) {
|
|
89
|
+
const re = new RegExp('(^|[^A-Za-z0-9-])' + escapeRe(ref) + '(?![A-Za-z0-9])', 'i');
|
|
90
|
+
const found = new Set();
|
|
91
|
+
for (const line of text.split(/\r?\n/)) {
|
|
92
|
+
if (!re.test(line)) continue;
|
|
93
|
+
const rest = line.replace(new RegExp(escapeRe(ref), 'ig'), ' ');
|
|
94
|
+
// every status the line names counts: "was In Review, now Done" states two, and two is not evidence
|
|
95
|
+
let left = rest;
|
|
96
|
+
for (const [state, sre] of STATUS) { const g = new RegExp(sre.source, 'ig'); if (g.test(left)) { found.add(state); left = left.replace(g, ' '); } }
|
|
97
|
+
}
|
|
98
|
+
if (!found.size) return null;
|
|
99
|
+
return found.size === 1 ? { state: [...found][0] } : { many: [...found] };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The item's last move (or its creation): the day a file must be later than. */
|
|
103
|
+
function lastMoveOf(it) {
|
|
104
|
+
const moved = (it.history || []).filter((h) => h && h.ev === 'moved' && h.at).map((h) => h.at).sort();
|
|
105
|
+
return moved.length ? moved[moved.length - 1] : it.createdAt || null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function refresh(root, { runtimeDir, now = new Date() } = {}) {
|
|
109
|
+
let fold;
|
|
110
|
+
try { fold = planItems.readFold(root); } catch (e) { return { ok: false, error: 'could not read the plan items: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
111
|
+
const state = stateDirOf(root);
|
|
112
|
+
const items = Object.values(fold.items || {}).filter((it) => it && !it.proposed && OPEN.has(it.state) && /^tracker:./.test(String(it.owner || '')));
|
|
113
|
+
const moved = [], left = [], notFound = [];
|
|
114
|
+
const { files, skipped } = items.length ? filesOf(root, state) : { files: [], skipped: 0 };
|
|
115
|
+
const texts = new Map();
|
|
116
|
+
const textOf = (f) => {
|
|
117
|
+
if (!texts.has(f)) { let t = null; try { if (fs.statSync(f).size <= MAX_BYTES) t = fs.readFileSync(f, 'utf8'); } catch { t = null; } texts.set(f, t); }
|
|
118
|
+
return texts.get(f);
|
|
119
|
+
};
|
|
120
|
+
const events = [];
|
|
121
|
+
for (const it of items) {
|
|
122
|
+
const ref = String(it.owner).slice('tracker:'.length).trim();
|
|
123
|
+
const base = { item: it.id, title: it.title, ref };
|
|
124
|
+
const hits = [];
|
|
125
|
+
let many = null;
|
|
126
|
+
for (const f of files) {
|
|
127
|
+
const text = textOf(f);
|
|
128
|
+
if (!text || !text.toLowerCase().includes(ref.toLowerCase())) continue;
|
|
129
|
+
const st = statusIn(text, ref);
|
|
130
|
+
if (!st) continue;
|
|
131
|
+
const rel = path.relative(root, f).split(path.sep).join('/');
|
|
132
|
+
if (st.many) { many = many || { file: rel, states: st.many }; continue; }
|
|
133
|
+
const date = dateOf(root, f, text);
|
|
134
|
+
if (!date) continue;
|
|
135
|
+
hits.push({ file: rel, date, state: st.state });
|
|
136
|
+
}
|
|
137
|
+
if (!hits.length) { notFound.push({ ...base, why: many ? `${many.file} states more than one status (${many.states.join(', ')})` : 'no local file states its status' }); continue; }
|
|
138
|
+
hits.sort((a, b) => b.date.localeCompare(a.date) || a.file.localeCompare(b.file));
|
|
139
|
+
const top = hits[0];
|
|
140
|
+
const disagree = hits.some((h) => h.state !== top.state) ? ` (older files say ${[...new Set(hits.filter((h) => h.state !== top.state).map((h) => h.state))].join(', ')}; the newest is used)` : '';
|
|
141
|
+
const since = lastMoveOf(it);
|
|
142
|
+
if (since && !(top.date > since)) { left.push({ ...base, file: top.file, date: top.date, why: 'file older than the last move' + disagree }); continue; }
|
|
143
|
+
if (top.state === it.state) { left.push({ ...base, file: top.file, date: top.date, why: 'already ' + it.state + disagree }); continue; }
|
|
144
|
+
events.push({ ev: 'moved', item: it.id, to: top.state, evidence: 'file:' + top.file });
|
|
145
|
+
moved.push({ ...base, from: it.state, to: top.state, file: top.file, date: top.date, ...(disagree ? { why: disagree.trim() } : {}) });
|
|
146
|
+
}
|
|
147
|
+
if (events.length) {
|
|
148
|
+
const w = planItems.appendFromCli(root, events, { isTTY: false, env: {}, now: now.getTime ? now.getTime() : undefined });
|
|
149
|
+
if (!w.ok) return { ok: false, error: 'the moves were not saved: ' + w.error, moved: [], left, notFound };
|
|
150
|
+
}
|
|
151
|
+
let read = null;
|
|
152
|
+
if (runtimeDir) { try { read = TR.write(runtimeDir, root, { moved: moved.length, left: left.length, not_found: notFound.length }, now); } catch { read = null; } }
|
|
153
|
+
return { ok: true, moved, left, notFound, skipped, read };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** One short summary line for a run record. */
|
|
157
|
+
function summary(r) {
|
|
158
|
+
if (!r || !r.ok) return (r && r.error) || 'the refresh failed';
|
|
159
|
+
return `${r.moved.length} moved, ${r.left.length} left as they are, ${r.notFound.length} not found` + (r.skipped ? `, ${r.skipped} private files skipped` : '');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = { refresh, summary, statusIn, stateDirOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.671.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.671.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -382,8 +382,8 @@ function sugPageHtml(s, W) {
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/* ── writes ── */
|
|
385
|
-
/* the suggestions PMOS reads from the record (pop-work-model.js derivedOf): ✓ puts a task in a stage,
|
|
386
|
-
* does it in a real session; ✕ hides it on this computer */
|
|
385
|
+
/* the suggestions PMOS reads from the record (pop-work-model.js derivedOf): ✓ puts a task in a stage, writes a plain change at once (direct),
|
|
386
|
+
* or sends the words to Ask PMOS, which does it in a real session; ✕ hides it on this computer */
|
|
387
387
|
const DROP = 'pw-dropped';
|
|
388
388
|
const dropped = () => new Set(store.get(DROP, []));
|
|
389
389
|
let ASK_AT = null; // the initiative shown ({ id, ws }): a phone sends the words to Ask PMOS about it
|
|
@@ -399,10 +399,30 @@ function sendToChat(text) {
|
|
|
399
399
|
const f = ta.closest('form'); if (f && f.requestSubmit) f.requestSubmit(); else ta.focus();
|
|
400
400
|
return true;
|
|
401
401
|
}
|
|
402
|
+
/* a direct ✓ (bet 1f): the plan end, closing the open tasks, reopening. One press writes through POST /api/boards/ini-<act> with Undo; no chat
|
|
403
|
+
* message, no session. Only when the route answers ask: true (the plain reading does not hold) do the words go to Ask PMOS, as before. */
|
|
404
|
+
async function direct(d, ask, x, h) {
|
|
405
|
+
const w = h.where ? h.where() : {}, id = x.o().id;
|
|
406
|
+
const res = await pmPost('/api/boards/ini-' + d.act, { ws: w.ws, board: w.board, id, ...(d.to ? { to: d.to } : {}) }).catch(() => null);
|
|
407
|
+
if (!res || res.ask) { if (ask && !sendToChat(ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
|
|
408
|
+
if (res.ok === false) { if (h.toast) h.toast(res.error || 'Nothing was changed.'); return; }
|
|
409
|
+
if (h.reload) await h.reload();
|
|
410
|
+
if (res.same) { if (h.toast) h.toast(res.said || 'Nothing to change.'); return; }
|
|
411
|
+
const back = async (route, body) => { const u = await pmPost(route, { ws: w.ws, board: w.board, ...body }).catch(() => null); return !!u && u.ok !== false; };
|
|
412
|
+
undoToast(res.said || 'Done.', async () => {
|
|
413
|
+
let ok = true;
|
|
414
|
+
if (d.act === 'plan-end') ok = await back('/api/boards/tasks/edit', { task: res.task, due: (res.from && res.from.due) || '' });
|
|
415
|
+
else if (d.act === 'close-open') { for (const c of res.closed || []) ok = (await back('/api/boards/tasks/state', { task: c.task, state: c.from })) && ok; }
|
|
416
|
+
else if (res.undo && /^\/api\/boards\/(move|wontdo)$/.test(res.undo.route)) ok = await back(res.undo.route, res.undo.body);
|
|
417
|
+
if (!ok && h.toast) h.toast('The undo did not land.');
|
|
418
|
+
if (h.reload) await h.reload();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
402
421
|
async function keepSug(s, x, h) {
|
|
403
422
|
if (s.derived) {
|
|
404
423
|
if (s.move && h.move) { await h.move(s.move.uid, { to: s.move.to, from: '', name: s.move.name }); return; }
|
|
405
424
|
if (s.moveAll) { await moveAll(s.moveAll, h); return; }
|
|
425
|
+
if (s.direct) { await direct(s.direct, s.ask, x, h); return; }
|
|
406
426
|
if (s.ask && !sendToChat(s.ask) && h.toast) h.toast('Open Ask PMOS to send this.');
|
|
407
427
|
return;
|
|
408
428
|
}
|
|
@@ -506,7 +526,7 @@ export function wire(body, h0, x0) {
|
|
|
506
526
|
if (d.pwLdrop) { const dd = dropped(); for (const k of d.pwLdrop.split(',')) dd.add(k); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
|
|
507
527
|
if ('pwPdocs' in d) { if (PH_ARTS.has(c.id)) PH_ARTS.delete(c.id); else PH_ARTS.add(c.id); redraw(); return; }
|
|
508
528
|
if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
|
|
509
|
-
if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && !sendToChat(ch.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
|
|
529
|
+
if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && ch.direct) { b.disabled = true; await direct(ch.direct, ch.ask, x, h); return; } if (ch && !sendToChat(ch.ask) && h.toast) h.toast('Open Ask PMOS to send this.'); return; }
|
|
510
530
|
if (d.pwMore != null) { S.moreOpen.add(d.pwMore); redraw(); return; }
|
|
511
531
|
if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
|
|
512
532
|
if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h, body); return; }
|
|
@@ -439,8 +439,10 @@ const whenOf = (w, t) => { const s = String(w || ''); return day(s) ? dayText(s,
|
|
|
439
439
|
|
|
440
440
|
/* ── what PMOS suggests from the record itself (board 3, 25), next to what lib/proposals.js proposes ── */
|
|
441
441
|
const andList = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
|
|
442
|
-
/** derivedOf(r, v, o, bd, arts) → { top: [s], rows: Map(uid → s) }. Each s: { id, derived: true, say, why, ask?, move? }. ask: the words ✓
|
|
443
|
-
* to Ask PMOS, which does it in a real session; move: { uid, to, name } ✓ puts a task in a stage.
|
|
442
|
+
/** derivedOf(r, v, o, bd, arts) → { top: [s], rows: Map(uid → s) }. Each s: { id, derived: true, say, why, ask?, move?, direct? }. ask: the words ✓
|
|
443
|
+
* sends to Ask PMOS, which does it in a real session; move: { uid, to, name } ✓ puts a task in a stage. direct: { act, to? } ✓ (or a choice)
|
|
444
|
+
* writes at once through POST /api/boards/ini-<act>, with Undo, and sends `ask` only when the route answers ask: true (bet 1f). o.dropped: the
|
|
445
|
+
* ids the PM said No to. */
|
|
444
446
|
export function derivedOf(r, v, o, bd, arts) {
|
|
445
447
|
const t = todayOf(o), drop = o.dropped || new Set(), top = [], rows = new Map(), title = v.title || r.title || 'this initiative';
|
|
446
448
|
const live = r.status !== 'done' && !r.ended && !r.closed;
|
|
@@ -451,7 +453,7 @@ export function derivedOf(r, v, o, bd, arts) {
|
|
|
451
453
|
const last = all.sort((a, b) => b.end.localeCompare(a.end))[0];
|
|
452
454
|
if (last) top.push({ id: 'd:plan-end', derived: true, say: 'Move the plan end to ' + dayText(last.end, t) + '. It follows ' + last.title + '.',
|
|
453
455
|
why: 'The plan ended on ' + dayText(r.end, t) + ', and ' + last.title + ' is due on ' + dayText(last.end, t) + '.',
|
|
454
|
-
ask: 'Move the plan end of ' + title + ' to ' + last.end + ': it follows the task ' + last.title + '. Tell me what else moves.' });
|
|
456
|
+
ask: 'Move the plan end of ' + title + ' to ' + last.end + ': it follows the task ' + last.title + '. Tell me what else moves.', direct: { act: 'plan-end', to: last.end } });
|
|
455
457
|
}
|
|
456
458
|
// a document the gate needs is not written: PMOS drafts it from what is written, for the PM to read
|
|
457
459
|
const miss = (arts || []).filter((a) => a.missing).map((a) => a.title);
|
|
@@ -466,8 +468,8 @@ export function derivedOf(r, v, o, bd, arts) {
|
|
|
466
468
|
if ((r.closed || r.ended || r.status === 'done') && nOpen > 0) {
|
|
467
469
|
const w = r.status === 'done' && !r.closed && !r.ended ? 'done' : 'closed';
|
|
468
470
|
top.unshift({ id: 'd:closed-open', derived: true, say: 'It is ' + w + ', but ' + plural(nOpen, 'task is', 'tasks are') + ' open. Close them, or reopen the initiative?',
|
|
469
|
-
why: '', choices: [{ label: 'Close them', ask: 'Close the ' + plural(nOpen, 'open task', 'open tasks') + ' of ' + title + '. It is ' + w + '. Tell me what you closed.' },
|
|
470
|
-
{ label: 'Reopen', ask: 'Reopen ' + title + ': it has ' + plural(nOpen, 'open task', 'open tasks') + '. Put it back in the stage it was in before, and tell me where.' }] });
|
|
471
|
+
why: '', choices: [{ label: 'Close them', ask: 'Close the ' + plural(nOpen, 'open task', 'open tasks') + ' of ' + title + '. It is ' + w + '. Tell me what you closed.', direct: { act: 'close-open' } },
|
|
472
|
+
{ label: 'Reopen', ask: 'Reopen ' + title + ': it has ' + plural(nOpen, 'open task', 'open tasks') + '. Put it back in the stage it was in before, and tell me where.', direct: { act: 'reopen' } }] });
|
|
471
473
|
}
|
|
472
474
|
// one ✦ on the Not in a stage row (round 3 point 21), keyed 'stage:' (the row of no stage)
|
|
473
475
|
const lz = (bd && bd.loose) || [];
|
package/workspace/server.js
CHANGED
|
@@ -2640,9 +2640,27 @@ function endSupersededRuns(origin, now = Date.now()) {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
return ended;
|
|
2642
2642
|
}
|
|
2643
|
+
/* A skill done by code, not an agent session (bet 1f): the tracker refresh reads local files and moves items by a fixed procedure, so it
|
|
2644
|
+
* needs no model (lib/tracker-refresh-run.js). → { ok, got?, error? } */
|
|
2645
|
+
function isCodeSkill(skill) { return skill === 'tracker-refresh'; }
|
|
2646
|
+
function codeSkillRun(skill, wsId) {
|
|
2647
|
+
if (!isCodeSkill(skill)) return { ok: false, error: `${skill} is not done by code` };
|
|
2648
|
+
const w = (wsId && workspaces.get(wsId)) || homeWorkspace();
|
|
2649
|
+
if (!w) return { ok: false, error: 'no workspace' };
|
|
2650
|
+
const TRR = require('./lib/tracker-refresh-run.js');
|
|
2651
|
+
const r = TRR.refresh(w.root, { runtimeDir: STATE });
|
|
2652
|
+
try { if (r.ok && r.moved.length) boardCache.invalidate(w.root); } catch { /* the next read rebuilds */ }
|
|
2653
|
+
return r.ok ? { ok: true, got: TRR.summary(r), result: r } : { ok: false, error: r.error };
|
|
2654
|
+
}
|
|
2643
2655
|
function fireSchedule(sched, opts = {}) {
|
|
2644
2656
|
const w = workspaces.get(sched.ws) || homeWorkspace();
|
|
2645
2657
|
const root = w ? w.root : SELF_ROOT;
|
|
2658
|
+
if (isCodeSkill(sched.skill) || isCodeSkill(sched.task)) {
|
|
2659
|
+
const r = codeSkillRun(isCodeSkill(sched.skill) ? sched.skill : sched.task, sched.ws);
|
|
2660
|
+
const list = readSchedules(); const cur = list.find((x) => x.id === sched.id);
|
|
2661
|
+
if (cur) { cur.lastRun = nowISO(); cur.lastStatus = r.ok ? 'ok' : 'fail'; if (!opts.release) { cur.nextRun = scheduleLogic.nextRun(cur); if (cur.cadence === 'once') cur.enabled = false; countRun(cur); } writeSchedules(list); }
|
|
2662
|
+
return { ok: r.ok, kind: 'code', sessionId: null, reason: r.ok ? r.got : r.error };
|
|
2663
|
+
}
|
|
2646
2664
|
// One corpus load probing both keys — taskById would re-read every .skill file per probe.
|
|
2647
2665
|
const tasks = loadTasks(root);
|
|
2648
2666
|
const byId = (id) => tasks.find((t) => t.id === id || t.skill === id) || null;
|
|
@@ -5702,6 +5720,15 @@ function myWorkRead(wsId) {
|
|
|
5702
5720
|
/** Refresh now (workspace-data-freshness R7): start skill `skillId` in a session of repository `wsId`, as myWorkRead does. */
|
|
5703
5721
|
function startSkillSession(wsId, skillId, name, origin, opts) {
|
|
5704
5722
|
if (Array.isArray(skillId)) return startSharedRefreshSession(wsId, skillId, name, origin, opts); // smart refresh step 2: several due sources, one session
|
|
5723
|
+
// a skill done by code (bet 1f: the tracker refresh): no session; the refresh engine writes its run lines from the answer (code: true)
|
|
5724
|
+
// the refresh log records it as a run with no session: started, then ended with the script's answer (lib/refresh-run.js started, ended)
|
|
5725
|
+
if (isCodeSkill(skillId)) {
|
|
5726
|
+
const s = { id: 'code-' + crypto.randomBytes(4).toString('hex'), ws: wsId || null, origin: origin || 'refresh:' + (refreshLib.SKILL_OF.get(skillId) || skillId), state: 'running' };
|
|
5727
|
+
try { refreshRun.started(s); } catch (e) { warnWriteFail('refresh log (code run)', e); }
|
|
5728
|
+
const r = codeSkillRun(skillId, wsId);
|
|
5729
|
+
try { refreshRun.ended(s, { result: r.ok ? 'done' : 'failed', got: r.got || null, error: r.ok ? null : r.error }); } catch (e) { warnWriteFail('refresh log (code run)', e); }
|
|
5730
|
+
return { ...r, code: true, session: null };
|
|
5731
|
+
}
|
|
5705
5732
|
const w = getWs(wsId);
|
|
5706
5733
|
if (!w) return { ok: false, status: 400, error: 'no workspace' };
|
|
5707
5734
|
const task = taskById(skillId, w.root);
|
|
@@ -13,6 +13,8 @@ output:
|
|
|
13
13
|
|
|
14
14
|
/tracker-refresh — bring the plan items that a tracker owns up to date for THIS repository. A tracker-owned item has an owner that starts with `tracker:`. You read files that are already here and you append evidence lines. You call no tracker.
|
|
15
15
|
|
|
16
|
+
The weekly schedule and the Refresh press do this procedure by code, with no agent session (lib/tracker-refresh-run.js, bet 1f). You run it only when the PM asks an agent for it.
|
|
17
|
+
|
|
16
18
|
This skill runs before the bi-weekly report (`report-biweekly`). The report script reads only the ledgers. It cannot call a tracker (R30, D71), so the evidence lines you write are the only way a tracker item reaches the report.
|
|
17
19
|
|
|
18
20
|
Rules that always hold (D71):
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Plain ✓ actions write directly (initiative direct-plain-actions, done test C1-C10): the popup's plan end, close-open and reopen presses write through board routes with Undo; a move the PM pressed wakes no Driver run; the tracker refresh is a script. Scratch server and pure checks. No connector, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"direct-acts.test.js",
|
|
5
|
+
"tracker-refresh-run.test.js"
|
|
6
|
+
],
|
|
7
|
+
"seconds": {
|
|
8
|
+
"direct-acts.test.js": 40,
|
|
9
|
+
"tracker-refresh-run.test.js": 10
|
|
10
|
+
}
|
|
11
|
+
}
|