create-pmos 0.775.0 → 0.777.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 +44 -44
- package/payload/AGENTS.md +1 -0
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +43 -0
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/cli.md +10 -0
- package/workspace/guide/initiatives-and-next-steps.md +2 -0
- package/workspace/guide/jira.md +6 -2
- package/workspace/lib/headless.js +1 -0
- package/workspace/lib/jira-cli.js +20 -5
- package/workspace/lib/jira-criteria.js +87 -11
- package/workspace/lib/job-graph.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/routes-jira-epics.js +1 -1
- package/workspace/lib/routes-principles.js +6 -4
- package/workspace/lib/routes-strategy-card.js +65 -4
- package/workspace/lib/strategy-card.js +69 -6
- package/workspace/lib/strategy-cli.js +105 -0
- package/workspace/lib/strategy-sources.js +76 -0
- package/workspace/lib/task-describe.js +3 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-strategy.js +35 -7
- package/workspace/public/pm/cozy-pop-work.js +12 -6
- package/workspace/skills/jira-criteria.skill +3 -3
- package/workspace/skills/strategy-draft.skill +31 -0
- package/workspace/test-lists/strategy-draft.json +9 -0
- package/workspace/test-lists/ticket-criteria-from-files.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.777.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,49 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.777.0",
|
|
38
|
+
"at": "2026-11-24T14:02:27.034Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1744,
|
|
43
|
+
"t": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
44
|
+
"s": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"Open Work",
|
|
50
|
+
"Open an initiative that tracks Jira tickets and has no done test",
|
|
51
|
+
"Read the ✦ Add acceptance criteria above the breakdown"
|
|
52
|
+
],
|
|
53
|
+
"see": "The ✦ lists each open ticket with up to three checks taken from the initiative's own files, each naming the file and line it comes from. ✓ asks, and Undo in the toast takes it back.",
|
|
54
|
+
"open": "/premium-board.html"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"v": "0.776.0",
|
|
61
|
+
"at": "2026-11-24T12:44:48.670Z",
|
|
62
|
+
"f": 4,
|
|
63
|
+
"prs": [
|
|
64
|
+
{
|
|
65
|
+
"n": 1739,
|
|
66
|
+
"t": "Release notes find a build's record when its PR names the initiative in prose",
|
|
67
|
+
"s": "Release notes find a build's record when its PR names the initiative in prose",
|
|
68
|
+
"k": "fix",
|
|
69
|
+
"h": "Release notes find a build's record when its PR names the initiative in prose"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"n": 1737,
|
|
73
|
+
"t": "PMOS drafts each product's five-line strategy from its own files",
|
|
74
|
+
"s": "PMOS drafts each product's five-line strategy from its own files",
|
|
75
|
+
"k": "new"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
36
79
|
{
|
|
37
80
|
"v": "0.775.0",
|
|
38
81
|
"at": "2026-11-24T10:49:49.601Z",
|
|
@@ -387,49 +430,6 @@
|
|
|
387
430
|
"k": "fix"
|
|
388
431
|
}
|
|
389
432
|
]
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
"v": "0.757.0",
|
|
393
|
-
"at": "2026-11-24T01:28:20.135Z",
|
|
394
|
-
"f": 4,
|
|
395
|
-
"prs": [
|
|
396
|
-
{
|
|
397
|
-
"n": 1706,
|
|
398
|
-
"t": "Sample PMOS's landed changes across kinds; a run alone is not eval",
|
|
399
|
-
"s": "Sample PMOS's landed changes across kinds; a run alone is not eval",
|
|
400
|
-
"k": "fix",
|
|
401
|
-
"try": {
|
|
402
|
-
"steps": [
|
|
403
|
-
"Open Today and look at What PMOS did",
|
|
404
|
-
"Wait a day for the checks",
|
|
405
|
-
"Open an initiative that had a run logged but no build yet"
|
|
406
|
-
],
|
|
407
|
-
"see": "Changes of different kinds get checked, not only the oldest of one kind, and a failed check undoes the change. The initiative with only a run reads at its spec stage, not Evaluate."
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
]
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
"v": "0.756.0",
|
|
414
|
-
"at": "2026-11-24T01:12:35.636Z",
|
|
415
|
-
"f": 4,
|
|
416
|
-
"prs": [
|
|
417
|
-
{
|
|
418
|
-
"n": 1704,
|
|
419
|
-
"t": "Line tab on Work and Today's dashed line (quiet rows slice B)",
|
|
420
|
-
"s": "Line tab on Work and Today's dashed line (quiet rows slice B)",
|
|
421
|
-
"k": "new",
|
|
422
|
-
"try": {
|
|
423
|
-
"steps": [
|
|
424
|
-
"Open Work",
|
|
425
|
-
"Press the Line tab",
|
|
426
|
-
"On Today, press the dashed line under Your move"
|
|
427
|
-
],
|
|
428
|
-
"see": "One table per product, grouped by station, with Initiative, Days here, Still missing to finish, Next move and State; tabs All, Stuck, Can't tell and Your move. Today's dashed line says how many move…",
|
|
429
|
-
"open": "/premium-board.html?work=line"
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
]
|
|
433
433
|
}
|
|
434
434
|
]
|
|
435
435
|
}
|
package/payload/AGENTS.md
CHANGED
|
@@ -114,6 +114,7 @@ The PM talks to you from an initiative's popup in the workspace. PMOS acts by it
|
|
|
114
114
|
|
|
115
115
|
- **The merge ✦ ("7 references and 2 retros can each be one artefact. Merge them?").** The popup derives it from the files: it shows while several different files of one kind belong to the initiative. When you merge files, put `superseded_by: <path of the merged file>` in the frontmatter of each old file. The Artefacts list then shows the merged file, folds each old file under it as an earlier version, and the ✦ goes away by itself. Delete nothing.
|
|
116
116
|
- **The case card (Problem, Goal, Done when).** It reads the Experiment and Done test artefacts first, then the record's Problem, Goal and Done test sections. When the PM says yes to a case line, save it where the card reads it: `pmos artefacts set experiment:<id> experiment why --text "<problem>"`, `pmos artefacts set experiment:<id> experiment hypothesis --text "<goal>"`, and `pmos artefacts set experiment:<id> done-test check --text "<one check>"` once for each check. `pmos why` and `pmos ready check` read the same lines.
|
|
117
|
+
- **The Strategy card (five lines).** When the PM asks to write, change or redraft the strategy, run `pmos strategy set --line <for|problem|bet|win|wont> --text "<line>"` once per line. To draft blank lines from the product's files, run `pmos strategy sources`, read them, then `pmos strategy draft --line <key> --text "<line>" --source <file>` for each line the files support. `pmos strategy undo` takes PMOS's draft back; `pmos strategy show` lists the lines. The card reads the same file.
|
|
117
118
|
- **The Positioning part of the Strategy card.** When the PM agrees a positioning statement or key message, keep it with `pmos positioning keep --text "<line>" --cites <keys> [--kind positioning]`, citing the strategy lines it comes from (`pmos positioning strategy` lists the keys). Drop one with `pmos positioning drop <id>`. Work shows what these write.
|
|
118
119
|
- **The product glossary (a word's meaning on hover).** When the PM asks to explain, add or change one of the product's own words ("add MAGW to the glossary"), run `pmos glossary set <term> "<meaning>"` in the product's repository; `pmos glossary remove <term>` takes one out and `pmos glossary` lists them. Every page reads the same file and shows the meaning on hover, or on a long press on a phone.
|
|
119
120
|
- **Standing rules (Settings › How PMOS decides › Standing rules).** When the PM asks to see, reword, retire or bring back a rule PMOS learned from their corrections, run `pmos rules` to list them numbered, then `pmos rules edit <n> --text "<new words>"`, `pmos rules retire <n>` or `pmos rules restore <n>` (the R number under Retired). The page reads the same memory entries.
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T14:02:23Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T14:02:23Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T14:02:23Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.777.0",
|
|
4
|
+
"at": "2026-11-24T14:02:27.034Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1744,
|
|
9
|
+
"t": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
10
|
+
"s": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "Acceptance criteria for Jira tickets from the initiative's files",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"Open Work",
|
|
16
|
+
"Open an initiative that tracks Jira tickets and has no done test",
|
|
17
|
+
"Read the ✦ Add acceptance criteria above the breakdown"
|
|
18
|
+
],
|
|
19
|
+
"see": "The ✦ lists each open ticket with up to three checks taken from the initiative's own files, each naming the file and line it comes from. ✓ asks, and Undo in the toast takes it back.",
|
|
20
|
+
"open": "/premium-board.html"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"v": "0.776.0",
|
|
27
|
+
"at": "2026-11-24T12:44:48.670Z",
|
|
28
|
+
"f": 4,
|
|
29
|
+
"prs": [
|
|
30
|
+
{
|
|
31
|
+
"n": 1739,
|
|
32
|
+
"t": "Release notes find a build's record when its PR names the initiative in prose",
|
|
33
|
+
"s": "Release notes find a build's record when its PR names the initiative in prose",
|
|
34
|
+
"k": "fix",
|
|
35
|
+
"h": "Release notes find a build's record when its PR names the initiative in prose"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"n": 1737,
|
|
39
|
+
"t": "PMOS drafts each product's five-line strategy from its own files",
|
|
40
|
+
"s": "PMOS drafts each product's five-line strategy from its own files",
|
|
41
|
+
"k": "new"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
2
45
|
{
|
|
3
46
|
"v": "0.775.0",
|
|
4
47
|
"at": "2026-11-24T10:49:49.601Z",
|
|
@@ -124,6 +124,7 @@ A loop never sends a message, moves a Jira ticket, merges into a product reposit
|
|
|
124
124
|
| [Prototypes before a meeting](notes.md) | A meeting starts in the next 60 minutes, and its title, agenda or material names an initiative in Triage or Discover with no prototype. One round at a time. An initiative is tried once a week at most, and never while a round waits for you. | The initiative, as a live round reads it | Round 1 under the initiative's ✦ at minute 0. In the meeting, ✓ on **✦ Show it?** starts the next round. | `pmos ai off meeting-prewarm` |
|
|
125
125
|
| [What you might have missed](claude-proposes.md) | Each Monday, for the week before. It uses no model. | Records only: tasks, dates, initiatives and Jira status | One ✦ in Today's chat, at most 3 items | `pmos ai off drift`. `PMOS_DRIFT=off` |
|
|
126
126
|
| [The story so far](home.md) | Once, when you open a product that has no story yet. At most once a day for each product. | The initiatives, their stages and dates, and the Intent and Goal | "The story so far" on the product page. After that, the weekly report keeps it current. | `pmos ai off story-seed`. `PMOS_STORY_SEED=off` |
|
|
127
|
+
| [Strategy](initiatives-and-next-steps.md) | Once, when you open a product whose five strategy lines are all blank. At most once a day for each product. ✦ on the empty card starts it at once. | The product's initiatives, PRDs, done tests, goal files and docs (`pmos strategy sources`) | The five lines on the Strategy card, each with ✦ and the files it came from. Undo takes them back. | `pmos ai off strategy-draft` |
|
|
127
128
|
| [Principles](initiatives-and-next-steps.md) | Once, when you open Work for a product that has 3 or more decisions and no principles. At most once a day for each product. | The decisions in `DECISIONS.md` and its ADRs, and `pmos decisions` | Drafts with ✦ in Work's Principles block, each citing its decisions. Nothing is a principle until you keep it. | `pmos ai off principles-draft` |
|
|
128
129
|
| [Press release](cli.md) | Only when you run `pmos press-release <initiative>`. One run, no tools. | The initiative's record: Intent, Goal, Narrative, Hypothesis, outcome and kill rule | One press release and FAQ file beside the record, for you to edit. PMOS never writes over it. Job `press-release`. | `pmos ai off press-release`. `--no-ai` |
|
|
129
130
|
| Change check | When no merged pull request waits for the verifier. At most 4 a day. | One change that PMOS made by itself, the record it changed, and its sources | Nothing when it passes. A FAIL removes the change from "did" and counts like an Undo. | `pmos ai off verify`. `PMOS_VERIFY_CHANGES=off` |
|
package/workspace/guide/cli.md
CHANGED
|
@@ -396,6 +396,16 @@ PMOS drafts 4 to 6 principles for a product from its past decisions. Each draft
|
|
|
396
396
|
- `pmos principles keep <id>` and `pmos principles drop <id>` answer a draft. `pmos principles undo <id>` puts it back to a draft.
|
|
397
397
|
- `pmos principles add --text "<principle>"` adds your own principle, kept at once. `--why` and `--source` are optional.
|
|
398
398
|
|
|
399
|
+
### pmos strategy: the product's five-line strategy
|
|
400
|
+
|
|
401
|
+
The same five lines as the Strategy card on Work ([The strategy in five lines](initiatives-and-next-steps.md)). The keys are `for`, `problem`, `bet`, `win` and `wont`. Run the commands in the product's repository, or pass `--root <dir>`. The lines are in `strategy-card.jsonl` in the product's records folder, and the card shows what these commands write.
|
|
402
|
+
|
|
403
|
+
- `pmos strategy show` shows the five lines. A line PMOS drafted shows ✦ and the files it came from.
|
|
404
|
+
- `pmos strategy sources` lists the product's files a drafted line can cite: initiative records, PRDs, done tests, goal files and docs.
|
|
405
|
+
- `pmos strategy draft --line <key> --text "<line>" --source <file>` is PMOS's draft of one blank line. It needs 1 to 5 `--source` values: a file of the product, or a tracker key such as `ABC-123`. A line that is already written is not changed.
|
|
406
|
+
- `pmos strategy set --line <key> --text "<line>"` writes your own line. `--text ""` blanks it.
|
|
407
|
+
- `pmos strategy undo` takes back every line PMOS drafted. `--line <key>` takes back one.
|
|
408
|
+
|
|
399
409
|
### pmos positioning: positioning and key messages from the strategy
|
|
400
410
|
|
|
401
411
|
Once a product's five strategy lines are written, PMOS drafts a positioning statement and key messages from them on Work's Strategy card ([Positioning](positioning.md)). Each line cites the strategy lines it comes from. Run the commands in the product's repository, or pass `--root <dir>`. The kept lines are in `positioning.jsonl` in the product's records folder, and Work shows what these commands write.
|
|
@@ -115,6 +115,8 @@ A published copy of a board does not show customer signals.
|
|
|
115
115
|
|
|
116
116
|
A Work that shows one product has a **Strategy** card above its initiatives. It holds five lines: who the product is for, the problem, the bet, how you win, and what you won't do. Press the pencil to write or change them. Press the tick or Enter to save, or Esc to cancel. A save offers Undo.
|
|
117
117
|
|
|
118
|
+
You do not have to write the lines yourself. When a product has no strategy, PMOS drafts the five lines from that product's own files: its initiatives, PRDs, goals and docs. While it works, the card says "drafting from this product's files…". Each line it drafts shows ✦ and, under it, the files it came from. A line the files do not support stays blank. PMOS never writes over a line you wrote. Change a drafted line with the pencil and it becomes yours. The Undo icon in the card's head takes back every drafted line, and then PMOS does not draft again by itself; press ✦ on the empty card to draft again. PMOS starts at most once a day for each product. Turn it off with `pmos ai off strategy-draft`.
|
|
119
|
+
|
|
118
120
|
When all five lines are written, PMOS checks the initiatives that are not built yet (Triage to Prioritize, not chore or incident). An initiative gets a short note when:
|
|
119
121
|
|
|
120
122
|
- its title shares a word with "what we won't do", or
|
package/workspace/guide/jira.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Jira: tickets drafted from the PRD, and their status"
|
|
4
4
|
description: "How to draft Jira tickets from a PRD in your ticket template, push the ones that are ready, and see their status, sprint and progress on the initiative's Jira tickets tab."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-24
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Jira: tickets drafted from the PRD, and their status
|
|
@@ -116,7 +116,10 @@ pmos jira criteria <initiative>
|
|
|
116
116
|
|
|
117
117
|
### On the tickets you already have in Jira
|
|
118
118
|
|
|
119
|
-
Most tickets an initiative tracks were made in Jira, not drafted by PMOS.
|
|
119
|
+
Most tickets an initiative tracks were made in Jira, not drafted by PMOS. The Work breakdown shows a ✦: "Add acceptance criteria to 3 Jira tickets". Open it to see each ticket and the checks that fit it. PMOS leaves out tickets that are done.
|
|
120
|
+
|
|
121
|
+
- When the initiative has a done test, PMOS takes the checks from it, with the same matching as above.
|
|
122
|
+
- For a ticket the done test does not cover, or when the initiative has no done test, PMOS takes the checks from the initiative's own files: its record, its PRD and its core documents. It uses only lines about that ticket that read as checks (must, should, done when, expected, or a line under an Acceptance, Criteria or Requirements heading), at most three. Each check names its file and line, in a block that starts **From the initiative's files**. A ticket that nothing in the files is about gets no block.
|
|
120
123
|
|
|
121
124
|
- Press ✓ to say yes. A ticket assigned to you gets the block at the end of its description. A session with your own Atlassian connection writes it, and it changes nothing else on the ticket.
|
|
122
125
|
- A ticket of another owner is not changed. It goes to the day's draft for that owner, with the block to paste. PMOS does not send the draft.
|
|
@@ -130,6 +133,7 @@ pmos jira criteria-propose <initiative> what PMOS proposes, ticket by t
|
|
|
130
133
|
pmos jira criteria-ask <initiative> [KEY …] say yes to all, or to the keys you name
|
|
131
134
|
pmos jira criteria-asks [--direct | --draft] what waits for Jira, or the draft by owner
|
|
132
135
|
pmos jira criteria-done <ask id> [--refused "<why>"] the session's answer for one ticket
|
|
136
|
+
pmos jira criteria-reach [--count] how many open tickets get criteria, from the done test and from the files
|
|
133
137
|
```
|
|
134
138
|
|
|
135
139
|
## The dry run: where a builder would guess
|
|
@@ -88,6 +88,7 @@ const HEADLESS_SKILLS = Object.freeze([
|
|
|
88
88
|
'tracker-refresh', 'measure', 'memory-groom', 'backlog-triage',
|
|
89
89
|
'story-first', // batch 29 item 5: the first story so far, once, when a product has none (lib/story-seed.js)
|
|
90
90
|
'principles-draft', // bet A352: the product's principles from its decisions, once, when it has none (lib/routes-principles.js)
|
|
91
|
+
'strategy-draft', // initiative strategy-draft: the product's five-line strategy from its own files, once, when it has none (lib/routes-strategy-card.js)
|
|
91
92
|
]);
|
|
92
93
|
// The note passes that run headless, by the origin prefix lib/routes-notes.js gives them.
|
|
93
94
|
const HEADLESS_ORIGINS = Object.freeze(['notes-bullets:', 'notes-summary:']);
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
* assigned to the PM go to the jira-criteria agent, the rest to the draft
|
|
32
32
|
* pmos jira criteria-asks [--direct | --draft | --health] the criteria asks waiting; --health prints the percent Jira accepted
|
|
33
33
|
* pmos jira criteria-done <ask id> [--refused "<why>"] the jira-criteria agent's answer for one ask
|
|
34
|
+
* pmos jira criteria-reach [--count] over all initiatives, the open tickets with a proposal from the done test
|
|
35
|
+
* and from the initiative's files (ticket-criteria-from-files)
|
|
34
36
|
* pmos jira guesses <initiative> [--from <file|->] a ticket dry run (lib/ticket-dry-run.js), recorded or shown
|
|
35
37
|
* pmos jira answer <initiative> <ticket> <n> --text "<answer>" | --keep-default the PM's answer to one dry-run gap, or its default kept
|
|
36
38
|
* pmos jira digest [--since <YYYY-MM-DD or time>] the standup facts from the stored reads (lib/tracker-digest.js)
|
|
@@ -54,7 +56,7 @@ const pmName = (env) => { const e = String(((env || process.env).PMOS_PM_NAME) |
|
|
|
54
56
|
const planItems = require('./plan-items.js');
|
|
55
57
|
const guard = require('./pm-guard.js');
|
|
56
58
|
|
|
57
|
-
const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'pin', 'summary', 'which', 'moves', 'moved', 'epic-asks', 'epic-done', 'guesses', 'answer', 'criteria', 'digest', 'criteria-propose', 'criteria-ask', 'criteria-asks', 'criteria-done'] };
|
|
59
|
+
const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'pin', 'summary', 'which', 'moves', 'moved', 'epic-asks', 'epic-done', 'guesses', 'answer', 'criteria', 'digest', 'criteria-propose', 'criteria-ask', 'criteria-asks', 'criteria-done', 'criteria-reach'] };
|
|
58
60
|
const USAGE = [
|
|
59
61
|
'usage: pmos jira draft|show|epic|approve|pending|record|query|sync|summary|which — Jira tickets from the PRD, and their status',
|
|
60
62
|
' pmos jira draft <initiative> [--dry-run] draft one ticket per PRD item, in the ticket template',
|
|
@@ -89,11 +91,12 @@ const USAGE = [
|
|
|
89
91
|
' pmos jira criteria-ask <initiative> [KEY …] say yes: your own tickets get them in Jira, the others go to the draft for their owners',
|
|
90
92
|
' pmos jira criteria-asks [--direct | --draft | --health] the criteria asks waiting for Jira, the draft by owner, or the health number',
|
|
91
93
|
' pmos jira criteria-done <ask id> [--refused "<why>"] what Jira did with one criteria ask',
|
|
94
|
+
' pmos jira criteria-reach [--count] how many open tickets get acceptance criteria, from the done test and from the files',
|
|
92
95
|
' pmos jira digest [--since <YYYY-MM-DD or time>] what moved since the last working day, who moved it, and what is worth a question',
|
|
93
96
|
' every command: [--json] [--root <dir>]',
|
|
94
97
|
'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
|
|
95
98
|
];
|
|
96
|
-
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints', 'keep-default', 'direct', 'draft', 'changed', 'off', 'all', 'health']);
|
|
99
|
+
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints', 'keep-default', 'direct', 'draft', 'changed', 'off', 'all', 'health', 'count']);
|
|
97
100
|
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint', 'text', 'since']);
|
|
98
101
|
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' };
|
|
99
102
|
|
|
@@ -284,6 +287,14 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
284
287
|
return out(r, [r.ask.state === 'set' ? `${r.ask.key} · under ${r.ask.epic} in Jira` : `${r.ask.key} · refused: ${r.ask.why}`]);
|
|
285
288
|
}
|
|
286
289
|
// acceptance criteria written onto the Jira tickets an initiative tracks (jira-criteria-write, A384)
|
|
290
|
+
if (verb === 'criteria-reach') {
|
|
291
|
+
// initiative ticket-criteria-from-files: the health number (--count, the files count on the last line) and the check-date read (--json)
|
|
292
|
+
const r = jiraCriteria.reach(root);
|
|
293
|
+
if (flags.count) return out(r, [String(r.from_files)]);
|
|
294
|
+
const L = [`${r.initiatives} ${r.initiatives === 1 ? 'initiative tracks' : 'initiatives track'} open Jira tickets · ${r.from_done_test} get acceptance criteria from the done test · ${r.from_files} from the initiative's files`];
|
|
295
|
+
for (const b of r.by) L.push(` ${b.ini} · ${b.tickets} open · ${b.from_done_test} from the done test · ${b.from_files} from the files`);
|
|
296
|
+
return out(r, L);
|
|
297
|
+
}
|
|
287
298
|
if (verb === 'criteria-asks') {
|
|
288
299
|
const F = jiraCriteria.readCriteriaAsks(root);
|
|
289
300
|
if (flags.health) { const h = jiraCriteria.healthOf(F, now == null ? Date.now() : now); return out({ ok: true, ...h }, [`${h.written} written, ${h.refused} refused in 14 days`, String(h.pct)]); }
|
|
@@ -400,9 +411,13 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
400
411
|
if (verb === 'criteria-propose') {
|
|
401
412
|
const r = jiraCriteria.propose(root, initiative, { me: pmName(env) });
|
|
402
413
|
if (!r.ok) return fail(r.error);
|
|
403
|
-
if (!r.checks) return out(r, [`${initiative} · ${r.note}`]);
|
|
404
|
-
const
|
|
405
|
-
|
|
414
|
+
if (!r.checks && !r.proposals.length) return out(r, [`${initiative} · ${r.note || 'no open ticket to propose: each one is done, asked already, or has nothing in the files that fits'}`]);
|
|
415
|
+
const nd = r.proposals.length - r.fromFiles;
|
|
416
|
+
const L = [r.fromFiles
|
|
417
|
+
? `${initiative} · ${r.proposals.length} ${r.proposals.length === 1 ? 'ticket' : 'tickets'} to get acceptance criteria`
|
|
418
|
+
+ (nd ? ` · ${nd} from the done test (${r.doneTest})` : '') + ` · ${r.fromFiles} from the initiative's files` + (r.unmatched.length ? ` · done-test checks on no ticket: ${r.unmatched.join(', ')}` : '')
|
|
419
|
+
: `${initiative} · ${r.proposals.length} ${r.proposals.length === 1 ? 'ticket' : 'tickets'} to get the done test's checks (${r.doneTest})${r.unmatched.length ? ` · on no ticket: ${r.unmatched.join(', ')}` : ''}`];
|
|
420
|
+
for (const p of r.proposals) L.push('', `${p.key} · ${p.summary || 'no summary read'} · ${p.direct ? 'yours: written in Jira' : 'draft for ' + (p.who || 'its owner')} · from the ${p.from === 'files' ? 'files' : 'done test'}`, p.block);
|
|
406
421
|
return out(r, L);
|
|
407
422
|
}
|
|
408
423
|
if (verb === 'criteria-ask') {
|
|
@@ -133,17 +133,93 @@ function proposalsFor(checks, tickets, o = {}) {
|
|
|
133
133
|
return { proposals, unmatched: a.unmatched };
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
/* ── criteria from the initiative's own files (initiative ticket-criteria-from-files) ──
|
|
137
|
+
* Most initiatives have no done test (proof T47: 3 of 34), so most tickets got nothing above. For each open ticket the done test leaves
|
|
138
|
+
* out, PMOS takes the lines of the initiative's own files (record, PRD, core documents: lib/task-describe.js sourcesOf) that are about the
|
|
139
|
+
* ticket and read as checks, at most FILE_MAX, each with its file and line. No model: the words are the files' own. Nothing about a
|
|
140
|
+
* ticket: no block (zero is silence). */
|
|
141
|
+
const FILES_MARK = "**From the initiative's files**";
|
|
142
|
+
const FILE_MAX = 3;
|
|
143
|
+
const CHECK_WORDS = /\b(must|should|shall|needs? to|done when|expected|acceptance|definition of done|so that)\b/i;
|
|
144
|
+
const CHECK_HEAD = /^#{1,6}\s*.*\b(acceptance|criteria|requirements?|done|success|must|checks?)\b/i;
|
|
145
|
+
/** The heading a line sits under (1-based line), or ''. */
|
|
146
|
+
function headOf(lines, line) { for (let i = line - 2; i >= 0; i--) if (/^#{1,6}\s/.test(lines[i])) return lines[i]; return ''; }
|
|
147
|
+
/** PURE: the block for one ticket from its passages. rows: [{ path, line, text }]. */
|
|
148
|
+
function filesBlockOf(rows, { subject } = {}) {
|
|
149
|
+
if (!rows || !rows.length) return '';
|
|
150
|
+
const out = [FILES_MARK, ''];
|
|
151
|
+
rows.forEach((r, i) => {
|
|
152
|
+
const g = TA.gwt({ check: r.text, how: '' }, { subject });
|
|
153
|
+
out.push(`- Check F${i + 1} (\`${r.path}:${r.line}\`)`, ` - Given ${g.given}`, ` - When ${g.when}`, ` - Then ${g.then}`);
|
|
154
|
+
});
|
|
155
|
+
return out.join('\n');
|
|
156
|
+
}
|
|
157
|
+
/** Proposals from the files for the open tickets given. o: { me, skip: a path to leave out (the done test) }. READ-ONLY. */
|
|
158
|
+
function fromFiles(root, ini, tickets, o = {}) {
|
|
159
|
+
const open = (tickets || []).filter((t) => t && KEY_RE.test(String(t.key || '')) && !t.done && t.summary);
|
|
160
|
+
if (!open.length) return [];
|
|
161
|
+
const TD = require('./task-describe.js');
|
|
162
|
+
const docs = TD.docsOf(root, ini).filter((d) => !o.skip || d.path !== o.skip);
|
|
163
|
+
if (!docs.length) return [];
|
|
164
|
+
const byPath = new Map(docs.map((d) => [d.path, d]));
|
|
165
|
+
const out = [];
|
|
166
|
+
for (const t of open) {
|
|
167
|
+
const rows = [];
|
|
168
|
+
for (const p of TD.sourcesOf({ root, ini, task: { title: t.summary }, docs })) {
|
|
169
|
+
if (p.why) continue; // the initiative's why is about all of it, never a check of one ticket
|
|
170
|
+
const d = byPath.get(p.path);
|
|
171
|
+
if (!d) continue;
|
|
172
|
+
if (!CHECK_WORDS.test(p.text) && !CHECK_HEAD.test(headOf(d.lines, p.line))) continue;
|
|
173
|
+
if (rows.some((r) => r.text === p.text)) continue;
|
|
174
|
+
rows.push({ path: p.path, line: p.line, text: p.text });
|
|
175
|
+
if (rows.length >= FILE_MAX) break;
|
|
176
|
+
}
|
|
177
|
+
if (!rows.length) continue;
|
|
178
|
+
const block = filesBlockOf(rows, { subject: t.summary });
|
|
179
|
+
out.push({ key: t.key, summary: t.summary, who: t.who, direct: isPmName(t.who, o.me), labels: rows.map((_, i) => 'F' + (i + 1)), block, hash: hashOf(block),
|
|
180
|
+
from: 'files', sources: rows.map((r) => ({ path: r.path, line: r.line })) });
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** What PMOS proposes now for an initiative: the done test's proposals, then the files' for the tickets the done test leaves out, minus a
|
|
186
|
+
* ticket already asked or written with the same block. Each proposal says from: 'done test' | 'files'. */
|
|
187
|
+
function propose(root, ini, { me, all: every } = {}) {
|
|
138
188
|
if (!jiraTickets.recordFm(root, ini)) return { ok: false, status: 404, error: `no initiative ${ini} in this repository` };
|
|
139
189
|
const dt = doneTestOf(root, ini);
|
|
140
190
|
const checks = dt ? TA.checksOf(dt.text) : [];
|
|
141
|
-
if (!dt || !checks.length) return { ok: true, initiative: ini, doneTest: dt ? dt.path : null, checks: 0, proposals: [], unmatched: [], note: dt ? 'the done test has no checks' : 'the initiative has no done test' };
|
|
142
191
|
const tickets = ticketsOf(root, ini);
|
|
143
|
-
const r = proposalsFor(checks, tickets, { path: dt.path, me });
|
|
192
|
+
const r = checks.length ? proposalsFor(checks, tickets, { path: dt.path, me }) : { proposals: [], unmatched: [] };
|
|
193
|
+
const have = new Set(r.proposals.map((p) => p.key));
|
|
194
|
+
const files = fromFiles(root, ini, tickets.filter((t) => !have.has(t.key)), { me, skip: dt && dt.path });
|
|
195
|
+
const all = [...r.proposals.map((p) => ({ ...p, from: 'done test' })), ...files];
|
|
144
196
|
const F = readCriteriaAsks(root);
|
|
145
|
-
const fresh =
|
|
146
|
-
|
|
197
|
+
const fresh = every ? all : all.filter((p) => { const a = F.get(p.key); return !a || !(a.state === 'asked' || (a.state === 'written' && a.hash === p.hash)); });
|
|
198
|
+
const note = all.length ? '' : !dt ? "the initiative has no done test, and its files say nothing checkable about its open tickets" : !checks.length ? 'the done test has no checks' : '';
|
|
199
|
+
return { ok: true, initiative: ini, doneTest: dt ? dt.path : null, checks: checks.length, tickets: tickets.filter((t) => !t.done).length, proposals: fresh, unmatched: r.unmatched,
|
|
200
|
+
fromFiles: fresh.filter((p) => p.from === 'files').length, ...(note ? { note } : {}) };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The reach over every initiative of the checkout (asked and written tickets count too): open tickets with a proposal from the done test, and from the files. READ-ONLY. */
|
|
204
|
+
function reach(root) {
|
|
205
|
+
let ids = [];
|
|
206
|
+
const dirs = [];
|
|
207
|
+
try { const l = require('./console-state').loadEngine(); if (l.ok) dirs.push(l.engine.layout(root).initiatives); } catch { /* the two layouts below */ }
|
|
208
|
+
dirs.push(path.join(root, 'pmos', 'state', 'initiatives'), path.join(root, 'planning', 'initiatives'));
|
|
209
|
+
for (const dir of dirs) {
|
|
210
|
+
try { ids = fs.readdirSync(dir).filter((f) => f.endsWith('.md')).map((f) => f.slice(0, -3)); } catch { continue; }
|
|
211
|
+
if (ids.length) break;
|
|
212
|
+
}
|
|
213
|
+
const out = { initiatives: 0, from_done_test: 0, from_files: 0, by: [] };
|
|
214
|
+
for (const ini of ids.filter((i) => /^[a-z0-9][a-z0-9-]{0,80}$/.test(i)).sort()) {
|
|
215
|
+
let p; try { p = propose(root, ini, { all: true }); } catch { continue; } // a ticket asked or written still got its criteria
|
|
216
|
+
if (!p.ok || !p.tickets) continue;
|
|
217
|
+
const d = p.proposals.filter((x) => x.from === 'done test').length, f = p.proposals.filter((x) => x.from === 'files').length;
|
|
218
|
+
out.initiatives++; out.from_done_test += d; out.from_files += f;
|
|
219
|
+
if (d || f) out.by.push({ ini, tickets: p.tickets, from_done_test: d, from_files: f });
|
|
220
|
+
}
|
|
221
|
+
console.log('[jira-criteria] files', `reach from_done_test=${out.from_done_test}`, `from_files=${out.from_files}`);
|
|
222
|
+
return out;
|
|
147
223
|
}
|
|
148
224
|
|
|
149
225
|
/** The PM's yes for some of an initiative's proposals. o: { ini, keys, me }. The blocks are computed here, never taken from the caller.
|
|
@@ -155,16 +231,16 @@ function askCriteria(root, o, by, now = Date.now()) {
|
|
|
155
231
|
if (keys && (!keys.length || keys.length > 100 || keys.some((k) => !KEY_RE.test(k)))) return { ok: false, status: 400, error: 'keys is a list of 1 to 100 Jira keys, for example IDPF-2746' };
|
|
156
232
|
const p = propose(root, ini, { me: o.me });
|
|
157
233
|
if (!p.ok) return p;
|
|
158
|
-
if (!p.
|
|
234
|
+
if (!p.proposals.length && p.note) return { ok: false, status: 409, error: `${ini}: ${p.note}` };
|
|
159
235
|
const pick = keys ? p.proposals.filter((x) => keys.includes(x.key)) : p.proposals;
|
|
160
236
|
const skipped = keys ? keys.filter((k) => !pick.some((x) => x.key === k)) : [];
|
|
161
237
|
if (!pick.length) return { ok: false, status: 409, error: 'no ticket to write: each one has no check that fits, is done, or is asked already', skipped };
|
|
162
238
|
const at = new Date(now).toISOString();
|
|
163
|
-
const out = pick.map((x) => ({ v: 1, kind: 'ask', id: 'ac-' + crypto.randomBytes(5).toString('hex'), key: x.key, ini, labels: x.labels, block: x.block, hash: x.hash, who: x.who, direct: x.direct, at, by: by || 'pm' }));
|
|
239
|
+
const out = pick.map((x) => ({ v: 1, kind: 'ask', id: 'ac-' + crypto.randomBytes(5).toString('hex'), key: x.key, ini, labels: x.labels, block: x.block, hash: x.hash, who: x.who, direct: x.direct, from: x.from, at, by: by || 'pm' }));
|
|
164
240
|
append(root, out);
|
|
165
241
|
const F = readCriteriaAsks(root);
|
|
166
242
|
const A = out.map((l) => F.get(l.key));
|
|
167
|
-
log('ask', ini, `direct=${A.filter((a) => a.direct).length}`, `draft=${A.filter((a) => !a.direct).length}`, `skipped=${skipped.length}`);
|
|
243
|
+
log('ask', ini, `files=${out.filter((l) => l.from === 'files').length}`, `direct=${A.filter((a) => a.direct).length}`, `draft=${A.filter((a) => !a.direct).length}`, `skipped=${skipped.length}`);
|
|
168
244
|
return { ok: true, direct: A.filter((a) => a.direct), draft: A.filter((a) => !a.direct), ids: out.map((l) => l.id), skipped };
|
|
169
245
|
}
|
|
170
246
|
/** The agent's answer for one direct ask: r { written: true } or { why }. */
|
|
@@ -196,7 +272,7 @@ function criteriaDraftText(F) {
|
|
|
196
272
|
const out = [];
|
|
197
273
|
for (const [who, A] of by) {
|
|
198
274
|
out.push(`To ${who}:`);
|
|
199
|
-
out.push(`Please add these acceptance criteria to ${A.length === 1 ? 'this ticket' : 'these tickets'}. They come from the done test
|
|
275
|
+
out.push(`Please add these acceptance criteria to ${A.length === 1 ? 'this ticket' : 'these tickets'}. They come from what we agreed for this work (the done test, or the initiative's own files, each named), so the work is checked the same way it is built:`);
|
|
200
276
|
for (const a of A) out.push('', `${a.key}:`, a.block);
|
|
201
277
|
out.push('');
|
|
202
278
|
}
|
|
@@ -210,5 +286,5 @@ function healthOf(F, now = Date.now()) {
|
|
|
210
286
|
return { written: w, refused: A.length - w, answered: A.length, pct: A.length ? Math.round((100 * w) / A.length) : 100 };
|
|
211
287
|
}
|
|
212
288
|
|
|
213
|
-
module.exports = { FILE, KEY_RE, ID_RE, LOG, criteriaFile, foldCriteriaAsks, readCriteriaAsks, isPmName, doneTestOf, ticketsOf, proposalsFor, propose,
|
|
289
|
+
module.exports = { FILE, KEY_RE, ID_RE, LOG, criteriaFile, foldCriteriaAsks, readCriteriaAsks, isPmName, doneTestOf, ticketsOf, proposalsFor, propose, FILES_MARK, filesBlockOf, fromFiles, reach,
|
|
214
290
|
askCriteria, answerCriteriaAsk, withdrawCriteriaAsks, pendingCriteriaAsks, criteriaDraftText, healthOf };
|
|
@@ -175,6 +175,7 @@ const JOBS = Object.freeze([
|
|
|
175
175
|
ai('next-prompt', 'lib/next-prompt.js', []),
|
|
176
176
|
ai('sharpen-prompt', 'lib/next-prompt.js', []),
|
|
177
177
|
ai('principles-draft', 'lib/routes-principles.js', [], ['repo:DECISIONS.md']), // bet A352: the drafts land in principles.jsonl through `pmos principles draft`
|
|
178
|
+
ai('strategy-draft', 'lib/routes-strategy-card.js', [], ['repo:planning']), // initiative strategy-draft: the lines land in strategy-card.jsonl through `pmos strategy draft`
|
|
178
179
|
{ id: 'improve-self', kind: 'script', module: 'repo:scripts/improve.js', reads: ['repo:planning/improve/signals.jsonl'], writes: ['repo:planning/improve/loop.jsonl'] },
|
|
179
180
|
{ id: 'log-run', kind: 'script', module: 'repo:scripts/log-run.js', reads: [], writes: ['repo:planning/runs/agent-runs.jsonl', 'repo:planning/runs/verify-queue.jsonl'] },
|
|
180
181
|
]);
|
|
@@ -166,6 +166,9 @@ const VERBS = Object.freeze({
|
|
|
166
166
|
// Not a pm-os-absorb verb (run: null): initiative positioning-draft (idea A328) added it through the same table.
|
|
167
167
|
positioning: Object.freeze({ module: 'positioning-cli.js', run: null, guide: 'cli.md',
|
|
168
168
|
help: 'pmos positioning strategy|list|keep|drop — the product\'s positioning and key messages, each citing its strategy lines (pmos positioning help)' }),
|
|
169
|
+
// Not a pm-os-absorb verb (run: null): initiative strategy-draft (Wawan 2026-11-24) added it through the same table.
|
|
170
|
+
strategy: Object.freeze({ module: 'strategy-cli.js', run: null, guide: 'cli.md',
|
|
171
|
+
help: 'pmos strategy show|sources|draft|set|undo — the product\'s five-line strategy; PMOS drafts blank lines from the product\'s files, each citing them (pmos strategy help)' }),
|
|
169
172
|
// Not a pm-os-absorb verb (run: null): initiative parked-reason-way-back (bet A446) added it through the same table.
|
|
170
173
|
parked: Object.freeze({ module: 'parked-cli.js', run: null, guide: 'cli.md',
|
|
171
174
|
help: 'pmos parked list|hold|back|coverage — parked initiatives: why each is parked, what brings it back, and bringing it back (pmos parked help)' }),
|
|
@@ -48,7 +48,7 @@ async function handleCriteria(req, res, url, ctx) {
|
|
|
48
48
|
const r = JC.propose(w.root, ini, { me: pmNameOf() });
|
|
49
49
|
if (!r.ok) { ctx.json(res, r, r.status || 400); return true; }
|
|
50
50
|
ctx.json(res, { ...base, doneTest: r.doneTest, checks: r.checks, unmatched: r.unmatched,
|
|
51
|
-
proposals: r.proposals.map((x) => ({ key: x.key, summary: x.summary, who: x.who, direct: x.direct, labels: x.labels, block: x.block })) });
|
|
51
|
+
proposals: r.proposals.map((x) => ({ key: x.key, summary: x.summary, who: x.who, direct: x.direct, labels: x.labels, block: x.block, from: x.from, sources: x.sources || [] })) });
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
if (req.method !== 'POST' || (p !== '/api/jira-criteria/ask' && p !== '/api/jira-criteria/undo')) return false;
|
|
@@ -28,12 +28,14 @@ function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? c
|
|
|
28
28
|
/** The product checkout whose decisions are read. */
|
|
29
29
|
const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
|
|
30
30
|
|
|
31
|
-
/** The seed: deps { env, headlessOff() → bool, aiOff() → reason | null, stateDirFor(w) → dir | null, start(w, { onDone }) → { ok, session?, error? }
|
|
31
|
+
/** The seed: deps { env, headlessOff() → bool, aiOff() → reason | null, stateDirFor(w) → dir | null, start(w, { onDone }) → { ok, session?, error? },
|
|
32
|
+
* file? } (file: the seed file's name, SEED_FILE by default; lib/routes-strategy-card.js uses this seed too). seed(w, { force }) skips the once-a-day
|
|
33
|
+
* limit: the PM pressed for a run. */
|
|
32
34
|
function createSeed(deps) {
|
|
33
35
|
const running = new Set();
|
|
34
|
-
const fileOf = (w) => { const d = deps.stateDirFor ? deps.stateDirFor(w) : null; return d ? path.join(d, SEED_FILE) : null; };
|
|
36
|
+
const fileOf = (w) => { const d = deps.stateDirFor ? deps.stateDirFor(w) : null; return d ? path.join(d, deps.file || SEED_FILE) : null; };
|
|
35
37
|
const readAll = (f) => { try { const o = JSON.parse(fs.readFileSync(f, 'utf8')); return o && typeof o === 'object' ? o : {}; } catch { return {}; } };
|
|
36
|
-
function seed(w, { now = Date.now() } = {}) {
|
|
38
|
+
function seed(w, { now = Date.now(), force = false } = {}) {
|
|
37
39
|
if (!w || !w.id) return { started: false, why: 'no product' };
|
|
38
40
|
const env = deps.env || {};
|
|
39
41
|
if (String(env.PMOS_STATE_DIR || '').trim()) return { started: false, why: 'scratch server' };
|
|
@@ -45,7 +47,7 @@ function createSeed(deps) {
|
|
|
45
47
|
if (!f) return { started: false, why: 'no state folder' };
|
|
46
48
|
const all = readAll(f);
|
|
47
49
|
const last = Date.parse(all[w.id] || '');
|
|
48
|
-
if (Number.isFinite(last) && now - last < RETRY_MS) return { started: false, why: 'tried in the last day' };
|
|
50
|
+
if (!force && Number.isFinite(last) && now - last < RETRY_MS) return { started: false, why: 'tried in the last day' };
|
|
49
51
|
try { all[w.id] = new Date(now).toISOString(); fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, JSON.stringify(all) + '\n'); } catch { return { started: false, why: 'could not record the start' }; }
|
|
50
52
|
let r = null;
|
|
51
53
|
try { r = deps.start(w, { onDone: () => running.delete(w.id) }); } catch { r = null; }
|