create-pmos 0.774.0 → 0.776.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 +34 -45
- 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 +33 -0
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/backlog.md +6 -6
- package/workspace/guide/cli.md +10 -0
- package/workspace/guide/initiatives-and-next-steps.md +2 -0
- package/workspace/lib/headless.js +1 -0
- package/workspace/lib/job-graph.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- 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/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-backlog.css +28 -0
- package/workspace/public/pm/bd-strategy.js +35 -7
- package/workspace/public/pm/line-view.js +68 -27
- package/workspace/skills/strategy-draft.skill +31 -0
- package/workspace/test-lists/strategy-draft.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.776.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,39 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.776.0",
|
|
38
|
+
"at": "2026-11-24T12:44:48.670Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1739,
|
|
43
|
+
"t": "Release notes find a build's record when its PR names the initiative in prose",
|
|
44
|
+
"s": "Release notes find a build's record when its PR names the initiative in prose",
|
|
45
|
+
"k": "fix",
|
|
46
|
+
"h": "Release notes find a build's record when its PR names the initiative in prose"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"n": 1737,
|
|
50
|
+
"t": "PMOS drafts each product's five-line strategy from its own files",
|
|
51
|
+
"s": "PMOS drafts each product's five-line strategy from its own files",
|
|
52
|
+
"k": "new"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"v": "0.775.0",
|
|
58
|
+
"at": "2026-11-24T10:49:49.601Z",
|
|
59
|
+
"f": 4,
|
|
60
|
+
"prs": [
|
|
61
|
+
{
|
|
62
|
+
"n": 1736,
|
|
63
|
+
"t": "The Line tab reads as a table",
|
|
64
|
+
"s": "The Line tab reads as a table",
|
|
65
|
+
"k": "fix"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
36
69
|
{
|
|
37
70
|
"v": "0.774.0",
|
|
38
71
|
"at": "2026-11-24T10:37:50.703Z",
|
|
@@ -395,50 +428,6 @@
|
|
|
395
428
|
}
|
|
396
429
|
}
|
|
397
430
|
]
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
"v": "0.756.0",
|
|
401
|
-
"at": "2026-11-24T01:12:35.636Z",
|
|
402
|
-
"f": 4,
|
|
403
|
-
"prs": [
|
|
404
|
-
{
|
|
405
|
-
"n": 1704,
|
|
406
|
-
"t": "Line tab on Work and Today's dashed line (quiet rows slice B)",
|
|
407
|
-
"s": "Line tab on Work and Today's dashed line (quiet rows slice B)",
|
|
408
|
-
"k": "new",
|
|
409
|
-
"try": {
|
|
410
|
-
"steps": [
|
|
411
|
-
"Open Work",
|
|
412
|
-
"Press the Line tab",
|
|
413
|
-
"On Today, press the dashed line under Your move"
|
|
414
|
-
],
|
|
415
|
-
"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…",
|
|
416
|
-
"open": "/premium-board.html?work=line"
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
]
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
"v": "0.755.0",
|
|
423
|
-
"at": "2026-11-24T00:55:56.769Z",
|
|
424
|
-
"f": 4,
|
|
425
|
-
"prs": [
|
|
426
|
-
{
|
|
427
|
-
"n": 1699,
|
|
428
|
-
"t": "A new product passes a Setup station before PMOS plans its work",
|
|
429
|
-
"s": "A new product passes a Setup station before PMOS plans its work",
|
|
430
|
-
"k": "new",
|
|
431
|
-
"try": {
|
|
432
|
-
"steps": [
|
|
433
|
-
"Add a first initiative to a product you just set up, then open Today",
|
|
434
|
-
"Read the Setup row: it names what is still missing",
|
|
435
|
-
"Ask the chat: agree the drafted goal"
|
|
436
|
-
],
|
|
437
|
-
"see": "Until the tracker is read, a goal is agreed and an owner is named, Today shows one Setup row saying which of the three is missing, and the chat can keep the drafted goal or the owner for you. Once…",
|
|
438
|
-
"open": "/today.html"
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
]
|
|
442
431
|
}
|
|
443
432
|
]
|
|
444
433
|
}
|
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-24T12:44:45Z"}
|
|
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-24T12:44:45Z"}
|
|
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-24T12:44:45Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.776.0",
|
|
4
|
+
"at": "2026-11-24T12:44:48.670Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1739,
|
|
9
|
+
"t": "Release notes find a build's record when its PR names the initiative in prose",
|
|
10
|
+
"s": "Release notes find a build's record when its PR names the initiative in prose",
|
|
11
|
+
"k": "fix",
|
|
12
|
+
"h": "Release notes find a build's record when its PR names the initiative in prose"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"n": 1737,
|
|
16
|
+
"t": "PMOS drafts each product's five-line strategy from its own files",
|
|
17
|
+
"s": "PMOS drafts each product's five-line strategy from its own files",
|
|
18
|
+
"k": "new"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"v": "0.775.0",
|
|
24
|
+
"at": "2026-11-24T10:49:49.601Z",
|
|
25
|
+
"f": 4,
|
|
26
|
+
"prs": [
|
|
27
|
+
{
|
|
28
|
+
"n": 1736,
|
|
29
|
+
"t": "The Line tab reads as a table",
|
|
30
|
+
"s": "The Line tab reads as a table",
|
|
31
|
+
"k": "fix"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
2
35
|
{
|
|
3
36
|
"v": "0.774.0",
|
|
4
37
|
"at": "2026-11-24T10:37:50.703Z",
|
|
@@ -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` |
|
|
@@ -20,13 +20,13 @@ The Work page uses the PMOS design system (see [Layout](layout.md#the-design-sys
|
|
|
20
20
|
|
|
21
21
|
## The Line
|
|
22
22
|
|
|
23
|
-
Press **Line** on the switch to see every live initiative of your pick in one table
|
|
23
|
+
Press **Line** on the switch to see every live initiative of your pick in one table. Rows are grouped by workflow first (for example Simple feature), then by that workflow's stages in order (Discovery, then Implementation). Two workflows never share a group, so "Discover" of one workflow and "Discovery" of another stay apart. The address `/premium-board.html?work=line` opens it directly.
|
|
24
24
|
|
|
25
|
-
- The sentence above the table says where the line stands, for example "9 initiatives on the line.
|
|
26
|
-
- The columns are **Initiative**, **Days
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
25
|
+
- The sentence above the table says where the line stands, for example "9 initiatives on the line. 6 move by themselves. 2 still moving but over their stage's expected days. 1 stuck."
|
|
26
|
+
- The columns are **Initiative**, **Days in stage** (for example "28 days" with "expected 15 · 13 over" under it, in the alert colour when it is over), **To finish the stage** (the exit items still missing, or the next move when that is something else, such as waiting for capacity) and **State**.
|
|
27
|
+
- **State** is one of: **moving**, **over time** (still active, but past the stage's expected days), **stuck** (past the expected days with no activity), **waits on you**, **waiting** (on capacity, on hold or on another initiative; never stuck) and **can't tell** (PMOS could not place it, so it leaves it alone).
|
|
28
|
+
- The tabs **All**, **Stuck**, **Over time**, **Waits on you**, **Waiting** and **Can't tell** filter the table. A tab with nothing in it is not shown.
|
|
29
|
+
- A row that waits on you is answered on Today, so it is marked here and not repeated there.
|
|
30
30
|
- Press an initiative's name to open it.
|
|
31
31
|
|
|
32
32
|
## The columns
|
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
|
|
@@ -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:']);
|
|
@@ -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)' }),
|
|
@@ -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; }
|
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
/* routes-strategy-card.js — a product's five-line strategy over HTTP (bet A458, initiative strategy-five-lines). The card and its fit rule are
|
|
3
3
|
* lib/strategy-card.js; the file is strategy-card.jsonl in the product's records folder (lib/records-dir.js).
|
|
4
4
|
*
|
|
5
|
-
* GET /api/strategy-card?ws=<id>[&board=<id>] → { ok, card, labels, complete, notes } notes: null while the Board is
|
|
5
|
+
* GET /api/strategy-card?ws=<id>[&board=<id>] → { ok, card, labels, complete, notes, sources, drafting } notes: null while the Board is
|
|
6
|
+
* still being read; sources: { <line>: [{ ref, title }] } for each line PMOS drafted
|
|
6
7
|
* POST /api/strategy-card { ws, fields } → { ok, card, complete } | 400 when no known line is named
|
|
8
|
+
* POST /api/strategy-card { ws, undo: true, line? } → { ok, card, complete } | 400 take PMOS's draft back (all drafted lines, or one)
|
|
9
|
+
* POST /api/strategy-card/draft { ws } → { ok, drafting, why? } the PM's ✦: start the drafting run now
|
|
10
|
+
*
|
|
11
|
+
* THE DRAFTING RUN (initiative strategy-draft). When a GET finds a product whose five lines are all blank and whose last draft was not undone,
|
|
12
|
+
* it starts ONE background run of the built-in `strategy-draft` skill (headless kind `skill`, `claude -p` under the PM's own login), whose
|
|
13
|
+
* only write is `pmos strategy draft`. The seed is the one lib/routes-principles.js uses: at most one start per product per day (kept in
|
|
14
|
+
* <state folder>/strategy-seed.json), one run at a time, off with `pmos ai off strategy-draft`, PMOS_HEADLESS=off or on a scratch server.
|
|
7
15
|
*
|
|
8
16
|
* GET /api/positioning?ws=<id> → { ok, complete, missing, kept, draft } draft: the kept draft for this strategy, pending, or null
|
|
9
17
|
* POST /api/positioning { ws, again } → { ok, draft } starts a draft (lib/positioning-draft.js; idea A328): pending, then ready
|
|
@@ -15,7 +23,44 @@
|
|
|
15
23
|
const guard = require('./pm-guard.js');
|
|
16
24
|
const SC = require('./strategy-card.js');
|
|
17
25
|
const PD = require('./positioning-draft.js');
|
|
26
|
+
const SS = require('./strategy-sources.js');
|
|
18
27
|
const { recordsDirFor } = require('./records-dir.js');
|
|
28
|
+
const fs = require('fs');
|
|
29
|
+
const path = require('path');
|
|
30
|
+
|
|
31
|
+
const JOB = 'strategy-draft';
|
|
32
|
+
const SEED_FILE = 'strategy-seed.json';
|
|
33
|
+
const SKILL = path.join(__dirname, '..', 'skills', 'strategy-draft.skill');
|
|
34
|
+
const CHECKOUT = path.join(__dirname, '..', '..');
|
|
35
|
+
function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
|
|
36
|
+
const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
|
|
37
|
+
|
|
38
|
+
let shared = null;
|
|
39
|
+
function seedFor(ctx) {
|
|
40
|
+
if (ctx && ctx.strategySeed) return ctx.strategySeed;
|
|
41
|
+
if (shared) return shared;
|
|
42
|
+
if (!ctx || typeof ctx.spawnSession !== 'function' || typeof ctx.stateDirFor !== 'function') return null;
|
|
43
|
+
shared = require('./routes-principles.js').createSeed({
|
|
44
|
+
file: SEED_FILE,
|
|
45
|
+
env: process.env,
|
|
46
|
+
headlessOff: () => require('./headless.js').switchedOff(process.env),
|
|
47
|
+
aiOff: () => require('./ai-guard.js').off(JOB, { settingsDir: ctx.runtimeDir || null }),
|
|
48
|
+
stateDirFor: (w) => ctx.stateDirFor(w, { create: true }),
|
|
49
|
+
start: (w, { onDone } = {}) => {
|
|
50
|
+
let prompt = '';
|
|
51
|
+
try { prompt = require('./skill-store.js').parseSkill(fs.readFileSync(SKILL, 'utf8')).body || ''; } catch { prompt = ''; }
|
|
52
|
+
if (!prompt) return { ok: false, error: 'the strategy-draft skill is not installed' };
|
|
53
|
+
const s = ctx.spawnSession({ name: 'Drafting the strategy', agent: 'claude', ws: w.id, origin: JOB + ':' + w.id, initialInput: prompt + '\r', autoDelete: undefined, onDone,
|
|
54
|
+
modelAsk: { scheduleTier: null, skillTier: null, skill: JOB } });
|
|
55
|
+
if (!s || s.state === 'exited') return { ok: false, error: (s && s.note) || 'the run could not start' };
|
|
56
|
+
return { ok: true, session: s.id };
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return shared;
|
|
60
|
+
}
|
|
61
|
+
const blank = (card) => SC.FIELDS.every((k) => !String(card[k] || '').trim());
|
|
62
|
+
/** The sources of each drafted line, with their titles. */
|
|
63
|
+
const sourcesOf = (root, card) => Object.fromEntries(Object.entries(card.drafted || {}).map(([k, d]) => [k, d.sources.map((ref) => ({ ref, title: SS.titleOf(root, ref) }))]));
|
|
19
64
|
|
|
20
65
|
/** GET a route module's own handler, as routes-board-premium.js does, and return { status, body }. */
|
|
21
66
|
async function via(mod, pathAndQuery, req, ctx) {
|
|
@@ -62,14 +107,29 @@ async function positioning(req, res, url, ctx, send) {
|
|
|
62
107
|
async function handle(req, res, url, ctx) {
|
|
63
108
|
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
64
109
|
if (url.pathname.startsWith('/api/positioning')) return positioning(req, res, url, ctx, send);
|
|
110
|
+
if (url.pathname === '/api/strategy-card/draft') {
|
|
111
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'POST' });
|
|
112
|
+
const rd = await ctx.readJson(req);
|
|
113
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
114
|
+
const body = rd.body || {};
|
|
115
|
+
const g = guard.requirePagePress(req, body);
|
|
116
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
117
|
+
const w = wsOf(ctx, body.ws || null), seeder = seedFor(ctx);
|
|
118
|
+
if (!seeder || !w) return send(200, { ok: true, drafting: false, why: 'PMOS cannot start a run here' });
|
|
119
|
+
const r = seeder.seed(w, { force: true });
|
|
120
|
+
return send(200, { ok: true, drafting: !!r.started || r.why === 'running', why: r.started ? undefined : r.why });
|
|
121
|
+
}
|
|
65
122
|
if (url.pathname !== '/api/strategy-card') return false;
|
|
66
123
|
if (req.method === 'GET') {
|
|
67
124
|
const ws = url.searchParams.get('ws') || null;
|
|
68
125
|
const card = SC.read(recordsDirFor(ctx, ws));
|
|
69
126
|
const complete = SC.complete(card);
|
|
127
|
+
const w = wsOf(ctx, ws), seeder = seedFor(ctx);
|
|
128
|
+
if (blank(card) && !card.declined && seeder && w) seeder.seed(w);
|
|
129
|
+
const drafting = !!(seeder && w && seeder.running && seeder.running(w.id));
|
|
70
130
|
let notes = [];
|
|
71
131
|
if (complete) { const rows = ctx.strategyRows ? ctx.strategyRows : await rowsOf(req, ctx, ws, url.searchParams.get('board') || null); notes = rows ? SC.notes(card, rows) : null; }
|
|
72
|
-
return send(200, { ok: true, card, labels: SC.LABELS, complete, notes });
|
|
132
|
+
return send(200, { ok: true, card, labels: SC.LABELS, complete, notes, sources: sourcesOf(rootFor(ctx, w), card), drafting });
|
|
73
133
|
}
|
|
74
134
|
if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
|
|
75
135
|
const rd = await ctx.readJson(req);
|
|
@@ -77,8 +137,9 @@ async function handle(req, res, url, ctx) {
|
|
|
77
137
|
const body = rd.body || {};
|
|
78
138
|
const g = guard.requirePagePress(req, body);
|
|
79
139
|
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
80
|
-
const
|
|
140
|
+
const dir = recordsDirFor(ctx, body.ws || null);
|
|
141
|
+
const r = body.undo ? SC.undo(dir, body.line || null) : SC.save(dir, body.fields);
|
|
81
142
|
return r.ok ? send(200, { ok: true, card: r.card, complete: SC.complete(r.card) }) : send(400, { ok: false, error: r.error });
|
|
82
143
|
}
|
|
83
144
|
|
|
84
|
-
module.exports = { prefixes: ['/api/strategy-card', '/api/positioning'], handle }; // /api/positioning: its own first segment, so a change to it does not reach every page that reads the strategy card
|
|
145
|
+
module.exports = { prefixes: ['/api/strategy-card', '/api/positioning'], handle, seedFor, JOB, SEED_FILE }; // /api/positioning: its own first segment, so a change to it does not reach every page that reads the strategy card
|
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
* fit(card, row) → null (fits, or nothing to say) | { kind: 'wont' | 'none', why }
|
|
9
9
|
* notes(card, rows) → [{ id, title, stage, kind, why }] at most MAX_NOTES
|
|
10
10
|
* count(dirs) → how many of the folders hold a complete card
|
|
11
|
+
* draft(dir, fields, sources, now?) → { ok, card, wrote } | { ok: false, error } PMOS's draft (initiative strategy-draft): only blank lines,
|
|
12
|
+
* each citing 1 to MAX_SOURCES refs that lib/strategy-sources.js accepts; appends { at, by: 'pmos', fields, sources }
|
|
13
|
+
* undo(dir, key?, now?) → { ok, card, blanked } | { ok: false, error } blanks the lines that still hold PMOS's draft (or one), { ev: 'undo' }
|
|
14
|
+
* drafted(dirs) → how many lines PMOS drafted still stand (the health number of strategy-draft)
|
|
15
|
+
*
|
|
16
|
+
* PMOS'S DRAFT. `read` also returns `drafted: { <line>: { sources, at } }` for each line whose current text is PMOS's, and `declined: true`
|
|
17
|
+
* when the PM undid a draft and no draft came after (then PMOS does not draft again by itself). A save that changes a line makes it the PM's;
|
|
18
|
+
* a save leaves out the lines it does not change, so editing one drafted line keeps the ✦ on the others.
|
|
11
19
|
*
|
|
12
20
|
* WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit product.
|
|
13
21
|
* The file is append-only; nothing rewrites it, so the history of the strategy stays.
|
|
@@ -25,6 +33,7 @@ const FIELDS = ['for', 'problem', 'bet', 'win', 'wont'];
|
|
|
25
33
|
const LABELS = { for: 'Who it is for', problem: 'The problem', bet: 'The bet', win: 'How we win', wont: "What we won't do" };
|
|
26
34
|
const MAX_LEN = 160;
|
|
27
35
|
const MAX_NOTES = 20;
|
|
36
|
+
const MAX_SOURCES = 5;
|
|
28
37
|
const NEW_STAGES = ['triage', 'discover', 'plan', 'prioritize', 'intake', 'ideate', 'strategize']; // old names count for the new ones (lib/board-premium.js)
|
|
29
38
|
const SKIP_LANES = ['chore', 'incident'];
|
|
30
39
|
const STOP = new Set(('a an and are but for from have into its more most much must not only our over same some such than that the their them then '
|
|
@@ -56,9 +65,17 @@ function readLines(dir) {
|
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
function read(dir) {
|
|
59
|
-
const card = { for: '', problem: '', bet: '', win: '', wont: '', at: null, since: null };
|
|
68
|
+
const card = { for: '', problem: '', bet: '', win: '', wont: '', at: null, since: null, drafted: {}, declined: false };
|
|
60
69
|
for (const l of readLines(dir)) {
|
|
61
|
-
|
|
70
|
+
const pmos = l.by === 'pmos';
|
|
71
|
+
if (pmos) card.declined = false;
|
|
72
|
+
if (l.ev === 'undo') card.declined = true;
|
|
73
|
+
for (const k of FIELDS) {
|
|
74
|
+
if (!Object.prototype.hasOwnProperty.call(l.fields, k)) continue;
|
|
75
|
+
card[k] = line(l.fields[k]);
|
|
76
|
+
const src = pmos && l.sources && Array.isArray(l.sources[k]) ? l.sources[k].map(String) : null;
|
|
77
|
+
if (src && card[k]) card.drafted[k] = { sources: src, at: l.at || null }; else delete card.drafted[k];
|
|
78
|
+
}
|
|
62
79
|
card.at = l.at || card.at;
|
|
63
80
|
if (!card.since && complete(card)) card.since = l.at || null; // the day all five lines were first written
|
|
64
81
|
}
|
|
@@ -73,17 +90,62 @@ function clean(fields) {
|
|
|
73
90
|
return out;
|
|
74
91
|
}
|
|
75
92
|
|
|
93
|
+
function append(dir, obj) {
|
|
94
|
+
try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(fileOf(dir), JSON.stringify(obj) + '\n'); return null; } catch (e) { return 'could not save the strategy: ' + ((e && e.message) || e); }
|
|
95
|
+
}
|
|
96
|
+
|
|
76
97
|
function save(dir, fields, now = Date.now()) {
|
|
77
98
|
const f = fileOf(dir);
|
|
78
99
|
if (!f) return { ok: false, error: 'This product has no records folder.' };
|
|
79
100
|
const c = clean(fields);
|
|
80
101
|
if (!Object.keys(c).length) return { ok: false, error: 'Name a line to save: ' + FIELDS.join(', ') + '.' };
|
|
81
|
-
|
|
102
|
+
const before = read(dir);
|
|
103
|
+
// a line saved with the text it already has is left out, so a PMOS-drafted line the PM did not touch keeps its ✦
|
|
104
|
+
for (const k of Object.keys(c)) if (c[k] === before[k] && before.at) delete c[k];
|
|
105
|
+
if (!Object.keys(c).length) return { ok: true, card: before };
|
|
106
|
+
const err = append(dir, { at: new Date(now).toISOString(), fields: c });
|
|
107
|
+
if (err) return { ok: false, error: err };
|
|
82
108
|
const card = read(dir);
|
|
83
109
|
say('saved ' + Object.keys(c).join(', ') + (complete(card) ? ' (all five lines written)' : ''));
|
|
84
110
|
return { ok: true, card };
|
|
85
111
|
}
|
|
86
112
|
|
|
113
|
+
/** PMOS's draft: only the lines that are blank now, each with the refs it came from. `check(ref)` → true when the ref is a source of the product. */
|
|
114
|
+
function draft(dir, fields, sources, { now = Date.now(), check = null } = {}) {
|
|
115
|
+
if (!fileOf(dir)) return { ok: false, error: 'This product has no records folder.' };
|
|
116
|
+
const c = clean(fields);
|
|
117
|
+
if (!Object.keys(c).length) return { ok: false, error: 'Name a line to draft: ' + FIELDS.join(', ') + '.' };
|
|
118
|
+
const before = read(dir), out = {}, src = {}, kept = [];
|
|
119
|
+
for (const k of Object.keys(c)) {
|
|
120
|
+
if (!c[k]) continue;
|
|
121
|
+
if (String(before[k] || '').trim()) { kept.push(k); continue; } // the PM's line, or a draft already there: never overwritten
|
|
122
|
+
const refs = [...new Set((Array.isArray(sources && sources[k]) ? sources[k] : []).map((r) => String(r || '').trim()).filter(Boolean))];
|
|
123
|
+
if (!refs.length) return { ok: false, error: `Cite where "${LABELS[k]}" comes from (--source <ref>, 1 to ${MAX_SOURCES}). \`pmos strategy sources\` lists them.` };
|
|
124
|
+
if (refs.length > MAX_SOURCES) return { ok: false, error: `Cite at most ${MAX_SOURCES} sources for "${LABELS[k]}".` };
|
|
125
|
+
const bad = check ? refs.filter((r) => !check(r)) : [];
|
|
126
|
+
if (bad.length) return { ok: false, error: 'Not a source of this product: ' + bad.join(', ') + '. `pmos strategy sources` lists the files a line may cite; a tracker key (ABC-123) is accepted too.' };
|
|
127
|
+
out[k] = c[k]; src[k] = refs;
|
|
128
|
+
}
|
|
129
|
+
if (!Object.keys(out).length) return { ok: false, code: 'written', error: 'Those lines are written already (' + kept.map((k) => LABELS[k]).join(', ') + '); PMOS drafts only blank lines.' };
|
|
130
|
+
const err = append(dir, { at: new Date(now).toISOString(), by: 'pmos', fields: out, sources: src });
|
|
131
|
+
if (err) return { ok: false, error: err };
|
|
132
|
+
say('drafted ' + Object.keys(out).join(', '));
|
|
133
|
+
return { ok: true, card: read(dir), wrote: Object.keys(out), kept };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Take PMOS's draft back: blank every line that still holds it, or the one named. The PM's lines stay. */
|
|
137
|
+
function undo(dir, key = null, { now = Date.now() } = {}) {
|
|
138
|
+
if (!fileOf(dir)) return { ok: false, error: 'This product has no records folder.' };
|
|
139
|
+
if (key && !FIELDS.includes(key)) return { ok: false, error: 'Name a line: ' + FIELDS.join(', ') + '.' };
|
|
140
|
+
const before = read(dir);
|
|
141
|
+
const keys = Object.keys(before.drafted).filter((k) => !key || k === key);
|
|
142
|
+
if (!keys.length) return { ok: false, error: key ? `"${LABELS[key]}" does not hold a PMOS draft.` : 'No line holds a PMOS draft.' };
|
|
143
|
+
const err = append(dir, { at: new Date(now).toISOString(), ev: 'undo', fields: Object.fromEntries(keys.map((k) => [k, ''])) });
|
|
144
|
+
if (err) return { ok: false, error: err };
|
|
145
|
+
say('undid the draft of ' + keys.join(', '));
|
|
146
|
+
return { ok: true, card: read(dir), blanked: keys };
|
|
147
|
+
}
|
|
148
|
+
|
|
87
149
|
const complete = (card) => !!card && FIELDS.every((k) => String(card[k] || '').trim() !== '');
|
|
88
150
|
|
|
89
151
|
/** Is this row new work: open, before Build, not upkeep? */
|
|
@@ -121,13 +183,14 @@ function notes(card, rows) {
|
|
|
121
183
|
}
|
|
122
184
|
|
|
123
185
|
const count = (dirs) => (dirs || []).filter((d) => complete(read(d))).length;
|
|
186
|
+
const drafted = (dirs) => (dirs || []).reduce((n, d) => n + Object.keys(read(d).drafted).length, 0);
|
|
124
187
|
|
|
125
|
-
module.exports = { FILE, FIELDS, LABELS, MAX_LEN, MAX_NOTES, words, read, save, clean, complete, fit, notes, count, readLines };
|
|
188
|
+
module.exports = { FILE, FIELDS, LABELS, MAX_LEN, MAX_NOTES, MAX_SOURCES, words, read, save, draft, undo, clean, complete, fit, notes, count, drafted, readLines };
|
|
126
189
|
|
|
127
190
|
if (require.main === module) {
|
|
128
191
|
const cmd = process.argv[2];
|
|
129
|
-
if (cmd !== 'count') { console.error('usage: node workspace/lib/strategy-card.js count [<product checkout>] (products with all five lines saved)'); process.exit(2); }
|
|
192
|
+
if (cmd !== 'count' && cmd !== 'drafted') { console.error('usage: node workspace/lib/strategy-card.js count|drafted [<product checkout>] (products with all five lines saved | PMOS-drafted lines that still stand)'); process.exit(2); }
|
|
130
193
|
let dir = null;
|
|
131
194
|
try { const { repoScript } = require('./repo-script.js'); dir = require(repoScript('signals/layout-paths.js')).pathsFor(process.argv[3] || process.cwd()).recordsDir; } catch { dir = path.join(process.argv[3] || process.cwd(), 'planning', 'records'); }
|
|
132
|
-
console.log(String(count([dir])));
|
|
195
|
+
console.log(String(cmd === 'drafted' ? drafted([dir]) : count([dir])));
|
|
133
196
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* strategy-cli.js — `pmos strategy`: the product's five-line strategy, the same lines the Strategy card on Work shows (initiatives
|
|
3
|
+
* strategy-five-lines and strategy-draft). The store is lib/strategy-card.js (strategy-card.jsonl in the product's records folder).
|
|
4
|
+
*
|
|
5
|
+
* pmos strategy show [--json] the five lines; a line PMOS drafted shows ✦ and its sources
|
|
6
|
+
* pmos strategy sources [--json] the product's files a drafted line may cite (lib/strategy-sources.js)
|
|
7
|
+
* pmos strategy draft --line <key> --text "<line>" --source <ref> [--source <ref>…] PMOS's draft of one blank line, citing its sources
|
|
8
|
+
* pmos strategy set --line <key> --text "<line>" the PM's own line (the chat writes it for the PM); "" blanks it
|
|
9
|
+
* pmos strategy undo [--line <key>] take PMOS's draft back: the drafted lines go blank
|
|
10
|
+
* every command: [--root <dir>] (default: this repository)
|
|
11
|
+
*
|
|
12
|
+
* Keys: for, problem, bet, win, wont. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { execFileSync } = require('child_process');
|
|
15
|
+
const SC = require('./strategy-card.js');
|
|
16
|
+
const SS = require('./strategy-sources.js');
|
|
17
|
+
|
|
18
|
+
const COMMANDS = { strategy: ['show', 'sources', 'draft', 'set', 'undo'] };
|
|
19
|
+
const USAGE = [
|
|
20
|
+
'usage: pmos strategy show|sources|draft|set|undo — the product\'s five-line strategy (keys: ' + SC.FIELDS.join(', ') + ')',
|
|
21
|
+
' pmos strategy show [--json] the five lines; ✦ marks a line PMOS drafted, with its sources',
|
|
22
|
+
' pmos strategy sources [--json] the product\'s files a drafted line may cite',
|
|
23
|
+
' pmos strategy draft --line bet --text "<line>" --source <ref> [--source <ref>] draft one blank line, citing 1 to ' + SC.MAX_SOURCES + ' sources',
|
|
24
|
+
' pmos strategy set --line bet --text "<line>" write the PM\'s own line',
|
|
25
|
+
' pmos strategy undo [--line bet] take PMOS\'s draft back (all drafted lines, or one)',
|
|
26
|
+
'Run it in the product\'s repository, or pass --root <dir>.',
|
|
27
|
+
];
|
|
28
|
+
const ALLOWED = { show: ['json', 'root'], sources: ['json', 'root'], draft: ['json', 'root', 'line', 'text', 'source'], set: ['json', 'root', 'line', 'text'], undo: ['json', 'root', 'line'] };
|
|
29
|
+
const BOOL = new Set(['json']);
|
|
30
|
+
const MULTI = new Set(['source']);
|
|
31
|
+
|
|
32
|
+
function parse(args) {
|
|
33
|
+
const pos = [], flags = {};
|
|
34
|
+
for (let i = 0; i < args.length; i++) {
|
|
35
|
+
const a = args[i];
|
|
36
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
37
|
+
const k = a.slice(2);
|
|
38
|
+
if (BOOL.has(k)) { flags[k] = true; continue; }
|
|
39
|
+
const v = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
40
|
+
if (MULTI.has(k)) (flags[k] = flags[k] || []).push(v); else flags[k] = v;
|
|
41
|
+
}
|
|
42
|
+
return { pos, flags };
|
|
43
|
+
}
|
|
44
|
+
function repoRoot(cwd) {
|
|
45
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
46
|
+
}
|
|
47
|
+
function recordsDirOf(root) {
|
|
48
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd() } = {}) {
|
|
52
|
+
const args = argv[0] === 'strategy' ? argv.slice(1) : argv.slice();
|
|
53
|
+
const sub = args[0];
|
|
54
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
55
|
+
if (!COMMANDS.strategy.includes(sub)) { say(`unknown strategy command "${sub}". Use one of: ${COMMANDS.strategy.join(', ')}`); return 2; }
|
|
56
|
+
const { pos, flags } = parse(args.slice(1));
|
|
57
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos strategy ${sub}`); return 2; }
|
|
58
|
+
if (pos.length) { say(`✗ pmos strategy ${sub} takes options, not an argument (pmos strategy help)`); return 2; }
|
|
59
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
60
|
+
const dir = recordsDirOf(root);
|
|
61
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
62
|
+
const needLine = () => (SC.FIELDS.includes(flags.line) ? null : fail('--line is one of: ' + SC.FIELDS.join(', '), 2));
|
|
63
|
+
|
|
64
|
+
if (sub === 'show') {
|
|
65
|
+
const card = SC.read(dir);
|
|
66
|
+
const lines = SC.FIELDS.map((k) => ({ key: k, label: SC.LABELS[k], text: card[k] || '', drafted: !!card.drafted[k],
|
|
67
|
+
sources: card.drafted[k] ? card.drafted[k].sources.map((ref) => ({ ref, title: SS.titleOf(root, ref) })) : [] }));
|
|
68
|
+
if (flags.json) { say(JSON.stringify({ ok: true, complete: SC.complete(card), declined: card.declined, lines })); return 0; }
|
|
69
|
+
for (const l of lines) {
|
|
70
|
+
say(` ${l.drafted ? '✦' : ' '} ${l.key.padEnd(8)} ${l.label}: ${l.text || '(not written)'}`);
|
|
71
|
+
if (l.drafted) say(` from: ${l.sources.map((s) => s.title).join(' · ')}`);
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
if (sub === 'sources') {
|
|
76
|
+
const list = SS.sourcesOf(root);
|
|
77
|
+
if (flags.json) { say(JSON.stringify({ ok: true, sources: list })); return 0; }
|
|
78
|
+
if (!list.length) say('No initiative, PRD, goal or doc file found. A tracker key (ABC-123) can be cited too.');
|
|
79
|
+
for (const s of list) say(` ${s.kind.padEnd(10)} ${s.ref} — ${s.title}`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
if (sub === 'draft') {
|
|
83
|
+
const bad = needLine(); if (bad != null) return bad;
|
|
84
|
+
const r = SC.draft(dir, { [flags.line]: flags.text }, { [flags.line]: flags.source || [] }, { check: (ref) => SS.checkRef(root, ref) });
|
|
85
|
+
if (!r.ok) return fail(r.error);
|
|
86
|
+
say(flags.json ? JSON.stringify({ ok: true, wrote: r.wrote }) : `✦ drafted ${SC.LABELS[flags.line]}: ${r.card[flags.line]}`);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
if (sub === 'set') {
|
|
90
|
+
const bad = needLine(); if (bad != null) return bad;
|
|
91
|
+
if (flags.text === undefined) return fail('--text "<line>" is needed ("" blanks the line)', 2);
|
|
92
|
+
const r = SC.save(dir, { [flags.line]: flags.text });
|
|
93
|
+
if (!r.ok) return fail(r.error);
|
|
94
|
+
say(flags.json ? JSON.stringify({ ok: true, card: r.card }) : `saved ${SC.LABELS[flags.line]}: ${r.card[flags.line] || '(blank)'}`);
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
// undo
|
|
98
|
+
if (flags.line !== undefined) { const bad = needLine(); if (bad != null) return bad; }
|
|
99
|
+
const r = SC.undo(dir, flags.line || null);
|
|
100
|
+
if (!r.ok) return fail(r.error);
|
|
101
|
+
say(flags.json ? JSON.stringify({ ok: true, blanked: r.blanked }) : 'took back the draft of ' + r.blanked.map((k) => SC.LABELS[k]).join(', '));
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* strategy-sources.js — the product's own files a drafted strategy line may cite (initiative strategy-draft; done test
|
|
3
|
+
* planning/done-tests/strategy-draft.md C4). READ-ONLY.
|
|
4
|
+
*
|
|
5
|
+
* sourcesOf(root) → [{ ref, kind, title }] ref: the file's path relative to the product root ('/' separators)
|
|
6
|
+
* kind ∈ initiative · prd · done-test · goal · brief · doc
|
|
7
|
+
* checkRef(root, ref) → true when `ref` is a file inside the product root (not under .git or node_modules), or a tracker key (ABC-123)
|
|
8
|
+
* titleOf(root, ref) → the file's title (frontmatter `title`, else its first heading, else its name), or the key itself
|
|
9
|
+
*
|
|
10
|
+
* WHERE. Both layouts: the PMOS repo keeps its records under planning/, a kit product under pmos/planning/ and pmos/state/. Newest first in
|
|
11
|
+
* each kind, at most PER_KIND per kind, so a product with hundreds of initiatives gives a short list. Nothing outside the root is read. */
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
const PER_KIND = 40;
|
|
16
|
+
const KEY = /^[A-Z][A-Z0-9]{1,15}-\d{1,7}$/;
|
|
17
|
+
const SKIP = /(^|\/)(\.git|node_modules)(\/|$)/;
|
|
18
|
+
const DIRS = [['initiatives', 'initiative'], ['prd', 'prd'], ['done-tests', 'done-test'], ['okrs', 'goal'], ['briefs', 'brief']];
|
|
19
|
+
const BASES = ['planning', 'pmos/planning', 'pmos/state'];
|
|
20
|
+
const DOC_NAME = /(readme|vision|strategy|brief|product|overview|about)/i;
|
|
21
|
+
|
|
22
|
+
const posix = (p) => p.split(path.sep).join('/');
|
|
23
|
+
const inside = (root, f) => { const a = path.resolve(f); return a.startsWith(root + path.sep); };
|
|
24
|
+
|
|
25
|
+
function head(f) {
|
|
26
|
+
let text = '';
|
|
27
|
+
try { const fd = fs.openSync(f, 'r'); const b = Buffer.alloc(4096); const n = fs.readSync(fd, b, 0, 4096, 0); fs.closeSync(fd); text = b.slice(0, n).toString('utf8'); } catch { return ''; }
|
|
28
|
+
const m = /^---\s*\n([\s\S]*?)\n---/.exec(text);
|
|
29
|
+
const t = m && /^title:\s*(.+)$/m.exec(m[1]);
|
|
30
|
+
if (t) return t[1].trim().replace(/^["']|["']$/g, '');
|
|
31
|
+
const h = /^#\s+(.+)$/m.exec(text);
|
|
32
|
+
return h ? h[1].trim() : '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function mdIn(dir) {
|
|
36
|
+
try { return fs.readdirSync(dir, { withFileTypes: true }).filter((d) => d.isFile() && d.name.endsWith('.md') && !['index.md', 'log.md'].includes(d.name)).map((d) => path.join(dir, d.name)); } catch { return []; }
|
|
37
|
+
}
|
|
38
|
+
const newest = (files) => files.map((f) => { let t = 0; try { t = fs.statSync(f).mtimeMs; } catch { /* gone */ } return [f, t]; }).sort((a, b) => b[1] - a[1]).map((x) => x[0]);
|
|
39
|
+
|
|
40
|
+
function sourcesOf(root) {
|
|
41
|
+
root = path.resolve(String(root || ''));
|
|
42
|
+
const out = [], seen = new Set();
|
|
43
|
+
const push = (f, kind) => {
|
|
44
|
+
const ref = posix(path.relative(root, f));
|
|
45
|
+
if (seen.has(ref) || !inside(root, f)) return;
|
|
46
|
+
seen.add(ref);
|
|
47
|
+
out.push({ ref, kind, title: head(f) || path.basename(f, '.md') });
|
|
48
|
+
};
|
|
49
|
+
for (const [sub, kind] of DIRS) {
|
|
50
|
+
const files = [];
|
|
51
|
+
for (const b of BASES) files.push(...mdIn(path.join(root, b, sub)));
|
|
52
|
+
for (const f of newest(files).slice(0, PER_KIND)) push(f, kind);
|
|
53
|
+
}
|
|
54
|
+
const docs = [...mdIn(root), ...mdIn(path.join(root, 'docs'))].filter((f) => DOC_NAME.test(path.basename(f)));
|
|
55
|
+
for (const f of newest(docs).slice(0, PER_KIND)) push(f, 'doc');
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function checkRef(root, ref) {
|
|
60
|
+
const r = String(ref || '').trim();
|
|
61
|
+
if (KEY.test(r)) return true;
|
|
62
|
+
if (!r || path.isAbsolute(r) || SKIP.test(r)) return false;
|
|
63
|
+
root = path.resolve(String(root || ''));
|
|
64
|
+
const f = path.resolve(root, r);
|
|
65
|
+
if (!inside(root, f)) return false;
|
|
66
|
+
try { return fs.statSync(f).isFile(); } catch { return false; }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function titleOf(root, ref) {
|
|
70
|
+
const r = String(ref || '').trim();
|
|
71
|
+
if (KEY.test(r)) return r;
|
|
72
|
+
if (!checkRef(root, r)) return r;
|
|
73
|
+
return head(path.resolve(String(root || ''), r)) || path.basename(r).replace(/\.md$/, '');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { PER_KIND, sourcesOf, checkRef, titleOf };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.776.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.776.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -239,3 +239,31 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
|
|
|
239
239
|
.sbo-mq { grid-column: 1 / -1; white-space: normal; }
|
|
240
240
|
.sbo-two { grid-template-columns: 1fr; }
|
|
241
241
|
}
|
|
242
|
+
|
|
243
|
+
/* the Line tab (pm/line-view.js, board QuietLine): one Komorebi table (.pm-table) grouped by workflow, then by its stations.
|
|
244
|
+
* Komorebi tokens only. Every class starts with ln-. */
|
|
245
|
+
.pm-ds section.ln { padding: 0; gap: 0; }
|
|
246
|
+
.pm-ds section.ln .ln-say { margin: 0; padding: var(--space-16) var(--space-16) var(--space-8); font-size: var(--fs-row); color: var(--ink); }
|
|
247
|
+
.pm-ds section.ln .ln-tabs { align-self: flex-start; margin: 0 var(--space-16) var(--space-12); }
|
|
248
|
+
.pm-ds section.ln .ln-wrap { overflow-x: auto; }
|
|
249
|
+
.pm-ds .ln-t { table-layout: fixed; font-size: var(--fs-row); }
|
|
250
|
+
.pm-ds .ln-t thead th { font-size: var(--fs-meta); padding: var(--space-8) var(--space-12); }
|
|
251
|
+
.pm-ds .ln-t thead th:first-child, .pm-ds .ln-t .ln-r > :first-child { padding-left: var(--space-16); }
|
|
252
|
+
.pm-ds .ln-t .ln-c-ini { width: 34%; }
|
|
253
|
+
.pm-ds .ln-t .ln-c-days { width: 150px; }
|
|
254
|
+
.pm-ds .ln-t .ln-c-st { width: 128px; }
|
|
255
|
+
.pm-ds .ln-t .ln-r > th, .pm-ds .ln-t .ln-r > td { padding: 10px var(--space-12); vertical-align: top; text-align: left; font-weight: inherit; }
|
|
256
|
+
.pm-ds .ln-t .ln-g th { padding: 6px var(--space-16); background: var(--well); color: var(--muted); font-size: var(--fs-meta); font-weight: var(--fw-strong); text-align: left; border-bottom: 1px solid var(--line); }
|
|
257
|
+
.pm-ds .ln-t .ln-g .ln-n { font-weight: var(--fw-regular); margin-left: 4px; }
|
|
258
|
+
.pm-ds .ln-t .ln-wf th { padding: var(--space-12) var(--space-16) 6px; color: var(--ink); font-size: var(--fs-row); font-weight: var(--fw-strong); text-align: left; border-bottom: 1px solid var(--line); }
|
|
259
|
+
.pm-ds .ln-t .ln-wf .pm-meta { font-weight: var(--fw-regular); margin-left: 4px; }
|
|
260
|
+
.pm-ds .ln-name { all: unset; cursor: pointer; font-weight: var(--fw-strong); color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
|
|
261
|
+
.pm-ds .ln-name:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
|
|
262
|
+
.pm-ds .ln-name:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
|
|
263
|
+
.pm-ds .ln-c-days .ln-d { display: block; color: var(--ink); white-space: nowrap; }
|
|
264
|
+
.pm-ds .ln-c-days .ln-sub { display: block; font-size: var(--fs-meta); line-height: 18px; color: var(--muted); }
|
|
265
|
+
.pm-ds .ln-c-days.ln-over .ln-d, .pm-ds .ln-c-days.ln-over .ln-sub { color: var(--alert); }
|
|
266
|
+
.pm-ds .ln-c-days.ln-over .ln-d { font-weight: var(--fw-strong); }
|
|
267
|
+
.pm-ds .ln-c-fin { color: var(--ink); line-height: 1.4; }
|
|
268
|
+
.pm-ds .ln-t .pm-badge.ln-ok { background: var(--leaf-tint); color: var(--leaf); }
|
|
269
|
+
.pm-ds .ln-t .pm-badge.ln-late { background: none; box-shadow: inset 0 0 0 1px var(--alert); color: var(--alert); }
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Built only from Komorebi parts: a Detail block (pm-block, its head with icon buttons, pm-field), pm-input to edit in place, pm-fold and
|
|
6
6
|
* pm-li for the notes. It reads and writes GET and POST /api/strategy-card (lib/routes-strategy-card.js) and nothing else.
|
|
7
|
-
* · Not written: one quiet line, "Strategy · not written yet", and the pencil.
|
|
7
|
+
* · Not written: one quiet line, "Strategy · not written yet", the ✦ that has PMOS draft it (bdStratDraft) and the pencil. While PMOS
|
|
8
|
+
* drafts (initiative strategy-draft: it starts by itself on a product with no strategy), "drafting from this product's files…".
|
|
9
|
+
* · A line PMOS drafted shows ✦ and, under it, the files it came from. One Undo in the head (bdStratUndo) takes every drafted line back;
|
|
10
|
+
* editing a line makes it the PM's. The inputs carry neutral hints, never an example product's strategy.
|
|
8
11
|
* · Written: the five lines. Once all five are written, new work that does not fit folds under one line, "2 don't fit", that opens
|
|
9
12
|
* them, each with why. A note informs only; nothing is moved or blocked. No note, no line (zero is silence).
|
|
10
13
|
* · The pencil turns the lines into inputs; the tick (or Enter) saves, Esc puts them back. A save offers Undo in the Board's toast.
|
|
@@ -17,10 +20,10 @@ import * as POS from './bd-positioning.js';
|
|
|
17
20
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
18
21
|
const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
19
22
|
const I = { compass: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M15.5 8.5l-2 5-5 2 2-5z', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', ok: 'M5 12l5 5 9-10',
|
|
20
|
-
x: 'M6 6l12 12M18 6L6 18', chev: 'M7 10l5 5 5-5' };
|
|
23
|
+
x: 'M6 6l12 12M18 6L6 18', chev: 'M7 10l5 5 5-5', spark: 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3' };
|
|
21
24
|
export const FIELDS = ['for', 'problem', 'bet', 'win', 'wont'];
|
|
22
25
|
const LABELS = { for: 'Who it is for', problem: 'The problem', bet: 'The bet', win: 'How we win', wont: "What we won't do" };
|
|
23
|
-
const HINT = { for: '
|
|
26
|
+
const HINT = { for: 'The people this product serves', problem: 'What they struggle with today', bet: 'What the product does about it', win: 'Why it wins over other ways', wont: 'What it leaves out on purpose' };
|
|
24
27
|
|
|
25
28
|
/** The fold's words: "1 doesn't fit", "3 don't fit". */
|
|
26
29
|
export const fitsLine = (n) => n + (n === 1 ? " doesn't fit" : " don't fit");
|
|
@@ -35,14 +38,20 @@ export function cardHtml(state) {
|
|
|
35
38
|
const rows = FIELDS.map((k) => `<dt><label for="bdStrat-${k}">${esc(LABELS[k])}</label></dt><dd><input class="pm-input" id="bdStrat-${k}" data-strat="${k}" maxlength="160" value="${esc(card && card[k])}" placeholder="${esc(HINT[k])}" /></dd>`).join('');
|
|
36
39
|
return `<section class="pm-block" aria-label="Strategy">${head('Strategy', '', btn('bdStratCancel', I.x, 'Cancel (Esc)', 'outline') + btn('bdStratSave', I.ok, 'Save the strategy', 'primary'))}<dl class="pm-field" style="margin:0">${rows}</dl></section>`;
|
|
37
40
|
}
|
|
38
|
-
if (isEmpty(card))
|
|
39
|
-
|
|
41
|
+
if (isEmpty(card)) {
|
|
42
|
+
if (state.drafting) return `<section class="pm-block flat" aria-label="Strategy">${head('Strategy', "drafting from this product's files…", '')}</section>`;
|
|
43
|
+
return `<section class="pm-block flat" aria-label="Strategy">${head('Strategy', 'not written yet', btn('bdStratDraft', I.spark, "Draft the strategy from this product's files") + btn('bdStratEdit', I.pen, 'Write the strategy in five lines'))}</section>`;
|
|
44
|
+
}
|
|
45
|
+
const drafted = (card && card.drafted) || {}, src = state.sources || {};
|
|
46
|
+
const from = (k) => (src[k] && src[k].length ? `<span class="pm-meta" style="display:block">From ${src[k].map((x) => esc(x.title)).join(' · ')}</span>` : '');
|
|
47
|
+
const rows = FIELDS.map((k) => `<dt>${esc(LABELS[k])}</dt><dd${drafted[k] ? ' data-drafted="1"' : ''}>${String(card[k] || '').trim() ? (drafted[k] ? `<span aria-label="Drafted by PMOS" title="Drafted by PMOS">✦</span> ` : '') + esc(card[k]) + (drafted[k] ? from(k) : '') : '<span class="pm-meta">Not written</span>'}</dd>`).join('');
|
|
48
|
+
const undo = Object.keys(drafted).length ? btn('bdStratUndo', I.undo, "Undo PMOS's draft", 'outline') : '';
|
|
40
49
|
const n = Array.isArray(notes) ? notes.length : 0;
|
|
41
50
|
const fold = n ? `<button type="button" class="pm-fold" id="bdStratFits" aria-expanded="${!!open}">${SV(I.chev)}${esc(fitsLine(n))}</button>`
|
|
42
51
|
+ (open ? `<div role="list">${notes.map((x) => `<div class="pm-li" role="listitem" data-ini="${esc(x.id)}"><span class="txt"><span class="t">${esc(x.title)}</span><span class="w">Doesn't fit the strategy because it ${esc(x.why)}</span></span></div>`).join('')}</div>` : '')
|
|
43
52
|
: '';
|
|
44
53
|
const pos = state.complete ? '<div id="bdPos" hidden></div>' : '';
|
|
45
|
-
return `<section class="pm-block" aria-label="Strategy">${head('Strategy', '', btn('bdStratEdit', I.pen, 'Edit the strategy'))}<dl class="pm-field" style="margin:0">${rows}</dl>${fold}${pos}</section>`;
|
|
54
|
+
return `<section class="pm-block" aria-label="Strategy">${head('Strategy', '', undo + btn('bdStratEdit', I.pen, 'Edit the strategy'))}<dl class="pm-field" style="margin:0">${rows}</dl>${fold}${pos}</section>`;
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
/** Draw the card again after a read of the Board, unless the PM is writing in it. */
|
|
@@ -61,7 +70,12 @@ export async function mount(host, opts = {}) {
|
|
|
61
70
|
const q = (ws ? '?ws=' + encodeURIComponent(ws) : '?') + (board ? (ws ? '&' : '') + 'board=' + encodeURIComponent(board) : '');
|
|
62
71
|
let r = null; try { r = await (await fetch('/api/strategy-card' + q, { credentials: 'same-origin' })).json(); } catch { r = null; }
|
|
63
72
|
if (!r || !r.ok) { host.hidden = true; return; } // the card is an extra: a failed read leaves the Board as it was
|
|
64
|
-
const S = { card: r.card, complete: r.complete, notes: r.notes, editing: false, open: host.dataset.open === '1' };
|
|
73
|
+
const S = { card: r.card, complete: r.complete, notes: r.notes, sources: r.sources || {}, drafting: !!r.drafting, editing: false, open: host.dataset.open === '1' };
|
|
74
|
+
// while PMOS drafts, read again now and then until the lines land (at most ~5 minutes)
|
|
75
|
+
clearTimeout(host._stratPoll);
|
|
76
|
+
const tries = Number(host.dataset.polls || 0);
|
|
77
|
+
if (S.drafting && isEmpty(S.card) && tries < 60) { host.dataset.polls = String(tries + 1); host._stratPoll = setTimeout(() => { if (host.isConnected) refresh(host, opts); }, 5000); }
|
|
78
|
+
else host.dataset.polls = '';
|
|
65
79
|
const draw = () => {
|
|
66
80
|
host.hidden = false; host.innerHTML = cardHtml(S);
|
|
67
81
|
if (S.editing) { const f = host.querySelector('[data-strat]'); if (f) f.focus(); }
|
|
@@ -81,6 +95,20 @@ export async function mount(host, opts = {}) {
|
|
|
81
95
|
if (b.id === 'bdStratEdit') { S.editing = true; draw(); }
|
|
82
96
|
else if (b.id === 'bdStratCancel') { S.editing = false; draw(); }
|
|
83
97
|
else if (b.id === 'bdStratSave') save();
|
|
98
|
+
else if (b.id === 'bdStratDraft') {
|
|
99
|
+
S.drafting = true; draw();
|
|
100
|
+
pmPost('/api/strategy-card/draft', { ws }).then((x) => {
|
|
101
|
+
if (!x || !x.ok || !x.drafting) { S.drafting = false; draw(); if (say) say((x && (x.error || x.why)) ? "PMOS could not draft: " + (x.error || x.why) + '.' : 'PMOS could not draft the strategy.'); return; }
|
|
102
|
+
host.dataset.polls = ''; mount(host, opts);
|
|
103
|
+
}).catch(() => { S.drafting = false; draw(); });
|
|
104
|
+
}
|
|
105
|
+
else if (b.id === 'bdStratUndo') {
|
|
106
|
+
pmPost('/api/strategy-card', { ws, undo: true }).then((x) => {
|
|
107
|
+
if (!x || !x.ok) { if (say) say((x && x.error) || 'The draft was not taken back.'); return; }
|
|
108
|
+
if (say) say("PMOS's draft taken back.");
|
|
109
|
+
mount(host, opts);
|
|
110
|
+
}).catch(() => null);
|
|
111
|
+
}
|
|
84
112
|
else if (b.id === 'bdStratFits') { S.open = !S.open; host.dataset.open = S.open ? '1' : ''; draw(); }
|
|
85
113
|
};
|
|
86
114
|
host.onkeydown = (e) => {
|
|
@@ -7,64 +7,105 @@
|
|
|
7
7
|
* dashHtml(D) → the dashed line, a link to /premium-board.html?work=line
|
|
8
8
|
*
|
|
9
9
|
* rows: lib/line.js lineOf rows (GET /api/line), each with its product (ws). you: Set of '<ws>|<initiative>' that have a Your move row (a question
|
|
10
|
-
* to the PM, a check due). A row in Your move is marked "
|
|
11
|
-
* reads moving. "Can't tell" never moves an item and never raises a row. The UI says PMOS. Text from records goes through esc(). */
|
|
10
|
+
* to the PM, a check due). A row in Your move is marked "waits on you" here and not repeated on Today. Waiting (capacity, on hold, another initiative) is never
|
|
11
|
+
* stuck and reads "waiting"; a moving row past its stage's expected days reads "over time". "Can't tell" never moves an item and never raises a row. The UI says PMOS. Text from records goes through esc(). */
|
|
12
12
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
13
13
|
const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
|
|
14
14
|
const cap1 = (s) => String(s || '').replace(/^[a-z]/, (c) => c.toUpperCase());
|
|
15
15
|
|
|
16
|
-
export const TABS = [['', 'All', 'all'], ['stuck', 'Stuck', 'stuck'], ['
|
|
17
|
-
|
|
16
|
+
export const TABS = [['', 'All', 'all'], ['stuck', 'Stuck', 'stuck'], ['late', 'Over time', 'late'], ['you', 'Waits on you', 'you'], ['waiting', 'Waiting', 'waiting'], ['cant', 'Can’t tell', 'cant']];
|
|
17
|
+
// state → [word, badge class]. Only stuck is the alert; over time is a warning in the days cell, its badge stays quiet.
|
|
18
|
+
const STATE = { you: ['waits on you', 'blue'], stuck: ['stuck', 'alert'], late: ['over time', 'ln-late'], waiting: ['waiting', ''], cant: ['can’t tell', ''], moving: ['moving', 'ln-ok'] };
|
|
19
|
+
const numLimit = (r) => (typeof r.limit === 'number' && r.limit > 0 ? r.limit : null);
|
|
18
20
|
|
|
19
|
-
/** One row's state:
|
|
21
|
+
/** One row's real state: waits on you first, then stuck, can't tell, waiting (capacity, on hold, another initiative), over time (moving,
|
|
22
|
+
* but past its station's expected days), moving. */
|
|
20
23
|
export function stateOf(r, you) {
|
|
21
24
|
if (you && you.has((r.ws || '') + '|' + r.id)) return 'you';
|
|
22
25
|
if (r.flag === 'stuck') return 'stuck';
|
|
23
26
|
if (r.flag === 'cant-tell') return 'cant';
|
|
27
|
+
if (r.flag === 'waiting') return 'waiting';
|
|
28
|
+
const lim = numLimit(r);
|
|
29
|
+
if (lim != null && r.daysThere != null && r.daysThere > lim) return 'late';
|
|
24
30
|
return 'moving';
|
|
25
31
|
}
|
|
26
|
-
/** Days
|
|
27
|
-
export function
|
|
28
|
-
if (r.daysThere == null) return r.quietDays != null ? 'quiet ' + plural(r.quietDays, 'day', 'days') : '';
|
|
29
|
-
|
|
32
|
+
/** Days in the stage against the stage's expected days. → { text, sub, over } ('' text when no record says). */
|
|
33
|
+
export function daysOf(r) {
|
|
34
|
+
if (r.daysThere == null) return { text: r.quietDays != null ? 'quiet ' + plural(r.quietDays, 'day', 'days') : '', sub: '', over: 0 };
|
|
35
|
+
const text = plural(r.daysThere, 'day', 'days');
|
|
36
|
+
const lim = numLimit(r);
|
|
37
|
+
if (lim != null) {
|
|
38
|
+
const over = Math.max(0, r.daysThere - lim);
|
|
39
|
+
return { text, sub: over ? `expected ${lim} · ${over} over` : `expected ${lim}`, over };
|
|
40
|
+
}
|
|
41
|
+
return { text, sub: typeof r.limit === 'string' && r.limit ? 'moves with its tickets' : '', over: 0 };
|
|
42
|
+
}
|
|
43
|
+
/** The short form, for a line of text: "28 days, expected 15 · 13 over". */
|
|
44
|
+
export function daysWord(r) { const d = daysOf(r); return d.text + (d.text && d.sub ? ', ' + d.sub : ''); }
|
|
45
|
+
/** What finishes it: the missing exit items, or the next move when it is not "finish: <the first missing item>" (said once). */
|
|
46
|
+
export function toFinish(r) {
|
|
47
|
+
const miss = (r.missing || []).filter(Boolean);
|
|
48
|
+
const next = String(r.next || '');
|
|
49
|
+
if (next && !/^finish:/i.test(next)) return cap1(next);
|
|
50
|
+
return miss.length ? miss.join(' · ') : cap1(next.replace(/^finish:\s*/i, ''));
|
|
30
51
|
}
|
|
31
52
|
export function lineModel(rows, o = {}) {
|
|
32
53
|
const you = o.you instanceof Set ? o.you : new Set(o.you || []);
|
|
33
54
|
const live = (rows || []).filter((r) => r && r.id && r.live);
|
|
34
55
|
const all = live.map((r) => ({ ...r, state: stateOf(r, you) }));
|
|
35
|
-
const counts = { all: all.length
|
|
56
|
+
const counts = { all: all.length };
|
|
57
|
+
for (const k of ['stuck', 'late', 'you', 'waiting', 'cant']) counts[k] = all.filter((r) => r.state === k).length;
|
|
36
58
|
const tab = TABS.some(([k]) => k === o.tab) && (o.tab === '' || counts[o.tab]) ? o.tab : '';
|
|
37
59
|
const shown = tab ? all.filter((r) => r.state === tab) : all;
|
|
38
|
-
|
|
60
|
+
// grouped by workflow, then by its stations in order: Discover (one workflow) and Discovery (another) never share a group
|
|
61
|
+
const wfs = new Map();
|
|
39
62
|
for (const r of shown) {
|
|
63
|
+
const wn = r.workflow || 'No workflow';
|
|
64
|
+
if (!wfs.has(wn)) wfs.set(wn, new Map());
|
|
40
65
|
const st = r.station || { key: '', name: 'No station', n: 999 };
|
|
41
|
-
const
|
|
42
|
-
|
|
66
|
+
const n = st.n == null ? 999 : st.n;
|
|
67
|
+
const k = n + '|' + String(st.name || '').toLowerCase();
|
|
68
|
+
const by = wfs.get(wn);
|
|
69
|
+
if (!by.has(k)) by.set(k, { key: wn + '|' + k, name: st.name || 'No station', n, rows: [] });
|
|
43
70
|
by.get(k).rows.push(r);
|
|
44
71
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
const workflows = [...wfs.entries()].map(([name, by]) => {
|
|
73
|
+
const groups = [...by.values()].sort((a, b) => a.n - b.n || a.name.localeCompare(b.name));
|
|
74
|
+
for (const g of groups) g.rows.sort((a, b) => String(a.title).localeCompare(String(b.title)));
|
|
75
|
+
return { name, n: groups.reduce((s, g) => s + g.rows.length, 0), groups };
|
|
76
|
+
}).sort((a, b) => (a.name === 'No workflow') - (b.name === 'No workflow') || b.n - a.n || a.name.localeCompare(b.name));
|
|
77
|
+
const groups = workflows.flatMap((w) => w.groups);
|
|
78
|
+
return { workflows, groups, counts, tab, live: all.length };
|
|
48
79
|
}
|
|
49
|
-
/** The Line block. M: lineModel(). o: { name: the product's name, say: a line above the table
|
|
80
|
+
/** The Line block: one Komorebi table (pm-table). M: lineModel(). o: { name: the product's name, say: a line above the table } */
|
|
50
81
|
export function lineHtml(M, o = {}) {
|
|
51
82
|
if (!M || !M.live) return `<section class="pm-block ln" aria-label="The line"><p class="pm-meta">No initiative is on a workflow yet, so the line is empty.</p></section>`;
|
|
52
83
|
const tabs = TABS.filter(([k, , c]) => k === '' || M.counts[c]).map(([k, n, c]) => `<button type="button" class="pm-tab${M.tab === k ? ' on' : ''}" role="tab" aria-selected="${M.tab === k}" data-line-tab="${k}">${esc(n)} <span class="pm-meta">${M.counts[c]}</span></button>`).join('');
|
|
53
|
-
const head = `<
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
const head = `<thead><tr><th scope="col" class="ln-c-ini">Initiative</th><th scope="col" class="ln-c-days">Days in stage</th><th scope="col">To finish the stage</th><th scope="col" class="ln-c-st">State</th></tr></thead>`;
|
|
85
|
+
const many = (M.workflows || []).length > 1;
|
|
86
|
+
const row = (r) => {
|
|
87
|
+
const d = daysOf(r), [word, cls] = STATE[r.state];
|
|
88
|
+
return `<tr class="ln-r ln-${r.state}"><th scope="row" class="ln-c-ini"><button type="button" class="ln-name" data-line-ini="${esc(r.id)}" data-line-ws="${esc(r.ws || '')}">${esc(r.title || r.id)}</button></th>`
|
|
89
|
+
+ `<td class="ln-c-days${d.over && (r.state === 'late' || r.state === 'stuck') ? ' ln-over' : ''}">${d.text ? `<span class="ln-d">${esc(d.text)}</span>` : ''}${d.sub ? `<span class="ln-sub">${esc(d.sub)}</span>` : ''}</td>`
|
|
90
|
+
+ `<td class="ln-c-fin">${esc(toFinish(r))}</td>`
|
|
91
|
+
+ `<td class="ln-c-st"><span class="pm-badge${cls ? ' ' + cls : ''}" title="${esc(r.why || '')}">${esc(word)}</span></td></tr>`;
|
|
92
|
+
};
|
|
93
|
+
const body = (M.workflows || [{ name: '', groups: M.groups }]).map((w) => `<tbody>`
|
|
94
|
+
+ (many ? `<tr class="ln-wf"><th scope="colgroup" colspan="4">${esc(w.name)} <span class="pm-meta">${w.n}</span></th></tr>` : '')
|
|
95
|
+
+ w.groups.map((g) => `<tr class="ln-g"><th scope="colgroup" colspan="4">${esc(g.name)} <span class="ln-n">${g.rows.length}</span></th></tr>` + g.rows.map(row).join('')).join('')
|
|
96
|
+
+ `</tbody>`).join('');
|
|
97
|
+
return `<section class="pm-block list ln" aria-label="The line">${o.say ? `<p class="ln-say">${esc(o.say)}</p>` : ''}<div class="pm-tabs ln-tabs" role="tablist" aria-label="Show">${tabs}</div>`
|
|
98
|
+
+ `<div class="ln-wrap"><table class="pm-table ln-t" aria-label="${esc((o.name ? o.name + ': ' : '') + 'initiatives by workflow stage')}">${head}${body}</table></div></section>`;
|
|
60
99
|
}
|
|
61
100
|
/** Where it stands, one sentence over the table. */
|
|
62
101
|
export function sayOf(M) {
|
|
63
102
|
if (!M || !M.live) return '';
|
|
64
|
-
const moving = M.live -
|
|
103
|
+
const c = M.counts, moving = M.live - c.you - c.stuck - c.cant - (c.late || 0) - (c.waiting || 0);
|
|
65
104
|
return [plural(M.live, 'initiative', 'initiatives') + ' on the line.', moving ? moving + (moving === 1 ? ' moves by itself.' : ' move by themselves.') : '',
|
|
66
|
-
|
|
67
|
-
|
|
105
|
+
c.late ? c.late + ' still moving but over ' + (c.late === 1 ? 'its' : 'their') + ' stage’s expected days.' : '',
|
|
106
|
+
c.you ? c.you + ' wait' + (c.you === 1 ? 's' : '') + ' on you, already in Your move.' : '',
|
|
107
|
+
c.stuck ? c.stuck + ' stuck.' : '', c.waiting ? c.waiting + ' waiting on capacity or another initiative.' : '',
|
|
108
|
+
c.cant ? c.cant + ' can’t be placed, so PMOS leaves ' + (c.cant === 1 ? 'it' : 'them') + ' alone.' : ''].filter(Boolean).join(' ');
|
|
68
109
|
}
|
|
69
110
|
/** Today's dashed line. lines: [{ ws, rows, you: [initiative id] }]. null when nothing is on the line (zero is silence). */
|
|
70
111
|
export function dashModel(lines) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: strategy-draft
|
|
3
|
+
label: "Draft the product's five-line strategy (once, from its own files)"
|
|
4
|
+
description: "Draft the five strategy lines of this product (who it is for, the problem, the bet, how we win, what we won't do) from its own initiatives, PRDs, goals and docs, each line citing the files it came from. The lines show at once on the Strategy card, where the PM edits or undoes them."
|
|
5
|
+
run: agent
|
|
6
|
+
agent: claude
|
|
7
|
+
output:
|
|
8
|
+
- Strategy
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
/strategy-draft — draft the FIVE-LINE STRATEGY of THIS product from its own files. Each line is short, plain and true to what the product's files already say. The PM edits or undoes each line on the Strategy card. Work only from what you can read here.
|
|
12
|
+
|
|
13
|
+
The five lines and their keys:
|
|
14
|
+
- `for` — Who it is for: the people the product serves, as its files name them.
|
|
15
|
+
- `problem` — The problem: what those people struggle with, that the product exists to fix.
|
|
16
|
+
- `bet` — The bet: what the product does about it, the one idea it stakes on.
|
|
17
|
+
- `win` — How we win: why this product wins over the other ways people solve the problem.
|
|
18
|
+
- `wont` — What we won't do: what the product leaves out on purpose, as its files show (out-of-scope lists, non-goals, parked or killed work).
|
|
19
|
+
|
|
20
|
+
Rules that always hold:
|
|
21
|
+
1. ONE KIND OF WRITE. Your only write is `pmos strategy draft` (step 3), once per line. Write no file. Send, post or share nothing.
|
|
22
|
+
2. CITED. Every line cites 1 to 5 sources it came from: file paths that `pmos strategy sources` lists (or another file of this product), or a tracker key (ABC-123). Cite the files that say it, not the files near it.
|
|
23
|
+
3. NOTHING INVENTED. Never invent customers, numbers, dates, competitors or features the files do not name. If the files do not show a line, leave that line blank: four true lines are correct, five guessed ones are not.
|
|
24
|
+
4. SHORT. One line each, at most 160 characters, in the product's own words. No marketing tone.
|
|
25
|
+
5. NEVER OVER THE PM. `pmos strategy draft` refuses a line that is already written. Leave it.
|
|
26
|
+
|
|
27
|
+
Procedure:
|
|
28
|
+
1. Run `pmos strategy show` for the lines already written, and `pmos strategy sources` for the product's files you may cite.
|
|
29
|
+
2. Read the files that tell you most: the product's README or brief, its goals (okrs), its PRDs and the intent of its newest initiatives. Look for who it serves, the pain, the bet, the edge and the deliberate limits.
|
|
30
|
+
3. For each blank line you can support, run once: `pmos strategy draft --line <key> --text "<the line>" --source <ref> [--source <ref>]`. A refused draft says why: fix it or leave the line out.
|
|
31
|
+
4. End with one line: which lines you drafted, and which you left blank and why.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "PMOS drafts each product's five-line strategy from its own files (initiative strategy-draft, done test planning/done-tests/strategy-draft.md C1-C8). Pure checks, the CLI and the routes in process, with a stubbed seed. No connector, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"strategy-draft.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"strategy-draft.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|