create-pmos 0.672.0 → 0.675.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 +28 -28
- 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 +27 -2
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/cli.md +13 -1
- package/workspace/guide/jira.md +3 -1
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/critic-cli.js +99 -0
- package/workspace/lib/design-critic.js +6 -5
- package/workspace/lib/jira-cli.js +7 -7
- package/workspace/lib/jira-tickets.js +3 -3
- package/workspace/lib/metric-drafts.js +1 -0
- package/workspace/lib/metric-read-runs.js +23 -2
- package/workspace/lib/metric-source.js +86 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-spec-critic.js +80 -0
- package/workspace/lib/spec-critic.js +241 -0
- package/workspace/lib/ticket-dry-run.js +29 -10
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/skills/initiative-drive.skill +2 -2
- package/workspace/skills/metric-draft.skill +3 -2
- package/workspace/test-lists/metric-source.json +9 -0
- package/workspace/test-lists/spec-critic.json +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.675.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -34,8 +34,21 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-22T05:
|
|
37
|
+
"v": "0.675.0",
|
|
38
|
+
"at": "2026-11-22T05:53:46.914Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1460,
|
|
43
|
+
"t": "Read one goal metric per product from the query its source names",
|
|
44
|
+
"s": "Read one goal metric per product from the query its source names",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.674.0",
|
|
51
|
+
"at": "2026-11-22T05:18:00.036Z",
|
|
39
52
|
"f": 4,
|
|
40
53
|
"prs": [
|
|
41
54
|
{
|
|
@@ -55,6 +68,18 @@
|
|
|
55
68
|
"t": "Default decisions with a deadline, and the cost of waiting",
|
|
56
69
|
"s": "Default decisions with a deadline, and the cost of waiting",
|
|
57
70
|
"k": "new"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"n": 1461,
|
|
74
|
+
"t": "Every dry-run question carries a default answer, and the PM can keep it",
|
|
75
|
+
"s": "Every dry-run question carries a default answer, and the PM can keep it",
|
|
76
|
+
"k": "new"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"n": 1462,
|
|
80
|
+
"t": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
|
|
81
|
+
"s": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
|
|
82
|
+
"k": "new"
|
|
58
83
|
}
|
|
59
84
|
]
|
|
60
85
|
},
|
|
@@ -339,31 +364,6 @@
|
|
|
339
364
|
"k": "new"
|
|
340
365
|
}
|
|
341
366
|
]
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
"v": "0.642.0",
|
|
345
|
-
"at": "2026-11-20T01:43:00.385Z",
|
|
346
|
-
"f": 4,
|
|
347
|
-
"prs": [
|
|
348
|
-
{
|
|
349
|
-
"n": 1423,
|
|
350
|
-
"t": "Welcome, capture and the meeting pages on the PMOS design system",
|
|
351
|
-
"s": "Welcome, capture and the meeting pages on the PMOS design system",
|
|
352
|
-
"k": "new"
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
"n": 1420,
|
|
356
|
-
"t": "The rail of places is the design system's Navigation part",
|
|
357
|
-
"s": "The rail of places is the design system's Navigation part",
|
|
358
|
-
"k": "new"
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
"n": 1421,
|
|
362
|
-
"t": "Library, Present and the Viewer page on the PMOS design system",
|
|
363
|
-
"s": "Library, Present and the Viewer page on the PMOS design system",
|
|
364
|
-
"k": "new"
|
|
365
|
-
}
|
|
366
|
-
]
|
|
367
367
|
}
|
|
368
368
|
]
|
|
369
369
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:53:43Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:53:43Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-22T05:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T05:53:43Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-22T05:
|
|
3
|
+
"v": "0.675.0",
|
|
4
|
+
"at": "2026-11-22T05:53:46.914Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1460,
|
|
9
|
+
"t": "Read one goal metric per product from the query its source names",
|
|
10
|
+
"s": "Read one goal metric per product from the query its source names",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.674.0",
|
|
17
|
+
"at": "2026-11-22T05:18:00.036Z",
|
|
5
18
|
"f": 4,
|
|
6
19
|
"prs": [
|
|
7
20
|
{
|
|
@@ -21,6 +34,18 @@
|
|
|
21
34
|
"t": "Default decisions with a deadline, and the cost of waiting",
|
|
22
35
|
"s": "Default decisions with a deadline, and the cost of waiting",
|
|
23
36
|
"k": "new"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"n": 1461,
|
|
40
|
+
"t": "Every dry-run question carries a default answer, and the PM can keep it",
|
|
41
|
+
"s": "Every dry-run question carries a default answer, and the PM can keep it",
|
|
42
|
+
"k": "new"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"n": 1462,
|
|
46
|
+
"t": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
|
|
47
|
+
"s": "Before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask",
|
|
48
|
+
"k": "new"
|
|
24
49
|
}
|
|
25
50
|
]
|
|
26
51
|
},
|
|
@@ -237,6 +237,7 @@ What each part does:
|
|
|
237
237
|
- **What the canvas can do.** The prototype runs in a sandboxed frame. It cannot reach PMOS. The canvas talks to it only to show a screen, point, pin, play and apply your edits.
|
|
238
238
|
- **Your prototype rules.** After a version renders and before it opens, PMOS checks it against your prototype rules: no device or browser frame, no instructions on the screen, no sample copy, and each rule PMOS learns from your corrections. When a correction is true of every prototype (for example "no device frame"), the chat adds it as a rule (`pmos lab rule add`). PMOS keeps a rule only when it fails a bad example and passes a good one, so a button such as "See the week" is never read as an instruction. A change to one version ("make the alert orange") or a taste ("calmer") never becomes a rule. A version that breaks a rule gets one fix run, given only the lines that broke it. You see only the fixed version, with one quiet line: "PMOS fixed 3 things before showing you this." When the fix does not reach a rule, the version still opens and the line names the rule it breaks. When nothing was fixed, there is no line. Settings › Prototype rules lists the rules with Undo.
|
|
239
239
|
- **The design critic.** After the prototype rules, a separate read-only session reads the version's desk and phone screenshots and its page against every standing design rule of your product. Each rule is a named check: each numbered principle in your design principles and each rule in your `design-rules.json`. A finding must name the rule it breaks, so the critic reports broken rules, not taste. Its findings go into the same one fix run. After the fix it reads only those rules again, so "PMOS fixed n things" is never claimed unchecked. A critic that cannot run never holds the version. `pmos lab critic` runs it on any screenshots, and `PMOS_CRITIC=off` turns it off.
|
|
240
|
+
- **The sceptical reviewer.** Before you share a document, the chat's agent runs `pmos critic <file>`: a separate read-only session reads it as a sceptical reviewer and lists at most 3 hard questions. Each names its lens, quotes the document and gives the smallest fix; a question whose quote is not in the document is dropped. `pmos critic stats` shows how many you called real, and the gaps that repeat across documents.
|
|
240
241
|
- **No time limit.** A version takes as long as the ask needs. While PMOS makes it, the Viewer shows what it is doing now (for example "Building screen 3 of 7"), the steps done, a progress bar and the time so far, with a Stop press. A run that writes nothing for 10 minutes is stuck: PMOS stops it. A version that does not render, that is stuck or that you stop is "not made" with the reason, and the chat says so. The Viewer still opens it: it says why and shows the version it was made from. While a version is being made, a new ask on the same initiative waits: PMOS says what is running.
|
|
241
242
|
- **Lessons.** Each change sentence, ✓ and ✕ is a Lessons line of the experiment (`pmos artefacts show`). Each version that rendered is a Specimens line. The one you keep is the kept specimen.
|
|
242
243
|
- **The grill runs after the session, not during it.** When you keep a version, the grill runs once on the kept specimen, as the Review step. Its findings wait under the ✦ (D60 as amended on 2026-11-17).
|
package/workspace/guide/cli.md
CHANGED
|
@@ -184,6 +184,18 @@ PMOS's grill run files with these commands, which refuse outside that run:
|
|
|
184
184
|
- `pmos grill voices --sources <n>`: how many stored sources Voices can use.
|
|
185
185
|
- `pmos grill status`: what is open, kept and dropped.
|
|
186
186
|
|
|
187
|
+
### pmos critic: questions before you share a document
|
|
188
|
+
|
|
189
|
+
Before you share a spec, a strategy, a roadmap or a report, PMOS reads it as a sceptical reviewer would and lists the hardest questions that reviewer would ask. Each question names its lens (evidence, outcome, trade-off, scope, risk, owner, contradiction or unverified claim), quotes the words of the document it rests on, and gives the smallest fix. A question whose quote is not in the document is dropped. The chat's agent runs it when you say you are about to share a document. Nothing is sent and the document is not changed.
|
|
190
|
+
|
|
191
|
+
- `pmos critic <file> [--ws <id>]`: one pass on a markdown, text or HTML document. It prints at most 3 questions, the hardest first. The running PMOS server starts one read-only session.
|
|
192
|
+
- `pmos critic show <file> [--ws <id>]`: the newest pass on that file, and whether the file changed since.
|
|
193
|
+
- `pmos critic lenses [--root <dir>]`: the lenses. Add your product's own reviewer questions in `pmos/review-questions.json` (or `okf/products/<slug>/references/review-questions.json`): `{ "questions": [{ "id", "title", "rule" }] }`. An id that is a base lens replaces it. No server is needed.
|
|
194
|
+
- `pmos critic label <run> <n> real|noise`: your word on question `n` of a run.
|
|
195
|
+
- `pmos critic stats`: the runs, the questions, how many you called real or noise, how many were dropped for a quote not in the document, and the gaps that repeat across documents. When the same gap is in several documents, fix the template or the generator that makes them.
|
|
196
|
+
|
|
197
|
+
`PMOS_CRITIC=off` turns this critic and the design critic off.
|
|
198
|
+
|
|
187
199
|
### pmos ai: the AI jobs, their kill switch and audit
|
|
188
200
|
|
|
189
201
|
- `pmos ai status`: whether each AI job is on, whether its replay passed, and what its last run filed. It also shows the keep rate of each job that files under ✦ for the last 14 days, and each product.
|
|
@@ -621,7 +633,7 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
|
|
|
621
633
|
- `pmos jira moves`
|
|
622
634
|
- `pmos jira moved <move id> --status "<Jira status>"` or `--refused "<why>"`
|
|
623
635
|
- `pmos jira guesses <initiative> [--from <file|->]`
|
|
624
|
-
- `pmos jira answer <initiative> <ticket> <n> --text "<answer>"`
|
|
636
|
+
- `pmos jira answer <initiative> <ticket> <n> --text "<answer>"` or `--keep-default`
|
|
625
637
|
|
|
626
638
|
Every command takes `--json` and `--root <dir>`.
|
|
627
639
|
|
package/workspace/guide/jira.md
CHANGED
|
@@ -99,6 +99,7 @@ A ticket points to the PRD, but the builder holds only the ticket. Before you se
|
|
|
99
99
|
- PMOS keeps a quote only when it finds it word for word in the PRD, the done test or the initiative record. A quote it cannot find is dropped.
|
|
100
100
|
- The quoted lines go into the ticket's Additional Context, under **From the PRD (dry run)**. A ticket you edited, selected or pushed is not changed: your text wins.
|
|
101
101
|
- A guess that no document answers is a gap. The gaps go on your question list for the day, one card per initiative, beside the changes PMOS held and the outside sign-offs with no answer ([pmos signoff](cli.md)).
|
|
102
|
+
- Each question comes with a default: the answer a builder would assume, taken from the PRD line where there is one. The ticket says "Unless the PM says otherwise: <default>", and the list asks "<question>? Unless you say otherwise: <default>." To accept it, keep the default; to change it, type your answer.
|
|
102
103
|
- When you answer a gap, the answer goes into the ticket and the question leaves the list. When the PRD item of a ticket changes, its dry run is out of date and its gaps leave the list until the dry run runs again.
|
|
103
104
|
|
|
104
105
|
In the terminal:
|
|
@@ -107,9 +108,10 @@ In the terminal:
|
|
|
107
108
|
pmos jira guesses <initiative>
|
|
108
109
|
pmos jira guesses <initiative> --from guesses.json
|
|
109
110
|
pmos jira answer <initiative> <ticket> <n> --text "Fail closed: show the paywall"
|
|
111
|
+
pmos jira answer <initiative> <ticket> <n> --keep-default
|
|
110
112
|
```
|
|
111
113
|
|
|
112
|
-
The file has one entry for each ticket: `{"tickets": [{"id": "018", "guesses": [{"question": "If the flag lookup times out, is the article free or locked?", "prd": ["<a line quoted from the PRD>"], "answered": "yes|partly|no"}]}]}`.
|
|
114
|
+
The file has one entry for each ticket: `{"tickets": [{"id": "018", "guesses": [{"question": "If the flag lookup times out, is the article free or locked?", "prd": ["<a line quoted from the PRD>"], "answered": "yes|partly|no", "default": "<the answer a builder would assume>"}]}]}`.
|
|
113
115
|
|
|
114
116
|
## Choose the epic
|
|
115
117
|
|
|
@@ -112,7 +112,7 @@ An "off" switch accepts `off`, `0`, `false` or `no` unless the row says a differ
|
|
|
112
112
|
| `PMOS_HEADLESS` | `off` sends every background job back to a terminal pane. | on | — |
|
|
113
113
|
| `PMOS_AI` | `off` turns every AI job off (the kill switch of [what agents may do](agent-capabilities.md)). | on | `pmos ai off` (the `ai.on` setting) |
|
|
114
114
|
| `PMOS_AI_<JOB>` | `off` turns one AI job off. The names are `PMOS_AI_PAST_REPEAT`, `PMOS_AI_DECISION_MEMORY`, `PMOS_AI_OUTCOMES`, `PMOS_AI_DESCRIPTIONS`, `PMOS_AI_DRIFT`, `PMOS_AI_REHEARSE`, `PMOS_AI_NEXT_PROMPT`, `PMOS_AI_SHARPEN_PROMPT` and `PMOS_AI_IDLE_LAB`. | on | `pmos ai off <job>` (the `ai.off` setting) |
|
|
115
|
-
| `PMOS_CRITIC` | `off` stops the design critic: no critic reads a prototype version before it opens, and `pmos lab critic`
|
|
115
|
+
| `PMOS_CRITIC` | `off` stops the design critic and the sceptical reviewer: no critic reads a prototype version before it opens, and `pmos lab critic` and `pmos critic` refuse. The prototype rules still run. | on | — |
|
|
116
116
|
| `PMOS_AUTONOMY` | `off` stops every change PMOS applies by itself (D106) and every goal loop; proposals still wait for your ✓. | on | `pmos ai off` |
|
|
117
117
|
| `PMOS_BUILD_SANDBOX` | `docker` or `podman` runs `pmos build check` in a container with no network (the image is `check.image` in `pmos/factory.json`). Without it the check runs in the worktree, and only you can run it. | off | — |
|
|
118
118
|
| `PMOS_FACTORY_GH_TOKEN` | The factory's own GitHub token, when `pmos/factory.json` names it in `identity.token_env`. The name must start with `PMOS_FACTORY_`. PMOS gives it to gh for its own calls and removes it from every agent run. Never put it in a file. | not set: your gh login | — |
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* critic-cli.js — `pmos critic`: before you share a document, the hardest questions a sceptical reviewer would ask (initiative spec-critic;
|
|
3
|
+
* lib/spec-critic.js, POST and GET /api/spec-critic in lib/routes-spec-critic.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos critic <file> [--ws <id>] one pass through the running server: at most 3 questions, each with its lens, the quoted words and
|
|
6
|
+
* the smallest fix. The chat's agent runs it when the PM says they are about to share a document.
|
|
7
|
+
* pmos critic show <file> [--ws <id>] the newest pass on that file, and whether the file changed since (through the server)
|
|
8
|
+
* pmos critic lenses [--root <dir>] the lenses: the base set plus the product's review-questions.json (no server)
|
|
9
|
+
* pmos critic label <run> <n> real|noise the PM's word on question n of a run (no server)
|
|
10
|
+
* pmos critic stats runs, questions, real, noise, dropped for a missing quote, and the gaps that repeat across documents
|
|
11
|
+
*
|
|
12
|
+
* Nothing is sent and no document is changed. Exit codes: 0 done, 1 refused, 2 usage. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const SC = require('./spec-critic.js');
|
|
15
|
+
|
|
16
|
+
const COMMANDS = { critic: ['show', 'lenses', 'label', 'stats'] };
|
|
17
|
+
const USAGE = [
|
|
18
|
+
'usage: pmos critic <file> [--ws <id>] — before you share a document, the hardest questions a sceptical reviewer would ask',
|
|
19
|
+
' pmos critic <file> [--ws <id>] a markdown, text or HTML document: at most 3 questions, each quoting the document, with the smallest fix',
|
|
20
|
+
' pmos critic show <file> [--ws <id>] the newest pass on that file, and whether the file changed since',
|
|
21
|
+
' pmos critic lenses [--root <dir>] the lenses the critic asks through: the base set plus the product\'s review-questions.json',
|
|
22
|
+
' pmos critic label <run> <n> real|noise your word on question n of a run',
|
|
23
|
+
' pmos critic stats runs, questions, real, noise, and the gaps that repeat across documents',
|
|
24
|
+
'A question whose quote is not in the document is dropped. Nothing is sent. PMOS_CRITIC=off turns the critic off.',
|
|
25
|
+
];
|
|
26
|
+
const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
|
|
27
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
28
|
+
const plural = (n, w) => `${n} ${w}${n === 1 ? '' : 's'}`;
|
|
29
|
+
const fileArg = (args, from) => { for (let i = from; i < args.length; i++) { if (args[i] === '--ws' || args[i] === '--root') { i++; continue; } if (!args[i].startsWith('--')) return args[i]; } return ''; };
|
|
30
|
+
const pathFor = (f) => (path.isAbsolute(f) ? f : path.resolve(f));
|
|
31
|
+
|
|
32
|
+
function printQuestions(say, qs) {
|
|
33
|
+
qs.forEach((q, i) => {
|
|
34
|
+
say(` ${i + 1}. [${q.lens}] ${q.question}`);
|
|
35
|
+
say(` quotes: "${one(q.quote, 200)}"`);
|
|
36
|
+
if (q.why) say(` why it is hard: ${q.why}`);
|
|
37
|
+
if (q.fix) say(` fix before sharing: ${q.fix}`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function run(argv, { say = (s) => console.log(s), call = null, env = process.env } = {}) {
|
|
42
|
+
const args = argv.slice(1);
|
|
43
|
+
const sub = args[0];
|
|
44
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 2; }
|
|
45
|
+
const rt = () => require('./state-root.js').defaultRoot({ env });
|
|
46
|
+
|
|
47
|
+
if (sub === 'lenses') {
|
|
48
|
+
const root = typeof flag(args, 'root') === 'string' ? path.resolve(flag(args, 'root')) : process.cwd();
|
|
49
|
+
const K = SC.lensesFor(root);
|
|
50
|
+
say(K.added ? `${K.lenses.length} lenses: the base set and ${plural(K.added, 'question')} from ${K.from.join(' and ')}` : `${K.lenses.length} base lenses (add your own in pmos/review-questions.json):`);
|
|
51
|
+
for (const l of K.lenses) say(` [${l.id}] ${l.title} ${one(l.rule, 160)}`);
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if (sub === 'stats') {
|
|
55
|
+
const st = SC.stats(rt());
|
|
56
|
+
say(`${plural(st.runs, 'critic run')}${st.notRun ? ` (${st.notRun} did not run)` : ''} on ${plural(st.files, 'document')} · ${plural(st.questions, 'question')}: ${st.real} real, ${st.noise} noise, ${st.unlabelled} not labelled · ${st.dropped} dropped for a quote not in the document`);
|
|
57
|
+
for (const r of st.repeats) say(` the same gap in ${r.files.length} documents: [${r.lens}] ${r.files.map((f) => path.basename(f)).join(', ')}. Fix the template or the generator that makes them.`);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
if (sub === 'label') {
|
|
61
|
+
const [id, n, lab] = args.slice(1);
|
|
62
|
+
if (!id || !n || !lab) { say('usage: pmos critic label <run> <n> real|noise'); return 2; }
|
|
63
|
+
let by = ''; try { by = require('./actor.js').fromCli({ env }).by || ''; } catch { by = ''; }
|
|
64
|
+
const r = SC.label(rt(), id, n, lab, { by: by || 'pm:cli' });
|
|
65
|
+
if (!r.ok) { say('✗ ' + r.error); return 1; }
|
|
66
|
+
say(`✓ question ${n} of ${id} is ${lab}: [${r.question.lens}] ${r.question.question}`);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
const ws = flag(args, 'ws');
|
|
70
|
+
const wsq = typeof ws === 'string' ? ws : undefined;
|
|
71
|
+
if (sub === 'show') {
|
|
72
|
+
const f = fileArg(args, 1);
|
|
73
|
+
if (!f) { say('usage: pmos critic show <file> [--ws <id>]'); return 2; }
|
|
74
|
+
if (typeof call !== 'function') { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
|
|
75
|
+
let r = null; try { r = await call('GET', `/api/spec-critic?path=${encodeURIComponent(pathFor(f))}${wsq ? '&ws=' + encodeURIComponent(wsq) : ''}`); } catch { r = null; }
|
|
76
|
+
if (!r) { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
|
|
77
|
+
if (!r.ok) { say('✗ ' + (r.error || 'the critic could not read it')); return 1; }
|
|
78
|
+
if (!r.run) { say(`No critic pass on ${path.basename(r.file)} yet: pmos critic ${f}`); return 0; }
|
|
79
|
+
const x = r.run;
|
|
80
|
+
say(`${x.at.slice(0, 16).replace('T', ' ')} · run ${x.id}${r.changed ? ' · the document changed since: run it again before you share' : ''}`);
|
|
81
|
+
if (!x.ok) { say('✗ it did not run: ' + (x.why || 'no answer')); return 0; }
|
|
82
|
+
if (!x.questions.length) say('✓ no hard question'); else printQuestions(say, x.questions);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
const f = fileArg(args, 0);
|
|
86
|
+
if (!f) { for (const l of USAGE) say(l); return 2; }
|
|
87
|
+
if (typeof call !== 'function') { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
|
|
88
|
+
let r = null; try { r = await call('POST', '/api/spec-critic', { path: pathFor(f), ...(wsq ? { ws: wsq } : {}) }); } catch { r = null; }
|
|
89
|
+
if (!r) { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
|
|
90
|
+
if (!r.ok) { say('✗ ' + (r.error || 'the critic did not run')); return 1; }
|
|
91
|
+
say(r.questions.length
|
|
92
|
+
? `${plural(r.questions.length, 'hard question')} a sceptical reviewer would ask of ${path.basename(r.file)} · run ${r.run}`
|
|
93
|
+
: `✓ no hard question on ${path.basename(r.file)} (${r.lenses} lenses) · run ${r.run}`);
|
|
94
|
+
printQuestions(say, r.questions);
|
|
95
|
+
if (r.questions.length) say(`Label each: pmos critic label ${r.run} <n> real|noise`);
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* parse(text, checks) PURE → [finding] | null (null: the answer could not be read)
|
|
30
30
|
* asFailed(findings, checks) PURE → [{ id: 'critic:<check>', critic: true, check, title, words, lines }] (lib/prototype-rules.js run() shape)
|
|
31
31
|
* critique(ask, { root?, checks?, targets, only?, product? }) → Promise<{ ok, findings, checks, ms } | { ok: false, why, off? }>
|
|
32
|
-
* askVia(spawnSession, { timeoutMs? }) → ask(prompt, { key, addDirs }) → Promise<text | null>
|
|
32
|
+
* askVia(spawnSession, { timeoutMs?, name?, origin?, model? }) → ask(prompt, { key, addDirs }) → Promise<text | null>
|
|
33
33
|
* file(rt) · record(rt, run) → id · label(rt, run, n, label, { by }) → { ok } | { ok: false, error } · read(rt) → [run + { labels }] · stats(rt) */
|
|
34
34
|
const fs = require('fs');
|
|
35
35
|
const path = require('path');
|
|
@@ -192,16 +192,17 @@ async function critique(ask, { root = '', checks = null, targets = [], only = nu
|
|
|
192
192
|
if (!findings) return { ok: false, why: 'the critic\'s answer could not be read', ms };
|
|
193
193
|
return { ok: true, findings, checks: list.map((c) => c.id), ms };
|
|
194
194
|
}
|
|
195
|
-
/** The ask path through the server's spawnSession: a read-only `briefing-ask:` run (kind ask), its answer text or null.
|
|
196
|
-
|
|
195
|
+
/** The ask path through the server's spawnSession: a read-only `briefing-ask:` run (kind ask), its answer text or null. The spec critic
|
|
196
|
+
* (lib/spec-critic.js) uses it with its own origin under `briefing-ask:`. */
|
|
197
|
+
function askVia(spawnSession, { timeoutMs = TIMEOUT_MS, name = 'design critic', origin = ORIGIN, model = MODEL } = {}) {
|
|
197
198
|
if (typeof spawnSession !== 'function') return null;
|
|
198
199
|
return (prompt, { key = '', addDirs = [] } = {}) => new Promise((resolve) => {
|
|
199
200
|
let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(t); resolve(v); };
|
|
200
201
|
const t = setTimeout(() => done(null), timeoutMs);
|
|
201
202
|
let s = null;
|
|
202
203
|
try {
|
|
203
|
-
s = spawnSession({ name, agent: 'claude', origin:
|
|
204
|
-
modelAsk: { explicit: { model
|
|
204
|
+
s = spawnSession({ name, agent: 'claude', origin: origin + (key || Date.now().toString(36)), initialInput: prompt, addDirs,
|
|
205
|
+
modelAsk: { explicit: { model, effort: 'medium' } }, launchFlags: LEAN.map((f) => ({ ...f })),
|
|
205
206
|
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
|
|
206
207
|
} catch { s = null; }
|
|
207
208
|
if (!s || s.state === 'exited') done(null);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* pmos jira moves the status moves the PM asked in PMOS, not answered yet (lib/jira-moves.js)
|
|
20
20
|
* pmos jira moved <move id> --status "<Jira status>" | --refused "<why>" the agent's answer for one move
|
|
21
21
|
* pmos jira guesses <initiative> [--from <file|->] a ticket dry run (lib/ticket-dry-run.js), recorded or shown
|
|
22
|
-
* pmos jira answer <initiative> <ticket> <n> --text "<answer>"
|
|
22
|
+
* pmos jira answer <initiative> <ticket> <n> --text "<answer>" | --keep-default the PM's answer to one dry-run gap, or its default kept
|
|
23
23
|
* every command: [--json] [--root <dir>]
|
|
24
24
|
*
|
|
25
25
|
* This command never talks to Jira. An agent session does, with the PM's own Atlassian connection (D53, D88), and
|
|
@@ -44,7 +44,7 @@ const USAGE = [
|
|
|
44
44
|
' pmos jira guesses <initiative> --from <file|-> record a dry run: each ticket\'s guesses, with the PRD lines that answer them',
|
|
45
45
|
' Quotes not found word for word in the PRD, done test or record are dropped. Gaps go to the day\'s question list.',
|
|
46
46
|
' pmos jira guesses <initiative> the dry run so far: the guesses of each ticket and the open gaps',
|
|
47
|
-
' pmos jira answer <initiative> <ticket> <n> --text "<answer>" the PM\'s answer to gap n: it goes into the ticket',
|
|
47
|
+
' pmos jira answer <initiative> <ticket> <n> --text "<answer>" | --keep-default the PM\'s answer to gap n, or keep its default: it goes into the ticket',
|
|
48
48
|
' pmos jira epic <initiative> new|<KEY or link> [--group <g>] create a new epic at the first push, or use an existing one',
|
|
49
49
|
' pmos jira approve <initiative> <ID> … select tickets to push (you, in your own terminal)',
|
|
50
50
|
' pmos jira pending <initiative> what the push creates or updates in Jira',
|
|
@@ -63,7 +63,7 @@ const USAGE = [
|
|
|
63
63
|
' every command: [--json] [--root <dir>]',
|
|
64
64
|
'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
|
|
65
65
|
];
|
|
66
|
-
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints']);
|
|
66
|
+
const BOOL = new Set(['json', 'dry-run', 'help', 'sprints', 'keep-default']);
|
|
67
67
|
const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint', 'text']);
|
|
68
68
|
const FLAG_TEXT = { 'prd-changed': 'PRD changed', removed: 'Removed from PRD', blocked: 'Blocked', incomplete: 'Missing text', pushing: 'Selected, waiting for the push', edited: 'Edited, not in Jira yet' };
|
|
69
69
|
|
|
@@ -229,7 +229,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
229
229
|
if (!v) return fail(`no ticket draft for ${initiative} — press Draft tickets, or run pmos jira draft ${initiative}`);
|
|
230
230
|
const done = v.filter((t) => t.dryRun);
|
|
231
231
|
const lines = [`${initiative} · ${done.length} of ${v.length} ${v.length === 1 ? 'ticket' : 'tickets'} dry-run · ${gaps.length} open ${gaps.length === 1 ? 'gap' : 'gaps'}`];
|
|
232
|
-
for (const t of done) lines.push(` ${t.id} · ${t.dryRun.guesses} ${t.dryRun.guesses === 1 ? 'guess' : 'guesses'} · ${t.dryRun.answered} answered · ${t.dryRun.partly} partly · ${t.dryRun.gaps} ${t.dryRun.gaps === 1 ? 'gap' : 'gaps'}${t.dryRun.stale ? ' · PRD changed since: run it again' : ''}`);
|
|
232
|
+
for (const t of done) lines.push(` ${t.id} · ${t.dryRun.guesses} ${t.dryRun.guesses === 1 ? 'guess' : 'guesses'} · ${t.dryRun.answered} answered · ${t.dryRun.partly} partly · ${t.dryRun.gaps} ${t.dryRun.gaps === 1 ? 'gap' : 'gaps'}${t.dryRun.gaps ? ` (${t.dryRun.withDefault} with a default)` : ''}${t.dryRun.kept || t.dryRun.changed ? ` · ${t.dryRun.kept} kept, ${t.dryRun.changed} changed` : ''}${t.dryRun.stale ? ' · PRD changed since: run it again' : ''}`);
|
|
233
233
|
for (const g of gaps) lines.push(` gap ${g.ticket} ${g.n} · ${g.q}`);
|
|
234
234
|
return out({ ok: true, initiative, tickets: done.map((t) => ({ id: t.id, ...t.dryRun })), gaps }, lines);
|
|
235
235
|
}
|
|
@@ -245,10 +245,10 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
245
245
|
}
|
|
246
246
|
if (verb === 'answer') {
|
|
247
247
|
const [, ticket, n] = pos;
|
|
248
|
-
if (!ticket || !n || !flags.text) return need('<initiative> <ticket> <n> --text "<the answer>"');
|
|
249
|
-
const r = jiraTickets.answerDryRun(root, initiative, ticket, n, flags.text, { now });
|
|
248
|
+
if (!ticket || !n || (!flags.text === !flags['keep-default'])) return need('<initiative> <ticket> <n> --text "<the answer>" | --keep-default');
|
|
249
|
+
const r = jiraTickets.answerDryRun(root, initiative, ticket, n, flags.text, { now, keep: !!flags['keep-default'] });
|
|
250
250
|
if (!r.ok) return fail(r.error);
|
|
251
|
-
return out(r, [`${initiative} ${ticket} gap ${r.n} answered${r.written.length ? ' and added to the ticket' : ''}${r.kept.length ? ` · the ticket was not changed: ${r.kept[0].why}` : ''}`]);
|
|
251
|
+
return out(r, [`${initiative} ${ticket} gap ${r.n} answered${r.keptDefault ? ` with its default (${r.answer})` : ''}${r.written.length ? ' and added to the ticket' : ''}${r.kept.length ? ` · the ticket was not changed: ${r.kept[0].why}` : ''}`]);
|
|
252
252
|
}
|
|
253
253
|
if (verb === 'show') {
|
|
254
254
|
const r = jiraTickets.view(root, initiative, { snapshot: jiraStatus.readSnapshot(root, initiative) });
|
|
@@ -606,16 +606,16 @@ function dryRun(root, initiative, raw, { now } = {}) {
|
|
|
606
606
|
return { ok: true, initiative, tickets: Object.keys(c.tickets), ...sum, unverified: c.unverified, unknown: c.unknown, written: ap.written, kept: ap.kept, file: relOf(root, dryRunPath(root, initiative)) };
|
|
607
607
|
}
|
|
608
608
|
/** The PM's answer to a gap: it goes into the ticket and the question leaves the list. */
|
|
609
|
-
function answerDryRun(root, initiative, ticket, n, text, { now } = {}) {
|
|
609
|
+
function answerDryRun(root, initiative, ticket, n, text, { now, keep = false } = {}) {
|
|
610
610
|
const file = DRm().read(dryRunPath(root, initiative));
|
|
611
611
|
if (!file) return { ok: false, status: 404, error: `no dry run for ${initiative}: run the dry run first` };
|
|
612
|
-
const a = DRm().answer(file, ticket, n, text, now);
|
|
612
|
+
const a = DRm().answer(file, ticket, n, text, now, { keep });
|
|
613
613
|
if (!a.ok) return { ok: false, status: 400, error: a.error };
|
|
614
614
|
DRm().write(dryRunPath(root, initiative), file);
|
|
615
615
|
const d = readDraft(root, initiative);
|
|
616
616
|
let ap = { written: [], kept: [] };
|
|
617
617
|
if (d) { ap = applyDryRun(d, file, new Set([ticket])); if (ap.written.length) writeDraft(root, initiative, d, { now, prd: prdOf(recordFm(root, initiative)) }); }
|
|
618
|
-
return { ok: true, initiative, ticket, n: a.guess.n, q: a.guess.q, answer: a.guess.answer, written: ap.written, kept: ap.kept };
|
|
618
|
+
return { ok: true, initiative, ticket, n: a.guess.n, q: a.guess.q, answer: a.guess.answer, keptDefault: !!a.guess.kept, written: ap.written, kept: ap.kept };
|
|
619
619
|
}
|
|
620
620
|
/** The gaps of an initiative's dry run that nobody answered: [{ ticket, n, q }]. Stale and removed tickets are left out. */
|
|
621
621
|
function dryRunGaps(root, initiative) {
|
|
@@ -395,6 +395,7 @@ function keepFields(scope, id, row, o = {}) {
|
|
|
395
395
|
if (scope === 'initiative') { f.initiative = id; f.window = WINDOW; }
|
|
396
396
|
if (scope === 'product') f.product = id;
|
|
397
397
|
if (row.recipe) f.recipe = row.recipe;
|
|
398
|
+
else { const d = require('./metric-source.js').trackerRecipeOf({ source: f.source, metric: f.metric, type, why: f.why }); if (d) f.recipe = d; } // A3-pre: the query its own source names
|
|
398
399
|
f.draft = row.id;
|
|
399
400
|
return { fields: f, reading: now != null && DAY_RE.test(String(o.today || '')) ? { at: o.today, value: now } : null };
|
|
400
401
|
}
|
|
@@ -20,13 +20,19 @@
|
|
|
20
20
|
* _RUN, _RIDS, _TEST). A value lands on the record with its source and time; a test value lands only in the ledger. Nothing is sent.
|
|
21
21
|
* When the run ends, a goal it neither read nor said it could not read is filed as not read ("the run ended before it read this").
|
|
22
22
|
*
|
|
23
|
+
* A3-pre (one-goal-read-per-product): before a scan, a product with no goal PMOS can read gets the cheapest query one of its goals names
|
|
24
|
+
* (lib/metric-source.js pickOf), saved on that goal's record (deps.saveRecipe, else scripts/records edit by `pmos:metric-source`). It is due
|
|
25
|
+
* at once and read daily after. The PM changes or removes it on the goal page (POST /api/goal-status/recipe).
|
|
26
|
+
*
|
|
23
27
|
* deps: { workspaces(), isLead(w), stateDirFor(w), recordsDir(w), records(w) → [kr-metrics record], open(now), workOpen(now), hours() → { start, end },
|
|
24
28
|
* headlessOff(), env,
|
|
25
29
|
* promptFor(skillId), spawn(spec), spawnNow(spec), stop(session), afterRead(w, rids) (the alert check and the bell), warn(what, err),
|
|
26
|
-
* draftsFile(w) → the metric-drafts ledger, testItems(w, rids) → [{ rid, title, unit, recipe }] for drafted rows
|
|
30
|
+
* draftsFile(w) → the metric-drafts ledger, testItems(w, rids) → [{ rid, title, unit, recipe }] for drafted rows,
|
|
31
|
+
* saveRecipe(w, rid, recipe) → { ok } (optional) }
|
|
27
32
|
*/
|
|
28
33
|
const crypto = require('crypto');
|
|
29
34
|
const MR = require('./metric-reads.js');
|
|
35
|
+
const MS = require('./metric-source.js');
|
|
30
36
|
|
|
31
37
|
const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
|
|
32
38
|
const off = (env) => flagOff((env || process.env).PMOS_METRIC_READ);
|
|
@@ -107,6 +113,19 @@ function create(deps) {
|
|
|
107
113
|
return { ok: true, run, rids: ids };
|
|
108
114
|
}
|
|
109
115
|
|
|
116
|
+
/** A3-pre: a product with no goal PMOS can read gets the cheapest query its own goals name, saved on that one goal (lib/metric-source.js).
|
|
117
|
+
* → true when a query was saved (the records are read again). */
|
|
118
|
+
function saveCheapest(w, recs, F) {
|
|
119
|
+
const pick = MS.pickOf(recs, F);
|
|
120
|
+
if (!pick) return false;
|
|
121
|
+
try {
|
|
122
|
+
const save = deps.saveRecipe || ((ws, rid, recipe) => require(require('./repo-script.js').repoScript('records/index.js'))
|
|
123
|
+
.edit(deps.recordsDir(ws), 'kr-metrics', rid, { recipe }, { by: 'pmos:metric-source', via: 'server' }, MS.WHY));
|
|
124
|
+
const r = save(w, pick.rid, pick.recipe);
|
|
125
|
+
return !!(r && r.ok);
|
|
126
|
+
} catch (e) { warn('metric source save', e); return false; }
|
|
127
|
+
}
|
|
128
|
+
|
|
110
129
|
function stop(run) { const a = active.get(run); if (a && a.session && deps.stop) deps.stop(a.session); }
|
|
111
130
|
|
|
112
131
|
function tick({ now = Date.now(), env } = {}) {
|
|
@@ -124,7 +143,9 @@ function create(deps) {
|
|
|
124
143
|
const dir = deps.stateDirFor(w); if (!dir) continue;
|
|
125
144
|
lastScan.set(w.id, now);
|
|
126
145
|
let recs = []; try { recs = deps.records(w) || []; } catch (e) { warn('metric read records', e); continue; }
|
|
127
|
-
const
|
|
146
|
+
const F = MR.read(dir);
|
|
147
|
+
if (saveCheapest(w, recs, F)) { try { recs = deps.records(w) || []; } catch (e) { warn('metric read records', e); continue; } }
|
|
148
|
+
const due = MR.dueOf(recs, F, now, { only, hours });
|
|
128
149
|
if (!due.length) continue;
|
|
129
150
|
const r = start({ ws: w.id, rids: due.slice(0, PER_RUN), why: 'due', now });
|
|
130
151
|
if (r.ok) return { started: w.id, rids: r.rids };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* metric-source.js — the cheapest way to read one goal (bet A3-pre, initiative one-goal-read-per-product; critic F2: 0 readings on 5 of 5
|
|
3
|
+
* test products). PURE: no file, no clock, no network. lib/metric-read-runs.js saves what it picks; lib/metric-drafts.js keepFields uses it
|
|
4
|
+
* when the PM keeps a draft that names its source and has no recipe.
|
|
5
|
+
*
|
|
6
|
+
* trackerRecipeOf(goal) → recipe | null the query a goal's own words name, in the recipe shape of lib/metric-drafts.js recipeOf.
|
|
7
|
+
* goal: { source, metric | name, type, why? }. Only a tracker source (Jira) gives one:
|
|
8
|
+
* a "Done or not" goal that names an issue key key = ABC-123, counted 1 when done, 0 while open
|
|
9
|
+
* a Count goal that names a project, no issue project = ABC AND created >= -<window>d [AND issuetype = Bug]
|
|
10
|
+
* The window is the goal's own ("per 8 weeks" → 56 days, "30 days" → 30), else 28 days. Analytics, a sheet,
|
|
11
|
+
* a typed goal or any other type gets null: the review run (lib/metric-draft-runs.js gapsOf) drafts its fix.
|
|
12
|
+
* pickOf(records, F) → { rid, recipe } | null the ONE goal of a product to save a query on. null when a live goal already has a
|
|
13
|
+
* query that has not failed its last try (F: lib/metric-reads.js fold, optional), or when no goal's source
|
|
14
|
+
* gives one. Order: north-star, kr, program-goal, success, input, the rest; a retired or watch goal never.
|
|
15
|
+
* WHY the why on the record's edit line
|
|
16
|
+
*
|
|
17
|
+
* Why the tracker first: the read is one saved query through the PM's own tracker connection. It needs no event, no analytics setup and no
|
|
18
|
+
* PM time (proof pmos-ideas/proofs/A3-pre: three goals that named Jira read in one query each).
|
|
19
|
+
*/
|
|
20
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
21
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
22
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
23
|
+
|
|
24
|
+
const WHY = 'PMOS saved the cheapest query this goal names, so it is read every day';
|
|
25
|
+
const ORDER = ['north-star', 'kr', 'program-goal', 'success', 'input'];
|
|
26
|
+
const DEFAULT_DAYS = 28;
|
|
27
|
+
const TRACKER_RE = /\bjira\b/i;
|
|
28
|
+
const KEY_RE = /\b([A-Z][A-Z0-9_]{1,9})-(\d{1,7})\b/;
|
|
29
|
+
const PROJECT_RE = /^[\s:·,-]*(?:project\s+)?([A-Z][A-Z0-9_]{1,9})\b(?!-\d)/i; // right after the word Jira
|
|
30
|
+
const BUG_RE = /\bbugs?\b|\bdefects?\b/i;
|
|
31
|
+
|
|
32
|
+
/** The days a goal counts over, from its own words; DEFAULT_DAYS when it names none. */
|
|
33
|
+
function windowDays(text) {
|
|
34
|
+
const t = str(text);
|
|
35
|
+
let m = /(\d{1,3})\s*weeks?\b/i.exec(t); if (m && +m[1] > 0) return Math.min(+m[1] * 7, 366);
|
|
36
|
+
m = /(\d{1,3})\s*days?\b/i.exec(t); if (m && +m[1] > 0) return Math.min(+m[1], 366);
|
|
37
|
+
if (/\bper\s+(?:a\s+)?week\b|\bweekly\b/i.test(t)) return 7;
|
|
38
|
+
if (/\bper\s+(?:a\s+)?month\b|\bmonthly\b/i.test(t)) return 30;
|
|
39
|
+
return DEFAULT_DAYS;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function trackerRecipeOf(goal) {
|
|
43
|
+
if (!isObj(goal)) return null;
|
|
44
|
+
const source = str(goal.source), name = one(goal.metric || goal.name, 120), type = str(goal.type);
|
|
45
|
+
if (!TRACKER_RE.test(source)) return null;
|
|
46
|
+
const key = KEY_RE.exec(source);
|
|
47
|
+
if (type === 'Done or not' || (!type && str(goal.unit) === 'done')) {
|
|
48
|
+
if (!key) return null;
|
|
49
|
+
const k = key[0];
|
|
50
|
+
return { connector: 'Jira', query: `key = ${k}`, cadence: 'daily',
|
|
51
|
+
counts: { what: `1 when ${k} is in a done status, 0 while it is open`, num_label: '', den_label: '' } };
|
|
52
|
+
}
|
|
53
|
+
if (type === 'Count') {
|
|
54
|
+
if (key) return null; // one ticket is not a count
|
|
55
|
+
const after = source.slice(source.search(TRACKER_RE) + 4), p = PROJECT_RE.exec(after);
|
|
56
|
+
if (p && !/^[A-Z][A-Z0-9_]*$/.test(p[1])) return null; // a project key is upper case: "Jira board" names none
|
|
57
|
+
if (!p) return null;
|
|
58
|
+
const days = windowDays([name, source, str(goal.why)].join(' ')), bugs = BUG_RE.test(name);
|
|
59
|
+
return { connector: 'Jira', query: `project = ${p[1]}${bugs ? ' AND issuetype = Bug' : ''} AND created >= -${days}d`, cadence: 'daily',
|
|
60
|
+
counts: { what: `${bugs ? 'Bugs' : 'Issues'} created in ${p[1]} in the last ${days} days${name ? ` that match the goal "${name}"` : ''}`, num_label: '', den_label: '' } };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const live = (r) => isObj(r) && r.retired !== true && r.role !== 'watch';
|
|
66
|
+
const rank = (r) => { const i = ORDER.indexOf(r.role); return i < 0 ? ORDER.length : i; };
|
|
67
|
+
/** A goal whose query has not failed its last try reads already. */
|
|
68
|
+
function reads(rec, F) {
|
|
69
|
+
if (!(isObj(rec.recipe) && rec.recipe.connector && rec.recipe.query)) return false;
|
|
70
|
+
const x = F && F.rids && F.rids.get(rec.rid);
|
|
71
|
+
return !(x && x.last && x.last.ok === false);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function pickOf(records, F) {
|
|
75
|
+
const R = (records || []).filter(live);
|
|
76
|
+
if (R.some((r) => reads(r, F))) return null;
|
|
77
|
+
const order = R.map((r, i) => ({ r, i })).sort((a, b) => rank(a.r) - rank(b.r) || a.i - b.i);
|
|
78
|
+
for (const { r } of order) {
|
|
79
|
+
if (isObj(r.recipe) && r.recipe.connector) continue; // its own query failed: its fix is drafted, never overwritten here
|
|
80
|
+
const recipe = trackerRecipeOf(r);
|
|
81
|
+
if (recipe) return { rid: r.rid, recipe };
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { trackerRecipeOf, pickOf, windowDays, WHY, DEFAULT_DAYS };
|
|
@@ -151,6 +151,9 @@ const VERBS = Object.freeze({
|
|
|
151
151
|
// Not a pm-os-absorb verb (run: null): initiative core-documents added it through the same table.
|
|
152
152
|
coredoc: Object.freeze({ module: 'coredoc-cli.js', run: null, guide: 'cli.md',
|
|
153
153
|
help: 'pmos coredoc write --scope <scope> --key <key> --file <path|-> — write one draft of a core document; the PM issues it on the page (pmos coredoc help)' }),
|
|
154
|
+
// Not a pm-os-absorb verb (run: null): initiative spec-critic (bet A330) added it through the same table.
|
|
155
|
+
critic: Object.freeze({ module: 'critic-cli.js', run: null, guide: 'cli.md',
|
|
156
|
+
help: 'pmos critic <file>|show|lenses|label|stats — before you share a document, the hardest questions a sceptical reviewer would ask, each quoting the document (pmos critic help)' }),
|
|
154
157
|
// Not a pm-os-absorb verb (run: null): the Grill and Forecast build (F-A) added it through the same table.
|
|
155
158
|
forecast: Object.freeze({ module: 'forecast-cli.js', run: null, guide: 'cli.md',
|
|
156
159
|
help: 'pmos forecast baseline|baseline-off|turned … — a goal forecast\'s kept baseline, and the forecasts that turned (pmos forecast help)' }),
|
|
@@ -134,6 +134,7 @@ const MODULES = Object.freeze([
|
|
|
134
134
|
'routes-next-prompt', // batch 26 item 2: the chat's suggested next prompt and Sharper card (lib/next-prompt.js, through lib/ai-guard.js)
|
|
135
135
|
'routes-drift', // weekly-drift-check: What would I have missed, Home's weekly ✦ and its ⋯ drop and Undo (runtime drift/drift.jsonl; page-press POST)
|
|
136
136
|
'routes-moments', // onboarding B3 gradual exposure: the day's ✦ in Home's chat, the menu dots, a quiet place's one line (onboarding-progress record; page-press POST)
|
|
137
|
+
'routes-spec-critic', // spec-critic: the sceptical reviewer's hardest questions on a document before it is shared (runtime spec-critic.jsonl)
|
|
137
138
|
]);
|
|
138
139
|
const PM_DIR = path.join(__dirname, '..', 'public', 'pm');
|
|
139
140
|
const MODULE_NAME = /^[a-z0-9][a-z0-9-]*\.js$/;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-spec-critic.js — the sceptical reviewer's routes (initiative spec-critic; lib/spec-critic.js).
|
|
3
|
+
*
|
|
4
|
+
* POST /api/spec-critic { path, ws? } → { ok, run, file, questions, dropped, lenses, added } | { ok: false, error }
|
|
5
|
+
* one critic pass on a markdown, text or HTML document: a path relative to the workspace (it must stay inside it) or a full path.
|
|
6
|
+
* `pmos critic <file>` reaches it with no Origin (D98, like `pmos lab critic`); from a page it needs a page press.
|
|
7
|
+
* GET /api/spec-critic?path=&ws= → { ok, run: <the newest run on that file> | null, changed } a read; changed: the file differs from
|
|
8
|
+
* what the run read
|
|
9
|
+
* The run is read-only (lib/design-critic.js askVia, kind ask) and is recorded in <runtime>/spec-critic.jsonl. Nothing is sent. */
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const guard = require('./pm-guard.js');
|
|
13
|
+
const SC = require('./spec-critic.js');
|
|
14
|
+
|
|
15
|
+
const MAX_BYTES = 2e6;
|
|
16
|
+
const fail = (ctx, res, status, error) => { ctx.json(res, { ok: false, error }, status); return true; };
|
|
17
|
+
function wsOf(ctx, id) { let w = null; try { w = ctx.getWs(id || null); } catch { w = null; } return w && (!id || w.id === id) ? w : null; }
|
|
18
|
+
|
|
19
|
+
/** A document the critic may read → { ok, abs } | { ok: false, status, error }. */
|
|
20
|
+
function docOf(w, p) {
|
|
21
|
+
const given = String(p || '').trim();
|
|
22
|
+
if (!given) return { ok: false, status: 400, error: 'path names the document to read' };
|
|
23
|
+
let abs;
|
|
24
|
+
if (path.isAbsolute(given)) abs = path.resolve(given);
|
|
25
|
+
else {
|
|
26
|
+
if (!w || !w.root) return { ok: false, status: 404, error: 'no such workspace: give the document\'s full path' };
|
|
27
|
+
abs = path.resolve(w.root, given);
|
|
28
|
+
let rootReal = w.root; try { rootReal = fs.realpathSync(w.root); } catch { /* as given */ }
|
|
29
|
+
let real = abs; try { real = fs.realpathSync(abs); } catch { /* checked below */ }
|
|
30
|
+
if (real !== rootReal && !real.startsWith(rootReal + path.sep)) return { ok: false, status: 400, error: `${given}: the document must be inside the workspace` };
|
|
31
|
+
}
|
|
32
|
+
if (!SC.DOC_RE.test(abs)) return { ok: false, status: 400, error: `${given}: give a markdown, text or HTML document (.md, .txt, .html)` };
|
|
33
|
+
let st = null; try { st = fs.statSync(abs); } catch { st = null; }
|
|
34
|
+
if (!st || !st.isFile() || st.size > MAX_BYTES) return { ok: false, status: 400, error: `${given}: no such file, or over 2 MB` };
|
|
35
|
+
try { abs = fs.realpathSync(abs); } catch { /* as resolved */ }
|
|
36
|
+
return { ok: true, abs };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function run(ctx, res, b) {
|
|
40
|
+
const w = wsOf(ctx, typeof b.ws === 'string' && b.ws ? b.ws : null);
|
|
41
|
+
const d = docOf(w, b.path);
|
|
42
|
+
if (!d.ok) return fail(ctx, res, d.status, d.error);
|
|
43
|
+
if (SC.off(process.env)) return fail(ctx, res, 409, 'the critic is off (PMOS_CRITIC=off)');
|
|
44
|
+
let raw = ''; try { raw = fs.readFileSync(d.abs, 'utf8'); } catch { return fail(ctx, res, 400, 'the document could not be read'); }
|
|
45
|
+
const K = SC.lensesFor(w ? w.root : '');
|
|
46
|
+
const text = SC.textOf(raw, d.abs);
|
|
47
|
+
const ask = typeof ctx.specCritic === 'function' ? ctx.specCritic : SC.askVia(ctx.spawnSession);
|
|
48
|
+
const r = await SC.critique(ask, { lenses: K.lenses, text: raw, file: d.abs });
|
|
49
|
+
const id = ctx.runtimeDir ? SC.record(ctx.runtimeDir, { from: String(b.from || 'cli'), ws: w ? w.id : '', file: d.abs, sha: SC.sha(text), chars: text.length,
|
|
50
|
+
lenses: r.lenses || [], ok: r.ok, why: r.why, questions: r.questions, dropped: r.dropped, ms: r.ms }) : null;
|
|
51
|
+
if (!r.ok) return fail(ctx, res, r.off ? 409 : 502, r.why);
|
|
52
|
+
ctx.json(res, { ok: true, run: id, file: d.abs, questions: r.questions, dropped: r.dropped, lenses: r.lenses.length, added: K.added, from: K.from });
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function latest(ctx, res, url) {
|
|
57
|
+
const w = wsOf(ctx, url.searchParams.get('ws') || null);
|
|
58
|
+
const d = docOf(w, url.searchParams.get('path'));
|
|
59
|
+
if (!d.ok) return fail(ctx, res, d.status, d.error);
|
|
60
|
+
const r = ctx.runtimeDir ? SC.latest(ctx.runtimeDir, d.abs) : null;
|
|
61
|
+
let changed = false;
|
|
62
|
+
if (r) { try { changed = SC.sha(SC.textOf(fs.readFileSync(d.abs, 'utf8'), d.abs)) !== r.sha; } catch { changed = false; } }
|
|
63
|
+
ctx.json(res, { ok: true, file: d.abs, run: r, changed });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
prefixes: ['/api/spec-critic'],
|
|
69
|
+
docOf,
|
|
70
|
+
handle: async (req, res, url, ctx) => {
|
|
71
|
+
if (url.pathname !== '/api/spec-critic') return fail(ctx, res, 404, 'not found');
|
|
72
|
+
if (req.method === 'GET') return latest(ctx, res, url);
|
|
73
|
+
if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
|
|
74
|
+
const got = await ctx.readJson(req);
|
|
75
|
+
if (!got.ok || !got.body || typeof got.body !== 'object' || Array.isArray(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
76
|
+
// `pmos critic` comes with no Origin (D98, like `pmos lab critic`); a page needs a page press
|
|
77
|
+
if (req.headers.origin) { const g = guard.requirePagePress(req, got.body); if (!g.ok) return fail(ctx, res, g.status, g.error); }
|
|
78
|
+
return run(ctx, res, got.body);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* spec-critic.js — before a PM shares a document, PMOS lists the hardest questions a sceptical reviewer would ask (initiative spec-critic;
|
|
3
|
+
* bet A330 of the factory line, proof T10: a sceptical critic on two PRDs gave 8 quote-backed findings, 7 clearly valid, and the same gap
|
|
4
|
+
* in both pointed at the template that made them).
|
|
5
|
+
*
|
|
6
|
+
* EVERY QUESTION NAMES ITS LENS AND QUOTES THE DOCUMENT. lensesFor(root) is the base set below plus the PRODUCT's own reviewer questions,
|
|
7
|
+
* so it works on any product built with PMOS:
|
|
8
|
+
* base the questions every sceptical reader asks (evidence, outcome, trade-off, scope, risk, owner, contradiction, unverified).
|
|
9
|
+
* product review-questions.json under okf/products/<slug>/references/, else pmos/review-questions.json:
|
|
10
|
+
* { questions: [{ id, title, rule, source?, date? }] } (an id that is a base lens replaces that lens).
|
|
11
|
+
* parse() keeps a question only when it names a known lens AND its quote is found in the document (case, whitespace, quote marks and
|
|
12
|
+
* markdown emphasis ignored), so the PM never prepares for a question about words the document does not hold. At most 3 (MAX_QUESTIONS).
|
|
13
|
+
*
|
|
14
|
+
* THE RUN. One read-only session through the design critic's ask path (lib/design-critic.js askVia, origin `briefing-ask:spec-critic:<key>`,
|
|
15
|
+
* kind `ask`). The document's text is in the prompt, so the run needs no file. A run that cannot start, times out or answers nonsense
|
|
16
|
+
* files no questions, and the ledger says it did not run. PMOS_CRITIC=off runs none (the same switch as the design critic).
|
|
17
|
+
*
|
|
18
|
+
* WHERE IT RUNS. `pmos critic <file>` through the running server (POST /api/spec-critic, lib/routes-spec-critic.js); the chat's agent runs
|
|
19
|
+
* it when the PM says they are about to share a document. GET /api/spec-critic gives a page the latest run on a file.
|
|
20
|
+
*
|
|
21
|
+
* THE LEDGER. <runtime>/spec-critic.jsonl, append-only: { kind: 'run', id, at, from, ws?, file, sha, chars, lenses, ok, why?,
|
|
22
|
+
* questions: [{ lens, title, question, quote, why, fix }], dropped, ms } and { kind: 'label', run, n, label: real | noise, by, at } (the PM's
|
|
23
|
+
* word on question n, 1-based; the newest label wins). stats() counts them, and lists a lens flagged in 2 or more documents as a repeat:
|
|
24
|
+
* the same gap in several documents points at the template or generator that made them.
|
|
25
|
+
*
|
|
26
|
+
* BASE · ORIGIN · MAX_QUESTIONS · MAX_CHARS · DOC_RE · off(env)
|
|
27
|
+
* questionsOf(json, rel) PURE → [lens] · lensesFor(root) → { lenses, from, added }
|
|
28
|
+
* textOf(raw, file) PURE → the text the critic reads (HTML without its tags) · norm(s) PURE · sha(text) PURE
|
|
29
|
+
* promptOf({ lenses, text, file, product? }) PURE → string
|
|
30
|
+
* parse(answer, lenses, text) PURE → { questions, dropped } | null (null: the answer could not be read)
|
|
31
|
+
* critique(ask, { root?, lenses?, text, file, product?, env? }) → Promise<{ ok, questions, dropped, lenses, ms } | { ok: false, why, off? }>
|
|
32
|
+
* askVia(spawnSession, { timeoutMs? }) → ask
|
|
33
|
+
* file(rt) · record(rt, run) → id · read(rt) → [run + { labels }] · latest(rt, file) · label(rt, run, n, label, { by }) · stats(rt) */
|
|
34
|
+
const fs = require('fs');
|
|
35
|
+
const path = require('path');
|
|
36
|
+
const crypto = require('crypto');
|
|
37
|
+
const DC = require('./design-critic.js');
|
|
38
|
+
|
|
39
|
+
const FILE = 'spec-critic.jsonl';
|
|
40
|
+
const ORIGIN = 'briefing-ask:spec-critic:';
|
|
41
|
+
const MAX_QUESTIONS = 3, MAX_CHARS = 80000, MAX_RULE = 500, MIN_QUOTE = 6;
|
|
42
|
+
const DOC_RE = /\.(md|markdown|txt|html?)$/i;
|
|
43
|
+
const ID_RE = /^[a-z0-9][a-z0-9-]{0,59}$/;
|
|
44
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
45
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
46
|
+
const off = (env) => DC.off(env);
|
|
47
|
+
|
|
48
|
+
/* ── the base lenses: what a sceptical reviewer asks of any spec, strategy, roadmap or report ── */
|
|
49
|
+
const BASE = Object.freeze([
|
|
50
|
+
{ id: 'evidence', title: 'What is the evidence?', rule: 'A claim, number, need or user problem stated with no source, data or example behind it.' },
|
|
51
|
+
{ id: 'outcome', title: 'How will we know it worked?', rule: 'Success is measured by output (built, shipped, launched) rather than an outcome; no metric, baseline, target, key result or check date.' },
|
|
52
|
+
{ id: 'trade-off', title: 'What will you stop doing?', rule: 'No cost, no trade-off and nothing given up or delayed to make room for this; every option looks free.' },
|
|
53
|
+
{ id: 'scope', title: 'What is out?', rule: 'Scope or non-goals are missing or vague, so the ask can grow; no first cut that ships alone.' },
|
|
54
|
+
{ id: 'risk', title: 'What if you are wrong?', rule: 'The biggest assumption or risk is not named, or has no test, mitigation or kill line.' },
|
|
55
|
+
{ id: 'owner', title: 'Who decides, and by when?', rule: 'No owner, no date, or no clear decision or action asked of the reader.' },
|
|
56
|
+
{ id: 'contradiction', title: 'Which part is true?', rule: 'Two parts of the document disagree, or a summary says something its own detail contradicts.' },
|
|
57
|
+
{ id: 'unverified', title: 'Is it real yet?', rule: 'A status, delivery or result is claimed but marked unverified, assumed, or never checked.' },
|
|
58
|
+
].map((c) => Object.freeze({ ...c, source: 'PMOS base lenses' })));
|
|
59
|
+
|
|
60
|
+
/* ── the product's own reviewer questions ── */
|
|
61
|
+
function questionsOf(json, rel = 'review-questions.json') {
|
|
62
|
+
let j = json;
|
|
63
|
+
if (typeof j === 'string') { try { j = JSON.parse(j); } catch { return []; } }
|
|
64
|
+
const list = isObj(j) && Array.isArray(j.questions) ? j.questions : Array.isArray(j) ? j : [];
|
|
65
|
+
const out = [], seen = new Set();
|
|
66
|
+
for (const q of list) {
|
|
67
|
+
if (!isObj(q) || !ID_RE.test(String(q.id || '')) || !one(q.title, 120) || !one(q.rule, MAX_RULE) || seen.has(q.id)) continue;
|
|
68
|
+
seen.add(q.id);
|
|
69
|
+
out.push({ id: q.id, title: one(q.title, 120), rule: one(q.rule, MAX_RULE), source: one([q.source, q.date].filter(Boolean).join(', ') || rel, 160) });
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
const readOr = (abs) => { try { return fs.readFileSync(abs, 'utf8'); } catch { return null; } };
|
|
74
|
+
/** The base lenses plus the product's own reviewer questions (an id that is a base lens replaces it). */
|
|
75
|
+
function lensesFor(root) {
|
|
76
|
+
const R = String(root || '');
|
|
77
|
+
let lenses = BASE.map((c) => ({ ...c }));
|
|
78
|
+
const from = [];
|
|
79
|
+
let added = 0;
|
|
80
|
+
if (R) {
|
|
81
|
+
let slugs = []; try { slugs = fs.readdirSync(path.join(R, 'okf', 'products')).sort(); } catch { slugs = []; }
|
|
82
|
+
const cands = [...slugs.map((s) => `okf/products/${s}/references/review-questions.json`), 'pmos/review-questions.json'];
|
|
83
|
+
for (const rel of cands) {
|
|
84
|
+
const t = readOr(path.join(R, rel)); if (t == null) continue;
|
|
85
|
+
const qs = questionsOf(t, rel);
|
|
86
|
+
if (!qs.length) continue;
|
|
87
|
+
for (const q of qs) { const i = lenses.findIndex((l) => l.id === q.id); if (i >= 0) lenses[i] = q; else lenses.push(q); added++; }
|
|
88
|
+
from.push(rel);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { lenses, from, added };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ── the text ── */
|
|
96
|
+
/** What the critic reads: an HTML page without its scripts, styles and tags; any other document as it is. At most MAX_CHARS. */
|
|
97
|
+
function textOf(raw, file = '') {
|
|
98
|
+
let t = String(raw || '');
|
|
99
|
+
if (/\.html?$/i.test(file)) {
|
|
100
|
+
t = t.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi, ' ').replace(/<br\s*\/?>|<\/(p|div|li|h\d|tr|section)>/gi, '\n').replace(/<[^>]+>/g, ' ')
|
|
101
|
+
.replace(/ /g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'")
|
|
102
|
+
.replace(/[ \t]+/g, ' ').replace(/\n\s*\n+/g, '\n\n').trim();
|
|
103
|
+
}
|
|
104
|
+
return t.length > MAX_CHARS ? t.slice(0, MAX_CHARS) : t;
|
|
105
|
+
}
|
|
106
|
+
/** For the quote check: lower case, one space, plain quote marks and dashes, no markdown emphasis or table bars. */
|
|
107
|
+
function norm(s) {
|
|
108
|
+
return String(s || '').toLowerCase().replace(/[‘’‛`´]/g, "'").replace(/[“”„]/g, '"').replace(/[–—]/g, '-')
|
|
109
|
+
.replace(/[*_|]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
110
|
+
}
|
|
111
|
+
const sha = (text) => crypto.createHash('sha1').update(String(text || '')).digest('hex').slice(0, 16);
|
|
112
|
+
|
|
113
|
+
/* ── the run ── */
|
|
114
|
+
function promptOf({ lenses, text, file = '', product = '' }) {
|
|
115
|
+
return [
|
|
116
|
+
`You are PMOS's sceptical reviewer. The user is about to share this document${product ? ' about ' + one(product, 80) : ''}${file ? ' (' + one(path.basename(file), 120) + ')' : ''}. Read it as the most sceptical senior reader in the room would: an executive, an engineering lead, or a finance partner who has to say yes. List the hardest questions that reader would ask, so the user can answer them before sharing. Do not write or change anything.`,
|
|
117
|
+
'The lenses. Each question must name exactly one of these ids:\n' + lenses.map((l) => `[${l.id}] ${l.title} ${l.rule}`).join('\n'),
|
|
118
|
+
`Rules. At most ${MAX_QUESTIONS} questions, the hardest first. Each question quotes the document's own words it rests on, copied exactly (a few words to one sentence). For something missing, quote the heading or sentence where it should be. A question whose quote is not in the document is thrown away. Give the smallest fix the user can make before sharing, in one line. No praise, no style or grammar notes, no question the document already answers. If a strong reader would ask nothing hard, answer an empty list.`,
|
|
119
|
+
'The document:\n<<<DOCUMENT\n' + text + '\nDOCUMENT>>>',
|
|
120
|
+
'Answer with JSON only: {"questions":[{"lens":"<id>","question":"<the question, as the reviewer would ask it>","quote":"<the exact words>","why":"<why it is hard, one line>","fix":"<the smallest fix>"}]}',
|
|
121
|
+
].join('\n\n');
|
|
122
|
+
}
|
|
123
|
+
/** The critic's answer → questions that name a known lens and quote the document, and how many were dropped; null when unreadable. */
|
|
124
|
+
function parse(answer, lenses, text) {
|
|
125
|
+
const t = String(answer || '').replace(/```(?:json)?/gi, '');
|
|
126
|
+
const at = t.indexOf('{'), end = t.lastIndexOf('}');
|
|
127
|
+
if (at < 0 || end < at) return null;
|
|
128
|
+
let o = null;
|
|
129
|
+
try { o = JSON.parse(t.slice(at, end + 1)); } catch {
|
|
130
|
+
const m = /\{\s*"questions"\s*:\s*\[[\s\S]*?\]\s*\}/.exec(t); if (!m) return null;
|
|
131
|
+
try { o = JSON.parse(m[0]); } catch { return null; }
|
|
132
|
+
}
|
|
133
|
+
if (!isObj(o) || !Array.isArray(o.questions)) return null;
|
|
134
|
+
const byId = new Map(lenses.map((l) => [l.id, l]));
|
|
135
|
+
const doc = norm(text);
|
|
136
|
+
const out = [], seen = new Set();
|
|
137
|
+
let dropped = 0;
|
|
138
|
+
for (const q of o.questions) {
|
|
139
|
+
if (!isObj(q)) continue;
|
|
140
|
+
const l = byId.get(String(q.lens || '').replace(/^\[|\]$/g, '').trim());
|
|
141
|
+
const question = one(q.question, 300), quote = one(q.quote, 400).replace(/^["'“‘]+|["'”’]+$/g, '').replace(/^\.\.\.|\.\.\.$/g, '').trim();
|
|
142
|
+
if (!l || !question) continue;
|
|
143
|
+
const nq = norm(quote);
|
|
144
|
+
if (nq.length < MIN_QUOTE || !doc.includes(nq)) { dropped++; continue; }
|
|
145
|
+
const k = l.id + '|' + nq;
|
|
146
|
+
if (seen.has(k)) continue;
|
|
147
|
+
seen.add(k);
|
|
148
|
+
if (out.length < MAX_QUESTIONS) out.push({ lens: l.id, title: l.title, question, quote, why: one(q.why, 240), fix: one(q.fix, 240) });
|
|
149
|
+
}
|
|
150
|
+
return { questions: out, dropped };
|
|
151
|
+
}
|
|
152
|
+
/** One critic pass. ask(prompt, { key, addDirs }) → Promise<text | null>. */
|
|
153
|
+
async function critique(ask, { root = '', lenses = null, text = '', file = '', product = '', env = process.env } = {}) {
|
|
154
|
+
if (off(env)) return { ok: false, off: true, why: 'the critic is off (PMOS_CRITIC=off)' };
|
|
155
|
+
if (typeof ask !== 'function') return { ok: false, why: 'PMOS could not start a critic session' };
|
|
156
|
+
const T = textOf(text, file);
|
|
157
|
+
if (!T.trim()) return { ok: false, why: 'the document is empty' };
|
|
158
|
+
const L = lenses || lensesFor(root).lenses;
|
|
159
|
+
const started = Date.now();
|
|
160
|
+
const key = crypto.createHash('sha1').update(String(file) + '\n' + sha(T) + '\n' + started).digest('hex').slice(0, 12);
|
|
161
|
+
let answer = null;
|
|
162
|
+
try { answer = await ask(promptOf({ lenses: L, text: T, file, product }), { key, addDirs: [] }); } catch { answer = null; }
|
|
163
|
+
const ms = Date.now() - started;
|
|
164
|
+
if (answer == null) return { ok: false, why: 'the critic session did not answer', ms };
|
|
165
|
+
const p = parse(answer, L, T);
|
|
166
|
+
if (!p) return { ok: false, why: 'the critic\'s answer could not be read', ms };
|
|
167
|
+
return { ok: true, questions: p.questions, dropped: p.dropped, lenses: L.map((l) => l.id), ms };
|
|
168
|
+
}
|
|
169
|
+
/** The design critic's ask path with this critic's origin: a read-only `briefing-ask:` run (kind ask). */
|
|
170
|
+
const askVia = (spawnSession, { timeoutMs } = {}) => DC.askVia(spawnSession, { name: 'spec critic', origin: ORIGIN, ...(timeoutMs ? { timeoutMs } : {}) });
|
|
171
|
+
|
|
172
|
+
/* ── the ledger ── */
|
|
173
|
+
const file = (rt) => path.join(String(rt || ''), FILE);
|
|
174
|
+
function append(rt, line) {
|
|
175
|
+
if (!rt) return false;
|
|
176
|
+
try { fs.mkdirSync(rt, { recursive: true }); fs.appendFileSync(file(rt), JSON.stringify(line) + '\n'); return true; } catch { return false; }
|
|
177
|
+
}
|
|
178
|
+
/** Record one run. → its id */
|
|
179
|
+
function record(rt, run = {}) {
|
|
180
|
+
const id = 'sc-' + Date.now().toString(36) + crypto.randomBytes(3).toString('hex');
|
|
181
|
+
append(rt, { kind: 'run', id, at: new Date().toISOString(), from: one(run.from || 'cli', 40), ...(run.ws ? { ws: one(run.ws, 80) } : {}),
|
|
182
|
+
file: one(run.file, 400), sha: one(run.sha, 16), chars: Number.isFinite(run.chars) ? run.chars : null, lenses: (run.lenses || []).slice(0, 40),
|
|
183
|
+
ok: !!run.ok, ...(run.why ? { why: one(run.why, 200) } : {}),
|
|
184
|
+
questions: (run.questions || []).slice(0, MAX_QUESTIONS).map((q) => ({ lens: q.lens, title: one(q.title, 120), question: one(q.question, 300), quote: one(q.quote, 400), why: one(q.why, 240), fix: one(q.fix, 240) })),
|
|
185
|
+
dropped: Number.isInteger(run.dropped) ? run.dropped : 0, ms: Number.isFinite(run.ms) ? run.ms : null });
|
|
186
|
+
return id;
|
|
187
|
+
}
|
|
188
|
+
function lines(rt) {
|
|
189
|
+
let t = ''; try { t = fs.readFileSync(file(rt), 'utf8'); } catch { return []; }
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const l of t.split('\n')) { if (!l) continue; try { const o = JSON.parse(l); if (isObj(o)) out.push(o); } catch { /* a torn line */ } }
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
/** Runs, oldest first, each with its labels { n → real | noise } (the newest label wins). */
|
|
195
|
+
function read(rt) {
|
|
196
|
+
const runs = new Map();
|
|
197
|
+
for (const l of lines(rt)) {
|
|
198
|
+
if (l.kind === 'run' && l.id) runs.set(l.id, { ...l, questions: Array.isArray(l.questions) ? l.questions : [], labels: {} });
|
|
199
|
+
else if (l.kind === 'label' && runs.has(l.run)) runs.get(l.run).labels[l.n] = l.label;
|
|
200
|
+
}
|
|
201
|
+
return [...runs.values()];
|
|
202
|
+
}
|
|
203
|
+
/** The newest run on one file (its path as recorded), or null. */
|
|
204
|
+
function latest(rt, f) {
|
|
205
|
+
const R = read(rt).filter((r) => r.file === String(f || ''));
|
|
206
|
+
return R.length ? R[R.length - 1] : null;
|
|
207
|
+
}
|
|
208
|
+
/** The PM's word on question n (1-based) of a run: real or noise. */
|
|
209
|
+
function label(rt, run, n, lab, { by = 'pm:cli' } = {}) {
|
|
210
|
+
const r = read(rt).find((x) => x.id === run);
|
|
211
|
+
if (!r) return { ok: false, error: `there is no critic run ${one(run, 40)}: pmos critic stats lists them` };
|
|
212
|
+
const i = Number(n);
|
|
213
|
+
if (!Number.isInteger(i) || i < 1 || i > r.questions.length) return { ok: false, error: `run ${r.id} has ${r.questions.length} question${r.questions.length === 1 ? '' : 's'}: give a number from 1` };
|
|
214
|
+
if (lab !== 'real' && lab !== 'noise') return { ok: false, error: 'the label is real or noise' };
|
|
215
|
+
append(rt, { kind: 'label', run: r.id, n: i, label: lab, by: one(by, 80), at: new Date().toISOString() });
|
|
216
|
+
return { ok: true, question: r.questions[i - 1] };
|
|
217
|
+
}
|
|
218
|
+
/** The counts the Checker reads, and the lenses that repeat across documents (the newest run per file counts for repeats). */
|
|
219
|
+
function stats(rt) {
|
|
220
|
+
const R = read(rt);
|
|
221
|
+
const s = { runs: R.length, notRun: 0, files: 0, questions: 0, real: 0, noise: 0, unlabelled: 0, dropped: 0, byLens: {}, repeats: [] };
|
|
222
|
+
const newest = new Map();
|
|
223
|
+
for (const r of R) {
|
|
224
|
+
if (!r.ok) { s.notRun++; continue; }
|
|
225
|
+
s.dropped += r.dropped || 0;
|
|
226
|
+
newest.set(r.file, r);
|
|
227
|
+
r.questions.forEach((q, i) => {
|
|
228
|
+
s.questions++;
|
|
229
|
+
s.byLens[q.lens] = (s.byLens[q.lens] || 0) + 1;
|
|
230
|
+
const l = r.labels[i + 1];
|
|
231
|
+
if (l === 'real') s.real++; else if (l === 'noise') s.noise++; else s.unlabelled++;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
s.files = newest.size;
|
|
235
|
+
const docs = {};
|
|
236
|
+
for (const r of newest.values()) for (const lens of new Set(r.questions.map((q) => q.lens))) (docs[lens] = docs[lens] || []).push(r.file);
|
|
237
|
+
s.repeats = Object.entries(docs).filter(([, f]) => f.length >= 2).map(([lens, f]) => ({ lens, files: f })).sort((a, b) => b.files.length - a.files.length);
|
|
238
|
+
return s;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
module.exports = { FILE, BASE, ORIGIN, MAX_QUESTIONS, MAX_CHARS, DOC_RE, off, questionsOf, lensesFor, textOf, norm, sha, promptOf, parse, critique, askVia, file, record, read, latest, label, stats };
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
* blockOf(entry) → the text that goes into the ticket's Additional Context, or '' PURE
|
|
14
14
|
* withBlock(text, block) → the section text with the old block replaced PURE
|
|
15
15
|
* gapsOf(file, sourceOf) → [{ ticket, n, q }] the guesses no document answers and nobody answered yet PURE
|
|
16
|
-
* countsOf(entry) → { guesses, answered, partly, gaps, open }
|
|
16
|
+
* countsOf(entry) → { guesses, answered, partly, gaps, open, withDefault, kept, changed } PURE
|
|
17
|
+
* askOf(guess) → the question with its default offered first (A396, spec-questions-with-defaults) PURE
|
|
18
|
+
*
|
|
19
|
+
* DEFAULTS (initiative spec-questions-with-defaults; A396). A guess may carry `default`: the answer a builder would assume. The ticket
|
|
20
|
+
* says it ("Unless the PM says otherwise: …") until the PM answers, the question list offers it, and the PM can close the gap by keeping it
|
|
21
|
+
* (`kept: true`), so the Checker can count kept against changed.
|
|
17
22
|
* read(file) · write(file, data)
|
|
18
23
|
*
|
|
19
24
|
* A guess is 'answered' (a quote found, and the agent did not say partly), 'partly' (a quote found, the agent said partly) or 'gap'
|
|
@@ -30,6 +35,7 @@ const MAX_QUOTES = 3;
|
|
|
30
35
|
const MAX_Q = 300;
|
|
31
36
|
const MAX_QUOTE = 400;
|
|
32
37
|
const MAX_ANSWER = 1000;
|
|
38
|
+
const MAX_DEFAULT = 300;
|
|
33
39
|
const MIN_QUOTE = 12;
|
|
34
40
|
|
|
35
41
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -63,7 +69,8 @@ function parse(raw) {
|
|
|
63
69
|
const rawQ = isObj(g) ? (g.prd != null ? g.prd : g.quotes != null ? g.quotes : g.quote) : null;
|
|
64
70
|
const quotes = (Array.isArray(rawQ) ? rawQ : rawQ != null ? [rawQ] : []).map((x) => one(x, MAX_QUOTE)).filter(Boolean).slice(0, MAX_QUOTES);
|
|
65
71
|
const s = isObj(g) ? String(g.answered != null ? g.answered : g.status || '').toLowerCase() : '';
|
|
66
|
-
|
|
72
|
+
const def = isObj(g) ? one(g.default != null ? g.default : g.assume, MAX_DEFAULT) : '';
|
|
73
|
+
guesses.push({ q, said: /part/.test(s) ? 'partly' : /^(no|gap|none|false)$/.test(s) ? 'no' : 'yes', quotes, ...(def ? { default: def } : {}) });
|
|
67
74
|
if (guesses.length >= MAX_GUESSES) break;
|
|
68
75
|
}
|
|
69
76
|
tickets.push({ id: one(t.id, 41), guesses });
|
|
@@ -84,7 +91,7 @@ function check(parsed, { ids, sourceOf = () => null, haystack = '', now } = {})
|
|
|
84
91
|
const prd = g.quotes.filter((x) => found(x, hay));
|
|
85
92
|
unverified += g.quotes.length - prd.length;
|
|
86
93
|
const status = !prd.length ? 'gap' : g.said === 'partly' || g.said === 'no' ? 'partly' : 'answered';
|
|
87
|
-
return { n: i + 1, q: g.q, status, prd };
|
|
94
|
+
return { n: i + 1, q: g.q, status, prd, ...(g.default ? { default: g.default } : {}) };
|
|
88
95
|
});
|
|
89
96
|
out[t.id] = { source: sourceOf(t.id) || null, at, guesses };
|
|
90
97
|
}
|
|
@@ -97,7 +104,7 @@ function merge(old, checked, { initiative, now } = {}) {
|
|
|
97
104
|
const tickets = { ...prev };
|
|
98
105
|
for (const [id, e] of Object.entries(checked.tickets || {})) {
|
|
99
106
|
const answers = new Map(((prev[id] && prev[id].guesses) || []).filter((g) => g.answer).map((g) => [qKey(g.q), g]));
|
|
100
|
-
tickets[id] = { ...e, guesses: e.guesses.map((g) => { const a = answers.get(qKey(g.q)); return a ? { ...g, answer: a.answer, answeredAt: a.answeredAt } : g; }) };
|
|
107
|
+
tickets[id] = { ...e, guesses: e.guesses.map((g) => { const a = answers.get(qKey(g.q)); return a ? { ...g, answer: a.answer, answeredAt: a.answeredAt, ...(a.kept != null ? { kept: a.kept } : {}) } : g; }) };
|
|
101
108
|
}
|
|
102
109
|
return { initiative: initiative || (old && old.initiative) || null, at: new Date(now == null ? Date.now() : now).toISOString(), tickets };
|
|
103
110
|
}
|
|
@@ -108,6 +115,7 @@ function blockOf(entry) {
|
|
|
108
115
|
for (const g of (entry && entry.guesses) || []) {
|
|
109
116
|
if (g.prd && g.prd.length) lines.push(`- ${g.q} PRD: ${g.prd.map((x) => `"${x}"`).join(' · ')}${g.status === 'partly' && !g.answer ? ' (partly)' : ''}`);
|
|
110
117
|
if (g.answer) lines.push(`- ${g.q} PM: ${g.answer}`);
|
|
118
|
+
else if (g.default && g.status !== 'answered') lines.push(`- ${g.q} Unless the PM says otherwise: ${g.default}`);
|
|
111
119
|
}
|
|
112
120
|
return lines.length ? [MARK, '', ...lines].join('\n') : '';
|
|
113
121
|
}
|
|
@@ -124,7 +132,9 @@ function withBlock(text, block) {
|
|
|
124
132
|
function countsOf(entry) {
|
|
125
133
|
const g = (entry && entry.guesses) || [];
|
|
126
134
|
const n = (s) => g.filter((x) => x.status === s).length;
|
|
127
|
-
|
|
135
|
+
const gaps = g.filter((x) => x.status === 'gap');
|
|
136
|
+
return { guesses: g.length, answered: n('answered'), partly: n('partly'), gaps: gaps.length, open: gaps.filter((x) => !x.answer).length,
|
|
137
|
+
withDefault: gaps.filter((x) => x.default).length, kept: g.filter((x) => x.answer && x.kept === true).length, changed: g.filter((x) => x.answer && x.kept === false).length };
|
|
128
138
|
}
|
|
129
139
|
|
|
130
140
|
/** The gaps nobody answered, on tickets whose PRD item has not changed since the dry run. */
|
|
@@ -134,20 +144,29 @@ function gapsOf(file, sourceOf = () => null) {
|
|
|
134
144
|
if (!isObj(e) || !Array.isArray(e.guesses)) continue;
|
|
135
145
|
const cur = sourceOf(id);
|
|
136
146
|
if (cur === undefined || (e.source && cur && cur !== e.source)) continue; // the ticket is gone, or its PRD item changed: stale
|
|
137
|
-
for (const g of e.guesses) if (g.status === 'gap' && !g.answer) out.push({ ticket: id, n: g.n, q: g.q });
|
|
147
|
+
for (const g of e.guesses) if (g.status === 'gap' && !g.answer) out.push({ ticket: id, n: g.n, q: askOf(g), question: g.q, default: g.default || null });
|
|
138
148
|
}
|
|
139
149
|
return out;
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
/** Set the PM's answer to guess n of a ticket. → { ok, guess } | { ok: false, error } */
|
|
143
|
-
|
|
153
|
+
/** The question as the PM reads it: with its default first offered, when it has one (A396). */
|
|
154
|
+
function askOf(g) {
|
|
155
|
+
if (!g.default) return g.q;
|
|
156
|
+
const q = /[?.!]$/.test(g.q) ? g.q : g.q + '?';
|
|
157
|
+
return `${q} Unless you say otherwise: ${/[.!?]$/.test(g.default) ? g.default : g.default + '.'}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Set the PM's answer to guess n of a ticket, or keep its default ({ keep: true }). → { ok, guess } | { ok: false, error } */
|
|
161
|
+
function answer(file, ticket, n, text, now, { keep = false } = {}) {
|
|
144
162
|
const e = file && file.tickets && file.tickets[ticket];
|
|
145
163
|
if (!e) return { ok: false, error: `no dry run for ticket ${ticket}` };
|
|
146
164
|
const g = e.guesses.find((x) => x.n === Number(n));
|
|
147
165
|
if (!g) return { ok: false, error: `ticket ${ticket} has no guess ${n}` };
|
|
148
|
-
|
|
166
|
+
if (keep && !g.default) return { ok: false, error: `guess ${n} of ticket ${ticket} has no default to keep: answer it with --text` };
|
|
167
|
+
const a = keep ? g.default : one(text, MAX_ANSWER);
|
|
149
168
|
if (!a) return { ok: false, error: 'an answer needs some text' };
|
|
150
|
-
g.answer = a; g.answeredAt = new Date(now == null ? Date.now() : now).toISOString();
|
|
169
|
+
g.answer = a; g.kept = !!keep; g.answeredAt = new Date(now == null ? Date.now() : now).toISOString();
|
|
151
170
|
return { ok: true, guess: g };
|
|
152
171
|
}
|
|
153
172
|
|
|
@@ -161,4 +180,4 @@ function write(file, data) {
|
|
|
161
180
|
fs.renameSync(tmp, file);
|
|
162
181
|
}
|
|
163
182
|
|
|
164
|
-
module.exports = { MARK, parse, check, merge, blockOf, withBlock, gapsOf, countsOf, answer, found, plain, read, write };
|
|
183
|
+
module.exports = { MARK, parse, check, merge, blockOf, withBlock, gapsOf, countsOf, answer, askOf, found, plain, read, write };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.675.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.675.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -57,8 +57,8 @@ Procedure:
|
|
|
57
57
|
|
|
58
58
|
9. Dry-run the drafted tickets (Plan and Do). Run `pmos jira guesses <id>`. When it says the initiative has a ticket draft and some tickets are not dry-run yet, or a dry run is out of date because the PRD changed, dry-run those tickets:
|
|
59
59
|
a. Read the draft file (`pmos jira show <id>` names it). For each ticket, read ONLY the ticket and pretend to build it. List every point where you would have to guess: an error or failure state, an empty or loading state, who may see it, a limit, a screen size, what happens on Back or cancel, a number or a word the ticket does not give. One plain question each, at most 12 per ticket.
|
|
60
|
-
b. Then read the PRD, the done test and the record. For each question, copy the lines that answer it word for word (at most 3). Mark it `"answered": "yes"`, `"partly"` or `"no"`. Never change a line you quote: PMOS drops a quote it cannot find word for word, and the question then counts as a gap.
|
|
61
|
-
c. Write `{"tickets": [{"id": "<ticket id>", "guesses": [{"question": "…", "prd": ["<quoted line>"], "answered": "yes|partly|no"}]}]}` to a file in your scratch folder and run `pmos jira guesses <id> --from <file>`. PMOS copies the quoted lines into the tickets and puts the gaps on the PM's question list. Never answer a gap yourself: the PM answers with `pmos jira answer`.
|
|
60
|
+
b. Then read the PRD, the done test and the record. For each question, copy the lines that answer it word for word (at most 3). Mark it `"answered": "yes"`, `"partly"` or `"no"`. Give every question a `"default"`: the answer a builder would assume, in one line. When the PRD answers it, restate the quoted line; when nothing answers it, name the safest choice and start it with "Assumed:". Never change a line you quote: PMOS drops a quote it cannot find word for word, and the question then counts as a gap.
|
|
61
|
+
c. Write `{"tickets": [{"id": "<ticket id>", "guesses": [{"question": "…", "prd": ["<quoted line>"], "answered": "yes|partly|no", "default": "<one line>"}]}]}` to a file in your scratch folder and run `pmos jira guesses <id> --from <file>`. PMOS copies the quoted lines into the tickets and puts the gaps on the PM's question list. Never answer a gap yourself, and never keep a default for the PM: the PM answers with `pmos jira answer`.
|
|
62
62
|
10. Outside sign-offs (Plan and Do). Run `pmos signoff list <id>`. Read the PRD, the record and the notes for each yes the work waits on from someone outside the team (a scope, a price, wording, a go or no-go). For each one not listed, run `pmos signoff ask <id> --who "<name or team>" --what "<what they must say yes to>" --asked <date> [--due <date>] --source "<pointer>"`. When a source you read shows the answer, run `pmos signoff answer <signoff id> --answer "<what they said>" --source "<pointer>"`. Never record an answer you cannot point at. PMOS puts the open ones on the PM's question list.
|
|
63
63
|
|
|
64
64
|
Output contract — produce EXACTLY these sections in your final message:
|
|
@@ -21,7 +21,8 @@ Rules that always hold:
|
|
|
21
21
|
6. NO EVENT, NO NUMBER. When no event counts a metric, file it with `"now": null` and a ticket: `"ticket": { "key": "<PROJECT>-<n> drafted", "text": "<the event to add, its name and its properties>" }`. Say it in `why`, for example "No event to count it. Ticket MS-212 drafted."
|
|
22
22
|
7. A TARGET HAS A REASON. Base it on the baseline and on past launches (what the same kind of change did before). `why` says that reason in one line.
|
|
23
23
|
8. DO NOT DRAFT AGAIN what the PM kept or dropped, unless the evidence is new.
|
|
24
|
-
9.
|
|
24
|
+
9. SAVE THE QUERY. Every row whose source can be queried carries `"recipe": { "connector", "query", "cadence": "daily" }`, so PMOS reads it every day from the PM's ✓. Use the cheapest source that measures the same thing: the tracker first (a Jira query: `key = ABC-123` for a done-or-not goal, `project = ABC AND created >= -56d` for a count), then analytics, then a sheet. Name the source in `source` the same way ("Jira ABC-123 status", "Jira ABC"). A row with no source that can be queried has no recipe.
|
|
25
|
+
10. PLAIN WORDS. First person, short sentences, no praise and no blame. Name a metric in a few words, the way a PM says it: "Weekly signed-in shoppers", not "WSS (7d)".
|
|
25
26
|
|
|
26
27
|
Procedure:
|
|
27
28
|
1. Run `pmos metrics draft read "<source>" --found "<what it says, one line>"` for each source as you read it. Read in this order, and skip what does not exist:
|
|
@@ -31,7 +32,7 @@ Procedure:
|
|
|
31
32
|
- a quarter start: last quarter's key results, their readings and how each one ended.
|
|
32
33
|
Use `--state now` while you read a source and `--state done` when you finish it. A source you cannot read: `--state wait`, and say so in your answer.
|
|
33
34
|
2. Run `pmos metrics draft step shape`. Decide the rows. File each with `pmos metrics draft row --json -`:
|
|
34
|
-
`{ "group", "name", "type", "now", "nowTxt", "target", "targetTxt", "by", "why", "source", "ticket", "direction" }`.
|
|
35
|
+
`{ "group", "name", "type", "now", "nowTxt", "target", "targetTxt", "by", "why", "source", "recipe", "ticket", "direction" }`.
|
|
35
36
|
- type is one of Count, Percentage, Amount, Duration, Done or not, Stay within. A guardrail that must not get worse is Stay within, with the limit as its target and `"direction": "down"` for a ceiling or `"up"` for a floor.
|
|
36
37
|
- nowTxt and targetTxt are short: "38.8k", "94.1%", "45k by Dec 31", "Stays under 1.2 s".
|
|
37
38
|
- by is YYYY-MM-DD. For an initiative, "Proves it worked" is read 4 weeks after release: the release day from the plan plus 28 days. With no release day, use the last day of this quarter and say so in why.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "A3-pre one goal read per product (pure, node): lib/metric-source.js, its save step in lib/metric-read-runs.js tick, and keepFields in lib/metric-drafts.js.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"metric-source.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"metric-source.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Sceptical spec critic (initiative spec-critic, bet A330 of the factory line): before a PM shares a document, at most 3 hard questions a sceptical reviewer would ask, each naming its lens and quoting the document (a question whose quote is not in the document is dropped); the product's own review-questions.json; ledger with the PM's real/noise labels and the gaps that repeat across documents (lib/spec-critic.js, lib/routes-spec-critic.js /api/spec-critic, lib/critic-cli.js `pmos critic`). Backend only.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"spec-critic.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": { "spec-critic.test.js": 1 }
|
|
7
|
+
}
|