create-pmos 0.666.0 → 0.667.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 +20 -20
- 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 +19 -0
- package/workspace/guide/cli.md +13 -0
- package/workspace/guide/jira.md +19 -0
- package/workspace/guide/layout.md +1 -1
- package/workspace/lib/headless.js +4 -1
- package/workspace/lib/jira-cli.js +36 -2
- package/workspace/lib/jira-tickets.js +101 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/question-batch.js +22 -8
- package/workspace/lib/routes-your-move.js +23 -4
- package/workspace/lib/signoff-cli.js +87 -0
- package/workspace/lib/signoffs.js +112 -0
- package/workspace/lib/ticket-dry-run.js +164 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-library.css +1 -0
- package/workspace/public/pm/premium-library.js +9 -3
- package/workspace/run-tests.js +43 -1
- package/workspace/skills/initiative-drive.skill +8 -1
- package/workspace/test-lists/dry-run-tickets-before-build.json +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.667.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,25 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.667.0",
|
|
38
|
+
"at": "2026-11-22T04:39:52.182Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1456,
|
|
43
|
+
"t": "Library draws 40 rows a group and hides every Final badge",
|
|
44
|
+
"s": "Library draws 40 rows a group and hides every Final badge",
|
|
45
|
+
"k": "fix"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1447,
|
|
49
|
+
"t": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
|
|
50
|
+
"s": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
|
|
51
|
+
"k": "new"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
36
55
|
{
|
|
37
56
|
"v": "0.666.0",
|
|
38
57
|
"at": "2026-11-22T04:26:58.946Z",
|
|
@@ -327,25 +346,6 @@
|
|
|
327
346
|
"k": "new"
|
|
328
347
|
}
|
|
329
348
|
]
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
"v": "0.635.0",
|
|
333
|
-
"at": "2026-11-19T14:42:50.865Z",
|
|
334
|
-
"f": 4,
|
|
335
|
-
"prs": [
|
|
336
|
-
{
|
|
337
|
-
"n": 1416,
|
|
338
|
-
"t": "Read repo identity off the event loop (stops the 15 s freezes)",
|
|
339
|
-
"s": "Read repo identity off the event loop (stops the 15 s freezes)",
|
|
340
|
-
"k": "fix"
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
"n": 1417,
|
|
344
|
-
"t": "One line per brief item or Jira ticket; Jira Work shows its key",
|
|
345
|
-
"s": "One line per brief item or Jira ticket; Jira Work shows its key",
|
|
346
|
-
"k": "fix"
|
|
347
|
-
}
|
|
348
|
-
]
|
|
349
349
|
}
|
|
350
350
|
]
|
|
351
351
|
}
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
|
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
|
|
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-22T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T04:39:48Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.667.0",
|
|
4
|
+
"at": "2026-11-22T04:39:52.182Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1456,
|
|
9
|
+
"t": "Library draws 40 rows a group and hides every Final badge",
|
|
10
|
+
"s": "Library draws 40 rows a group and hides every Final badge",
|
|
11
|
+
"k": "fix"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1447,
|
|
15
|
+
"t": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
|
|
16
|
+
"s": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
|
|
17
|
+
"k": "new"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
2
21
|
{
|
|
3
22
|
"v": "0.666.0",
|
|
4
23
|
"at": "2026-11-22T04:26:58.946Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -620,9 +620,22 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
|
|
|
620
620
|
- `pmos jira which <KEY>`
|
|
621
621
|
- `pmos jira moves`
|
|
622
622
|
- `pmos jira moved <move id> --status "<Jira status>"` or `--refused "<why>"`
|
|
623
|
+
- `pmos jira guesses <initiative> [--from <file|->]`
|
|
624
|
+
- `pmos jira answer <initiative> <ticket> <n> --text "<answer>"`
|
|
623
625
|
|
|
624
626
|
Every command takes `--json` and `--root <dir>`.
|
|
625
627
|
|
|
628
|
+
### pmos signoff
|
|
629
|
+
|
|
630
|
+
An outside sign-off is a yes that someone outside the team must give before the work can go on: a scope from Marketing, a price from Finance, a go or no-go. One line records each one.
|
|
631
|
+
|
|
632
|
+
- `pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]` records a sign-off the initiative waits on.
|
|
633
|
+
- `pmos signoff answer <id> --answer "<what they said>" --source <pointer>` records the answer. It needs a pointer to where it was given.
|
|
634
|
+
- `pmos signoff drop <id> [--why "<reason>"]` closes a sign-off that is no longer needed.
|
|
635
|
+
- `pmos signoff list [<initiative>] [--all]` lists the open sign-offs. `--all` lists the answered and dropped ones too.
|
|
636
|
+
|
|
637
|
+
An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day, on the same card as the dry-run gaps of your tickets ([Jira tickets](jira.md)). Nothing is sent. Every command takes `--json` and `--root <dir>`.
|
|
638
|
+
|
|
626
639
|
## Intelligence and reports
|
|
627
640
|
|
|
628
641
|
### pmos forecast
|
package/workspace/guide/jira.md
CHANGED
|
@@ -92,6 +92,25 @@ To see every ticket in the terminal:
|
|
|
92
92
|
pmos jira show <initiative>
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
## The dry run: where a builder would guess
|
|
96
|
+
|
|
97
|
+
A ticket points to the PRD, but the builder holds only the ticket. Before you select the tickets, PMOS dry-runs them: the initiative's background run reads each drafted ticket as a builder would, and lists every point where it would have to guess. For each guess it quotes the PRD lines that answer it.
|
|
98
|
+
|
|
99
|
+
- PMOS keeps a quote only when it finds it word for word in the PRD, the done test or the initiative record. A quote it cannot find is dropped.
|
|
100
|
+
- The quoted lines go into the ticket's Additional Context, under **From the PRD (dry run)**. A ticket you edited, selected or pushed is not changed: your text wins.
|
|
101
|
+
- A guess that no document answers is a gap. The gaps go on your question list for the day, one card per initiative, beside the changes PMOS held and the outside sign-offs with no answer ([pmos signoff](cli.md)).
|
|
102
|
+
- When you answer a gap, the answer goes into the ticket and the question leaves the list. When the PRD item of a ticket changes, its dry run is out of date and its gaps leave the list until the dry run runs again.
|
|
103
|
+
|
|
104
|
+
In the terminal:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
pmos jira guesses <initiative>
|
|
108
|
+
pmos jira guesses <initiative> --from guesses.json
|
|
109
|
+
pmos jira answer <initiative> <ticket> <n> --text "Fail closed: show the paywall"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The file has one entry for each ticket: `{"tickets": [{"id": "018", "guesses": [{"question": "If the flag lookup times out, is the article free or locked?", "prd": ["<a line quoted from the PRD>"], "answered": "yes|partly|no"}]}]}`.
|
|
113
|
+
|
|
95
114
|
## Choose the epic
|
|
96
115
|
|
|
97
116
|
The **Send to Jira** sheet shows the epic of each group. Press **Change** to choose **Create a new epic** (named after the group, or after the initiative for the tickets in no group) or to paste the link or key of an existing epic. After the first push the epic of a group is fixed. In the terminal:
|
|
@@ -203,7 +203,7 @@ A Jira date and the planned finish of an initiative get no ✓: PMOS cannot writ
|
|
|
203
203
|
|
|
204
204
|
## Library
|
|
205
205
|
|
|
206
|
-
**Library** in the navigation is a catalogue of everything that was made for your work, from every product: documents, links, meeting notes and prototypes. Each thing is one row: its kind icon, its name, a grey line with its kind, product (when you have two or more), what it is about, who made it and the day, and its state when it is not Final. Reports are not here: a report repeats, so it lives in Routine.
|
|
206
|
+
**Library** in the navigation is a catalogue of everything that was made for your work, from every product: documents, links, meeting notes and prototypes. Each thing is one row: its kind icon, its name, a grey line with its kind, product (when you have two or more), what it is about, who made it and the day, and its state when it is not Final (a Final edition, such as v2, shows no state either). A long group shows its first 40 rows; **Show 40 more** under them shows the next ones. Reports are not here: a report repeats, so it lives in Routine.
|
|
207
207
|
|
|
208
208
|
- **Kind** says what the thing is: PRD, Strategic brief, Design brief, Done test, Meeting notes, Prototype, Link · Confluence, and so on. PMOS reads it from the file's `type` first, then from its title ("Brief: …") and its file name. When the title only repeats the kind, the name leaves it out: "Brief: Scarlet lucky draw" shows as "Scarlet lucky draw", Kind Strategic brief.
|
|
209
209
|
- **About** is the program and the initiative ("Project Ascent › Tender new CIAM"). It is empty when it repeats the name.
|
|
@@ -175,7 +175,10 @@ const TOOLS = Object.freeze({
|
|
|
175
175
|
ask: Object.freeze(['Read', 'Glob', 'Grep']),
|
|
176
176
|
// core-documents: the driver drafts a current-stage document that is due with `pmos coredoc write` (a draft only; Keep issues it).
|
|
177
177
|
drive: Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos driver *)', 'Bash(pmos initiative list *)', 'Bash(pmos initiative export *)',
|
|
178
|
-
'Bash(pmos coredoc write *)', 'Bash(git log *)', 'Bash(ls *)', 'Bash(date *)'
|
|
178
|
+
'Bash(pmos coredoc write *)', 'Bash(git log *)', 'Bash(ls *)', 'Bash(date *)',
|
|
179
|
+
// dry-run-tickets-before-build: the dry run of drafted tickets and the outside sign-offs. PMOS-local records only: nothing is sent,
|
|
180
|
+
// and the PM's answer to a gap (`pmos jira answer`) is not in the list.
|
|
181
|
+
'Bash(pmos jira show *)', 'Bash(pmos jira guesses *)', 'Bash(pmos signoff ask *)', 'Bash(pmos signoff answer *)', 'Bash(pmos signoff list *)']),
|
|
179
182
|
// The web run: WebSearch, WebFetch and the one verb that files a finding. No Read, no Glob, no Grep, no repository path in its prompt or its add-dirs.
|
|
180
183
|
// `pmos scan section` writes a section of a report document; the web run gives each web claim a URL it read.
|
|
181
184
|
'scan-web': Object.freeze(['WebSearch', 'WebFetch', 'Bash(pmos scan file *)', 'Bash(pmos scan section *)']),
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* pmos jira which <KEY> [<KEY> …] the initiative a Jira key belongs to
|
|
19
19
|
* pmos jira moves the status moves the PM asked in PMOS, not answered yet (lib/jira-moves.js)
|
|
20
20
|
* pmos jira moved <move id> --status "<Jira status>" | --refused "<why>" the agent's answer for one move
|
|
21
|
+
* pmos jira guesses <initiative> [--from <file|->] a ticket dry run (lib/ticket-dry-run.js), recorded or shown
|
|
22
|
+
* pmos jira answer <initiative> <ticket> <n> --text "<answer>" the PM's answer to one dry-run gap
|
|
21
23
|
* every command: [--json] [--root <dir>]
|
|
22
24
|
*
|
|
23
25
|
* This command never talks to Jira. An agent session does, with the PM's own Atlassian connection (D53, D88), and
|
|
@@ -33,12 +35,16 @@ const jiraMoves = require('./jira-moves.js');
|
|
|
33
35
|
const planItems = require('./plan-items.js');
|
|
34
36
|
const guard = require('./pm-guard.js');
|
|
35
37
|
|
|
36
|
-
const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'summary', 'which', 'moves', 'moved'] };
|
|
38
|
+
const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'summary', 'which', 'moves', 'moved', 'guesses', 'answer'] };
|
|
37
39
|
const USAGE = [
|
|
38
40
|
'usage: pmos jira draft|show|epic|approve|pending|record|query|sync|summary|which — Jira tickets from the PRD, and their status',
|
|
39
41
|
' pmos jira draft <initiative> [--dry-run] draft one ticket per PRD item, in the ticket template',
|
|
40
42
|
' With no PRD stories section: one ticket per done-test check, else one per open task.',
|
|
41
43
|
' pmos jira show <initiative> every ticket, what needs you, and its status in Jira',
|
|
44
|
+
' pmos jira guesses <initiative> --from <file|-> record a dry run: each ticket\'s guesses, with the PRD lines that answer them',
|
|
45
|
+
' Quotes not found word for word in the PRD, done test or record are dropped. Gaps go to the day\'s question list.',
|
|
46
|
+
' pmos jira guesses <initiative> the dry run so far: the guesses of each ticket and the open gaps',
|
|
47
|
+
' pmos jira answer <initiative> <ticket> <n> --text "<answer>" the PM\'s answer to gap n: it goes into the ticket',
|
|
42
48
|
' pmos jira epic <initiative> new|<KEY or link> [--group <g>] create a new epic at the first push, or use an existing one',
|
|
43
49
|
' pmos jira approve <initiative> <ID> … select tickets to push (you, in your own terminal)',
|
|
44
50
|
' pmos jira pending <initiative> what the push creates or updates in Jira',
|
|
@@ -58,7 +64,7 @@ const USAGE = [
|
|
|
58
64
|
'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
|
|
59
65
|
];
|
|
60
66
|
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints']);
|
|
61
|
-
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint']);
|
|
67
|
+
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint', 'text']);
|
|
62
68
|
const FLAG_TEXT = { 'prd-changed': 'PRD changed', removed: 'Removed from PRD', blocked: 'Blocked', incomplete: 'Missing text', pushing: 'Selected, waiting for the push', edited: 'Edited, not in Jira yet' };
|
|
63
69
|
|
|
64
70
|
function parse(argv) {
|
|
@@ -216,6 +222,34 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
216
222
|
lines.push('Read them on the Jira tickets tab, or with pmos jira show. Select the ready ones there, or with pmos jira approve.');
|
|
217
223
|
return out(r, lines);
|
|
218
224
|
}
|
|
225
|
+
if (verb === 'guesses') {
|
|
226
|
+
if (flags.from == null) {
|
|
227
|
+
const gaps = jiraTickets.dryRunGaps(root, initiative);
|
|
228
|
+
const v = jiraTickets.dryRunView(root, initiative);
|
|
229
|
+
if (!v) return fail(`no ticket draft for ${initiative} — press Draft tickets, or run pmos jira draft ${initiative}`);
|
|
230
|
+
const done = v.filter((t) => t.dryRun);
|
|
231
|
+
const lines = [`${initiative} · ${done.length} of ${v.length} ${v.length === 1 ? 'ticket' : 'tickets'} dry-run · ${gaps.length} open ${gaps.length === 1 ? 'gap' : 'gaps'}`];
|
|
232
|
+
for (const t of done) lines.push(` ${t.id} · ${t.dryRun.guesses} ${t.dryRun.guesses === 1 ? 'guess' : 'guesses'} · ${t.dryRun.answered} answered · ${t.dryRun.partly} partly · ${t.dryRun.gaps} ${t.dryRun.gaps === 1 ? 'gap' : 'gaps'}${t.dryRun.stale ? ' · PRD changed since: run it again' : ''}`);
|
|
233
|
+
for (const g of gaps) lines.push(` gap ${g.ticket} ${g.n} · ${g.q}`);
|
|
234
|
+
return out({ ok: true, initiative, tickets: done.map((t) => ({ id: t.id, ...t.dryRun })), gaps }, lines);
|
|
235
|
+
}
|
|
236
|
+
const r = jiraTickets.dryRun(root, initiative, readInput(flags.from, cwd, stdin), { now });
|
|
237
|
+
if (!r.ok) return fail(r.error);
|
|
238
|
+
const lines = [`${initiative} · ${r.tickets.length} ${r.tickets.length === 1 ? 'ticket' : 'tickets'} · ${r.guesses} guesses: ${r.answered} answered, ${r.partly} partly, ${r.gaps} not in any document`];
|
|
239
|
+
if (r.written.length) lines.push(` PRD lines copied into ${r.written.join(', ')}`);
|
|
240
|
+
for (const k of r.kept) lines.push(` ${k.id} not changed: ${k.why}`);
|
|
241
|
+
if (r.unverified) lines.push(` ${r.unverified} ${r.unverified === 1 ? 'quote was' : 'quotes were'} not found word for word and dropped`);
|
|
242
|
+
if (r.unknown.length) lines.push(` not in the draft: ${r.unknown.join(', ')}`);
|
|
243
|
+
if (r.gaps) lines.push(` The ${r.gaps === 1 ? 'gap goes' : r.gaps + ' gaps go'} to the PM's question list for today or tomorrow.`);
|
|
244
|
+
return out(r, lines);
|
|
245
|
+
}
|
|
246
|
+
if (verb === 'answer') {
|
|
247
|
+
const [, ticket, n] = pos;
|
|
248
|
+
if (!ticket || !n || !flags.text) return need('<initiative> <ticket> <n> --text "<the answer>"');
|
|
249
|
+
const r = jiraTickets.answerDryRun(root, initiative, ticket, n, flags.text, { now });
|
|
250
|
+
if (!r.ok) return fail(r.error);
|
|
251
|
+
return out(r, [`${initiative} ${ticket} gap ${r.n} answered${r.written.length ? ' and added to the ticket' : ''}${r.kept.length ? ` · the ticket was not changed: ${r.kept[0].why}` : ''}`]);
|
|
252
|
+
}
|
|
219
253
|
if (verb === 'show') {
|
|
220
254
|
const r = jiraTickets.view(root, initiative, { snapshot: jiraStatus.readSnapshot(root, initiative) });
|
|
221
255
|
if (!r.ok) return fail(r.error);
|
|
@@ -549,6 +549,106 @@ function draft(root, initiative, { dryRun = false, now } = {}) {
|
|
|
549
549
|
return result;
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
+
// ── the dry run (initiative dry-run-tickets-before-build; A194) ─────────────────────────────────────
|
|
553
|
+
/** The dry-run helpers, loaded when a dry run is read or written. */
|
|
554
|
+
/** The state folder of the repository: <state>/tracker/ holds the ticket drafts, dry runs and sign-offs. */
|
|
555
|
+
function stateDirOf(root) { return stateDir(root); }
|
|
556
|
+
function DRm() { return require('./ticket-dry-run.js'); }
|
|
557
|
+
function dryRunPath(root, initiative) { return path.join(jiraDir(root), `${initiative}-dryrun.json`); }
|
|
558
|
+
/** The text a dry-run quote must be found in: the PRD, the story files, the done test and the record. */
|
|
559
|
+
function dryRunHaystack(root, initiative, st) {
|
|
560
|
+
const parts = [];
|
|
561
|
+
const rfm = recordFm(root, initiative) || {};
|
|
562
|
+
const prd = prdOf(rfm);
|
|
563
|
+
if (prd) { const t = readPrd(root, prd); if (t != null) parts.push(t); }
|
|
564
|
+
for (const rel of (st && st.ok ? st.sources : []) || []) { if (rel === prd) continue; const t = readPrd(root, rel); if (t != null) parts.push(t); }
|
|
565
|
+
const dt = readDoneTest(root, rfm); if (dt) parts.push(dt.text);
|
|
566
|
+
const file = planTree.recordPath(root, initiative);
|
|
567
|
+
if (file) { try { parts.push(fs.readFileSync(file, 'utf8')); } catch { /* no record text */ } }
|
|
568
|
+
return parts.join('\n');
|
|
569
|
+
}
|
|
570
|
+
/** A ticket the dry run may write into: drafted by PMOS, not edited, not selected, not in Jira. The PM's text always wins. */
|
|
571
|
+
function dryRunWritable(t) { return !t.jira && !t.approved && (!t.drafted || t.drafted === contentHash(t)); }
|
|
572
|
+
/** Put each ticket's dry-run block into its Additional Context. → { written: [id], kept: [{ id, why }] } */
|
|
573
|
+
function applyDryRun(d, file, only) {
|
|
574
|
+
const written = [], kept = [];
|
|
575
|
+
for (const t of d.tickets) {
|
|
576
|
+
const e = file.tickets[t.id];
|
|
577
|
+
if (!e || (only && !only.has(t.id))) continue;
|
|
578
|
+
if (e.source && t.source && e.source !== t.source) { kept.push({ id: t.id, why: 'its PRD item changed since the dry run: run it again' }); continue; }
|
|
579
|
+
if (!dryRunWritable(t)) { kept.push({ id: t.id, why: t.jira ? 'it is in Jira' : t.approved ? 'it is selected for a push' : 'you edited it' }); continue; }
|
|
580
|
+
const next = DRm().withBlock(t.sections.context, DRm().blockOf(e));
|
|
581
|
+
if (next === (t.sections.context || '')) continue;
|
|
582
|
+
t.sections.context = next; t.drafted = contentHash(t); written.push(t.id);
|
|
583
|
+
}
|
|
584
|
+
return { written, kept };
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Record an agent's dry run of the drafted tickets: keep the quotes found in the documents, copy them into each ticket, and keep the
|
|
588
|
+
* gaps for the owner's question list. raw: the agent's JSON (lib/ticket-dry-run.js parse). → { ok, tickets, guesses, answered, partly,
|
|
589
|
+
* gaps, unverified, unknown, written, kept }
|
|
590
|
+
*/
|
|
591
|
+
function dryRun(root, initiative, raw, { now } = {}) {
|
|
592
|
+
const { d, error } = mustDraft(root, initiative);
|
|
593
|
+
if (error) return { ok: false, status: 404, error };
|
|
594
|
+
const p = DRm().parse(raw);
|
|
595
|
+
if (!p.ok) return { ok: false, status: 400, error: p.error };
|
|
596
|
+
const st = items(root, initiative);
|
|
597
|
+
const byId = new Map(d.tickets.map((t) => [t.id, t]));
|
|
598
|
+
const c = DRm().check(p, { ids: new Set(byId.keys()), sourceOf: (id) => byId.get(id).source, haystack: dryRunHaystack(root, initiative, st), now });
|
|
599
|
+
if (!Object.keys(c.tickets).length) return { ok: false, status: 400, error: `no ticket of the draft is in the dry run (${c.unknown.join(', ') || 'none named'})` };
|
|
600
|
+
const file = DRm().merge(DRm().read(dryRunPath(root, initiative)), c, { initiative, now });
|
|
601
|
+
DRm().write(dryRunPath(root, initiative), file);
|
|
602
|
+
const ap = applyDryRun(d, file, new Set(Object.keys(c.tickets)));
|
|
603
|
+
if (ap.written.length) writeDraft(root, initiative, d, { now, prd: prdOf(recordFm(root, initiative)) });
|
|
604
|
+
const sum = { guesses: 0, answered: 0, partly: 0, gaps: 0 };
|
|
605
|
+
for (const e of Object.values(c.tickets)) { const k = DRm().countsOf(e); sum.guesses += k.guesses; sum.answered += k.answered; sum.partly += k.partly; sum.gaps += k.gaps; }
|
|
606
|
+
return { ok: true, initiative, tickets: Object.keys(c.tickets), ...sum, unverified: c.unverified, unknown: c.unknown, written: ap.written, kept: ap.kept, file: relOf(root, dryRunPath(root, initiative)) };
|
|
607
|
+
}
|
|
608
|
+
/** The PM's answer to a gap: it goes into the ticket and the question leaves the list. */
|
|
609
|
+
function answerDryRun(root, initiative, ticket, n, text, { now } = {}) {
|
|
610
|
+
const file = DRm().read(dryRunPath(root, initiative));
|
|
611
|
+
if (!file) return { ok: false, status: 404, error: `no dry run for ${initiative}: run the dry run first` };
|
|
612
|
+
const a = DRm().answer(file, ticket, n, text, now);
|
|
613
|
+
if (!a.ok) return { ok: false, status: 400, error: a.error };
|
|
614
|
+
DRm().write(dryRunPath(root, initiative), file);
|
|
615
|
+
const d = readDraft(root, initiative);
|
|
616
|
+
let ap = { written: [], kept: [] };
|
|
617
|
+
if (d) { ap = applyDryRun(d, file, new Set([ticket])); if (ap.written.length) writeDraft(root, initiative, d, { now, prd: prdOf(recordFm(root, initiative)) }); }
|
|
618
|
+
return { ok: true, initiative, ticket, n: a.guess.n, q: a.guess.q, answer: a.guess.answer, written: ap.written, kept: ap.kept };
|
|
619
|
+
}
|
|
620
|
+
/** The gaps of an initiative's dry run that nobody answered: [{ ticket, n, q }]. Stale and removed tickets are left out. */
|
|
621
|
+
function dryRunGaps(root, initiative) {
|
|
622
|
+
const file = DRm().read(dryRunPath(root, initiative));
|
|
623
|
+
if (!file) return [];
|
|
624
|
+
const d = readDraft(root, initiative);
|
|
625
|
+
const st = items(root, initiative);
|
|
626
|
+
const now = new Map((st.ok ? st.items : []).map((x) => [x.id, x.hash]));
|
|
627
|
+
// the PRD item as it is now (a ticket the PM edited keeps its old source hash, so the item says whether the PRD moved)
|
|
628
|
+
const src = new Map(((d && d.tickets) || []).map((t) => [t.id, now.get(t.id) || t.source || null]));
|
|
629
|
+
return DRm().gapsOf(file, (id) => (src.has(id) ? src.get(id) : undefined));
|
|
630
|
+
}
|
|
631
|
+
/** Each drafted ticket's dry run: [{ id, summary, dryRun: { guesses, answered, partly, gaps, open, stale } | null }]. stale: its PRD item
|
|
632
|
+
* changed since the dry run. null when no draft. */
|
|
633
|
+
function dryRunView(root, initiative) {
|
|
634
|
+
const d = readDraft(root, initiative);
|
|
635
|
+
if (!d) return null;
|
|
636
|
+
const file = DRm().read(dryRunPath(root, initiative));
|
|
637
|
+
const st = items(root, initiative);
|
|
638
|
+
const cur = new Map((st.ok ? st.items : []).map((x) => [x.id, x.hash]));
|
|
639
|
+
return d.tickets.map((t) => {
|
|
640
|
+
const e = file && file.tickets[t.id];
|
|
641
|
+
const now = cur.get(t.id) || t.source || null;
|
|
642
|
+
return { id: t.id, summary: t.summary, dryRun: e ? { ...DRm().countsOf(e), stale: !!(e.source && now && e.source !== now) } : null };
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
/** The initiatives with a dry-run file in this repository. */
|
|
646
|
+
function dryRunInitiatives(root) {
|
|
647
|
+
let names = [];
|
|
648
|
+
try { names = fs.readdirSync(jiraDir(root)); } catch { return []; }
|
|
649
|
+
return names.filter((n) => n.endsWith('-dryrun.json')).map((n) => n.slice(0, -'-dryrun.json'.length)).sort();
|
|
650
|
+
}
|
|
651
|
+
|
|
552
652
|
// ── J4, J5, J10, J12 · what the tab draws ──────────────────────────────────────────────────────────
|
|
553
653
|
function epicOf(d, rfm) {
|
|
554
654
|
const fm = (d && d.fm) || {};
|
|
@@ -910,4 +1010,5 @@ module.exports = {
|
|
|
910
1010
|
items, itemsInPrd, itemsInFile, fromItem, draft, view, edit, resolvePrd, setEpic, approve, pushPlan, record, groupsOf, groupId,
|
|
911
1011
|
readDraft, parseDraft, pushedTickets, draftedInitiatives, epicInitiatives, epicKeysOf, linkedEpics, anchorOf, missingOf, contentHash, describe,
|
|
912
1012
|
draftPath, draftRel, jiraDir, relOf, recordFm, prdOf,
|
|
1013
|
+
dryRun, answerDryRun, dryRunGaps, dryRunView, dryRunInitiatives, dryRunPath, stateDirOf,
|
|
913
1014
|
};
|
|
@@ -48,6 +48,9 @@ const VERBS = Object.freeze({
|
|
|
48
48
|
// Not a pm-os-absorb verb (run: null): people-directory added it through the same table.
|
|
49
49
|
people: Object.freeze({ module: 'people-cli.js', run: null, guide: 'cli.md',
|
|
50
50
|
help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
|
|
51
|
+
// Not a pm-os-absorb verb (run: null): initiative dry-run-tickets-before-build added it through the same table.
|
|
52
|
+
signoff: Object.freeze({ module: 'signoff-cli.js', run: null, guide: 'cli.md',
|
|
53
|
+
help: 'pmos signoff ask|answer|drop|list … — the outside sign-offs an initiative waits on; open ones go on your question list (pmos signoff help)' }),
|
|
51
54
|
// Not a pm-os-absorb verb (run: null): initiative my-work added it through the same table.
|
|
52
55
|
'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'cli.md',
|
|
53
56
|
help: 'pmos my-work list|show|submit … — the Jira tickets and WBS items assigned to you, ranked (pmos my-work help)' }),
|
|
@@ -47,8 +47,10 @@ function partOf(p, hold) {
|
|
|
47
47
|
return `${one(p.title || p.why || 'A change', 120)}?${only || ' PMOS found no source.'}`;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/** One question per owner and initiative, the PM's first, then by initiative. PURE.
|
|
51
|
-
|
|
50
|
+
/** One question per owner and initiative, the PM's first, then by initiative. PURE.
|
|
51
|
+
* extra: other open asks on the same card (initiative dry-run-tickets-before-build): [{ ini, id, text, title?, board?, owner? }] — the
|
|
52
|
+
* dry-run gaps of a ticket (lib/ticket-dry-run.js) and the outside sign-offs with no answer (lib/signoffs.js). */
|
|
53
|
+
function questionsOf(held, { pm = 'PM', extra = [] } = {}) {
|
|
52
54
|
const by = new Map();
|
|
53
55
|
for (const h of held || []) {
|
|
54
56
|
if (!isObj(h) || !isObj(h.prop) || !h.ini) continue;
|
|
@@ -58,10 +60,20 @@ function questionsOf(held, { pm = 'PM' } = {}) {
|
|
|
58
60
|
q.ids.push(h.prop.id);
|
|
59
61
|
q.parts.push(partOf(h.prop, h.hold));
|
|
60
62
|
}
|
|
63
|
+
for (const x of extra || []) {
|
|
64
|
+
if (!isObj(x) || !x.ini || !x.id || !x.text) continue;
|
|
65
|
+
const owner = one(x.owner || '', 60), key = (owner || '') + '|' + x.ini;
|
|
66
|
+
if (!by.has(key)) by.set(key, { key, owner: owner || pm, toPm: !owner, ini: x.ini, title: x.title || x.ini, board: x.board || '', parts: [], ids: [] });
|
|
67
|
+
const q = by.get(key);
|
|
68
|
+
q.ids.push(x.id);
|
|
69
|
+
q.parts.push(one(x.text, 400));
|
|
70
|
+
q.asks = (q.asks || 0) + 1;
|
|
71
|
+
}
|
|
61
72
|
const out = [...by.values()].map((q) => {
|
|
62
73
|
const shown = q.parts.slice(0, 3), more = q.parts.length - shown.length;
|
|
74
|
+
const moreWord = q.asks ? plural(more, 'more question', 'more questions') : plural(more, 'more change', 'more changes');
|
|
63
75
|
return { key: q.key, owner: q.owner, toPm: q.toPm, ini: q.ini, title: q.title, board: q.board, ids: q.ids, n: q.ids.length,
|
|
64
|
-
text: shown.join(' ') + (more > 0 ? ` And ${
|
|
76
|
+
text: shown.join(' ') + (more > 0 ? ` And ${moreWord}.` : '') };
|
|
65
77
|
});
|
|
66
78
|
return out.sort((a, b) => (a.toPm === b.toPm ? 0 : a.toPm ? -1 : 1) || a.title.localeCompare(b.title) || a.owner.localeCompare(b.owner));
|
|
67
79
|
}
|
|
@@ -75,17 +87,19 @@ function readDays(stateDir) {
|
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
/** The list fixed for `day`. The first read of a day writes its line; later reads that day keep it. */
|
|
78
|
-
function today(stateDir, held, { day, pm, now } = {}) {
|
|
90
|
+
function today(stateDir, held, { day, pm, now, extra = [] } = {}) {
|
|
79
91
|
const list = (held || []).filter((h) => isObj(h) && isObj(h.prop) && h.prop.id);
|
|
80
|
-
|
|
92
|
+
const asks = (extra || []).filter((x) => isObj(x) && x.id && x.ini && x.text);
|
|
93
|
+
if (!day) return { day: '', questions: questionsOf(list, { pm, extra: asks }), later: 0 };
|
|
81
94
|
let fixed = stateDir ? readDays(stateDir).filter((l) => l.day === day).pop() : null;
|
|
82
|
-
if (!fixed && stateDir && list.length) {
|
|
83
|
-
fixed = { day, at: new Date(now == null ? Date.now() : now).toISOString(), ids: [...new Set(list.map((h) => h.prop.id))].slice(0, MAX_IDS) };
|
|
95
|
+
if (!fixed && stateDir && (list.length || asks.length)) {
|
|
96
|
+
fixed = { day, at: new Date(now == null ? Date.now() : now).toISOString(), ids: [...new Set([...list.map((h) => h.prop.id), ...asks.map((x) => x.id)])].slice(0, MAX_IDS) };
|
|
84
97
|
try { fs.mkdirSync(stateDir, { recursive: true }); fs.appendFileSync(path.join(stateDir, LEDGER), JSON.stringify(fixed) + '\n'); } catch { /* the list still shows; tomorrow tries again */ }
|
|
85
98
|
}
|
|
86
99
|
const on = new Set(fixed ? fixed.ids : []);
|
|
87
100
|
const mine = fixed ? list.filter((h) => on.has(h.prop.id)) : list;
|
|
88
|
-
|
|
101
|
+
const mineAsks = fixed ? asks.filter((x) => on.has(x.id)) : asks;
|
|
102
|
+
return { day, questions: questionsOf(mine, { pm, extra: mineAsks }), later: list.length - mine.length + asks.length - mineAsks.length };
|
|
89
103
|
}
|
|
90
104
|
|
|
91
105
|
module.exports = { questionsOf, today, ownerOf, partOf, LEDGER };
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* staleOf), and `expired` lists the ones of the last 7 days, so Your move says it once. Idempotent: an expired proposal folds as dropped.
|
|
16
16
|
* DONE (C2, board CsD): what an agent kept by itself in the last 14 days, one line per batch with its Undo (lib/done-feed.js).
|
|
17
17
|
* QUESTIONS (act-alone-only-with-a-source): { day, questions: [lib/question-batch.js question], later } — the changes PMOS holds for want
|
|
18
|
-
* of a source, one question per owner and initiative, the PM's first; the list is fixed for the day (one line in question-days.jsonl).
|
|
18
|
+
* of a source, one question per owner and initiative, the PM's first; the list is fixed for the day (one line in question-days.jsonl).
|
|
19
|
+
* On the same card (dry-run-tickets-before-build): the dry-run gaps of drafted tickets and the outside sign-offs with no answer. */
|
|
19
20
|
const YM = require('./your-move.js');
|
|
20
21
|
|
|
21
22
|
const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
@@ -69,12 +70,30 @@ function expire(ctx, w, now = Date.now()) {
|
|
|
69
70
|
* initiative, fixed once a day (lib/question-batch.js). Questions for teammates are drafts: nothing is sent. */
|
|
70
71
|
function questions(ctx, w, today) {
|
|
71
72
|
const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
let held = [];
|
|
74
|
+
try { held = require('./routes-proposals.js').heldOf(ctx, w); } catch { held = []; }
|
|
75
|
+
let extra = [];
|
|
76
|
+
try { extra = asksOf(w.root); } catch { extra = []; }
|
|
77
|
+
return require('./question-batch.js').today(dir, held, { day: today, extra });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The other asks on the same card (dry-run-tickets-before-build): each ticket's dry-run gaps nobody answered (lib/ticket-dry-run.js),
|
|
81
|
+
* and the outside sign-offs that waited too long (lib/signoffs.js). Both are the PM's to chase: nothing is sent. */
|
|
82
|
+
function asksOf(root, now = Date.now()) {
|
|
83
|
+
const JT = require('./jira-tickets.js'), SO = require('./signoffs.js');
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const ini of JT.dryRunInitiatives(root)) {
|
|
86
|
+
const title = (JT.recordFm(root, ini) || {}).title || ini;
|
|
87
|
+
for (const g of JT.dryRunGaps(root, ini)) out.push({ ini, title, id: `dry:${ini}:${g.ticket}:${g.n}`, text: `Ticket ${g.ticket}: ${/[?.]$/.test(g.q) ? g.q : g.q + '?'}` });
|
|
88
|
+
}
|
|
89
|
+
for (const p of SO.partsOf(SO.list(SO.fileOf(JT.stateDirOf(root)), { open: true }), now)) {
|
|
90
|
+
out.push({ ini: p.ini, title: (JT.recordFm(root, p.ini) || {}).title || p.ini, id: p.id, text: p.text });
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
74
93
|
}
|
|
75
94
|
|
|
76
95
|
module.exports = {
|
|
77
|
-
expire, questions,
|
|
96
|
+
expire, questions, asksOf,
|
|
78
97
|
prefixes: ['/api/your-move'],
|
|
79
98
|
handle: async (req, res, url, ctx) => {
|
|
80
99
|
if (url.pathname !== '/api/your-move') return false;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* signoff-cli.js — `pmos signoff …`: the outside sign-offs an initiative waits on (initiative dry-run-tickets-before-build; A188).
|
|
3
|
+
*
|
|
4
|
+
* pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked YYYY-MM-DD] [--due YYYY-MM-DD] [--source <pointer>]
|
|
5
|
+
* pmos signoff answer <id> --answer "<what they said>" --source <pointer>
|
|
6
|
+
* pmos signoff drop <id> [--why "<why it is no longer needed>"]
|
|
7
|
+
* pmos signoff list [<initiative>] [--all]
|
|
8
|
+
* every command: [--json] [--root <dir>]
|
|
9
|
+
*
|
|
10
|
+
* The ledger is <state>/tracker/signoffs.jsonl (lib/signoffs.js). An open sign-off that waited 3 days, or is past its due date, goes
|
|
11
|
+
* on the PM's question list for the day (GET /api/your-move questions), beside the dry-run gaps. This command sends nothing.
|
|
12
|
+
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
13
|
+
*/
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { execFileSync } = require('child_process');
|
|
16
|
+
const { parseArgs } = require('./schedule-cli');
|
|
17
|
+
const SO = require('./signoffs.js');
|
|
18
|
+
const jiraTickets = require('./jira-tickets.js');
|
|
19
|
+
|
|
20
|
+
const COMMANDS = { signoff: ['ask', 'answer', 'drop', 'list'] };
|
|
21
|
+
const USAGE = [
|
|
22
|
+
'usage: pmos signoff ask|answer|drop|list — the outside sign-offs an initiative waits on',
|
|
23
|
+
' pmos signoff ask <initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]',
|
|
24
|
+
' pmos signoff answer <id> --answer "<what they said>" --source <pointer> only with a pointer to where they said it',
|
|
25
|
+
' pmos signoff drop <id> [--why "<reason>"] the sign-off is no longer needed',
|
|
26
|
+
' pmos signoff list [<initiative>] [--all] the open sign-offs (--all: answered and dropped too)',
|
|
27
|
+
' every command: [--json] [--root <dir>]',
|
|
28
|
+
'An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day. Nothing is sent.',
|
|
29
|
+
];
|
|
30
|
+
const BOOL = new Set(['json', 'help', 'all']);
|
|
31
|
+
const VALUE = new Set(['who', 'what', 'asked', 'due', 'source', 'answer', 'why', 'root']);
|
|
32
|
+
|
|
33
|
+
function repoRoot(cwd) {
|
|
34
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; }
|
|
35
|
+
catch { return cwd; }
|
|
36
|
+
}
|
|
37
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
38
|
+
const md = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
39
|
+
const lineOf = (s) => `${s.id} · ${s.ini} · ${s.who}: ${s.what} · asked ${md(s.asked)}${s.due ? ` · due ${md(s.due)}` : ''}${s.state === 'answered' ? ` · answered: ${s.answer}` : s.state === 'dropped' ? ' · dropped' : ''}`;
|
|
40
|
+
|
|
41
|
+
function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now } = {}) {
|
|
42
|
+
const args = argv[0] === 'signoff' ? argv.slice(1) : argv.slice();
|
|
43
|
+
const verb = args[0];
|
|
44
|
+
const rest = [], bools = {};
|
|
45
|
+
for (const a of args.slice(1)) { if (a.startsWith('--') && BOOL.has(a.slice(2))) bools[a.slice(2)] = true; else rest.push(a); }
|
|
46
|
+
const { pos, flags: f0 } = parseArgs(rest);
|
|
47
|
+
const flags = { ...f0, ...bools };
|
|
48
|
+
if (!verb || verb === 'help' || verb === '--help' || flags.help) { for (const l of USAGE) say(l); return verb ? 0 : 2; }
|
|
49
|
+
if (!COMMANDS.signoff.includes(verb)) { say(`unknown signoff command "${verb}" — one of ${COMMANDS.signoff.join(', ')}`); return 2; }
|
|
50
|
+
for (const k of Object.keys(flags)) {
|
|
51
|
+
if (!BOOL.has(k) && !VALUE.has(k)) { say(`unknown option --${k}`); return 2; }
|
|
52
|
+
if (VALUE.has(k) && flags[k] === '') { say(`--${k} needs a value`); return 2; }
|
|
53
|
+
}
|
|
54
|
+
const json = !!flags.json;
|
|
55
|
+
const root = flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd);
|
|
56
|
+
const t = now == null ? Date.now() : typeof now === 'function' ? +now() : +now;
|
|
57
|
+
const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say(`✗ ${error}`); return code; };
|
|
58
|
+
const out = (r, lines) => { if (json) say(JSON.stringify(r)); else for (const l of lines) say(l); return 0; };
|
|
59
|
+
const need = (what) => { say(`usage: pmos signoff ${verb} ${what}`); return 2; };
|
|
60
|
+
let file;
|
|
61
|
+
try { file = SO.fileOf(jiraTickets.stateDirOf(root)); } catch (e) { return fail(String((e && e.message) || e)); }
|
|
62
|
+
|
|
63
|
+
if (verb === 'ask') {
|
|
64
|
+
const ini = pos[0];
|
|
65
|
+
if (!ini || !flags.who || !flags.what) return need('<initiative> --who "<name or team>" --what "<what they must say yes to>" [--asked <date>] [--due <date>] [--source <pointer>]');
|
|
66
|
+
if (!jiraTickets.recordFm(root, ini)) return fail(`no initiative ${ini} in this repository`);
|
|
67
|
+
const r = SO.ask(file, { ini, who: flags.who, what: flags.what, asked: flags.asked, due: flags.due, source: flags.source }, t);
|
|
68
|
+
if (!r.ok) return fail(r.error);
|
|
69
|
+
return out(r, [`${r.already ? 'already open' : 'recorded'}: ${lineOf(r.signoff)}`]);
|
|
70
|
+
}
|
|
71
|
+
if (verb === 'answer') {
|
|
72
|
+
if (!pos[0] || !flags.answer || !flags.source) return need('<id> --answer "<what they said>" --source <pointer>');
|
|
73
|
+
const r = SO.answer(file, pos[0], { answer: flags.answer, source: flags.source }, t);
|
|
74
|
+
if (!r.ok) return fail(r.error);
|
|
75
|
+
return out(r, [`answered: ${lineOf(r.signoff)}`]);
|
|
76
|
+
}
|
|
77
|
+
if (verb === 'drop') {
|
|
78
|
+
if (!pos[0]) return need('<id> [--why "<reason>"]');
|
|
79
|
+
const r = SO.drop(file, pos[0], { why: flags.why }, t);
|
|
80
|
+
if (!r.ok) return fail(r.error);
|
|
81
|
+
return out(r, [`dropped: ${lineOf(r.signoff)}`]);
|
|
82
|
+
}
|
|
83
|
+
const L = SO.list(file, { ini: pos[0], open: !flags.all });
|
|
84
|
+
return out({ ok: true, signoffs: L }, L.length ? L.map(lineOf) : [`no ${flags.all ? '' : 'open '}sign-off${pos[0] ? ` for ${pos[0]}` : ''}`]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* signoffs.js — outside sign-offs: who outside the team must say yes before the work can go on (initiative
|
|
3
|
+
* dry-run-tickets-before-build; A188 in pmos-ideas/proofs). On the PSLE launch, 4 sign-offs (scope from Marketing, contract wording,
|
|
4
|
+
* Commerce's go or no-go, the add-on price) sat under a launch 5 days away with no answer recorded and nothing chasing them.
|
|
5
|
+
*
|
|
6
|
+
* One line per sign-off: who, what, asked on, due, and the answer. The Driver records them from the PRD and the notes, and records an
|
|
7
|
+
* answer only with a pointer to where it was given. An open sign-off that has waited WAIT_DAYS, or whose due date passed, goes on the
|
|
8
|
+
* owner's daily question list (lib/question-batch.js), on the same card as the dry-run gaps. Nothing here sends anything.
|
|
9
|
+
*
|
|
10
|
+
* ask(file, { ini, who, what, asked, due, source }, now) → { ok, signoff } | { ok: false, error }
|
|
11
|
+
* answer(file, id, { answer, source }, now) → { ok, signoff } | { ok: false, error }
|
|
12
|
+
* drop(file, id, { why }, now) → { ok, signoff } | { ok: false, error }
|
|
13
|
+
* list(file, { ini, open }) → [signoff] the ledger folded, oldest ask first
|
|
14
|
+
* partsOf(list, now) → [{ ini, id, text }] PURE: the open sign-offs to ask about today
|
|
15
|
+
* fileOf(stateDir) → <state>/tracker/signoffs.jsonl
|
|
16
|
+
*
|
|
17
|
+
* THE LEDGER is append-only, one JSON line per act: { op: 'ask' | 'answer' | 'drop', id, … , at }. A signoff:
|
|
18
|
+
* { id, ini, who, what, asked, due, source, state: 'open' | 'answered' | 'dropped', answer, answerSource, answeredAt, why }.
|
|
19
|
+
*/
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const crypto = require('crypto');
|
|
23
|
+
|
|
24
|
+
const DAY = 864e5;
|
|
25
|
+
const WAIT_DAYS = 3;
|
|
26
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
27
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
28
|
+
const INI_RE = /^[a-z0-9][a-z0-9._-]{0,80}$/i;
|
|
29
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
30
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
31
|
+
const isoDay = (t) => new Date(t).toISOString().slice(0, 10);
|
|
32
|
+
const md = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
33
|
+
const dayMs = (d) => Date.parse(String(d) + 'T00:00:00Z');
|
|
34
|
+
|
|
35
|
+
function fileOf(stateDir) { return path.join(stateDir, 'tracker', 'signoffs.jsonl'); }
|
|
36
|
+
|
|
37
|
+
function readLines(file) {
|
|
38
|
+
let text = '';
|
|
39
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && l.id && l.op) out.push(l); } catch { /* a torn line is skipped */ } }
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function append(file, line) {
|
|
45
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
46
|
+
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The ledger folded into one sign-off per id. */
|
|
50
|
+
function fold(lines) {
|
|
51
|
+
const by = new Map();
|
|
52
|
+
for (const l of lines) {
|
|
53
|
+
if (l.op === 'ask') { if (!by.has(l.id)) by.set(l.id, { id: l.id, ini: l.ini, who: l.who, what: l.what, asked: l.asked || null, due: l.due || null, source: l.source || null, state: 'open', at: l.at }); continue; }
|
|
54
|
+
const s = by.get(l.id); if (!s) continue;
|
|
55
|
+
if (l.op === 'answer') Object.assign(s, { state: 'answered', answer: l.answer, answerSource: l.source || null, answeredAt: l.at });
|
|
56
|
+
else if (l.op === 'drop') Object.assign(s, { state: 'dropped', why: l.why || null, droppedAt: l.at });
|
|
57
|
+
else if (l.op === 'reopen') Object.assign(s, { state: 'open', answer: undefined, answerSource: undefined, answeredAt: undefined });
|
|
58
|
+
}
|
|
59
|
+
return [...by.values()];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function list(file, { ini, open } = {}) {
|
|
63
|
+
return fold(readLines(file)).filter((s) => (!ini || s.ini === ini) && (!open || s.state === 'open'))
|
|
64
|
+
.sort((a, b) => String(a.asked || a.at).localeCompare(String(b.asked || b.at)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ask(file, { ini, who, what, asked, due, source } = {}, now = Date.now()) {
|
|
68
|
+
const I = one(ini, 81), W = one(who, 80), X = one(what, 200);
|
|
69
|
+
if (!INI_RE.test(I)) return { ok: false, error: 'a sign-off needs the initiative it holds up' };
|
|
70
|
+
if (!W || !/\p{L}/u.test(W)) return { ok: false, error: 'a sign-off needs who must give it (a name or a team)' };
|
|
71
|
+
if (!X) return { ok: false, error: 'a sign-off needs what they must say yes to' };
|
|
72
|
+
for (const [k, v] of [['asked', asked], ['due', due]]) if (v != null && v !== '' && !DATE_RE.test(String(v))) return { ok: false, error: `--${k} is a date like 2026-11-06` };
|
|
73
|
+
const id = 's-' + crypto.createHash('sha1').update(I + '|' + W.toLowerCase() + '|' + X.toLowerCase()).digest('hex').slice(0, 8);
|
|
74
|
+
const have = fold(readLines(file)).find((s) => s.id === id);
|
|
75
|
+
if (have && have.state === 'open') return { ok: true, signoff: have, already: true };
|
|
76
|
+
const line = { op: 'ask', id, ini: I, who: W, what: X, asked: asked || isoDay(now), due: due || null, source: one(source, 300) || null, at: new Date(now).toISOString() };
|
|
77
|
+
if (have) append(file, { op: 'reopen', id, at: line.at }); else append(file, line);
|
|
78
|
+
return { ok: true, signoff: fold(readLines(file)).find((s) => s.id === id) };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function act(file, id, op, extra, now) {
|
|
82
|
+
const s = fold(readLines(file)).find((x) => x.id === id);
|
|
83
|
+
if (!s) return { ok: false, error: `no sign-off ${id}` };
|
|
84
|
+
if (s.state !== 'open') return { ok: false, error: `sign-off ${id} is already ${s.state}` };
|
|
85
|
+
append(file, { op, id, ...extra, at: new Date(now).toISOString() });
|
|
86
|
+
return { ok: true, signoff: fold(readLines(file)).find((x) => x.id === id) };
|
|
87
|
+
}
|
|
88
|
+
function answer(file, id, { answer: a, source } = {}, now = Date.now()) {
|
|
89
|
+
const text = one(a, 500);
|
|
90
|
+
if (!text) return { ok: false, error: 'an answer needs what they said' };
|
|
91
|
+
return act(file, id, 'answer', { answer: text, source: one(source, 300) || null }, now);
|
|
92
|
+
}
|
|
93
|
+
function drop(file, id, { why } = {}, now = Date.now()) { return act(file, id, 'drop', { why: one(why, 300) || null }, now); }
|
|
94
|
+
|
|
95
|
+
/** The open sign-offs to ask about today: waited WAIT_DAYS or more since asked, or past their due date. PURE. */
|
|
96
|
+
function partsOf(signoffs, now = Date.now()) {
|
|
97
|
+
const today = dayMs(isoDay(now));
|
|
98
|
+
const out = [];
|
|
99
|
+
for (const s of signoffs || []) {
|
|
100
|
+
if (!isObj(s) || s.state !== 'open') continue;
|
|
101
|
+
const asked = s.asked ? dayMs(s.asked) : NaN, due = s.due ? dayMs(s.due) : NaN;
|
|
102
|
+
const waited = Number.isFinite(asked) ? Math.floor((today - asked) / DAY) : null;
|
|
103
|
+
const late = Number.isFinite(due) && due < today;
|
|
104
|
+
if (!late && !(waited != null && waited >= WAIT_DAYS)) continue;
|
|
105
|
+
const text = late ? `${s.who}'s yes on "${s.what}" was due ${md(s.due)}. Did it come?`
|
|
106
|
+
: `Did ${s.who} answer "${s.what}"? Asked ${md(s.asked)}, ${waited} days ago.`;
|
|
107
|
+
out.push({ ini: s.ini, id: 'signoff:' + s.id, text, signoff: s.id });
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = { ask, answer, drop, list, partsOf, fileOf, fold, WAIT_DAYS };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* ticket-dry-run.js — the dry run of a drafted ticket (initiative dry-run-tickets-before-build; bet 1e, A194 in pmos-ideas/proofs).
|
|
3
|
+
*
|
|
4
|
+
* Before a ticket is built, an agent that sees only the ticket pretends to build it and lists every point where it would have to
|
|
5
|
+
* guess. For each guess it quotes the lines of the PRD (or the record, or the done test) that answer it. PMOS keeps only the quotes it
|
|
6
|
+
* finds word for word in those documents, copies them into the ticket, and sends what no document answers to the owner's daily
|
|
7
|
+
* question list (lib/question-batch.js). On three PSLE launch tickets, 36 guesses: 86% were answered at least partly by the PRD, and
|
|
8
|
+
* 5 were real gaps.
|
|
9
|
+
*
|
|
10
|
+
* parse(raw) → { ok, tickets: [{ id, guesses: [{ q, said, quotes }] }] } | { ok: false, error } PURE
|
|
11
|
+
* check(parsed, { ids, sourceOf, haystack }) → { tickets: { [id]: entry }, unknown, unverified } PURE
|
|
12
|
+
* merge(old, checked, now) → the dry-run file, with the PM's earlier answers kept for the same questions PURE
|
|
13
|
+
* blockOf(entry) → the text that goes into the ticket's Additional Context, or '' PURE
|
|
14
|
+
* withBlock(text, block) → the section text with the old block replaced PURE
|
|
15
|
+
* gapsOf(file, sourceOf) → [{ ticket, n, q }] the guesses no document answers and nobody answered yet PURE
|
|
16
|
+
* countsOf(entry) → { guesses, answered, partly, gaps, open } PURE
|
|
17
|
+
* read(file) · write(file, data)
|
|
18
|
+
*
|
|
19
|
+
* A guess is 'answered' (a quote found, and the agent did not say partly), 'partly' (a quote found, the agent said partly) or 'gap'
|
|
20
|
+
* (no quote found). A quote PMOS cannot find in the documents is dropped, never kept: an agent cannot make a gap look answered.
|
|
21
|
+
* An entry carries the ticket's `source` hash: when the PRD item changes, the entry is stale and its gaps leave the list until the
|
|
22
|
+
* dry run is run again. Nothing here sends anything.
|
|
23
|
+
*/
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
|
|
27
|
+
const MARK = '**From the PRD (dry run)**';
|
|
28
|
+
const MAX_GUESSES = 40;
|
|
29
|
+
const MAX_QUOTES = 3;
|
|
30
|
+
const MAX_Q = 300;
|
|
31
|
+
const MAX_QUOTE = 400;
|
|
32
|
+
const MAX_ANSWER = 1000;
|
|
33
|
+
const MIN_QUOTE = 12;
|
|
34
|
+
|
|
35
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
36
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
37
|
+
/** Text for matching: no markdown marks, plain quotes and dashes, one space, lower case. */
|
|
38
|
+
const plain = (s) => String(s == null ? '' : s)
|
|
39
|
+
.replace(/[‘’]/g, "'").replace(/[“”]/g, '"').replace(/[–—]/g, '-')
|
|
40
|
+
.replace(/[*_`>#|]/g, ' ').replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
41
|
+
const qKey = (s) => plain(s).replace(/[^a-z0-9 ]/g, '').replace(/\s+/g, ' ').trim();
|
|
42
|
+
|
|
43
|
+
/** True when the quote is in the documents. A quote cut with "…" or "..." matches when each long part is there. */
|
|
44
|
+
function found(quote, haystack) {
|
|
45
|
+
const parts = plain(quote).split(/\s*(?:…|\.\.\.)\s*/).map((p) => p.replace(/^["']|["']$/g, '').trim()).filter(Boolean);
|
|
46
|
+
if (!parts.length || !parts.some((p) => p.length >= MIN_QUOTE)) return false;
|
|
47
|
+
return parts.every((p) => p.length < 4 || haystack.includes(p));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The agent's list: { tickets: [{ id, guesses: [{ question, prd: [quote] | quote, answered: yes|partly|no }] }] }, or the array alone. */
|
|
51
|
+
function parse(raw) {
|
|
52
|
+
let v = raw;
|
|
53
|
+
if (typeof v === 'string') { try { v = JSON.parse(v); } catch { return { ok: false, error: 'the dry run is not JSON' }; } }
|
|
54
|
+
const list = Array.isArray(v) ? v : isObj(v) && Array.isArray(v.tickets) ? v.tickets : null;
|
|
55
|
+
if (!list) return { ok: false, error: 'the dry run needs "tickets": [{ "id", "guesses": [{ "question", "prd": ["<a line quoted from the PRD>"] }] }]' };
|
|
56
|
+
const tickets = [];
|
|
57
|
+
for (const t of list) {
|
|
58
|
+
if (!isObj(t) || !one(t.id, 41)) continue;
|
|
59
|
+
const guesses = [];
|
|
60
|
+
for (const g of Array.isArray(t.guesses) ? t.guesses : []) {
|
|
61
|
+
const q = isObj(g) ? one(g.question || g.q, MAX_Q) : one(g, MAX_Q);
|
|
62
|
+
if (!q) continue;
|
|
63
|
+
const rawQ = isObj(g) ? (g.prd != null ? g.prd : g.quotes != null ? g.quotes : g.quote) : null;
|
|
64
|
+
const quotes = (Array.isArray(rawQ) ? rawQ : rawQ != null ? [rawQ] : []).map((x) => one(x, MAX_QUOTE)).filter(Boolean).slice(0, MAX_QUOTES);
|
|
65
|
+
const s = isObj(g) ? String(g.answered != null ? g.answered : g.status || '').toLowerCase() : '';
|
|
66
|
+
guesses.push({ q, said: /part/.test(s) ? 'partly' : /^(no|gap|none|false)$/.test(s) ? 'no' : 'yes', quotes });
|
|
67
|
+
if (guesses.length >= MAX_GUESSES) break;
|
|
68
|
+
}
|
|
69
|
+
tickets.push({ id: one(t.id, 41), guesses });
|
|
70
|
+
}
|
|
71
|
+
if (!tickets.length) return { ok: false, error: 'the dry run names no ticket' };
|
|
72
|
+
return { ok: true, tickets };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Keep only quotes found in the documents, and give each guess its status. ids: the draft's ticket ids; sourceOf: id → source hash. */
|
|
76
|
+
function check(parsed, { ids, sourceOf = () => null, haystack = '', now } = {}) {
|
|
77
|
+
const hay = plain(haystack);
|
|
78
|
+
const at = new Date(now == null ? Date.now() : now).toISOString();
|
|
79
|
+
const out = {}, unknown = [];
|
|
80
|
+
let unverified = 0;
|
|
81
|
+
for (const t of (parsed && parsed.tickets) || []) {
|
|
82
|
+
if (ids && !ids.has(t.id)) { unknown.push(t.id); continue; }
|
|
83
|
+
const guesses = t.guesses.map((g, i) => {
|
|
84
|
+
const prd = g.quotes.filter((x) => found(x, hay));
|
|
85
|
+
unverified += g.quotes.length - prd.length;
|
|
86
|
+
const status = !prd.length ? 'gap' : g.said === 'partly' || g.said === 'no' ? 'partly' : 'answered';
|
|
87
|
+
return { n: i + 1, q: g.q, status, prd };
|
|
88
|
+
});
|
|
89
|
+
out[t.id] = { source: sourceOf(t.id) || null, at, guesses };
|
|
90
|
+
}
|
|
91
|
+
return { tickets: out, unknown, unverified };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The new dry-run file: the checked tickets replace their old entries; an answer the PM gave to the same question is kept. */
|
|
95
|
+
function merge(old, checked, { initiative, now } = {}) {
|
|
96
|
+
const prev = isObj(old) && isObj(old.tickets) ? old.tickets : {};
|
|
97
|
+
const tickets = { ...prev };
|
|
98
|
+
for (const [id, e] of Object.entries(checked.tickets || {})) {
|
|
99
|
+
const answers = new Map(((prev[id] && prev[id].guesses) || []).filter((g) => g.answer).map((g) => [qKey(g.q), g]));
|
|
100
|
+
tickets[id] = { ...e, guesses: e.guesses.map((g) => { const a = answers.get(qKey(g.q)); return a ? { ...g, answer: a.answer, answeredAt: a.answeredAt } : g; }) };
|
|
101
|
+
}
|
|
102
|
+
return { initiative: initiative || (old && old.initiative) || null, at: new Date(now == null ? Date.now() : now).toISOString(), tickets };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** What the ticket carries: each guess a document answers, with its lines, and each gap the PM answered. '' when there is nothing. */
|
|
106
|
+
function blockOf(entry) {
|
|
107
|
+
const lines = [];
|
|
108
|
+
for (const g of (entry && entry.guesses) || []) {
|
|
109
|
+
if (g.prd && g.prd.length) lines.push(`- ${g.q} PRD: ${g.prd.map((x) => `"${x}"`).join(' · ')}${g.status === 'partly' && !g.answer ? ' (partly)' : ''}`);
|
|
110
|
+
if (g.answer) lines.push(`- ${g.q} PM: ${g.answer}`);
|
|
111
|
+
}
|
|
112
|
+
return lines.length ? [MARK, '', ...lines].join('\n') : '';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The section text with the old dry-run block taken out and the new one put at its end. */
|
|
116
|
+
function withBlock(text, block) {
|
|
117
|
+
const s = String(text || '');
|
|
118
|
+
const i = s.indexOf(MARK);
|
|
119
|
+
const base = (i >= 0 ? s.slice(0, i) : s).replace(/\s+$/, '');
|
|
120
|
+
const clean = /^[\s—–-]*$/.test(base) ? '' : base;
|
|
121
|
+
return [clean, block].filter(Boolean).join('\n\n');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function countsOf(entry) {
|
|
125
|
+
const g = (entry && entry.guesses) || [];
|
|
126
|
+
const n = (s) => g.filter((x) => x.status === s).length;
|
|
127
|
+
return { guesses: g.length, answered: n('answered'), partly: n('partly'), gaps: n('gap'), open: g.filter((x) => x.status === 'gap' && !x.answer).length };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The gaps nobody answered, on tickets whose PRD item has not changed since the dry run. */
|
|
131
|
+
function gapsOf(file, sourceOf = () => null) {
|
|
132
|
+
const out = [];
|
|
133
|
+
for (const [id, e] of Object.entries((file && file.tickets) || {})) {
|
|
134
|
+
if (!isObj(e) || !Array.isArray(e.guesses)) continue;
|
|
135
|
+
const cur = sourceOf(id);
|
|
136
|
+
if (cur === undefined || (e.source && cur && cur !== e.source)) continue; // the ticket is gone, or its PRD item changed: stale
|
|
137
|
+
for (const g of e.guesses) if (g.status === 'gap' && !g.answer) out.push({ ticket: id, n: g.n, q: g.q });
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Set the PM's answer to guess n of a ticket. → { ok, guess } | { ok: false, error } */
|
|
143
|
+
function answer(file, ticket, n, text, now) {
|
|
144
|
+
const e = file && file.tickets && file.tickets[ticket];
|
|
145
|
+
if (!e) return { ok: false, error: `no dry run for ticket ${ticket}` };
|
|
146
|
+
const g = e.guesses.find((x) => x.n === Number(n));
|
|
147
|
+
if (!g) return { ok: false, error: `ticket ${ticket} has no guess ${n}` };
|
|
148
|
+
const a = one(text, MAX_ANSWER);
|
|
149
|
+
if (!a) return { ok: false, error: 'an answer needs some text' };
|
|
150
|
+
g.answer = a; g.answeredAt = new Date(now == null ? Date.now() : now).toISOString();
|
|
151
|
+
return { ok: true, guess: g };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function read(file) {
|
|
155
|
+
try { const v = JSON.parse(fs.readFileSync(file, 'utf8')); return isObj(v) && isObj(v.tickets) ? v : null; } catch { return null; }
|
|
156
|
+
}
|
|
157
|
+
function write(file, data) {
|
|
158
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
159
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
160
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n');
|
|
161
|
+
fs.renameSync(tmp, file);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = { MARK, parse, check, merge, blockOf, withBlock, gapsOf, countsOf, answer, found, plain, read, write };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.667.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.667.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -107,3 +107,4 @@
|
|
|
107
107
|
.lb-find .pm-kbd { display: none; }
|
|
108
108
|
.lb-menu, .lb-cwr .lb-menu { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 80vh; border-radius: var(--radius-panel) var(--radius-panel) 0 0; padding: 18px 12px 28px; }
|
|
109
109
|
}
|
|
110
|
+
.lb .lb-more { margin: var(--space-4) 0 0 var(--space-4); }
|
|
@@ -42,11 +42,12 @@ const CHEV_D = 'M6 9l6 6 6-6', CHEV_R = 'M9 6l6 6-6 6', TICK = 'M5 12.5l4.5 4.5L
|
|
|
42
42
|
const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', OPEN = 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5';
|
|
43
43
|
const store = { get(k) { try { return JSON.parse(localStorage.getItem(k) || 'null'); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* a private window */ } } };
|
|
44
44
|
const saved = store.get('pmos.lib.view') || {};
|
|
45
|
+
const CAP = 40; // rows a group draws before Show more (A435)
|
|
45
46
|
const S = {
|
|
46
47
|
items: null, programs: [], error: '', at: 0, q: '', P: null, sel: { programs: [], projects: [] },
|
|
47
48
|
kinds: Array.isArray(saved.kinds) ? saved.kinds : [], states: Array.isArray(saved.states) ? saved.states : [],
|
|
48
49
|
group: GROUPS.some(([k]) => k === saved.group) ? saved.group : 'new',
|
|
49
|
-
open: new Set(), shut: new Set(), ed: new Set(), ck: new Set(), naming: null, pick: null, peek: new Map(),
|
|
50
|
+
open: new Set(), shut: new Set(), ed: new Set(), ck: new Set(), more: new Map(), naming: null, pick: null, peek: new Map(),
|
|
50
51
|
meaning: null, // { q, results, ranked, why, busy }
|
|
51
52
|
shown: [],
|
|
52
53
|
};
|
|
@@ -182,7 +183,7 @@ function groupPress(b) { if (!b.dataset.lg) return false; S.group = b.dataset.lg
|
|
|
182
183
|
const multi = () => new Set((S.items || []).map((x) => x.product).filter(Boolean)).size > 1;
|
|
183
184
|
function badge(r) {
|
|
184
185
|
const x = r.x, t = stateText(r);
|
|
185
|
-
if (!t ||
|
|
186
|
+
if (!t || x.state === 'Final') return ''; // Final is the usual state, whatever its edition: zero is silence (the editions fold under the row)
|
|
186
187
|
return `<span class="pm-badge${x.state === 'Issued' ? ' blue' : ''}">${esc(t)}</span>`;
|
|
187
188
|
}
|
|
188
189
|
function whyOf(x, shelf) {
|
|
@@ -240,12 +241,16 @@ function rowsHtml(groups) {
|
|
|
240
241
|
if (g.folded) continue;
|
|
241
242
|
} else if (!flat) h += `<div class="pm-group" role="presentation">${esc(g.label)}${S.group === 'work' ? ` <em>${g.n}</em>` : ''}</div>`;
|
|
242
243
|
const shelf = g.level === 2 && g.key !== 'w:none' ? g.label : '';
|
|
243
|
-
let rows = '';
|
|
244
|
+
let rows = '', n = 0;
|
|
245
|
+
const key = g.key || g.label, cap = S.more.get(key) || CAP, all = g.rows.filter((r) => !r.checks).length;
|
|
244
246
|
for (const r of g.rows) {
|
|
245
247
|
if (r.checks) { rows += checksHtml(r); continue; }
|
|
248
|
+
if (n++ >= cap) continue; // a long shelf draws its first rows; Show more draws the next ones (the real Library holds 1,000+ rows)
|
|
246
249
|
rows += rowHtml(r, S.shown.length, false, shelf); S.shown.push(r.x);
|
|
247
250
|
if (r.older.length && S.ed.has(r.x.id)) for (const o of r.older) { rows += rowHtml({ x: o, older: [] }, S.shown.length, true, shelf); S.shown.push(o); }
|
|
248
251
|
}
|
|
252
|
+
const left = all - cap;
|
|
253
|
+
if (left > 0) rows += `<button type="button" class="pm-chip lb-more" data-lb-more="${esc(key)}">${esc(left > CAP ? 'Show ' + CAP + ' more of ' + left : 'Show the other ' + left)}</button>`;
|
|
249
254
|
h += `<div class="rows" role="list">${rows}</div>`;
|
|
250
255
|
}
|
|
251
256
|
return h;
|
|
@@ -419,6 +424,7 @@ body.onclick = async (e) => {
|
|
|
419
424
|
if (folded) { S.open.add(k); S.shut.delete(k); } else { S.shut.add(k); S.open.delete(k); }
|
|
420
425
|
draw(); return;
|
|
421
426
|
}
|
|
427
|
+
if ((b = t.closest('[data-lb-more]'))) { const k = b.dataset.lbMore; S.more.set(k, (S.more.get(k) || CAP) + CAP); draw(); return; }
|
|
422
428
|
if ((b = t.closest('[data-lb-ed]'))) { const k = b.dataset.lbEd; if (S.ed.has(k)) S.ed.delete(k); else S.ed.add(k); draw(); return; }
|
|
423
429
|
if ((b = t.closest('[data-lb-ck]'))) { const k = b.dataset.lbCk; if (S.ck.has(k)) S.ck.delete(k); else S.ck.add(k); draw(); return; }
|
|
424
430
|
if ((b = t.closest('[data-lb-name]'))) { S.naming = b.dataset.lbName; draw(); return; }
|
package/workspace/run-tests.js
CHANGED
|
@@ -485,8 +485,20 @@ function traceChanges(changes, ctx) {
|
|
|
485
485
|
return undefined;
|
|
486
486
|
};
|
|
487
487
|
const touched = new Set();
|
|
488
|
+
// dry-run-tickets-before-build: the lines of a multi-line `module.exports = {` … `};` block. A changed line there names the exports it
|
|
489
|
+
// holds: each counts as touched, as if its declaration had changed (a new export reaches only the code that names it).
|
|
490
|
+
const exA = C.findIndex((l) => /^module\.exports\s*=\s*\{\s*$/.test(l));
|
|
491
|
+
let exB = exA; if (exA >= 0) while (exB < C.length && !/^\}\s*;?\s*$/.test(C[exB])) exB++;
|
|
488
492
|
for (const n of ch.lines) {
|
|
489
493
|
if (n > C.length || !(C[n - 1] || '').trim()) continue; // a comment, a blank line or past the end
|
|
494
|
+
if (exA >= 0 && n - 1 > exA && n - 1 < exB) {
|
|
495
|
+
for (const part of C[n - 1].split(',').map((x) => x.trim()).filter(Boolean)) {
|
|
496
|
+
const [k, v] = part.split(':').map((x) => x.trim());
|
|
497
|
+
if (!/^[\w$]+$/.test(k) || (v !== undefined && !/^[\w$]+$/.test(v))) return null;
|
|
498
|
+
touched.add(v || k);
|
|
499
|
+
}
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
490
502
|
const d = declAt(n);
|
|
491
503
|
if (!d) return null;
|
|
492
504
|
touched.add(d);
|
|
@@ -703,6 +715,11 @@ function traceChanges(changes, ctx) {
|
|
|
703
715
|
for (const s of list) if (s === 'headless.test.js' || rk.some((x) => (get(s) || '').includes(x))) picked.add(s);
|
|
704
716
|
continue;
|
|
705
717
|
}
|
|
718
|
+
const tk = f === 'lib/headless.js' ? toolsOnly(sget(f), lines) : null;
|
|
719
|
+
if (tk) { // only the tool list of existing kinds changed: only runs of those kinds see it, so the suites that name a kind's tools or origin
|
|
720
|
+
for (const s of list) if (s === 'headless.test.js' || tk.some((x) => (get(s) || '').includes(x))) picked.add(s);
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
706
723
|
const nv = f === VERBS_FILE ? newVerbOnly(sget(f), lines) : null;
|
|
707
724
|
if (nv) { // a new verb: only `pmos <verb>` calls reach it, so the suites that name the table or the verb's module
|
|
708
725
|
for (const s of list) { const t = get(s) || ''; if (t.includes('pmos-verbs') || nv.some((m) => t.includes(m))) picked.add(s); }
|
|
@@ -779,6 +796,31 @@ function newKindOnly(src, lines) {
|
|
|
779
796
|
return [...[...consts.values()].flat(), ...kinds].map((x) => `'${x}`);
|
|
780
797
|
}
|
|
781
798
|
|
|
799
|
+
/* dry-run-tickets-before-build: lib/headless.js TOOLS gives each kind its fixed tool list. A change whose every line sits inside one or more
|
|
800
|
+
* entries of TOOLS and is only quoted tool names (or blank, as a comment is once stripped) changes what runs of those kinds may call, not how
|
|
801
|
+
* any run is spawned: it reaches headless.test.js and the suites that name `TOOLS.<kind>`, `TOOLS['<kind>']` or an origin `'<kind>:`.
|
|
802
|
+
* Returns those markers, or null when any changed line is something else. `src` is without comments. */
|
|
803
|
+
function toolsOnly(src, lines) {
|
|
804
|
+
if (src == null || !Array.isArray(lines) || !lines.length) return null;
|
|
805
|
+
const C = src.split('\n');
|
|
806
|
+
const start = C.findIndex((l) => /^const TOOLS = Object\.freeze\(\{\s*$/.test(l.trim()));
|
|
807
|
+
if (start < 0) return null;
|
|
808
|
+
let end = start + 1; while (end < C.length && !/^\}\);\s*$/.test(C[end].trim())) end++;
|
|
809
|
+
const kinds = new Set();
|
|
810
|
+
for (const n of lines) {
|
|
811
|
+
const i = n - 1, l = (C[i] || '').trim();
|
|
812
|
+
if (i <= start || i >= end) return null;
|
|
813
|
+
if (!l) continue;
|
|
814
|
+
if (!/^(?:'?[\w-]+'?: Object\.freeze\(\[)?(?:\s*'[^'\n]*',?)*\s*(?:\]\),)?$/.test(l)) return null;
|
|
815
|
+
let k = null;
|
|
816
|
+
for (let j = i; j > start && !k; j--) { const m = /^\s*'?([\w-]+)'?: Object\.freeze\(\[/.exec(C[j]); if (m) k = m[1]; }
|
|
817
|
+
if (!k) return null;
|
|
818
|
+
kinds.add(k);
|
|
819
|
+
}
|
|
820
|
+
if (!kinds.size) return null;
|
|
821
|
+
return [...kinds].flatMap((k) => [`TOOLS.${k}`, `TOOLS['${k}']`, `'${k}:`]);
|
|
822
|
+
}
|
|
823
|
+
|
|
782
824
|
/* lib/headless.js RUN_ENV lists the variables a background run's spawn spec may set. A change whose every line sits inside that list and
|
|
783
825
|
* holds only quoted PMOS_ names changes what one kind of run is pinned with, not how any run is spawned: it reaches the suites that name
|
|
784
826
|
* one of the names on those lines. Returns those names, or null when any changed line is something else. `src` is without comments. */
|
|
@@ -1020,4 +1062,4 @@ async function main() {
|
|
|
1020
1062
|
}
|
|
1021
1063
|
|
|
1022
1064
|
if (require.main === module) main().catch((e) => { console.error(e); process.exitCode = 1; });
|
|
1023
|
-
else module.exports = { traceChanges, runEnvOnly, diffLines, strip, changedDeps, WIDE };
|
|
1065
|
+
else module.exports = { traceChanges, runEnvOnly, toolsOnly, diffLines, strip, changedDeps, WIDE };
|
|
@@ -15,7 +15,7 @@ output:
|
|
|
15
15
|
The prompt that starts this run names the target, the reason the run started, the stage category and what the PM already kept. Work on that target only.
|
|
16
16
|
|
|
17
17
|
Rules that always hold:
|
|
18
|
-
1. THE ONLY WRITES are `pmos driver propose
|
|
18
|
+
1. THE ONLY WRITES are `pmos driver propose`, `pmos coredoc write` (a draft of a core document of this initiative, nothing else), `pmos jira guesses` (the dry run of its drafted tickets, step 9) and `pmos signoff ask|answer` (its outside sign-offs, step 10). You have no Write and no Edit tool. Do not change a repository file, do not commit, do not push, and do not move the initiative to another stage. Keeping a proposal is the PM's act, not yours.
|
|
19
19
|
2. SEND NOTHING. Never send, reply, forward, post, comment, react, create, transition or label anything in mail, Slack, Jira, Confluence, GitHub, Drive, Figma or any other source. Read a connector only where it is already allowed. If a tool is refused, say so in your answer and go on without it.
|
|
20
20
|
3. EVERY CLAIM CARRIES A POINTER. A pointer is a Jira key, a Slack link, a meeting note path, a requirement note path or a document path. Give it with `--source label=ref`. A claim you cannot point at is not a claim: leave it out. An evidence line with no pointer is not evidence: leave it out.
|
|
21
21
|
4. NOTHING INVENTED. Write only what you read. Say "not known" and name who could tell you. A run that finds nothing new is a correct run: file nothing.
|
|
@@ -44,6 +44,7 @@ Procedure:
|
|
|
44
44
|
- Do: no ticket moved, or a ticket is blocked. File a `note` with the ticket keys, how long they have not moved and who could unblock them.
|
|
45
45
|
- Learn: the check-by date passed with no outcome check, or a kill condition tripped. File a `note` that names the date or the condition and the evidence you read.
|
|
46
46
|
- Any stage, stalled: File a `note` with the last change you can find and the one question whose answer would restart the work.
|
|
47
|
+
In Plan and Do, also do steps 9 and 10.
|
|
47
48
|
6. File each proposal like this, with one `--source` for each pointer:
|
|
48
49
|
`pmos driver propose initiative <id> --what artefact --file /tmp/kill.json --why "<one line: why the PM needs this>" --source "Jira DISC-12=https://…" --source "Meeting note=notes/2026-10-08.md"`
|
|
49
50
|
Write the JSON or text file in the scratch folder of this session. If `pmos driver propose` refuses, read the reason, fix the proposal and file it once more. Do not work around a refusal.
|
|
@@ -54,6 +55,12 @@ Procedure:
|
|
|
54
55
|
`pmos driver propose initiative <id> --what doc --data '{"key":"<key>","slot":"<the slot it printed>"}' --why "<one line>"`.
|
|
55
56
|
The PM's Keep issues the draft. While a document of this stage is due, do not propose a stage move: `pmos driver propose` refuses it.
|
|
56
57
|
|
|
58
|
+
9. Dry-run the drafted tickets (Plan and Do). Run `pmos jira guesses <id>`. When it says the initiative has a ticket draft and some tickets are not dry-run yet, or a dry run is out of date because the PRD changed, dry-run those tickets:
|
|
59
|
+
a. Read the draft file (`pmos jira show <id>` names it). For each ticket, read ONLY the ticket and pretend to build it. List every point where you would have to guess: an error or failure state, an empty or loading state, who may see it, a limit, a screen size, what happens on Back or cancel, a number or a word the ticket does not give. One plain question each, at most 12 per ticket.
|
|
60
|
+
b. Then read the PRD, the done test and the record. For each question, copy the lines that answer it word for word (at most 3). Mark it `"answered": "yes"`, `"partly"` or `"no"`. Never change a line you quote: PMOS drops a quote it cannot find word for word, and the question then counts as a gap.
|
|
61
|
+
c. Write `{"tickets": [{"id": "<ticket id>", "guesses": [{"question": "…", "prd": ["<quoted line>"], "answered": "yes|partly|no"}]}]}` to a file in your scratch folder and run `pmos jira guesses <id> --from <file>`. PMOS copies the quoted lines into the tickets and puts the gaps on the PM's question list. Never answer a gap yourself: the PM answers with `pmos jira answer`.
|
|
62
|
+
10. Outside sign-offs (Plan and Do). Run `pmos signoff list <id>`. Read the PRD, the record and the notes for each yes the work waits on from someone outside the team (a scope, a price, wording, a go or no-go). For each one not listed, run `pmos signoff ask <id> --who "<name or team>" --what "<what they must say yes to>" --asked <date> [--due <date>] --source "<pointer>"`. When a source you read shows the answer, run `pmos signoff answer <signoff id> --answer "<what they said>" --source "<pointer>"`. Never record an answer you cannot point at. PMOS puts the open ones on the PM's question list.
|
|
63
|
+
|
|
57
64
|
Output contract — produce EXACTLY these sections in your final message:
|
|
58
65
|
- Filed (the proposal ids and their kinds, or "nothing new")
|
|
59
66
|
- Skipped (what you did not file and why: already kept, no pointer, nothing found)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Dry-run tickets before they're built (initiative dry-run-tickets-before-build, done test D1-D12): a ticket dry run keeps only the PRD lines it finds word for word and copies them into the ticket; gaps and open outside sign-offs go on the day's question list. Synthetic kit-layout repositories. No connector, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"ticket-dry-run.test.js",
|
|
5
|
+
"signoffs.test.js"
|
|
6
|
+
],
|
|
7
|
+
"seconds": {
|
|
8
|
+
"ticket-dry-run.test.js": 5,
|
|
9
|
+
"signoffs.test.js": 5
|
|
10
|
+
}
|
|
11
|
+
}
|