create-pmos 0.816.0 → 0.818.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 +42 -16
- 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 +41 -2
- package/workspace/guide/agent-capabilities.md +2 -1
- package/workspace/guide/cli.md +13 -0
- package/workspace/guide/reports.md +8 -0
- package/workspace/lib/approver-cli.js +98 -0
- package/workspace/lib/approver-memory.js +119 -0
- package/workspace/lib/job-graph.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-cli.js +24 -4
- package/workspace/lib/report-translate.js +238 -0
- package/workspace/lib/routes-reports.js +5 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-attach-test.js +19 -1
- package/workspace/public/pm/premium-report-read.js +9 -5
- package/workspace/server.js +2 -0
- package/workspace/test-lists/approver-memory.json +5 -0
- package/workspace/test-lists/report-translate.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.818.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,45 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.818.0",
|
|
38
|
+
"at": "2026-11-25T08:22:03.053Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1878,
|
|
43
|
+
"t": "Pmos approver shows what each approver asked before",
|
|
44
|
+
"s": "Pmos approver shows what each approver asked before",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "Pmos approver shows what each approver asked before",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"In the chat on Today, ask: what did Ana ask on earlier sign-offs?",
|
|
50
|
+
"Open an initiative in Work that waits on a sign-off and ask the chat: what did its approvers ask before?"
|
|
51
|
+
],
|
|
52
|
+
"see": "The chat lists what that person had to sign off, what they answered and what they objected to, newest first, each with its source. A person with nothing recorded is left out.",
|
|
53
|
+
"open": "/premium-board.html"
|
|
54
|
+
},
|
|
55
|
+
"i": "approver-memory"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"n": 1867,
|
|
59
|
+
"t": "Each report draft in each reader's language",
|
|
60
|
+
"s": "Each report draft in each reader's language",
|
|
61
|
+
"k": "new",
|
|
62
|
+
"i": "report-reader-language",
|
|
63
|
+
"try": {
|
|
64
|
+
"steps": [
|
|
65
|
+
"On Today, ask the chat: Dita reads the weekly report in Indonesian.",
|
|
66
|
+
"Open that report from Today, press Redraft, then open ⋯ and press Also in Indonesian.",
|
|
67
|
+
"Compare a number and an initiative id with the original."
|
|
68
|
+
],
|
|
69
|
+
"see": "The copy opens in the Viewer, says it is a translation for Dita, and every number and id matches the original.",
|
|
70
|
+
"open": "/today.html"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
36
75
|
{
|
|
37
76
|
"v": "0.816.0",
|
|
38
77
|
"at": "2026-11-25T07:54:58.764Z",
|
|
@@ -43,6 +82,7 @@
|
|
|
43
82
|
"t": "File a typed Today line to its initiative (job #1870)",
|
|
44
83
|
"s": "File a typed Today line to its initiative (job #1870)",
|
|
45
84
|
"k": "new",
|
|
85
|
+
"i": "capture-to-initiative",
|
|
46
86
|
"h": "File a typed Today line to its initiative (job #1870)",
|
|
47
87
|
"try": {
|
|
48
88
|
"steps": [
|
|
@@ -52,8 +92,7 @@
|
|
|
52
92
|
],
|
|
53
93
|
"see": "The line shows a chip with the initiative and its stage, and a toast says where it was filed with Undo. A typed task also appears as a task on that initiative in Work. Picking Not filed removes the…",
|
|
54
94
|
"open": "/today.html"
|
|
55
|
-
}
|
|
56
|
-
"i": "capture-to-initiative"
|
|
95
|
+
}
|
|
57
96
|
},
|
|
58
97
|
{
|
|
59
98
|
"n": 1856,
|
|
@@ -397,19 +436,6 @@
|
|
|
397
436
|
"k": "new"
|
|
398
437
|
}
|
|
399
438
|
]
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
"v": "0.791.0",
|
|
403
|
-
"at": "2026-11-24T18:45:09.361Z",
|
|
404
|
-
"f": 4,
|
|
405
|
-
"prs": [
|
|
406
|
-
{
|
|
407
|
-
"n": 1764,
|
|
408
|
-
"t": "Ask PMOS answers with the real rows and a picker (ask-cards-and-pickers, job #1747)",
|
|
409
|
-
"s": "Ask PMOS answers with the real rows and a picker (ask-cards-and-pickers, job #1747)",
|
|
410
|
-
"k": "new"
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
439
|
}
|
|
414
440
|
]
|
|
415
441
|
}
|
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-25T08:21:59Z"}
|
|
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-25T08:21:59Z"}
|
|
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-25T08:21:59Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.818.0",
|
|
4
|
+
"at": "2026-11-25T08:22:03.053Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1878,
|
|
9
|
+
"t": "Pmos approver shows what each approver asked before",
|
|
10
|
+
"s": "Pmos approver shows what each approver asked before",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "Pmos approver shows what each approver asked before",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"In the chat on Today, ask: what did Ana ask on earlier sign-offs?",
|
|
16
|
+
"Open an initiative in Work that waits on a sign-off and ask the chat: what did its approvers ask before?"
|
|
17
|
+
],
|
|
18
|
+
"see": "The chat lists what that person had to sign off, what they answered and what they objected to, newest first, each with its source. A person with nothing recorded is left out.",
|
|
19
|
+
"open": "/premium-board.html"
|
|
20
|
+
},
|
|
21
|
+
"i": "approver-memory"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"n": 1867,
|
|
25
|
+
"t": "Each report draft in each reader's language",
|
|
26
|
+
"s": "Each report draft in each reader's language",
|
|
27
|
+
"k": "new",
|
|
28
|
+
"i": "report-reader-language",
|
|
29
|
+
"try": {
|
|
30
|
+
"steps": [
|
|
31
|
+
"On Today, ask the chat: Dita reads the weekly report in Indonesian.",
|
|
32
|
+
"Open that report from Today, press Redraft, then open ⋯ and press Also in Indonesian.",
|
|
33
|
+
"Compare a number and an initiative id with the original."
|
|
34
|
+
],
|
|
35
|
+
"see": "The copy opens in the Viewer, says it is a translation for Dita, and every number and id matches the original.",
|
|
36
|
+
"open": "/today.html"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
2
41
|
{
|
|
3
42
|
"v": "0.816.0",
|
|
4
43
|
"at": "2026-11-25T07:54:58.764Z",
|
|
@@ -9,6 +48,7 @@
|
|
|
9
48
|
"t": "File a typed Today line to its initiative (job #1870)",
|
|
10
49
|
"s": "File a typed Today line to its initiative (job #1870)",
|
|
11
50
|
"k": "new",
|
|
51
|
+
"i": "capture-to-initiative",
|
|
12
52
|
"h": "File a typed Today line to its initiative (job #1870)",
|
|
13
53
|
"try": {
|
|
14
54
|
"steps": [
|
|
@@ -18,8 +58,7 @@
|
|
|
18
58
|
],
|
|
19
59
|
"see": "The line shows a chip with the initiative and its stage, and a toast says where it was filed with Undo. A typed task also appears as a task on that initiative in Work. Picking Not filed removes the…",
|
|
20
60
|
"open": "/today.html"
|
|
21
|
-
}
|
|
22
|
-
"i": "capture-to-initiative"
|
|
61
|
+
}
|
|
23
62
|
},
|
|
24
63
|
{
|
|
25
64
|
"n": 1856,
|
|
@@ -117,6 +117,7 @@ A loop never sends a message, moves a Jira ticket, merges into a product reposit
|
|
|
117
117
|
| [You decided this before](claude-proposes.md) | You add an initiative that repeats an earlier decision | `DECISIONS.md`, the decision records, the PM journal, `planning/out-of-scope/` and the initiative records | The initiative's ✦ | `pmos ai off past-repeat` |
|
|
118
118
|
| [✦ drafts](claude-proposes.md#drafts-from-a-) | You press ✓ on a ✦ that offers a draft: a line of the Overview, a program's For or Goal, the documents a gate needs, a goal or initiatives from the strategy, an outcome verdict or a goal's name. One short run for each press. | The records in the product's folder. It writes nothing and sends nothing. | The row you pressed: "PMOS is drafting it", then the draft | Press ✕ on the draft. Nothing is kept until you keep it. |
|
|
119
119
|
| [Report readers](claude-proposes.md) | A report draft is written | The draft, read as the CFO, the engineering lead and the sceptic | The ✦ of each initiative the question quotes | `pmos ai off report-readers` |
|
|
120
|
+
| [Report translations](reports.md) | A report draft is written and its definition names `languages:` | The draft | A translated copy beside the draft, written only when every number and name is unchanged | `pmos ai off report-translate` |
|
|
120
121
|
| [Stuck work](claude-proposes.md) | Each time you open an initiative's ✦. No run, no model. | The tasks' own state days, and the last change of each Jira ticket | "Stuck" under the initiative's ✦: a drafted note to the owner, or Park | Press ✕ on the step. Nothing is sent: a note waits in the Outbox. |
|
|
121
122
|
| [Initiative descriptions](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. | The PRD's first Problem or Why paragraph, or the record's own first paragraph | "Description" under the initiative's ✦ | `pmos ai off descriptions`. `PMOS_DESCRIPTIONS=off` |
|
|
122
123
|
| [Expected outcomes](claude-proposes.md) | Once a day. At most 3 drafts a day for each product. When a check date passes: the verdict, from the goal's reading or one short run. | The PRD's success criteria, or the anchored key result. For a verdict: the goal's reading, or the lines the run cites | "Expected outcome" under the initiative's ✦. A verdict is recorded with Undo. Your move when PMOS cannot tell. | `pmos ai off outcomes`. `PMOS_OUTCOMES=off` |
|
|
@@ -167,7 +168,7 @@ When you ask an agent session to do a piece of work, it can finish it, including
|
|
|
167
168
|
- `pmos ai log [<job>]`: the last audit lines. Each dropped proposal shows why.
|
|
168
169
|
- `pmos ai off [<job>]` and `pmos ai on [<job>]`: turn every AI job, or one job, off or on. `PMOS_AI=off` in the environment wins over the setting.
|
|
169
170
|
|
|
170
|
-
The AI jobs are `past-repeat`, `report-readers`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt`, `idle-lab` and `live-round` (`pmos ai off live-round` stops new live rounds; one that runs ends by itself). The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `meeting-prewarm`, `driver`, `goal-loops`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
|
|
171
|
+
The AI jobs are `past-repeat`, `report-readers`, `report-translate`, `decision-memory`, `outcomes`, `descriptions`, `drift`, `rehearse`, `next-prompt`, `sharpen-prompt`, `idle-lab` and `live-round` (`pmos ai off live-round` stops new live rounds; one that runs ends by itself). The switch also covers each job in the queue by its queue name: `schedules`, `proactive`, `prepare`, `day`, `refresh`, `reports`, `meeting-prewarm`, `driver`, `goal-loops`, `finder`, `coredocs`, `milestones`, `propose`, `grill`, `metric-drafts`, `impact`, `metric-reads`, `forecast`, `report-design`, `report-structure`, `team`, `scan` and `idle-lab`. `pmos ai off` with no job stops all of them. Git sync uses no model, so the switch does not stop it. A background run cannot change the switch.
|
|
171
172
|
|
|
172
173
|
## The team of role agents
|
|
173
174
|
|
package/workspace/guide/cli.md
CHANGED
|
@@ -954,6 +954,17 @@ An outside sign-off is a yes that someone outside the team must give before the
|
|
|
954
954
|
|
|
955
955
|
An open sign-off that waited 3 days, or is past its due date, goes on your question list for the day, on the same card as the dry-run gaps of your tickets ([Jira tickets](jira.md)). Nothing is sent. Every command takes `--json` and `--root <dir>`.
|
|
956
956
|
|
|
957
|
+
### pmos approver
|
|
958
|
+
|
|
959
|
+
Walk into a sign-off with what that person asked last time. PMOS reads the sign-offs above and the decision journal, and groups what each approver had to say yes to, what they answered, and what they objected to. It writes nothing.
|
|
960
|
+
|
|
961
|
+
- `pmos approver list` lists the people who signed off or objected before, with the most items first.
|
|
962
|
+
- `pmos approver show "<name>"` lists one person's past asks, answers and objections, newest first, each with its source. "Ana" also finds "Ana Lim".
|
|
963
|
+
- `pmos approver brief <initiative>` is for before a sign-off: for each open sign-off of the initiative, at most 3 things that approver asked or objected to on other work. A person with nothing recorded is left out.
|
|
964
|
+
- An objection counts only when a decision's `--against` starts with the person's name, for example `--against "Ana: the ROI is not shown"`. PMOS never guesses a name from other text.
|
|
965
|
+
|
|
966
|
+
Every command takes `--json` and `--root <dir>`.
|
|
967
|
+
|
|
957
968
|
## Intelligence and reports
|
|
958
969
|
|
|
959
970
|
### pmos forecast
|
|
@@ -1021,6 +1032,8 @@ pmos report issue biweekly 2026-10-16
|
|
|
1021
1032
|
|
|
1022
1033
|
`pmos report finder` shows the report finder setting, or changes it.
|
|
1023
1034
|
|
|
1035
|
+
`pmos report language <cadence> "<Language>[ for <reader>]"` adds a reader who reads the report in another language. After each draft, PMOS writes a translated copy beside it with every number and name unchanged. Add `--off` to remove the language. With no language, the command lists the languages. Nothing is sent.
|
|
1036
|
+
|
|
1024
1037
|
`pmos report library` writes one page with every slide layout of the report library, filled with placeholder words. Open it in a browser to see the layouts a report can use. Add `--out <file>` to choose the file. `pmos report library --template <id>` draws one template with placeholder words.
|
|
1025
1038
|
|
|
1026
1039
|
Every command accepts `--root <dir>` to name the repository. `draft` and `list` also accept `--json`.
|
|
@@ -352,6 +352,14 @@ If a block is off track or at risk and has no reason, the script stops and write
|
|
|
352
352
|
|
|
353
353
|
The definition file tells the script and the agent what the report is for. For PMOS itself it is `planning/reports/definitions/biweekly.md`. In a kit repository it is `pmos/state/reports/definitions/biweekly.md`. Its frontmatter gives the `cadence`, the `audience` and the `sections`. If the definition names no audience, Needs your call stays empty.
|
|
354
354
|
|
|
355
|
+
### In each reader's language
|
|
356
|
+
|
|
357
|
+
A definition can name readers who read the report in another language: `languages: "Indonesian for Dita; Japanese"`. Ask PMOS in the chat, or run `pmos report language <cadence> "Indonesian for Dita"`. Add `--off` to stop one language.
|
|
358
|
+
|
|
359
|
+
After each draft, PMOS writes one translated copy per language beside the draft, for example `2026-11-20.id.md`. The copy opens with one line that says it is a translation, for whom, and that PMOS checked the numbers and names. PMOS writes a copy only when every number, initiative id, note, link and acronym of the original is in it. If one is missing, PMOS writes no copy and the server log says why. A draft whose text did not change is not translated again.
|
|
360
|
+
|
|
361
|
+
To read a copy, open the report and press **⋯ › Also in Indonesian**. The copy is not a cycle, so it has no Issue. Nothing is sent: share the copy yourself. `pmos ai off report-translate` stops the translations.
|
|
362
|
+
|
|
355
363
|
### Notes
|
|
356
364
|
|
|
357
365
|
Each block has a note between two markers:
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* approver-cli.js — `pmos approver`: what each approver asked or objected to before (initiative approver-memory, bet A190;
|
|
3
|
+
* lib/approver-memory.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos approver list [--json] the people who signed off or objected before, most items first
|
|
6
|
+
* pmos approver show <name> [--json] one person's past asks, answers and objections, newest first, each with its source
|
|
7
|
+
* pmos approver brief <initiative> [--json] before a sign-off: for each open sign-off of the initiative, what that approver asked or
|
|
8
|
+
* objected to on other work (at most 3 each). Nothing when nobody has history
|
|
9
|
+
* every command: [--root <dir>] (default: this repository)
|
|
10
|
+
*
|
|
11
|
+
* Read only: it writes nothing and sends nothing. Each run writes one `[approver]` line to the server log for the health number.
|
|
12
|
+
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
13
|
+
*/
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const A = require('./approver-memory.js');
|
|
17
|
+
|
|
18
|
+
const COMMANDS = { approver: ['list', 'show', 'brief'] };
|
|
19
|
+
const USAGE = [
|
|
20
|
+
'usage: pmos approver list|show|brief — what each approver asked or objected to before, from the sign-offs and the decision journal',
|
|
21
|
+
' pmos approver list [--json] the people who signed off or objected before',
|
|
22
|
+
' pmos approver show <name> [--json] one person\'s past asks, answers and objections, newest first, with sources',
|
|
23
|
+
' pmos approver brief <initiative> [--json] before a sign-off: what each open sign-off\'s approver asked on other work',
|
|
24
|
+
'Run it in the product\'s repository, or pass --root <dir>. It writes nothing.',
|
|
25
|
+
];
|
|
26
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,80}$/;
|
|
27
|
+
const KIND = { signoff: 'had to sign off', answer: 'answered', objection: 'objected' };
|
|
28
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
29
|
+
const short = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] + ' ' + m[1] : String(d || ''); };
|
|
30
|
+
|
|
31
|
+
/** The repository this runs in: the nearest folder up from cwd that holds .git (no program is run), else cwd. */
|
|
32
|
+
function repoRoot(cwd) {
|
|
33
|
+
let d = path.resolve(cwd);
|
|
34
|
+
for (;;) {
|
|
35
|
+
if (fs.existsSync(path.join(d, '.git'))) return d;
|
|
36
|
+
const up = path.dirname(d);
|
|
37
|
+
if (up === d) return path.resolve(cwd);
|
|
38
|
+
d = up;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function parse(args) {
|
|
42
|
+
const pos = [], flags = {};
|
|
43
|
+
for (let i = 0; i < args.length; i++) {
|
|
44
|
+
const a = args[i];
|
|
45
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
46
|
+
const k = a.slice(2);
|
|
47
|
+
if (k === 'json') flags.json = true;
|
|
48
|
+
else flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
49
|
+
}
|
|
50
|
+
return { pos, flags };
|
|
51
|
+
}
|
|
52
|
+
const itemLine = (it) => ` ${short(it.date)} · ${KIND[it.kind]}: ${it.text}${it.ini ? ' (' + it.ini + ')' : ''} · ${it.source}`;
|
|
53
|
+
|
|
54
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), log = (s) => console.error(s) } = {}) {
|
|
55
|
+
const args = argv[0] === 'approver' ? argv.slice(1) : argv.slice();
|
|
56
|
+
const sub = args[0];
|
|
57
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
58
|
+
if (!COMMANDS.approver.includes(sub)) { say(`unknown approver command "${sub}". Use one of: ${COMMANDS.approver.join(', ')}`); return 2; }
|
|
59
|
+
const { pos, flags } = parse(args.slice(1));
|
|
60
|
+
for (const k of Object.keys(flags)) if (!['json', 'root'].includes(k)) { say(`✗ --${k} is not an option of pmos approver ${sub}`); return 2; }
|
|
61
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
62
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
63
|
+
const note = (s) => { try { log(`${A.TAG} ${sub} ${s}`); } catch { /* no log */ } };
|
|
64
|
+
const items = A.itemsOf(root);
|
|
65
|
+
|
|
66
|
+
if (sub === 'list') {
|
|
67
|
+
if (pos.length) return fail('usage: pmos approver list', 2);
|
|
68
|
+
const rows = A.approvers(items);
|
|
69
|
+
note(`${rows.length}`);
|
|
70
|
+
if (flags.json) { say(JSON.stringify({ ok: true, approvers: rows })); return 0; }
|
|
71
|
+
if (!rows.length) { say('No approver has asked or objected yet. Sign-offs (pmos signoff) and decisions with --against "<Name>: <why>" fill this.'); return 0; }
|
|
72
|
+
for (const r of rows) say(`${r.who} · ${r.n} item${r.n === 1 ? '' : 's'} · last ${short(r.last)}`);
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
if (sub === 'show') {
|
|
76
|
+
if (pos.length !== 1) return fail('usage: pmos approver show "<name>"', 2);
|
|
77
|
+
const h = A.historyOf(items, pos[0]);
|
|
78
|
+
note(`${h.length}`);
|
|
79
|
+
if (flags.json) { say(JSON.stringify({ ok: true, who: pos[0], items: h })); return 0; }
|
|
80
|
+
if (!h.length) { say(`Nothing recorded for ${pos[0]} yet.`); return 0; }
|
|
81
|
+
say(`${h[0].who}, newest first:`);
|
|
82
|
+
for (const it of h) say(itemLine(it));
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
// brief
|
|
86
|
+
if (pos.length !== 1 || !ID_RE.test(pos[0])) return fail('usage: pmos approver brief <initiative id>', 2);
|
|
87
|
+
const B = A.briefOf(root, pos[0], { items });
|
|
88
|
+
note(`${pos[0]} ${B.length}`);
|
|
89
|
+
if (flags.json) { say(JSON.stringify({ ok: true, initiative: pos[0], brief: B })); return 0; }
|
|
90
|
+
if (!B.length) { say(`No open sign-off on ${pos[0]} has an approver with past asks.`); return 0; }
|
|
91
|
+
for (const b of B) {
|
|
92
|
+
say(`${b.who} must sign off: ${b.what}${b.due ? ' (due ' + short(b.due) + ')' : ''}. Before, on other work:`);
|
|
93
|
+
for (const it of b.past) say(itemLine(it));
|
|
94
|
+
}
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* approver-memory.js — what each approver asked or objected to before (initiative approver-memory, bet A190). THE PURE-ISH CORE of
|
|
3
|
+
* `pmos approver` (lib/approver-cli.js).
|
|
4
|
+
*
|
|
5
|
+
* A sign-off goes better when the PM walks in with what that person asked last time. PMOS already records the sign-offs
|
|
6
|
+
* (lib/signoffs.js: who, what, and the answer with its source) and the decision journal records who disagreed and why
|
|
7
|
+
* (lib/decision-journal.js `against`). Neither is read back by person. This reads both, groups them by approver, and, before an open
|
|
8
|
+
* sign-off, lists what that approver asked or objected to on earlier work.
|
|
9
|
+
*
|
|
10
|
+
* itemsOf(root) → [item] every past ask, answer and objection, oldest first. An item:
|
|
11
|
+
* { who, kind: 'signoff' | 'answer' | 'objection', text, ini, date, source }
|
|
12
|
+
* signoff a sign-off asked of them: what they had to say yes to (signoffs.jsonl)
|
|
13
|
+
* answer their recorded answer to it, with where it was given
|
|
14
|
+
* objection a journal decision's `against` that starts with a name: "Ana: the ROI is not shown" (never a guess from other text)
|
|
15
|
+
* whoOf(text) → { who, text } | null the name an `against` starts with, before ':', ' - ', ' — ', or ' said'/' asked'
|
|
16
|
+
* same(a, b) → true when two names are the same person: equal, or one is the other's first name ("Ana" and "Ana Lim")
|
|
17
|
+
* approvers(items) → [{ who, n, last }] one row per person, most items first
|
|
18
|
+
* historyOf(items, who, o) → [item] that person's items, newest first; o.except leaves out one initiative
|
|
19
|
+
* briefOf(root, ini, o) → [{ who, what, due, past: [item] }] for each OPEN sign-off of the initiative, at most MAX_PAST of the
|
|
20
|
+
* approver's items from OTHER initiatives, newest first. A person with none is left out (zero is silence)
|
|
21
|
+
* CLI: node lib/approver-memory.js count <root> prints `[approver] …` and the open sign-offs whose approver has history, alone on
|
|
22
|
+
* the last line (the health number)
|
|
23
|
+
*
|
|
24
|
+
* READ ONLY. It keeps no store of its own and writes nothing: every item comes from a record the PM or the Driver already wrote, and
|
|
25
|
+
* carries its source. Nothing is sent. Works on any product built with PMOS, in either layout.
|
|
26
|
+
*/
|
|
27
|
+
const path = require('path');
|
|
28
|
+
|
|
29
|
+
const MAX_PAST = 3;
|
|
30
|
+
const TAG = '[approver]';
|
|
31
|
+
const NAME_RE = /^\s*(\p{Lu}[\p{L}.'’-]*(?:\s+\p{Lu}[\p{L}.'’-]*){0,2})\s*(?::|\s[-—–]\s|\s(?:said|asked|wants|objected)\b)\s*(.+)$/u;
|
|
32
|
+
const one = (s, n = 300) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
33
|
+
const norm = (s) => one(s, 80).toLowerCase();
|
|
34
|
+
|
|
35
|
+
function whoOf(text) {
|
|
36
|
+
const m = NAME_RE.exec(one(text, 600));
|
|
37
|
+
if (!m) return null;
|
|
38
|
+
return { who: m[1].trim(), text: one(m[2]) };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function same(a, b) {
|
|
42
|
+
const x = norm(a), y = norm(b);
|
|
43
|
+
if (!x || !y) return false;
|
|
44
|
+
if (x === y) return true;
|
|
45
|
+
const fx = x.split(' ')[0], fy = y.split(' ')[0];
|
|
46
|
+
return (x === fy && !x.includes(' ')) || (y === fx && !y.includes(' '));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function signoffsOf(root) {
|
|
50
|
+
try {
|
|
51
|
+
const SO = require('./signoffs.js');
|
|
52
|
+
const JT = require('./jira-tickets.js');
|
|
53
|
+
return SO.list(SO.fileOf(JT.stateDirOf(root)));
|
|
54
|
+
} catch { return []; }
|
|
55
|
+
}
|
|
56
|
+
function decisionsOf(root) {
|
|
57
|
+
try { const J = require('./decision-journal.js'); return J.fold(J.read(root).rows); } catch { return []; }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function itemsOf(root) {
|
|
61
|
+
root = path.resolve(root);
|
|
62
|
+
const out = [];
|
|
63
|
+
for (const s of signoffsOf(root)) {
|
|
64
|
+
if (!s || !s.who) continue;
|
|
65
|
+
const date = String(s.asked || s.at || '').slice(0, 10);
|
|
66
|
+
out.push({ who: one(s.who, 80), kind: 'signoff', text: one(s.what), ini: s.ini || '', date, source: s.source || 'sign-off ' + s.id });
|
|
67
|
+
if (s.state === 'answered' && s.answer) out.push({ who: one(s.who, 80), kind: 'answer', text: one(s.answer), ini: s.ini || '', date: String(s.answeredAt || '').slice(0, 10) || date, source: s.answerSource || 'sign-off ' + s.id });
|
|
68
|
+
}
|
|
69
|
+
for (const e of decisionsOf(root)) {
|
|
70
|
+
const w = e && e.against ? whoOf(e.against) : null;
|
|
71
|
+
if (!w) continue;
|
|
72
|
+
out.push({ who: w.who, kind: 'objection', text: w.text, ini: e.initiative || '', date: e.date || '', source: 'decision ' + e.id, decided: one(e.decided, 160) });
|
|
73
|
+
}
|
|
74
|
+
return out.sort((a, b) => String(a.date).localeCompare(String(b.date)));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function approvers(items) {
|
|
78
|
+
const rows = [];
|
|
79
|
+
for (const it of items || []) {
|
|
80
|
+
const r = rows.find((x) => same(x.who, it.who));
|
|
81
|
+
if (r) { r.n++; if (String(it.date) > String(r.last)) r.last = it.date; if (it.who.length > r.who.length) r.who = it.who; }
|
|
82
|
+
else rows.push({ who: it.who, n: 1, last: it.date });
|
|
83
|
+
}
|
|
84
|
+
return rows.sort((a, b) => b.n - a.n || String(b.last).localeCompare(String(a.last)) || a.who.localeCompare(b.who));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function historyOf(items, who, { except } = {}) {
|
|
88
|
+
return (items || []).filter((it) => same(it.who, who) && (!except || it.ini !== except))
|
|
89
|
+
.sort((a, b) => String(b.date).localeCompare(String(a.date)));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function briefOf(root, ini, { items } = {}) {
|
|
93
|
+
const all = items || itemsOf(root);
|
|
94
|
+
const open = signoffsOf(path.resolve(root)).filter((s) => s.ini === ini && s.state === 'open');
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const s of open) {
|
|
97
|
+
const past = historyOf(all, s.who, { except: ini }).slice(0, MAX_PAST);
|
|
98
|
+
if (past.length) out.push({ who: s.who, what: s.what, due: s.due || null, past });
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The health number: open sign-offs (any initiative) whose approver has at least one item on other work. */
|
|
104
|
+
function countBriefed(root) {
|
|
105
|
+
const all = itemsOf(root);
|
|
106
|
+
const open = signoffsOf(path.resolve(root)).filter((s) => s.state === 'open');
|
|
107
|
+
const briefed = open.filter((s) => historyOf(all, s.who, { except: s.ini }).length > 0).length;
|
|
108
|
+
return { open: open.length, briefed, approvers: approvers(all).length };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = { MAX_PAST, TAG, whoOf, same, itemsOf, approvers, historyOf, briefOf, countBriefed };
|
|
112
|
+
|
|
113
|
+
if (require.main === module) {
|
|
114
|
+
const a = process.argv.slice(2);
|
|
115
|
+
if (a[0] !== 'count') { console.error('usage: node lib/approver-memory.js count <root>'); process.exit(2); }
|
|
116
|
+
const C = countBriefed(path.resolve(a[1] || '.'));
|
|
117
|
+
console.log(`${TAG} ${C.briefed} of ${C.open} open sign-offs have an approver with past asks (${C.approvers} approvers known)`);
|
|
118
|
+
console.log(String(C.briefed));
|
|
119
|
+
}
|
|
@@ -171,6 +171,7 @@ const JOBS = Object.freeze([
|
|
|
171
171
|
q('meeting-prewarm', 'lib/live-round-meeting.js', ['<runtime>/idle-lab/meeting-prewarm.jsonl'], [props, 'calendar', '<runtime>/meeting-material.jsonl'], 'round 1 itself is filed by lib/live-round.js (W1)'),
|
|
172
172
|
ai('past-repeat', 'lib/past-repeat.js', [props], ['repo:DECISIONS.md']),
|
|
173
173
|
ai('report-readers', 'lib/report-readers.js', [props, '<runtime>/spec-critic.jsonl'], ['report drafts']), // report-reader-review: each report draft read as the CFO, the engineer and the sceptic
|
|
174
|
+
ai('report-translate', 'lib/report-translate.js', [], ['report drafts', 'report definitions']), // report-reader-language: a translated copy beside each draft, numbers and names checked
|
|
174
175
|
ai('decision-memory', 'lib/decision-memory.js', [props], ['repo:DECISIONS.md']),
|
|
175
176
|
ai('outcomes', 'lib/outcome-props.js', [props, '<state>/outcome-runs.jsonl'], ['initiative records', 'repo:planning/runs/outcome_checks.jsonl', '<state>/metric-reads.jsonl']),
|
|
176
177
|
ai('descriptions', 'lib/description-props.js', [props], ['initiative records']),
|
|
@@ -163,6 +163,9 @@ const VERBS = Object.freeze({
|
|
|
163
163
|
// Not a pm-os-absorb verb (run: null): initiative decision-journal-outcome-checks added it through the same table.
|
|
164
164
|
decisions: Object.freeze({ module: 'decisions-cli.js', run: null, guide: 'cli.md',
|
|
165
165
|
help: 'pmos decisions add|list|show|check|record — a decision journal: what you decided, what you expect, a date to check, and how your calls turned out (pmos decisions help)' }),
|
|
166
|
+
// Not a pm-os-absorb verb (run: null): initiative approver-memory (bet A190) added it through the same table.
|
|
167
|
+
approver: Object.freeze({ module: 'approver-cli.js', run: null, guide: 'cli.md',
|
|
168
|
+
help: 'pmos approver list|show|brief — what each approver asked or objected to before, from the sign-offs and the decision journal, before the next sign-off (pmos approver help)' }),
|
|
166
169
|
// Not a pm-os-absorb verb (run: null): initiative balance-meter (bet A448) added it through the same table.
|
|
167
170
|
balance: Object.freeze({ module: 'balance-cli.js', run: null, guide: 'cli.md',
|
|
168
171
|
help: 'pmos balance show — the mix of a list in one line: feature, fix, debt, discovery, or with and without an expected outcome, with a note when one kind is over your line (pmos balance help)' }),
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* pmos report definitions [--json] the report definitions (read-only)
|
|
10
10
|
* pmos report setups [--json] the recurring reports (read-only)
|
|
11
11
|
* pmos report finder <weekly|off> the PM's: how often PMOS looks for reports you send (also: finder source <name> <on|off>)
|
|
12
|
+
* pmos report language <cadence> "<Language>[ for <reader>]" [--off] who reads it in another language (lib/report-translate.js; agent-allowed)
|
|
12
13
|
*
|
|
13
14
|
* `draft` is the script with no model (R22.1): lib/report-draft.js folds the ledgers since the last issue and writes
|
|
14
15
|
* every number into `<state>/reports/<cadence>/<slot>.md`, with one empty note marker per block. It refuses a slot that
|
|
@@ -37,7 +38,7 @@ const actorLib = require('./actor.js');
|
|
|
37
38
|
const RS = require('./report-setups.js');
|
|
38
39
|
const { parseArgs } = require('./schedule-cli');
|
|
39
40
|
|
|
40
|
-
const COMMANDS = { report: ['make', 'read', 'find', 'write', 'check', 'rule', 'draft', 'issue', 'list', 'propose', 'definitions', 'setups', 'finder', 'library'] };
|
|
41
|
+
const COMMANDS = { report: ['make', 'read', 'find', 'write', 'check', 'rule', 'draft', 'issue', 'list', 'propose', 'definitions', 'setups', 'finder', 'library', 'language'] };
|
|
41
42
|
const USAGE = [
|
|
42
43
|
'usage: pmos report make|read|find|write|check|rule — the report engine: brief, read, find, answer, render (any report, any shape)',
|
|
43
44
|
' pmos report make <id> [--ask "<the question>"] [--readers "<who>"] [--source <kind:ref>,…] [--template <id>] [--slot <date>]',
|
|
@@ -74,12 +75,15 @@ const USAGE = [
|
|
|
74
75
|
' Show the recurring reports (read-only).',
|
|
75
76
|
' pmos report finder <weekly|off> | pmos report finder source <calendar|slack|mail|drive> <on|off>',
|
|
76
77
|
' Only the PM can change how PMOS looks for the reports you send (default weekly; mail is off until you turn it on).',
|
|
78
|
+
' pmos report language <cadence> "<Language>[ for <reader>]" [--off]',
|
|
79
|
+
' A reader who reads the report in another language. After each draft PMOS writes a translated copy beside it',
|
|
80
|
+
' (<slot>.<code>.md) with every number and name unchanged; --off stops it. Nothing is sent. With no language: the list.',
|
|
77
81
|
' every command: [--json] [--root <dir>]. The cadence is the report skill id without "report-", for example biweekly.',
|
|
78
82
|
];
|
|
79
|
-
const BOOL = new Set(['json', 'redraft', 'help']);
|
|
83
|
+
const BOOL = new Set(['json', 'redraft', 'help', 'off']);
|
|
80
84
|
const VALUE = new Set(['now', 'root', 'ask', 'readers', 'source', 'slot', 'from', 'out', 'template']);
|
|
81
85
|
const ALLOWED = { make: ['json', 'now', 'root', 'ask', 'readers', 'source', 'slot', 'template'], read: ['json', 'now', 'root', 'slot', 'from', 'source'], find: ['json', 'now', 'root', 'slot', 'from'],
|
|
82
|
-
write: ['json', 'now', 'root', 'slot', 'from'], check: ['json', 'root', 'slot'], rule: ['json', 'root'], draft: ['json', 'redraft', 'now', 'root'], issue: ['root'], list: ['json', 'root'], propose: ['json', 'root'], definitions: ['json', 'root'], setups: ['json', 'root'], finder: ['json', 'root'], library: ['json', 'out', 'template'] };
|
|
86
|
+
write: ['json', 'now', 'root', 'slot', 'from'], check: ['json', 'root', 'slot'], rule: ['json', 'root'], draft: ['json', 'redraft', 'now', 'root'], issue: ['root'], list: ['json', 'root'], propose: ['json', 'root'], definitions: ['json', 'root'], setups: ['json', 'root'], finder: ['json', 'root'], language: ['json', 'root', 'off'], library: ['json', 'out', 'template'] };
|
|
83
87
|
const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
84
88
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
85
89
|
|
|
@@ -166,7 +170,7 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
|
|
|
166
170
|
return 0;
|
|
167
171
|
}
|
|
168
172
|
if (['make', 'read', 'find', 'write', 'check', 'rule'].includes(verb)) return engineVerb(verb, { pos, flags, root, json, say, fail, isTTY, env, stdin, now });
|
|
169
|
-
if (verb === 'definitions' || verb === 'setups' || verb === 'propose' || verb === 'finder') return reportWorkspace(verb, { pos, flags, root, json, say, fail, cwd, isTTY, env, stdin, now });
|
|
173
|
+
if (verb === 'definitions' || verb === 'setups' || verb === 'propose' || verb === 'finder' || verb === 'language') return reportWorkspace(verb, { pos, flags, root, json, say, fail, cwd, isTTY, env, stdin, now });
|
|
170
174
|
|
|
171
175
|
const [cadence, slot] = pos;
|
|
172
176
|
if (!cadence || !CADENCE_RE.test(cadence) || pos.length > 2) { say(`usage: pmos report ${verb} <cadence> ${verb === 'issue' ? '<slot>' : '[<slot>]'}`); return 2; }
|
|
@@ -312,6 +316,22 @@ async function engineVerb(verb, { pos, flags, root, json, say, fail, isTTY, env,
|
|
|
312
316
|
function reportWorkspace(verb, { pos, flags, root, json, say, fail, isTTY, env, stdin, now }) {
|
|
313
317
|
const E = env === undefined ? process.env : env;
|
|
314
318
|
const stamp = now == null ? undefined : now;
|
|
319
|
+
if (verb === 'language') {
|
|
320
|
+
const RT = require('./report-translate.js');
|
|
321
|
+
const cadence = pos[0], entry = pos.slice(1).join(' ').trim();
|
|
322
|
+
if (!cadence || !CADENCE_RE.test(cadence)) { say('usage: pmos report language <cadence> "<Language>[ for <reader>]" [--off]'); return 2; }
|
|
323
|
+
if (!entry) {
|
|
324
|
+
const list = RT.definitionLanguages(root, cadence);
|
|
325
|
+
if (json) { say(JSON.stringify({ ok: true, cadence, languages: list })); return 0; }
|
|
326
|
+
say(list.length ? list.map((x) => `${x.language}${x.reader ? ' for ' + x.reader : ''}`).join('\n') : `The ${cadence} report is read in one language.`);
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
const r = RT.setLanguage(root, cadence, entry, { off: !!flags.off });
|
|
330
|
+
if (!r.ok) return fail(r.error);
|
|
331
|
+
if (json) { say(JSON.stringify(r)); return 0; }
|
|
332
|
+
say(`✓ ${r.path}: ${r.languages.length ? 'also in ' + r.languages.map((x) => `${x.language}${x.reader ? ' for ' + x.reader : ''}`).join(', ') : 'one language only'}. The next draft writes the copies; nothing is sent.`);
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
315
335
|
if (verb === 'definitions') {
|
|
316
336
|
const defs = RS.definitionsOf(root);
|
|
317
337
|
if (json) { say(JSON.stringify({ ok: true, definitions: defs })); return 0; }
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* report-translate.js — a report in each reader's language (initiative report-reader-language, idea A111).
|
|
3
|
+
*
|
|
4
|
+
* WHY. A PM whose readers read different languages writes the report once and translates it by hand, or sends it in a language
|
|
5
|
+
* some readers read slowly. A hand translation is where a number or a name goes wrong. PMOS acts by itself: no run button.
|
|
6
|
+
*
|
|
7
|
+
* WHO READS WHAT. A report's definition (<state>/reports/definitions/<cadence>.md) may carry `languages: "Indonesian for Dita; Japanese"`:
|
|
8
|
+
* one language per reader, the reader optional. `pmos report language <cadence> "<Language>[ for <reader>]" [--off]` adds or removes one
|
|
9
|
+
* entry (the PM at a terminal, or the chat's agent). A language not in LANGS is skipped.
|
|
10
|
+
*
|
|
11
|
+
* WHEN IT RUNS. After every report draft this process writes (lib/report-draft.js onDraftWritten: Draft now, Redraft, a schedule), one
|
|
12
|
+
* read-only run per language through the design critic's ask path (lib/design-critic.js askVia: the normal `claude -p` session, kind ask).
|
|
13
|
+
* The draft's text is in the prompt. A copy whose `source_sha` is the draft's text already starts no run. Off: the AI switch for job
|
|
14
|
+
* `report-translate` (`pmos ai off report-translate`, or every AI job off), or the design critic's switch.
|
|
15
|
+
*
|
|
16
|
+
* WHAT IT WRITES. <state>/reports/<cadence>/<slot>.<code>.md beside the draft: the draft's frontmatter plus `translation_of`, `language`,
|
|
17
|
+
* `reader` and `source_sha`, then one line saying it is a translation, for whom, and that numbers and names are unchanged, then the
|
|
18
|
+
* translated body. The copy is written ONLY when keeps() finds every number and every name of the original in it: numbers are runs of
|
|
19
|
+
* digits with their decimals (counted), names are initiative ids, note markers, links, and acronyms or codes (two capitals, or a capital
|
|
20
|
+
* and a digit). Otherwise nothing is written and the server log says why. A copy is not a cycle: the report list reads <slot>.md only.
|
|
21
|
+
* Nothing is sent anywhere.
|
|
22
|
+
*
|
|
23
|
+
* LANGS · languagesOf(value) PURE → [{ language, code, reader }]
|
|
24
|
+
* bodyOf(text) PURE → { fm, body } · shaOf(body) PURE
|
|
25
|
+
* namesOf(body) PURE → { numbers: Map<string, count>, names: Set<string> } · keeps(orig, copy) PURE → { ok, why? }
|
|
26
|
+
* promptOf({ body, language, reader }) PURE · answerOf(answer) PURE → markdown | null
|
|
27
|
+
* copyPath(rel, code) PURE · copyText({ fm, body, rel, language, code, reader, sha }) PURE → the file
|
|
28
|
+
* alsoOf(root, rel) → [{ code, language, reader, path }] the copies on disk beside a draft (the ⋯ menu's Also in …)
|
|
29
|
+
* definitionLanguages(root, cadence) → [{ language, code, reader }] · setLanguage(root, cadence, entry, { off }) → { ok, languages, path } | { ok:false, error }
|
|
30
|
+
* translate({ root, rel, ask, runtime?, env?, guard? }) → Promise<{ written, refused, skipped, off? }>
|
|
31
|
+
* attach(ctxFactory) hook onDraftWritten once; ctx: { workspaceList, runtimeDir, spawnScheduled|spawnSession }
|
|
32
|
+
*/
|
|
33
|
+
const fs = require('fs');
|
|
34
|
+
const path = require('path');
|
|
35
|
+
const crypto = require('crypto');
|
|
36
|
+
|
|
37
|
+
const JOB = 'report-translate';
|
|
38
|
+
const ORIGIN = 'briefing-ask:report-translate:';
|
|
39
|
+
const MAX_CHARS = 60000;
|
|
40
|
+
const LANGS = Object.freeze({
|
|
41
|
+
en: 'English', id: 'Indonesian', ms: 'Malay', zh: 'Chinese', ja: 'Japanese', ko: 'Korean', th: 'Thai', vi: 'Vietnamese', tl: 'Filipino',
|
|
42
|
+
hi: 'Hindi', ta: 'Tamil', ar: 'Arabic', es: 'Spanish', fr: 'French', de: 'German', pt: 'Portuguese', it: 'Italian', nl: 'Dutch',
|
|
43
|
+
});
|
|
44
|
+
const ALIASES = Object.freeze({ 'bahasa indonesia': 'id', bahasa: 'id', 'bahasa melayu': 'ms', mandarin: 'zh', tagalog: 'tl' });
|
|
45
|
+
const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
46
|
+
const shaOf = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 16);
|
|
47
|
+
|
|
48
|
+
/** PURE. One language name or code → its code, or null. */
|
|
49
|
+
function codeOf(word) {
|
|
50
|
+
const w = String(word || '').trim().toLowerCase();
|
|
51
|
+
if (!w) return null;
|
|
52
|
+
if (LANGS[w]) return w;
|
|
53
|
+
if (ALIASES[w]) return ALIASES[w];
|
|
54
|
+
const hit = Object.entries(LANGS).find(([, n]) => n.toLowerCase() === w);
|
|
55
|
+
return hit ? hit[0] : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** PURE. `"Indonesian for Dita; Japanese"`, or a list → [{ language, code, reader }], one per code (the first reader wins). */
|
|
59
|
+
function languagesOf(value) {
|
|
60
|
+
const parts = (Array.isArray(value) ? value : String(value == null ? '' : value).split(/[;,]/)).map((x) => String(x).trim()).filter(Boolean);
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const p of parts) {
|
|
63
|
+
const m = /^(.+?)(?:\s+for\s+(.+))?$/i.exec(p);
|
|
64
|
+
const code = m && codeOf(m[1]);
|
|
65
|
+
if (!code || code === 'en' || out.some((x) => x.code === code)) continue;
|
|
66
|
+
out.push({ language: LANGS[code], code, reader: m[2] ? one(m[2], 60) : '' });
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
const entryOf = (x) => x.language + (x.reader ? ' for ' + x.reader : '');
|
|
71
|
+
|
|
72
|
+
/** PURE. A file's frontmatter block (with its fences) and its body. */
|
|
73
|
+
function bodyOf(text) {
|
|
74
|
+
const t = String(text == null ? '' : text);
|
|
75
|
+
const m = /^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/.exec(t);
|
|
76
|
+
return m ? { fm: m[0], body: t.slice(m[0].length) } : { fm: '', body: t };
|
|
77
|
+
}
|
|
78
|
+
function fmMap(fm) {
|
|
79
|
+
const map = {};
|
|
80
|
+
for (const l of String(fm || '').split(/\r?\n/)) { const kv = /^([A-Za-z_][\w-]*):\s*(.*?)\s*$/.exec(l); if (kv) map[kv[1]] = kv[2].replace(/^["']|["']$/g, ''); }
|
|
81
|
+
return map;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** PURE. What a translation must keep: numbers (counted) and names. */
|
|
85
|
+
function namesOf(body) {
|
|
86
|
+
const t = String(body || '');
|
|
87
|
+
const numbers = new Map();
|
|
88
|
+
for (const m of t.matchAll(/\d+(?:[.,]\d+)*/g)) {
|
|
89
|
+
const k = m[0].replace(/,/g, '.');
|
|
90
|
+
numbers.set(k, (numbers.get(k) || 0) + 1);
|
|
91
|
+
}
|
|
92
|
+
const names = new Set();
|
|
93
|
+
for (const m of t.matchAll(/<!--\s*\/?pmos:[^>]*-->/g)) names.add(m[0].replace(/\s+/g, ' '));
|
|
94
|
+
for (const m of t.matchAll(/^#{2,4}\s+.*\(([A-Za-z0-9._-]{1,80})\)\s*$/gm)) names.add('(' + m[1] + ')');
|
|
95
|
+
for (const m of t.matchAll(/\]\(([^)\s]+)\)/g)) names.add('](' + m[1] + ')');
|
|
96
|
+
for (const m of t.matchAll(/https?:\/\/[^\s)>\]]+/g)) names.add(m[0]);
|
|
97
|
+
for (const m of t.matchAll(/\b(?:[A-Z][A-Za-z0-9-]*[A-Z0-9][A-Za-z0-9-]*)\b/g)) if (/[A-Z].*[A-Z0-9]/.test(m[0]) && !/^\d/.test(m[0])) names.add(m[0]);
|
|
98
|
+
return { numbers, names };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** PURE. Does the copy keep every number and every name of the original? */
|
|
102
|
+
function keeps(orig, copy) {
|
|
103
|
+
const a = namesOf(orig), b = namesOf(copy);
|
|
104
|
+
for (const [n, c] of a.numbers) if ((b.numbers.get(n) || 0) < c) return { ok: false, why: `the number ${n} is not in the copy as often as in the original` };
|
|
105
|
+
const flat = String(copy || '').replace(/\s+/g, ' ');
|
|
106
|
+
for (const n of a.names) if (!flat.includes(n)) return { ok: false, why: `the name ${n} is not in the copy` };
|
|
107
|
+
return { ok: true };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** PURE. The run's prompt. */
|
|
111
|
+
function promptOf({ body, language, reader = '' } = {}) {
|
|
112
|
+
return [
|
|
113
|
+
`Translate this report into ${language}${reader ? ` for ${reader}` : ''}. Do not run any tool and do not read any file: the report is below.`,
|
|
114
|
+
'Translate the words only. Keep every number, date digit, percentage, initiative id in brackets, person and product name, acronym, link and',
|
|
115
|
+
'Markdown mark exactly as it is. Keep every line that starts with <!-- exactly as it is. Keep the same headings, lists and table rows, in the same order.',
|
|
116
|
+
'Answer with the translated report in one fenced block that starts with ```markdown and nothing else.',
|
|
117
|
+
'', '```markdown', String(body || '').slice(0, MAX_CHARS), '```',
|
|
118
|
+
].join('\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** PURE. The translated body from the answer, or null. */
|
|
122
|
+
function answerOf(answer) {
|
|
123
|
+
const t = String(answer == null ? '' : answer);
|
|
124
|
+
const m = /```(?:markdown|md)?[^\n]*\n([\s\S]*?)\n```\s*$/i.exec(t.trim()) || /```(?:markdown|md)[^\n]*\n([\s\S]*?)\n```/i.exec(t);
|
|
125
|
+
const out = m ? m[1] : '';
|
|
126
|
+
return out.trim() ? out.replace(/\s+$/, '') + '\n' : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** PURE. reports/<cadence>/<slot>.md → reports/<cadence>/<slot>.<code>.md */
|
|
130
|
+
const copyPath = (rel, code) => String(rel).replace(/\.md$/, '') + '.' + code + '.md';
|
|
131
|
+
|
|
132
|
+
/** PURE. The copy's file. */
|
|
133
|
+
function copyText({ fm = '', body = '', rel = '', language = '', code = '', reader = '', sha = '' } = {}) {
|
|
134
|
+
const q = (v) => `"${String(v).replace(/["\\]/g, "'")}"`;
|
|
135
|
+
const extra = [`translation_of: ${q(rel)}`, `language: ${code}`, ...(reader ? [`reader: ${q(reader)}`] : []), `source_sha: ${sha}`];
|
|
136
|
+
const head = fm
|
|
137
|
+
? fm.replace(/\r?\n---(\r?\n|$)$/, '\n' + extra.join('\n') + '\n---\n').replace(/^(title:\s*)(["']?)(.*?)\2\s*$/m, (all, k, qt, v) => `${k}${q(v + ' (' + language + ')')}`)
|
|
138
|
+
: ['---', 'type: Reference', `title: ${q(path.basename(rel) + ' (' + language + ')')}`, ...extra, '---', ''].join('\n');
|
|
139
|
+
const note = `> Translation of ${path.basename(rel)} into ${language}${reader ? ' for ' + reader : ''}. PMOS checked that numbers and names are unchanged from the original.`;
|
|
140
|
+
return head + '\n' + note + '\n\n' + String(body).replace(/^\s+/, '');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function stateRelOf(rel) { const m = /^(.*)\/reports\/([a-z][a-z0-9-]{0,39})\/(\d{4}-\d{2}-\d{2})\.md$/.exec(String(rel)); return m ? { state: m[1], cadence: m[2], slot: m[3] } : null; }
|
|
144
|
+
function defFile(root, state, cadence) { return path.join(path.resolve(String(root)), state, 'reports', 'definitions', cadence + '.md'); }
|
|
145
|
+
|
|
146
|
+
/** The languages a report's definition names. */
|
|
147
|
+
function definitionLanguages(root, cadence, state = null) {
|
|
148
|
+
let st = state;
|
|
149
|
+
if (!st) { try { st = require('./report-draft.js').stateRel(root); } catch { return []; } }
|
|
150
|
+
let t = ''; try { t = fs.readFileSync(defFile(root, st, cadence), 'utf8'); } catch { return []; }
|
|
151
|
+
return languagesOf(fmMap(bodyOf(t).fm).languages || '');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Add or remove one `<Language>[ for <reader>]` entry on a definition's `languages:` line. */
|
|
155
|
+
function setLanguage(root, cadence, entry, { off = false, state = null } = {}) {
|
|
156
|
+
if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(cadence || ''))) return { ok: false, error: 'the cadence is a report id, for example weekly' };
|
|
157
|
+
const want = languagesOf(entry || '');
|
|
158
|
+
if (!want.length) return { ok: false, error: `${JSON.stringify(String(entry || ''))} names no language PMOS knows (${Object.values(LANGS).filter((n) => n !== 'English').join(', ')})` };
|
|
159
|
+
let st = state;
|
|
160
|
+
if (!st) { try { st = require('./report-draft.js').stateRel(root); } catch (e) { return { ok: false, error: String((e && e.message) || e).slice(0, 160) }; } }
|
|
161
|
+
const file = defFile(root, st, cadence);
|
|
162
|
+
let t; try { t = fs.readFileSync(file, 'utf8'); } catch { return { ok: false, error: `the report ${cadence} has no definition (${path.relative(path.resolve(String(root)), file)}); set the report up first` }; }
|
|
163
|
+
const { fm, body } = bodyOf(t);
|
|
164
|
+
if (!fm) return { ok: false, error: 'the definition has no frontmatter' };
|
|
165
|
+
const cur = languagesOf(fmMap(fm).languages || '');
|
|
166
|
+
const next = off ? cur.filter((x) => !want.some((w) => w.code === x.code)) : [...cur.filter((x) => !want.some((w) => w.code === x.code)), ...want];
|
|
167
|
+
const line = next.length ? `languages: "${next.map(entryOf).join('; ').replace(/["\\]/g, "'")}"` : '';
|
|
168
|
+
let head = /^languages:.*$/m.test(fm) ? fm.replace(/^languages:.*\r?\n?/m, line ? line + '\n' : '') : (line ? fm.replace(/\r?\n---(\r?\n|$)$/, '\n' + line + '\n---\n') : fm);
|
|
169
|
+
fs.writeFileSync(file, head + body);
|
|
170
|
+
return { ok: true, languages: next, path: path.relative(path.resolve(String(root)), file).split(path.sep).join('/') };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The translated copies on disk beside a draft. */
|
|
174
|
+
function alsoOf(root, rel) {
|
|
175
|
+
const abs = path.resolve(String(root), String(rel || ''));
|
|
176
|
+
const dir = path.dirname(abs), base = path.basename(abs).replace(/\.md$/, '');
|
|
177
|
+
let names = []; try { names = fs.readdirSync(dir); } catch { return []; }
|
|
178
|
+
const out = [];
|
|
179
|
+
for (const n of names.sort()) {
|
|
180
|
+
const m = /^(.+)\.([a-z]{2})\.md$/.exec(n);
|
|
181
|
+
if (!m || m[1] !== base || !LANGS[m[2]]) continue;
|
|
182
|
+
let fm = {}; try { fm = fmMap(bodyOf(fs.readFileSync(path.join(dir, n), 'utf8')).fm); } catch { continue; }
|
|
183
|
+
if (!fm.translation_of) continue;
|
|
184
|
+
out.push({ code: m[2], language: LANGS[m[2]], reader: fm.reader || '', path: path.posix.join(path.posix.dirname(String(rel)), n) });
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function guardOf() { try { return require('./ai-guard.js'); } catch { return null; } }
|
|
190
|
+
|
|
191
|
+
/** One draft → one copy per language its definition names. */
|
|
192
|
+
async function translate({ root, rel, ask, runtime = null, env = process.env, guard = guardOf(), langs = null } = {}) {
|
|
193
|
+
const res = { written: [], refused: [], skipped: [] };
|
|
194
|
+
try { if (require('./design-critic.js').off(env)) return { ...res, off: 'the critic runs are off' }; } catch { /* no switch */ }
|
|
195
|
+
if (guard) { const stop = guard.off(JOB, { env, settingsDir: runtime || null }); if (stop) return { ...res, off: stop }; }
|
|
196
|
+
const at = stateRelOf(rel);
|
|
197
|
+
if (!at) return { ...res, off: 'not a cadence draft' };
|
|
198
|
+
const list = langs || definitionLanguages(root, at.cadence, at.state);
|
|
199
|
+
if (!list.length) return { ...res, off: 'the definition names no other language' };
|
|
200
|
+
if (typeof ask !== 'function') return { ...res, off: 'no run can start here' };
|
|
201
|
+
let raw; try { raw = fs.readFileSync(path.resolve(String(root), rel), 'utf8'); } catch { return { ...res, off: 'the draft could not be read' }; }
|
|
202
|
+
const { fm, body } = bodyOf(raw);
|
|
203
|
+
const sha = shaOf(body);
|
|
204
|
+
for (const L of list) {
|
|
205
|
+
const out = copyPath(rel, L.code), abs = path.resolve(String(root), out);
|
|
206
|
+
let prev = ''; try { prev = fs.readFileSync(abs, 'utf8'); } catch { prev = ''; }
|
|
207
|
+
if (prev && fmMap(bodyOf(prev).fm).source_sha === sha) { res.skipped.push({ code: L.code, why: 'this text was translated already' }); continue; }
|
|
208
|
+
const answer = await ask(promptOf({ body, language: L.language, reader: L.reader }), { key: at.cadence + '-' + at.slot + '-' + L.code });
|
|
209
|
+
const tr = answerOf(answer);
|
|
210
|
+
if (!tr) { res.refused.push({ code: L.code, why: answer == null ? 'the run did not answer' : 'the answer held no translated report' }); continue; }
|
|
211
|
+
const k = keeps(body, tr);
|
|
212
|
+
if (!k.ok) { res.refused.push({ code: L.code, why: k.why }); continue; }
|
|
213
|
+
fs.writeFileSync(abs, copyText({ fm, body: tr, rel, language: L.language, code: L.code, reader: L.reader, sha }));
|
|
214
|
+
res.written.push({ code: L.code, path: out });
|
|
215
|
+
}
|
|
216
|
+
for (const r of res.refused) console.log(`[report-translate] ${rel} ${r.code}: not written (${r.why})`);
|
|
217
|
+
if (res.written.length) console.log(`[report-translate] ${rel}: ${res.written.map((w) => w.code).join(', ')} written`);
|
|
218
|
+
return res;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
let attached = false;
|
|
222
|
+
/** server.js calls this once: every draft this process writes is translated for its readers, in the background. */
|
|
223
|
+
function attach(ctxFactory) {
|
|
224
|
+
if (attached || typeof ctxFactory !== 'function') return;
|
|
225
|
+
attached = true;
|
|
226
|
+
require('./report-draft.js').onDraftWritten(({ root, path: rel }) => {
|
|
227
|
+
setImmediate(() => {
|
|
228
|
+
let ctx = null; try { ctx = ctxFactory(); } catch { ctx = null; }
|
|
229
|
+
const spawn = ctx && (ctx.spawnScheduled || ctx.spawnSession);
|
|
230
|
+
if (typeof spawn !== 'function') return;
|
|
231
|
+
const ask = require('./design-critic.js').askVia(spawn, { name: 'report translation', origin: ORIGIN });
|
|
232
|
+
translate({ root: path.resolve(String(root)), rel, ask, runtime: ctx.runtimeDir || null })
|
|
233
|
+
.catch((e) => console.log(`[report-translate] ${rel}: not run (${one(e && e.message, 160)})`));
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
module.exports = { JOB, ORIGIN, LANGS, codeOf, languagesOf, bodyOf, shaOf, namesOf, keeps, promptOf, answerOf, copyPath, copyText, alsoOf, definitionLanguages, setLanguage, translate, attach };
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* GET /api/report?ws= the report files of the repository, drafts and issued, of every cadence,
|
|
5
5
|
* with the `sig` the page watches (public/pm/sig-watch.js, 10 s)
|
|
6
|
-
* GET /api/report/draft?ws=&cadence=&slot= one report file as it is now: its markdown, its note texts, its blob sha
|
|
6
|
+
* GET /api/report/draft?ws=&cadence=&slot= one report file as it is now: its markdown, its note texts, its blob sha, and `also`:
|
|
7
|
+
* the translated copies beside it (lib/report-translate.js alsoOf)
|
|
7
8
|
* POST /api/report/draft { ws, cadence, slot?, redraft? } Draft now, and Redraft (the notes are kept)
|
|
8
9
|
* POST /api/report/note { ws, cadence, slot, id, text } one note, by initiative id (or report.headline, report.asks, report.changelog)
|
|
9
10
|
* POST /api/report/issue { ws, cadence, slot, sha } Issue: the PM's act (R25)
|
|
@@ -29,6 +30,8 @@ const actorLib = require('./actor.js');
|
|
|
29
30
|
const RD = require('./report-draft.js');
|
|
30
31
|
const issues = require('./issues.js');
|
|
31
32
|
const RN = require('./report-needs.js');
|
|
33
|
+
/** The translated copies beside a draft; none when the module is not installed. */
|
|
34
|
+
const alsoOf = (root, rel) => { try { return require('./report-translate.js').alsoOf(root, rel); } catch { return []; } };
|
|
32
35
|
|
|
33
36
|
const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
34
37
|
const SLOT_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -97,6 +100,7 @@ async function handle(req, res, url, ctx) {
|
|
|
97
100
|
ctx.json(res, {
|
|
98
101
|
ok: true, ws: w.id, sig: list.sig, cadence: cs.cadence, slot: cs.slot, exists: true, path: hit.path, status: hit.status,
|
|
99
102
|
sha: RN.blobSha(file.buf), markdown: file.text, notes: RD.readNotes(file.text), issued: pageReport(hit).issued, edited: hit.edited, flags: pageFlags(list.flags),
|
|
103
|
+
also: alsoOf(w.root, hit.path),
|
|
100
104
|
});
|
|
101
105
|
return true;
|
|
102
106
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.818.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.818.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -41,6 +41,13 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
|
|
|
41
41
|
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
42
42
|
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
43
43
|
await T.waitForServer(BASE);
|
|
44
|
+
// Home stays on "Reading your day." until the board's first read lands, and that read scans the real checkout: ~9 s here, more than the
|
|
45
|
+
// 15 s the box gets on a loaded CI runner (ci-dynamic-shards: the pending reads showed only the live stream). Wait for it once, here.
|
|
46
|
+
for (const t0 = Date.now(); Date.now() - t0 < 90000;) {
|
|
47
|
+
const r = await fetch(BASE + '/api/board-premium').then((x) => x.json()).catch(() => null);
|
|
48
|
+
if (r && !(r.state === 'reading' || (r.pending && !r.model))) break;
|
|
49
|
+
await sleep(500);
|
|
50
|
+
}
|
|
44
51
|
browser = await chromium.launch({ executablePath: exe });
|
|
45
52
|
|
|
46
53
|
const open = async ({ w = 1280, h = 900, scheme = 'light', url = '/premium-chat.html?about=' + encodeURIComponent(KEY) } = {}) => {
|
|
@@ -48,13 +55,24 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
|
|
|
48
55
|
const page = await ctx.newPage();
|
|
49
56
|
const errors = [], asks = [], st = { session: null, messages: [] };
|
|
50
57
|
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
58
|
+
const failed = []; page.on('response', (r) => { if (r.status() >= 400) failed.push(`${r.status()} ${new URL(r.url()).pathname}`); });
|
|
59
|
+
// the reads still open when the box never shows: names the slow route rather than only the timeout
|
|
60
|
+
const pending = new Map(); page.on('request', (rq) => pending.set(rq, Date.now()));
|
|
61
|
+
const done = (rq) => pending.delete(rq); page.on('requestfinished', done); page.on('requestfailed', done);
|
|
51
62
|
if (process.env.ATT_DEBUG) page.on('request', (rq) => { if (/chat-file/.test(rq.url())) console.log('REQ', rq.method(), rq.url()); });
|
|
52
63
|
await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false, ...(st.session ? { session: st.session } : {}) }) }); });
|
|
53
64
|
await page.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'user', messages: st.messages } }));
|
|
54
65
|
await page.route('**/api/sessions', (r) => r.fulfill({ json: { ok: true, sessions: [{ id: 's-term', name: 'A terminal session', origin: '', shown: 'quiet' }] } }));
|
|
55
66
|
await page.goto(BASE + url, { waitUntil: 'domcontentloaded' });
|
|
56
67
|
// on a desktop the chat the address names opens in the popup (home-page-retire): wait until the box shows, not only exists
|
|
57
|
-
|
|
68
|
+
try {
|
|
69
|
+
await page.waitForFunction(() => { const i = document.querySelector('#hmIn'); return !!i && i.getClientRects().length > 0; }, null, { timeout: 15000 });
|
|
70
|
+
} catch (e) {
|
|
71
|
+
// say why the box never showed, so a red run names its cause (ci-dynamic-shards: it timed out on CI only, with nothing logged)
|
|
72
|
+
const seen = await page.evaluate(() => ({ url: location.href, hmIn: !!document.querySelector('#hmIn'), body: (document.body && document.body.innerText || '').slice(0, 400) })).catch((x) => String(x));
|
|
73
|
+
console.log('open: #hmIn never showed —', JSON.stringify({ seen, errors, failed, pending: [...pending].map(([rq, t]) => `${new URL(rq.url()).pathname}${new URL(rq.url()).search} ${Math.round((Date.now() - t) / 1000)}s`) }));
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
58
76
|
return { page, ctx, errors, asks, st };
|
|
59
77
|
};
|
|
60
78
|
const chips = (page) => page.$$eval('#hmFiles .hm-att', (xs) => xs.map((x) => ({ name: x.querySelector('b').textContent, meta: (x.querySelector('em') || {}).textContent || '' })));
|
|
@@ -292,18 +292,20 @@ function cycPop() {
|
|
|
292
292
|
/**
|
|
293
293
|
* What ⋯ holds (canvas note xvMore; OvReport): only what the card does not already show. The bar has the read-as switch, Edit, Present,
|
|
294
294
|
* Share and Download; the folds have the cycles and the Brief; the summary has the one primary. So ⋯ holds Schedule, Start the next cycle
|
|
295
|
-
* (an issued cycle) and, red and last, Discard this draft or Archive this cycle. Each item is { r, label, note, danger } or { sep }; r is the
|
|
295
|
+
* (an issued cycle), Also in <language> (a translated copy on disk) and, red and last, Discard this draft or Archive this cycle. Each item is { r, label, note, danger } or { sep }; r is the
|
|
296
296
|
* press, the same one the panel's own buttons send.
|
|
297
297
|
*/
|
|
298
298
|
export function moreItems(o) {
|
|
299
299
|
if (o.edit || o.archived) return [];
|
|
300
300
|
const L = [], sched = o.schedule && o.schedule !== 'Not scheduled' ? o.schedule.replace(/\s\d{2}:\d{2}$/, '') : '';
|
|
301
301
|
L.push({ r: 'sched', label: 'Schedule', note: sched });
|
|
302
|
+
// a translated copy beside the draft (lib/report-translate.js): one item per language, the reader under it
|
|
303
|
+
for (const a of o.also || []) if (a && a.path && a.language) L.push({ r: 'also|' + a.path, label: 'Also in ' + a.language, note: a.reader ? 'for ' + a.reader : '' });
|
|
302
304
|
if (o.issued) L.push({ r: 'nextcyc', label: 'Start the next cycle' });
|
|
303
305
|
L.push({ sep: true }, o.issued ? { r: 'archive', label: 'Archive this cycle', danger: true } : { r: 'discard', label: 'Discard this draft', danger: true });
|
|
304
306
|
return L;
|
|
305
307
|
}
|
|
306
|
-
const menuOf = () => moreItems({ edit: R.edit, issued: R.issued, archived: R.archived, schedule: R.setup === undefined ? '' : schedLabel(R.setup) });
|
|
308
|
+
const menuOf = () => moreItems({ edit: R.edit, issued: R.issued, archived: R.archived, schedule: R.setup === undefined ? '' : schedLabel(R.setup), also: R.also });
|
|
307
309
|
/** Shell A's ⋯ (open({ more })) reads the list when it opens, so the list is refilled in place as the cycle changes: one array per report. */
|
|
308
310
|
function syncMore() {
|
|
309
311
|
if (!R) return;
|
|
@@ -711,6 +713,7 @@ export function fit(root) { root.querySelectorAll('.vz-fr').forEach((c) => { if
|
|
|
711
713
|
/* ── the presses ── */
|
|
712
714
|
const say = (text, tone) => { R.msg = { text, tone }; draw(); const me = R, m = R.msg; if (tone !== 'bad') setTimeout(() => { if (R === me && R.msg === m) { R.msg = null; draw(); } }, 9000); };
|
|
713
715
|
async function act([k, v], t) {
|
|
716
|
+
if (k === 'also') { const a = (R.also || []).find((x) => x.path === v); return openReport({ path: v, state: 'draft' }, { ws: R.ws, name: R.name + (a ? ' · ' + a.language : ''), cycles: [] }); }
|
|
714
717
|
if (k === 'rv-do' || k === 'rv-no' || k === 'rv-all') return rvAct(k, v);
|
|
715
718
|
if (k === 'ord') return ordAct(v, t.dataset.r.split('|').slice(2).join('|'));
|
|
716
719
|
if (k === 'pop') { R.pop = v || null; return draw(); }
|
|
@@ -1118,10 +1121,11 @@ export async function openReport(row, hand = {}) {
|
|
|
1118
1121
|
vOpen(head());
|
|
1119
1122
|
try { R.text = await textOf('/api/doc?' + q({ ws: R.ws, path: row.path })); R.W = wordsOf(R.text, R.name); if (!hand.name && R.W.title) R.name = R.W.title; } catch (x) { R.err = String((x && x.message) || x); R.W = { title: R.name, sections: [] }; }
|
|
1120
1123
|
if (R !== me) return me;
|
|
1121
|
-
if (
|
|
1122
|
-
const d = await Promise.resolve(pmGet('/api/report/draft?' + q({ cadence: c.cadence, slot: c.slot }))).catch(() => null);
|
|
1124
|
+
if (c.cadence && c.slot) { // the report route names the workspace when the page was opened without one, and the translated copies (Also in …)
|
|
1125
|
+
const d = await Promise.resolve(pmGet('/api/report/draft?' + q({ ...(R.ws ? { ws: R.ws } : {}), cadence: c.cadence, slot: c.slot }))).catch(() => null);
|
|
1123
1126
|
if (R !== me) return me;
|
|
1124
|
-
if (d && d.ws) R.ws = d.ws;
|
|
1127
|
+
if (!R.ws && d && d.ws) R.ws = d.ws;
|
|
1128
|
+
R.also = d && Array.isArray(d.also) ? d.also : [];
|
|
1125
1129
|
}
|
|
1126
1130
|
await Promise.all([readCycle(), readSetup(), readShares()]);
|
|
1127
1131
|
if (R !== me) return me;
|
package/workspace/server.js
CHANGED
|
@@ -2943,6 +2943,8 @@ try { require('./lib/routes-report-design.js').attach(reportDesignCtx); } catch
|
|
|
2943
2943
|
// report-reader-review: every report draft this process writes is read once as the CFO, the engineer and the sceptic; their questions go under the
|
|
2944
2944
|
// ✦ of the initiatives the report covers (lib/report-readers.js, through lib/ai-guard.js). The read runs through spawnScheduled (the capacity governor).
|
|
2945
2945
|
try { require('./lib/report-readers.js').attach(() => ({ ...reportDesignCtx(), stateDirFor })); } catch { /* a checkout without the module still starts */ }
|
|
2946
|
+
// Each draft in each reader's language: a translated copy beside it when its definition names a `languages:` line (lib/report-translate.js).
|
|
2947
|
+
try { require('./lib/report-translate.js').attach(() => reportDesignCtx()); } catch { /* a checkout without the module still starts */ }
|
|
2946
2948
|
// report-structure: the structure jobs, the source checks (interactive sessions started like Work's approved steps, STEP_FLAGS) and the draft gate.
|
|
2947
2949
|
// The tick collects check answers and starts the drafts that waited for a failing source (4 hours, then without it).
|
|
2948
2950
|
// agent-orchestrator: the checks of a draft the schedule tick fired, and the tick's retries of them, use spawnScheduled (the capacity governor). A press uses spawnSession.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Reports in each reader's language (report-reader-language, idea A111, done test planning/done-tests/report-reader-language.md L1-L4, N1-N3): the definition's languages line, the translated copy with numbers and names checked, the ⋯ Also in item and pmos report language. The model's answer is recorded. No server, network, model or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"report-translate.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"report-translate.test.js": 2
|
|
8
|
+
}
|
|
9
|
+
}
|