create-pmos 0.725.0 → 0.727.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.725.0",
3
+ "version": "0.727.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,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.727.0",
38
+ "at": "2026-11-23T04:50:40.142Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1605,
43
+ "t": "Update PMOS from the phone",
44
+ "s": "Update PMOS from the phone",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.726.0",
51
+ "at": "2026-11-23T04:24:12.361Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1604,
56
+ "t": "What the chat writes shows on the workspace cards",
57
+ "s": "What the chat writes shows on the workspace cards",
58
+ "k": "fix"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.725.0",
38
64
  "at": "2026-11-23T03:46:31.972Z",
@@ -422,50 +448,6 @@
422
448
  "k": "new"
423
449
  }
424
450
  ]
425
- },
426
- {
427
- "v": "0.699.0",
428
- "at": "2026-11-22T10:23:23.766Z",
429
- "f": 4,
430
- "prs": [
431
- {
432
- "n": 1517,
433
- "t": "Fixed spacing and corner values read the same-value Komorebi token (token-first step 2)",
434
- "s": "Fixed spacing and corner values read the same-value Komorebi token (token-first step 2)",
435
- "k": "x"
436
- },
437
- {
438
- "n": 1518,
439
- "t": "Forms keep drafts when panels close",
440
- "s": "Forms keep drafts when panels close",
441
- "k": "new"
442
- }
443
- ]
444
- },
445
- {
446
- "v": "0.697.0",
447
- "at": "2026-11-22T09:56:23.025Z",
448
- "f": 4,
449
- "prs": [
450
- {
451
- "n": 1516,
452
- "t": "Your move's question list derives the rows once, not once per initiative",
453
- "s": "Your move's question list derives the rows once, not once per initiative",
454
- "k": "fix"
455
- },
456
- {
457
- "n": 1513,
458
- "t": "No \"Waiting for design\" tag or card reaches a user (A460)",
459
- "s": "No \"Waiting for design\" tag or card reaches a user (A460)",
460
- "k": "new"
461
- },
462
- {
463
- "n": 1498,
464
- "t": "One Komorebi token change reaches every page (token-first step 1)",
465
- "s": "One Komorebi token change reaches every page (token-first step 1)",
466
- "k": "new"
467
- }
468
- ]
469
451
  }
470
452
  ]
471
453
  }
package/payload/AGENTS.md CHANGED
@@ -111,6 +111,9 @@ If `pmos/mods` is installed in Claude Code, it guards the session. A hand-write
111
111
  The PM talks to you from an initiative's popup in the workspace. PMOS acts by itself and the PM approves through the ✦ lines. When the PM asks for something the popup shows, change the file the popup reads. Do not tell the PM to press a button, and do not say you cannot when a file change does it.
112
112
 
113
113
  - **The merge ✦ ("7 references and 2 retros can each be one artefact. Merge them?").** The popup derives it from the files: it shows while several different files of one kind belong to the initiative. When you merge files, put `superseded_by: <path of the merged file>` in the frontmatter of each old file. The Artefacts list then shows the merged file, folds each old file under it as an earlier version, and the ✦ goes away by itself. Delete nothing.
114
+ - **The case card (Problem, Goal, Done when).** It reads the Experiment and Done test artefacts first, then the record's Problem, Goal and Done test sections. When the PM says yes to a case line, save it where the card reads it: `pmos artefacts set experiment:<id> experiment why --text "<problem>"`, `pmos artefacts set experiment:<id> experiment hypothesis --text "<goal>"`, and `pmos artefacts set experiment:<id> done-test check --text "<one check>"` once for each check. `pmos why` and `pmos ready check` read the same lines.
115
+ - **A program's card (For, Goal).** After the PM's yes, run `pmos program charter <program id> --why "<what it is for>"` or `--goal "<goal>"` in the repository where the program was made. Its Done when comes from the last milestone and the target date.
116
+ - **The ✦ that drafts missing documents.** Save a PRD as a file the record names in `prd_path:`, a rubric in `rubric_path:`, and the done test with `pmos artefacts set experiment:<id> done-test check`. A file that nothing names does not show in the Artefacts list.
114
117
  - **A stage's dates on the timeline.** A stage's bar runs from the earliest start to the latest end of its tasks (a task with no start counts from its due date). To change a stage's dates, change the dates of its tasks, with the PM's yes. Do not edit the workflow history to move a bar.
115
118
 
116
119
  ## Decomposing an initiative into tickets (file mode has no board)
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@d4441e9a
1
+ kernel-source: pmos@9b002a5c
2
2
  assembled: 2026-11-23
3
3
  mode: vendor
@@ -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-23T03:46:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:50:37Z"}
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-23T03:46:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:50:37Z"}
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-23T03:46:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:50:37Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.727.0",
4
+ "at": "2026-11-23T04:50:40.142Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1605,
9
+ "t": "Update PMOS from the phone",
10
+ "s": "Update PMOS from the phone",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.726.0",
17
+ "at": "2026-11-23T04:24:12.361Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1604,
22
+ "t": "What the chat writes shows on the workspace cards",
23
+ "s": "What the chat writes shows on the workspace cards",
24
+ "k": "fix"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.725.0",
4
30
  "at": "2026-11-23T03:46:31.972Z",
@@ -498,6 +498,8 @@ The text form prints one column per block, then one line for each card: the init
498
498
 
499
499
  `pmos program suggest` is the only write of the milestone review run. It files a suggestion for you to keep, change or drop.
500
500
 
501
+ `pmos program charter <id> --goal "<text>"` or `--why "<text>"` saves the Goal or For line of a program's card, after you say yes in the chat. It writes one charter line and keeps every other key. Run it in the repository where the program was made. It prints the command that undoes it.
502
+
501
503
  ### pmos driver: the Initiative Driver
502
504
 
503
505
  The agent uses `pmos driver propose` to file a proposal and `pmos driver status` to read what exists. In Auto mode, `pmos driver propose` says whether it applied the proposal or left it for you, and why. The other commands are yours, at an interactive terminal:
@@ -515,7 +517,7 @@ The ledger is `driver.jsonl` in the state folder of the repository (`pmos/state`
515
517
 
516
518
  ### pmos artefacts: the seven artefacts
517
519
 
518
- `pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. A Done test check on `experiment:<id>` is also written to the experiment's done test file (`planning/done-tests/<id>.md`, or the file the record names), and the record gets `done_test_path:`; an Experiment kill condition becomes the record's `kill:`. So the ladder, the gates and `pmos jira draft` count it. A done test file you wrote by hand is left alone. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
520
+ `pmos artefacts show [<scope>]` lists the seven artefacts of a scope: Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons. The scope is `portfolio` (the default), `board:<id>`, `goal:<id>` or `experiment:<id>`; `experiment:<id>` is an initiative, and `initiative:<id>` works too. `pmos artefacts map` lists what each older core document, driver proposal kind, report cadence and lane becomes. `pmos artefacts migrate` puts every older record under its artefact as a pointer: issued and draft core documents, kept driver proposals and report drafts. It deletes and moves nothing, and a second run carries nothing new. `pmos artefacts set <scope> <artefact> [<field>] --text "<text>"` writes one field, and `pmos artefacts undo <id>` takes it back. A Done test check on `experiment:<id>` is also written to the experiment's done test file (`planning/done-tests/<id>.md`, or the file the record names), and the record gets `done_test_path:`; an Experiment kill condition becomes the record's `kill:`. So the ladder, the gates and `pmos jira draft` count it. A done test file you wrote by hand is left alone. The case card on an initiative reads `experiment:<id>`: Problem is `experiment why`, Goal is `experiment hypothesis` and Done when is `done-test check`. A line the ledger does not hold comes from the record's own Problem, Goal and Done test sections, and `pmos why` and `pmos ready check` read the ledger too, so a line written either way shows in all three. Intent is yours: an agent proposes a change to it and waits for you. Goal is read from the OKRs, health budgets and readings, so you cannot type it.
519
521
 
520
522
  ### pmos coredoc: core documents
521
523
 
@@ -296,7 +296,7 @@ A phone has its own layout. It is not the computer's page made smaller. There is
296
296
  - **Work** is the list of initiatives: the product, search and filter, the tabs **Initiatives**, **Backlog** with its count (for example **Backlog 14**) and **Sprint**, a short **Where it stands**, and the groups At risk or late, On track and No signal. A row shows its stage, its next milestone and how many milestones are late. A Project also shows its end date.
297
297
  - **An initiative** opens full screen: **Where it stands** with one ✦ proposal and the next 3 dates, the **Stages** as one strip with the stage now marked, the **Work breakdown** of the stage now (a red dot when late, blue in progress, an empty ring to do, a tick when done, the Jira key, subtasks under their task), one line that opens the other stages, **The case**, and **Artefacts**. There is no timeline on a phone. Swipe a ✦ line to the right to say yes and to the left to say no; press it to read why. A task, a milestone or an artefact opens full screen with ← back to the initiative, as one page with no boxes. The box at the end of the page asks PMOS about this work.
298
298
  - **Ask PMOS** lists your chats grouped by the work they are about, with its product. "Not in a work yet" is last. A blue dot after the time marks a chat that waits for you. Write in the box at the bottom to start a new chat. In a chat, when PMOS asks before it changes or sends something, the ask is a blue-lined line: swipe it to the right to allow it, and to the left to say no. Press **Why** under it to read why PMOS asks. After you allow a change, a line says **Done** with what changed and **Undo**, until you write again.
299
- - **Settings** has the theme (Light, Dark or Auto) and the version with **Check update**. Connectors, workspaces and updates are on your computer.
299
+ - **Settings** has the theme (Light, Dark or Auto) and the version with **Check update**. When a newer PMOS is ready, the button becomes **Update** (an arrow down to a line). Press it to install that version on your computer. The version line says each step, and Settings comes back on the new version when your computer restarts PMOS. This works when the phone opens the workspace at its Online address. Connectors and workspaces are on your computer.
300
300
  - **Recording** shows the red dot, the time, the meeting's name and a small red stop at the top. Under it: the shared screen cut to the slide, with the slides (only while a screen is shared); **So far**, newest first, each point with its time; and **PMOS proposes**, the line to tell the call. Swipe it to the right to copy it, and to the left to put it away. When you stop, Today opens.
301
301
 
302
302
  A chat on a phone uses the full width of the screen:
@@ -18,10 +18,11 @@ const actorLib = require('./actor.js');
18
18
  const COMMANDS = { artefacts: ['show', 'map', 'migrate', 'set', 'undo'] };
19
19
  const USAGE = [
20
20
  'usage: pmos artefacts show|map|migrate|set|undo — the seven artefacts: Intent, Goal, Narrative, Experiment, Specimens, Done test, Lessons',
21
- ' pmos artefacts show [<scope>] [--json] scope: portfolio (default), board:<id>, goal:<id> or experiment:<id>',
21
+ ' pmos artefacts show [<scope>] [--json] scope: portfolio (default), board:<id>, goal:<id> or experiment:<id> (an initiative)',
22
22
  ' pmos artefacts map [--json] what every older document, proposal kind, report cadence and lane becomes',
23
23
  ' pmos artefacts migrate [--json] carry the older records under their artefacts (idempotent; nothing is deleted)',
24
24
  ' pmos artefacts set <scope> <artefact> [<field>] --text "<text>" [--source label=ref]…',
25
+ ' an initiative is experiment:<id> (initiative:<id> works too). Its case card: experiment why (Problem), experiment hypothesis (Goal), done-test check (Done when, once per check)',
25
26
  ' pmos artefacts undo <a-id>',
26
27
  ];
27
28
  function parse(args) {
@@ -99,7 +100,7 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
99
100
  mirrorSay(say, r.mirror);
100
101
  return 0;
101
102
  }
102
- if (!pos[0]) { say(USAGE[5]); return 2; }
103
+ if (!pos[0]) { say(USAGE[6]); return 2; }
103
104
  const r = A.undo(f, { ref: pos[0] }, actor, { now });
104
105
  if (!r.ok) { say('✗ ' + r.error); return 1; }
105
106
  r.mirror = MIRROR.after(root, r.line, f);
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+ /* case-lines.js — one reader for an initiative's case: Problem, Goal and Done when (initiative chat-saves-to-cards).
3
+ *
4
+ * fromLedger(root, id) → { problem, goal, checks } the Experiment and Done test artefacts (lib/artefacts.js), what
5
+ * `pmos artefacts set experiment:<id> …` and the card's pencil write
6
+ * fromRecord(root, id) → { problem, goal, checks } the record's own sections, what `pmos why` and `pmos ready check` read:
7
+ * Problem (else Intent, "Why it exists", "The defect"), Goal (else Hypothesis), and
8
+ * the checks of the done test file the record names (else its Done test section)
9
+ * caseOf(root, id) → { problem, goal, checks } each line from the ledger when it holds one, else from the record
10
+ * saveCommand(id, line) → the `pmos artefacts set` command that writes one line where the card reads it
11
+ * each line: { text, from, path? } | null; checks: [{ text, from, path? }]
12
+ *
13
+ * WHY. The chat wrote a case into the record, `pmos why` and `pmos ready check` saw it, and The case card (which read only the ledger)
14
+ * said "No line of the case is written yet". The card, `pmos why` and `pmos ready check` now all read through here, so a line written
15
+ * either way shows everywhere. Reads only: nothing here writes, so no stored data moves.
16
+ */
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+
20
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/;
21
+ const PROBLEM = ['problem', 'intent', 'why it exists', 'why this exists', 'the defect'];
22
+ const GOAL = ['goal', 'hypothesis'];
23
+ const DONE = ['done test', 'done when', 'done criteria', 'definition of done'];
24
+ const LINES = Object.freeze({
25
+ problem: { artefact: 'experiment', field: 'why' },
26
+ goal: { artefact: 'experiment', field: 'hypothesis' },
27
+ done: { artefact: 'done-test', field: 'check' },
28
+ });
29
+
30
+ const W = () => require('./item-why.js');
31
+ const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
32
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
33
+ const blank = () => ({ problem: null, goal: null, checks: [] });
34
+
35
+ /** The Experiment and Done test artefacts of one initiative, from the ledger. */
36
+ function fromLedger(root, id) {
37
+ const out = blank();
38
+ if (!ID_RE.test(String(id || ''))) return out;
39
+ const A = require('./artefacts.js');
40
+ let dir;
41
+ try { dir = A.dirOf(root); } catch { return out; }
42
+ const f = A.file(dir);
43
+ if (!f) return out;
44
+ const v = A.viewOf(A.fold(A.readLines(f)), 'experiment:' + id);
45
+ if (!v) return out;
46
+ const by = new Map(v.artefacts.map((a) => [a.key, a]));
47
+ const ex = by.get('experiment'), dt = by.get('done-test');
48
+ const one = (x) => (x && x.text ? { text: String(x.text), from: 'the Experiment' } : null);
49
+ if (ex) { out.problem = one(ex.fields.why); out.goal = one(ex.fields.hypothesis); }
50
+ if (dt && Array.isArray(dt.fields.check)) out.checks = dt.fields.check.filter((x) => x && x.text).map((x) => ({ text: String(x.text), from: 'the Done test' }));
51
+ return out;
52
+ }
53
+
54
+ /** The record's own sections. A line the record does not hold is null; nothing is made up from the title. */
55
+ function fromRecord(root, id) {
56
+ const out = blank();
57
+ const I = W();
58
+ const f = I.recordPathOf(root, id);
59
+ if (!f) return out;
60
+ const body = readText(f) || '';
61
+ const fm = I.frontOf(body), secs = I.sectionsOf(body), at = rel(root, f);
62
+ const pick = (names) => { for (const n of names) { const t = secs.get(n); if (t && I.plain(t).trim()) return { name: n, text: t }; } return null; };
63
+ const line = (p) => (p ? { text: I.clip(p.text), from: 'the record', path: at } : null);
64
+ out.problem = line(pick(PROBLEM));
65
+ out.goal = line(pick(GOAL));
66
+ const TA = require('./ticket-acceptance.js');
67
+ const dtp = typeof fm.done_test_path === 'string' ? fm.done_test_path.trim().replace(/^\/+/, '') : '';
68
+ if (dtp && !/^(n\/a|na|none|-)$/i.test(dtp)) {
69
+ for (const base of [root, path.join(root, 'pmos')]) {
70
+ const abs = path.resolve(base, dtp);
71
+ if (!abs.startsWith(path.resolve(root) + path.sep)) continue;
72
+ const t = readText(abs);
73
+ if (t == null) continue;
74
+ out.checks = TA.checksOf(t).map((c) => ({ text: I.plain(c.check).trim(), from: 'the done test', path: rel(root, abs) })).filter((c) => c.text);
75
+ break;
76
+ }
77
+ }
78
+ if (!out.checks.length) {
79
+ const s = pick(DONE);
80
+ if (s) {
81
+ const list = TA.checksOf(s.text).map((c) => I.plain(c.check).trim()).filter(Boolean);
82
+ const words = list.length ? list : [I.clip(s.text)].filter(Boolean);
83
+ out.checks = words.map((text) => ({ text, from: 'the record', path: at }));
84
+ }
85
+ }
86
+ return out;
87
+ }
88
+
89
+ /** Each line from the ledger when it holds one, else from the record. */
90
+ function caseOf(root, id) {
91
+ const L = fromLedger(root, id), R = fromRecord(root, id);
92
+ return { problem: L.problem || R.problem, goal: L.goal || R.goal, checks: L.checks.length ? L.checks : R.checks };
93
+ }
94
+
95
+ /** The command that writes one case line where The case card reads it. line: problem | goal | done. */
96
+ function saveCommand(id, line) {
97
+ const t = LINES[line];
98
+ if (!t) return '';
99
+ return `pmos artefacts set experiment:${id} ${t.artefact} ${t.field} --text "<the text>"`;
100
+ }
101
+
102
+ module.exports = { fromLedger, fromRecord, caseOf, saveCommand, LINES };
@@ -11,6 +11,7 @@
11
11
  * (begins Closed, Cancelled or Killed), lifecycle.jsonl and acceptances.jsonl
12
12
  * coverage(root) → { active, complete, percent, missing: [{ id, lines: ['goal'|'problem'|'evidence'] }] }
13
13
  *
14
+ * The Experiment artefact's Problem and Hypothesis (lib/case-lines.js fromLedger), when written, win over the record's, as on The case card.
14
15
  * THE LINES, in the order each is tried. A line the records do not hold is null: nothing is made up from the title.
15
16
  * goal : the record's Goal · the PRD's Goal or Goals · `outcome_metric`
16
17
  * problem : the record's Intent · the PRD's Problem · a "Why it exists", "Why this exists" or "The defect" section
@@ -190,7 +191,16 @@ function readWhy(root, ref) {
190
191
  const p = String(fm.prd_path).replace(/^\/+/, '');
191
192
  for (const base of [root, path.join(root, 'pmos')]) { const t = readText(path.join(base, p)); if (t != null) { prd = t; prdPath = p; break; } }
192
193
  }
193
- return whyOf({ id, front: fm, body, prd, recordPath: rel(root, f), prdPath });
194
+ const w = whyOf({ id, front: fm, body, prd, recordPath: rel(root, f), prdPath });
195
+ // the case card's own lines (lib/case-lines.js): a Problem or Goal written with the card's pencil or `pmos artefacts set` wins, as on the
196
+ // card, so `pmos why` and The case say the same thing (initiative chat-saves-to-cards)
197
+ try {
198
+ const L = require('./case-lines.js').fromLedger(root, id);
199
+ if (L.problem) w.problem = line(L.problem.text, 'the Experiment artefact', 'Problem');
200
+ if (L.goal) w.goal = line(L.goal.text, 'the Experiment artefact', 'Hypothesis');
201
+ w.complete = !!(w.goal && w.problem && w.evidence);
202
+ } catch { /* no ledger: the record's lines stand */ }
203
+ return w;
194
204
  }
195
205
 
196
206
  function readJsonl(f) {
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  /* program-cli.js — `pmos program suggest`: the one write of Claude's milestone review run (feedback batch 4 item 6; canvas XmsgB).
3
+ * And `pmos program charter`: the program card's Goal and For lines, after the PM said yes in the chat (initiative chat-saves-to-cards).
3
4
  *
4
5
  * pmos program suggest --json <file|-> files one suggestion, or a list of them, for the program the review runs on
6
+ * pmos program charter <id> [--goal "<text>"] [--why "<text>"] [--root <dir>]
7
+ * one charter line with the new goal or why and every other key as it was (the last line wins),
8
+ * in this repository's <state>/programs.jsonl, where the program was made. It prints the Undo
5
9
  *
6
10
  * The server pins the program, the run and the file in the run's environment (PMOS_MS_REVIEW_PROGRAM, PMOS_MS_REVIEW_RUN, PMOS_MS_REVIEW_FILE;
7
11
  * lib/milestone-review.js); outside such a run the verb refuses. It writes `suggest` lines and nothing else: the charter changes only when the
@@ -11,7 +15,7 @@ const fs = require('fs');
11
15
  const pmItems = require('./pm-items.js');
12
16
  const MS = require('./milestone-suggest.js');
13
17
 
14
- const COMMANDS = { program: ['suggest'] };
18
+ const COMMANDS = { program: ['suggest', 'charter'] };
15
19
  const USAGE = [
16
20
  'usage: pmos program suggest — PMOS\'s milestone suggestions for a program',
17
21
  ' pmos program suggest --json <file|->',
@@ -19,6 +23,8 @@ const USAGE = [
19
23
  ' { "op": "add|move|rename|drop|risk", "milestone": "<id, not for add>", "name": "<add, rename>", "date": "YYYY-MM-DD (add, move)",',
20
24
  ' "waits": ["<initiative id>", … (add)], "why": "<one line>", "src": { "kind": "deliver|jira|meeting|task|target|member|charter", "label": "Steering, Oct 22" } }',
21
25
  ' It answers filed, duplicate or declined for each. The PM keeps, changes or drops it on the page. Nothing is sent.',
26
+ ' pmos program charter <id> [--goal "<text>"] [--why "<text>"]',
27
+ ' The program card\'s Goal and For lines, after the PM said yes in the chat. Run it in the repository where the program was made.',
22
28
  ];
23
29
  const MAX_PER_RUN = 8;
24
30
 
@@ -27,6 +33,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
27
33
  const verb = args[0];
28
34
  if (!verb || verb === 'help' || verb === '--help' || verb === '-h') { for (const l of USAGE) say(l); return verb ? 0 : 1; }
29
35
  if (!COMMANDS.program.includes(verb)) { say(`unknown program command "${verb}" — one of ${COMMANDS.program.join(', ')}`); return 2; }
36
+ if (verb === 'charter') return charter(args.slice(1), { say, cwd: process.cwd() });
30
37
  const i = args.indexOf('--json'), src = i >= 0 ? args[i + 1] : null;
31
38
  if (!src) { say('usage: pmos program suggest --json <file|->'); return 2; }
32
39
  const file = env.PMOS_MS_REVIEW_FILE, runId = env.PMOS_MS_REVIEW_RUN, program = env.PMOS_MS_REVIEW_PROGRAM;
@@ -53,4 +60,31 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
53
60
  return bad ? 1 : 0;
54
61
  }
55
62
 
56
- module.exports = { run, COMMANDS, USAGE };
63
+ /** `pmos program charter <id> --goal|--why`: one new charter line, every other key kept (lib/programs.js validProgram). Exit 0 written,
64
+ * 1 refused, 2 usage. The file is the charter's own: the state folder of this repository that already holds the program's charter. */
65
+ function charter(args, { say, cwd }) {
66
+ const path = require('path');
67
+ const P = require('./programs.js');
68
+ const pos = [], flags = {};
69
+ for (let k = 0; k < args.length; k++) { const a = args[k]; if (/^--(goal|why|root)$/.test(a)) flags[a.slice(2)] = args[++k]; else if (a.startsWith('--')) { say(`✗ unknown flag ${a}`); return 2; } else pos.push(a); }
70
+ const id = pos[0];
71
+ if (!id || (flags.goal === undefined && flags.why === undefined)) { say(USAGE[USAGE.length - 2]); return 2; }
72
+ if (!P.ID_RE.test(id)) { say('✗ the program id is lower-case letters, numbers and dashes'); return 2; }
73
+ const root = path.resolve(cwd, flags.root || '.');
74
+ const files = [['pmos', 'state'], ['state'], ['.pmos'], ['planning', 'runs']].map((r) => path.join(root, ...r, 'programs.jsonl')).filter((f) => fs.existsSync(f));
75
+ let file = null, prog = null;
76
+ for (const f of files) { const p = P.fold(pmItems.readLines(f).filter(Boolean))[id]; if (p && p.charter) { file = f; prog = p; break; } }
77
+ if (!prog) { say(`✗ no charter of ${id} in this repository. Run it in the product where the program was made`); return 1; }
78
+ const next = { ...prog, id };
79
+ if (flags.goal !== undefined) next.goal = String(flags.goal || '');
80
+ if (flags.why !== undefined) next.why = String(flags.why || '');
81
+ const v = P.validProgram(next);
82
+ if (v.error) { say('✗ ' + v.error); return 1; }
83
+ if (flags.goal !== undefined && String(flags.goal).trim().length > 160) say(' ! the goal was cut to 160 characters');
84
+ pmItems.appendEvent(file, { ...v, from: prog.from || undefined });
85
+ const undo = ['pmos program charter', id].concat(flags.goal !== undefined ? ['--goal', JSON.stringify(prog.goal || '')] : [], flags.why !== undefined ? ['--why', JSON.stringify(prog.why || '')] : []).join(' ');
86
+ say(`✓ ${id}: ${[flags.goal !== undefined ? 'goal' : '', flags.why !== undefined ? 'why' : ''].filter(Boolean).join(' and ')} saved to ${path.relative(root, file)}. The program card shows it. Undo: ${undo}`);
87
+ return 0;
88
+ }
89
+
90
+ module.exports = { run, COMMANDS, USAGE, charter };
@@ -63,20 +63,23 @@ const sectionsNamed = (secs, re) => secs.filter((s) => s.head && re.test(s.head)
63
63
  /** A section with at least one sentence: some words, not only a link or a placeholder. */
64
64
  const hasProse = (t) => /[\p{L}]{2,}(\s+[\p{L}\d'’,-]+){2,}/u.test(String(t || '').replace(/<!--[\s\S]*?-->/g, '').replace(/\b(TBD|TODO)\b/g, ''));
65
65
 
66
- function problemOf(fm, secs) {
66
+ function problemOf(fm, secs, ledger) {
67
67
  if (isStr(fm.problem)) return { status: 'ok', why: 'the record states it' };
68
+ if (ledger && ledger.problem) return { status: 'ok', why: 'the Experiment artefact (The case card)' };
68
69
  const s = secs.find((x) => H.problem.test(x.head) && hasProse(x.text));
69
70
  if (s) return { status: 'ok', why: `section "${one(s.head, 40)}"` };
70
71
  return { status: 'missing', why: 'add a Problem section: who has the problem and what it costs them' };
71
72
  }
72
73
 
73
- function doneOf(fm, secs, doneTest, rubric, checksOf) {
74
+ function doneOf(fm, secs, doneTest, rubric, checksOf, ledger) {
74
75
  if (doneTest && !doneTest.missing) {
75
76
  let n = 0; try { n = checksOf(doneTest.text).length; } catch { n = 0; }
76
77
  if (n) return { status: 'ok', why: `${doneTest.path}, ${n} ${n === 1 ? 'check' : 'checks'}` };
77
78
  }
78
79
  const s = secs.find((x) => H.done.test(x.head) && hasProse(x.text));
79
80
  if (s) return { status: 'ok', why: `section "${one(s.head, 40)}"` };
81
+ const n = ledger && Array.isArray(ledger.checks) ? ledger.checks.length : 0;
82
+ if (n) return { status: 'ok', why: `the Done test artefact, ${n} ${n === 1 ? 'check' : 'checks'}` };
80
83
  if (rubric) return { status: 'ok', why: `the rubric ${one(fm.rubric_path, 80)}` };
81
84
  if (doneTest && doneTest.missing) return { status: 'missing', why: `done_test_path names ${doneTest.path}, but there is no such file` };
82
85
  if (doneTest) return { status: 'missing', why: `${doneTest.path} has no check: add one row per check, with how to check it` };
@@ -139,8 +142,8 @@ function check(input = {}) {
139
142
  const secs = [...sectionsOf(body), ...sectionsOf(prd)];
140
143
  const checksOf = input.checksOf || require('./ticket-acceptance.js').checksOf;
141
144
  const got = {
142
- problem: problemOf(fm, secs),
143
- done: doneOf(fm, secs, input.doneTest || null, !!input.rubric, checksOf),
145
+ problem: problemOf(fm, secs, input.ledger || null),
146
+ done: doneOf(fm, secs, input.doneTest || null, !!input.rubric, checksOf, input.ledger || null),
144
147
  design: designOf(fm, secs, body + '\n' + prd),
145
148
  questions: questionsOf(secs, input.questions, input.gaps),
146
149
  signoffs: signoffsOf(secs, input.signoffs),
@@ -216,7 +219,10 @@ function read(root, ini, o = {}) {
216
219
  const held = (Array.isArray(o.held) ? o.held : heldAll(root, o)).filter((h) => h.ini === ini);
217
220
  questions = require('./question-batch.js').questionsOf(held, { pm: 'PM' });
218
221
  } catch { questions = []; }
219
- return { title: isStr(fm.title) ? fm.title.trim() : ini, input: { fm, body: text, prd, doneTest, rubric, signoffs, questions, gaps } };
222
+ // the case card's lines (lib/case-lines.js, initiative chat-saves-to-cards): a Problem or Done test written there counts here too
223
+ let ledger = null;
224
+ try { ledger = require('./case-lines.js').fromLedger(root, ini); } catch { ledger = null; }
225
+ return { title: isStr(fm.title) ? fm.title.trim() : ini, input: { fm, body: text, prd, doneTest, rubric, signoffs, questions, gaps, ledger } };
220
226
  }
221
227
 
222
228
  module.exports = { BASICS, STATES, check, render, line, read, heldAll, sectionsOf };
@@ -4,6 +4,8 @@
4
4
  * GET /api/artefacts?ws&scope → { ok, ws, scope, kind, factory, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
5
5
  * factory: a D65 factory runs in this repository (lib/work-kind.js factoryRuns), so "PMOS builds it" is true
6
6
  * scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
7
+ * An experiment's Problem, Goal and Done test checks the ledger lacks come from the record's own sections,
8
+ * carried as kind `record` (lib/case-lines.js), so the card shows what `pmos why` reads
7
9
  * GET /api/artefacts/story?ws → { ok, ws, story: { scope, at, lines: [{ text, sources }] } | null, seeding? } "The story so far" on the
8
10
  * product page (board AwE): the Narrative of board:<ws>, else of the portfolio (lib/artefacts.js storyOf). A
9
11
  * shared Board carries it without the sources (lib/board-pack.js). seeding: there is no story yet and PMOS is
@@ -129,7 +131,21 @@ async function handle(req, res, url, ctx) {
129
131
  const v = A.viewOf(A.fold(A.readLines(A.file(dir))), scope);
130
132
  const artefacts = v.artefacts.map((a) => ({ ...a,
131
133
  fields: Object.fromEntries(Object.entries(a.fields).map(([k, val]) => [k, Array.isArray(val) ? val.map(pageBy) : pageBy(val)])) }));
134
+ if (v.kind === 'experiment') withRecord(artefacts, w.root, v.scope.slice('experiment:'.length));
132
135
  return send(200, { ok: true, ws: w.id, scope: v.scope, kind: v.kind, factory: require('./work-kind.js').factoryRuns(w.root), artefacts });
133
136
  }
134
137
 
138
+ /** The case lines the record holds and the ledger does not, carried as `record` (initiative chat-saves-to-cards): the chat wrote the case
139
+ * into the record, `pmos why` read it, and The case card said nothing was written. Read at every GET, never appended to the ledger. */
140
+ function withRecord(artefacts, root, id) {
141
+ let R;
142
+ try { R = require('./case-lines.js').fromRecord(root, id); } catch { return; }
143
+ const at = (key) => artefacts.find((a) => a.key === key);
144
+ const carry = (a, field, x) => { if (!a || !x || !x.text) return; a.carried = [{ field, kind: 'record', ref: x.path || '', path: x.path || '', title: x.from, text: x.text, at: null }].concat(a.carried || []); a.empty = false; };
145
+ const ex = at('experiment'), dt = at('done-test');
146
+ if (ex && !ex.fields.why) carry(ex, 'why', R.problem);
147
+ if (ex && !ex.fields.hypothesis) carry(ex, 'hypothesis', R.goal);
148
+ if (dt && !(Array.isArray(dt.fields.check) && dt.fields.check.length)) for (const c of R.checks.slice().reverse()) carry(dt, 'check', c);
149
+ }
150
+
135
151
  module.exports = { prefixes: ['/api/artefacts'], handle, _migrated: migrated };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.725.0",
3
+ "version": "0.727.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.725.0",
9
+ "version": "0.727.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.725.0",
3
+ "version": "0.727.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -507,7 +507,11 @@ function levelOf(id) {
507
507
  if (p.owner) facts.push({ k: 'Owner', v: p.owner });
508
508
  const said = [p.goal ? p.goal.replace(/\.?$/, '.') : '', rows.length ? (late ? late + ' of ' + rows.length + (rows.length === 1 ? ' initiative is' : ' initiatives are') + ' late.' : rows.length + (rows.length === 1 ? ' initiative' : ' initiatives') + ', none late.') : 'No initiative is in it yet.', nx ? 'Next: ' + nx.name + (nx.day ? ', ' + nx.day : '') + '.' : ''].filter(Boolean).join(' ');
509
509
  const docs = [{ title: 'Charter', kind: 'Document', when: '', charter: true }].concat(docsOf(st).map((d) => ({ title: d.name, kind: 'Document · ' + d.ini, when: '', path: d.path })));
510
- return { kind: 'program', title: p.title, summary: said, facts, rows, docs, today };
510
+ // the case reads the charter (initiative chat-saves-to-cards): its why and goal, and Done when from its last milestone and target
511
+ const ms = (p.milestones || []).filter((m) => m && m.name), lastMs = ms.slice().sort((a, b) => String(a.date || '').localeCompare(String(b.date || ''))).pop();
512
+ const by = p.target ? new Date(p.target + 'T12:00:00Z').toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric', timeZone: 'UTC' }) : '';
513
+ const doneWhen = lastMs ? lastMs.name.replace(/\.$/, '') + (by ? ', by ' + by : '') + '.' : by ? 'Its initiatives are delivered by ' + by + '.' : '';
514
+ return { kind: 'program', id: p.id, title: p.title, summary: said, why: p.why || '', goal: p.goal || '', done: doneWhen, facts, rows, docs, today };
511
515
  }
512
516
  function levelDraw(body, id, from) {
513
517
  cur = { id, from: from || (cur && cur.id === id && cur.from) || null };
@@ -14,5 +14,9 @@ body.phs-on { overflow: hidden; }
14
14
  .phs .phs-seg button[aria-pressed="true"] { font-weight: var(--fw-strong); }
15
15
  .phs-b { flex: none; height: 40px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; font-size: var(--fs-row); font-weight: var(--fw-strong); cursor: pointer; }
16
16
  .phs-b:disabled { color: var(--cz-ink3); }
17
+ .phs-i { width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
18
+ .phs-i[aria-busy="true"] svg { animation: phs-pulse 1.2s ease-in-out infinite; }
19
+ @keyframes phs-pulse { 50% { opacity: .35; } }
20
+ @media (prefers-reduced-motion: reduce) { .phs-i[aria-busy="true"] svg { animation: none; } }
17
21
  .phs-note { margin: 14px 0 0; font-size: var(--fs-body); color: var(--cz-ink2); line-height: var(--lh-body); }
18
22
  .phs :focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
@@ -1,19 +1,28 @@
1
1
  /* pm/cozy-phone-settings.js — Settings on a phone (phone design, board Ph2_more on Exploring 2; build brief nav-structure/phone/build-brief-v2.md).
2
2
  *
3
- * One screen, no scrolling: Theme (Light, Dark, Auto: this phone), Version ("PMOS 0.630.0") with Check update, and the note "Connectors,
4
- * workspaces and updates are on your computer." Nothing else: Product, Your day, Jira writes, Your impact and Signed in stay in the
3
+ * One screen, no scrolling: Theme (Light, Dark, Auto: this phone), Version ("PMOS 0.630.0") with Check update, and the note "Connectors
4
+ * and workspaces are on your computer." Nothing else: Product, Your day, Jira writes, Your impact and Signed in stay in the
5
5
  * computer's Settings (pm/cozy-settings.js), which a phone no longer opens from the menu. The menu's ⋯ stays at the top right over it.
6
6
  *
7
7
  * phoneSettingsHtml({ pick, version, said }) → string PURE
8
8
  * openPhoneSettings() → the element pm/cozy-nav.js calls it on a phone; Back, Escape or another place closes it
9
9
  * closePhoneSettings()
10
10
  * Reads GET /api/kit/status (the version) when it opens. Writes only on a press: the theme on this phone (localStorage, cozy-nav.js
11
- * setTheme) and POST /api/kit/check (Check update; it reads the newest version and changes nothing on the computer). */
11
+ * setTheme) and POST /api/kit/check (Check update; it reads the newest version and changes nothing on the computer).
12
+ *
13
+ * UPDATE FROM THE PHONE (phone-update). When the check (or the last check, from GET /api/kit/status) finds a newer PMOS, Check update
14
+ * becomes an icon-only Update button. A press asks the computer to install that version through the same routes and guard as the
15
+ * computer's own Settings › Updates: POST /api/kit/update when the kit is behind, then POST /api/kit/upgrade-app (create-pmos@<version>
16
+ * workspace --reinstall --no-open, on the release line the computer follows). The server refuses it unless the phone came in on the
17
+ * Online address or with a kept token (kit-update.js whereFrom), because a phone on any other address could not come back. The
18
+ * Version line shows each step, and the screen reloads when the computer answers on the new version. */
12
19
  import { pmGet, pmPost } from './http.js';
13
20
  import { setTheme, themePick } from './cozy-nav.js';
14
21
 
15
22
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
16
- const S = { el: null, version: '', ws: '', said: '', busy: false, back: null };
23
+ const S = { el: null, version: '', ws: '', said: '', busy: false, back: null, latest: '', appBehind: false, kitBehind: false, updating: false };
24
+ const UPDATE_ICON = '<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 4v11M7 10l5 5 5-5M5 20h14"/></svg>';
25
+ const WAIT_MS = 6 * 60000;
17
26
  const THEMES = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
18
27
 
19
28
  export function phoneSettingsHtml(o = {}) {
@@ -23,17 +32,38 @@ export function phoneSettingsHtml(o = {}) {
23
32
  + `<div class="phs-row"><div class="phs-t"><b id="phsTheme">Theme</b><small>${esc(sub)}</small></div><div class="ev-seg phs-seg" role="group" aria-labelledby="phsTheme">`
24
33
  + THEMES.map(([k, l]) => `<button type="button" data-phs-theme="${k}" aria-pressed="${pick === k}">${l}</button>`).join('') + '</div></div>'
25
34
  + `<div class="phs-row"><div class="phs-t"><b>Version</b><small>${esc(o.version ? 'PMOS ' + o.version : 'PMOS')}</small>${o.said ? `<small class="phs-said" role="status">${esc(o.said)}</small>` : ''}</div>`
26
- + `<button type="button" class="phs-b" data-phs-check${o.busy ? ' disabled' : ''}>${o.busy ? 'Checking' : 'Check update'}</button></div>`
27
- + '<p class="phs-note">Connectors, workspaces and updates are on your computer.</p>';
35
+ + versionButton(o) + '</div>'
36
+ + '<p class="phs-note">Connectors and workspaces are on your computer.</p>';
37
+ }
38
+ /** Check update, or the icon-only Update once a newer PMOS is known (o.latest with o.ready). While it installs, the button is disabled. */
39
+ function versionButton(o) {
40
+ if (o.ready && o.latest) {
41
+ const label = o.updating ? 'Updating to PMOS ' + o.latest : 'Update to PMOS ' + o.latest;
42
+ return `<button type="button" class="phs-b phs-i" data-phs-update aria-label="${esc(label)}" title="${esc(label)}"${o.updating ? ' disabled aria-busy="true"' : ''}>${UPDATE_ICON}</button>`;
43
+ }
44
+ return `<button type="button" class="phs-b" data-phs-check${o.busy ? ' disabled' : ''}>${o.busy ? 'Checking' : 'Check update'}</button>`;
45
+ }
46
+ const ready = () => !!(S.latest && (S.appBehind || S.kitBehind));
47
+ function draw() {
48
+ if (S.el) S.el.innerHTML = phoneSettingsHtml({ pick: themePick(), version: S.version, said: S.said, busy: S.busy, latest: S.latest, ready: ready(), updating: S.updating });
49
+ }
50
+ /** Keep what a check (or the last check) says: the newest version and whether this computer is behind it. */
51
+ function keep(r) {
52
+ if (!r) return;
53
+ const latest = r.latest || (r.lastCheck && r.lastCheck.latest) || '';
54
+ if (latest) { S.latest = latest; S.appBehind = !!r.appBehind; S.kitBehind = !!r.kitBehind; }
28
55
  }
29
- function draw() { if (S.el) S.el.innerHTML = phoneSettingsHtml({ pick: themePick(), version: S.version, said: S.said, busy: S.busy }); }
30
56
  function addCss() {
31
57
  const href = new URL('./cozy-phone-settings.css', import.meta.url).href;
32
58
  if (!document.querySelector(`link[href="${href}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = href; document.head.appendChild(l); }
33
59
  }
34
60
  async function readVersion() {
35
61
  const r = await pmGet('/api/kit/status').catch(() => null);
36
- if (r && r.ok) { S.version = (r.app && r.app.version) || ''; S.ws = r.ws || ''; draw(); }
62
+ if (r && r.ok) {
63
+ S.version = (r.app && r.app.version) || ''; S.ws = r.ws || ''; keep(r);
64
+ if (!S.said && !S.updating && ready()) S.said = 'PMOS ' + S.latest + ' is ready.';
65
+ draw();
66
+ }
37
67
  }
38
68
  async function check() {
39
69
  if (S.busy) return;
@@ -41,9 +71,42 @@ async function check() {
41
71
  const r = await pmPost('/api/kit/check', { ws: S.ws || undefined }).catch(() => null);
42
72
  S.busy = false;
43
73
  if (!r || !r.ok) S.said = 'The check did not go through: ' + ((r && r.error) || 'the computer did not answer') + '.';
44
- else S.said = r.appBehind || r.kitBehind ? 'PMOS ' + r.latest + ' is ready. Update it on your computer.' : 'This is the newest PMOS.';
74
+ else { keep(r); S.said = ready() ? 'PMOS ' + S.latest + ' is ready.' : 'This is the newest PMOS.'; }
45
75
  draw();
46
76
  }
77
+ /** Update: the kit first when it is behind, then the app. The app update restarts the computer's PMOS, so wait for it. */
78
+ async function update() {
79
+ if (S.updating || !ready()) return;
80
+ const v = S.latest; const ws = S.ws || undefined;
81
+ S.updating = true; S.said = 'Updating PMOS on your computer to ' + v + '.'; draw();
82
+ const fail = (r, what) => { S.updating = false; S.said = what + ': ' + ((r && r.error) || 'the computer did not answer') + '.'; draw(); };
83
+ if (S.kitBehind) {
84
+ const r = await pmPost('/api/kit/update', { ws, version: v }).catch(() => null);
85
+ if (!r || !r.ok) return fail(r, 'The kit was not updated');
86
+ S.kitBehind = false;
87
+ }
88
+ if (!S.appBehind) { S.updating = false; S.said = 'Updated to PMOS ' + v + '.'; draw(); return; }
89
+ const from = S.version;
90
+ const r = await pmPost('/api/kit/upgrade-app', { ws, version: v, place: 'phone' }).catch(() => null);
91
+ if (!r || r.ok === false) return fail(r, 'The update did not start');
92
+ S.said = 'Installing PMOS ' + v + ' on your computer. This screen comes back when it restarts.'; draw();
93
+ waitBack(from);
94
+ }
95
+ /** Poll the computer until it answers on a new version, then reload. A phone that slept keeps polling when it wakes. */
96
+ async function waitBack(from) {
97
+ let down = false; const until = Date.now() + WAIT_MS;
98
+ while (Date.now() < until) {
99
+ await new Promise((ok) => setTimeout(ok, 2000));
100
+ const j = await pmGet('/api/sessions').catch(() => null);
101
+ if (!j || j.ok === false || !j.version) {
102
+ if (!down) { down = true; S.said = 'PMOS is restarting on your computer.'; draw(); }
103
+ continue;
104
+ }
105
+ if (j.version !== from) { location.reload(); return; }
106
+ if (down) { S.updating = false; S.said = 'PMOS started again on ' + j.version + ', so the update did not finish. The update log is on your computer.'; draw(); return; }
107
+ }
108
+ S.updating = false; S.said = 'Your computer did not come back on this address. Open PMOS on the computer to finish.'; draw();
109
+ }
47
110
  export function openPhoneSettings() {
48
111
  addCss();
49
112
  if (!S.el) {
@@ -53,11 +116,13 @@ export function openPhoneSettings() {
53
116
  S.el.addEventListener('click', (e) => {
54
117
  const t = e.target.closest('[data-phs-theme]'); if (t) { setTheme(t.dataset.phsTheme, document); draw(); return; }
55
118
  if (e.target.closest('[data-phs-check]')) check();
119
+ if (e.target.closest('[data-phs-update]')) update();
56
120
  });
57
121
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.el && !S.el.hidden) { e.stopPropagation(); closePhoneSettings(); } }, true);
58
122
  addEventListener('popstate', () => { if (S.el && !S.el.hidden) closePhoneSettings(true); });
59
123
  }
60
- S.said = ''; S.back = document.activeElement;
124
+ if (!S.updating) S.said = '';
125
+ S.back = document.activeElement;
61
126
  S.el.hidden = false; document.body.classList.add('phs-on');
62
127
  try { history.pushState({ phs: 1 }, ''); } catch { /* no history */ }
63
128
  draw(); readVersion();
@@ -86,7 +86,8 @@ export function openSetup(ctx) {
86
86
  const d = t.dataset;
87
87
  if ('glNskeep' in d) { t.disabled = true; await ctx.keepNs(ns.row); b.innerHTML = '<div class="pw gl-pg"><p class="grey">Kept. The North Star is set.</p></div>'; return; }
88
88
  if ('glNsdrop' in d) { t.disabled = true; await ctx.dropNs(ns.row); return; }
89
- if ('glNsdraft' in d) { toChat('Draft a North Star for this product from its key results. I approve it with a tick.'); return; }
89
+ // the draft run files the draft this page waits for; the chat could not (initiative chat-saves-to-cards)
90
+ if ('glNsdraft' in d) { t.disabled = true; if (ctx.startNs) { const ok = await ctx.startNs(); if (ok) b.innerHTML = '<div class="pw gl-pg"><p class="grey">PMOS is drafting the North Star. It shows here for your tick.</p></div>'; else t.disabled = false; } else toChat('Draft a North Star for this product from its key results. I approve it with a tick.'); return; }
90
91
  if (d.glName) { const n = S.names.find((x) => x.id === d.glName); if (n) toChat((n.named ? 'Check the name of ' : 'Name ') + n.label + ' (' + n.krs + '). Draft it from its key results; I approve it with a tick.'); return; }
91
92
  if (d.glSrc) { const s = S.sources.find((x) => x.need === d.glSrc); if (s) toChat('Connect ' + s.need + '. ' + s.frees + '. Test a read before you keep it, and tell me what you need from me.'); return; }
92
93
  if ('glAsk' in d) toChat('About setting up Goals: what should I confirm or connect first?');
@@ -253,25 +253,34 @@ export function overviewOf(r, v, o = {}) {
253
253
  const docs = (o.docs || []).filter((d) => d && (d.path || d.link) && d.title);
254
254
  const from = docs.find((d) => /brief/i.test(d.title)) || docs.find((d) => /\bprd\b/i.test(d.title)) || docs[0] || null;
255
255
  const fromW = from ? (/brief/i.test(from.title) ? 'the brief' : /\bprd\b/i.test(from.title) ? 'the PRD' : from.title) : '';
256
- const offer = (k, what) => ({ miss: k + ' is not written.' + (fromW ? ' Draft it from ' + fromW + '?' : ' Draft it with you?'),
257
- ask: 'Draft ' + what + ' for ' + title + (fromW ? ' from ' + fromW : '') + ', in two short sentences, for me to read. Say what you read. Do not invent anything the records do not say.' });
258
- const carriedPath = (a, f) => ((a.carried || []).find((c) => c.field === f && (c.path || c.text)) || null);
256
+ // the ask names the command that saves the draft where this card reads it (initiative chat-saves-to-cards): before, the chat wrote the
257
+ // case into the record and found no command that writes the card, so the card kept saying nothing was written
258
+ const iid = String(o.id || v.id || v.key || r.id || '');
259
+ const saveTo = (art, field) => (iid ? ' When I say yes, save it with `pmos artefacts set experiment:' + iid + ' ' + art + ' ' + field + ' --text "<the text>"`' + (art === 'done-test' ? ', once for each check' : '') + ', so The case card shows it.' : '');
260
+ const offer = (k, what, art, field) => ({ miss: k + ' is not written.' + (fromW ? ' Draft it from ' + fromW + '?' : ' Draft it with you?'),
261
+ ask: 'Draft ' + what + ' for ' + title + (fromW ? ' from ' + fromW : '') + ', in two short sentences, for me to read. Say what you read. Do not invent anything the records do not say.' + saveTo(art, field) });
262
+ // a carried line with words: the record's own section (kind record, lib/case-lines.js) or a problem statement the migration carried
263
+ const carriedPath = (a, f) => ((a.carried || []).find((c) => c.field === f && c.text) || (a.carried || []).find((c) => c.field === f && c.path) || null);
259
264
  const lines = [];
260
- // Problem: the Experiment's problem line, else the problem statement it carries
265
+ // Problem: the Experiment's problem line, else the problem statement it carries, else the record's Problem section
261
266
  const pb = textOf(ex.fields.why), pc = carriedPath(ex, 'why');
262
267
  if (pb) lines.push({ id: 'problem', k: 'Problem', text: pb, src: 'the Experiment', edit: { to: 'artefact', artefact: 'experiment', field: 'why' } });
263
268
  else if (pc && pc.text) lines.push({ id: 'problem', k: 'Problem', text: String(pc.text), src: pc.title || 'the problem statement', path: pc.path || '', edit: { to: 'artefact', artefact: 'experiment', field: 'why' } });
264
- else lines.push({ id: 'problem', k: 'Problem', text: '', edit: { to: 'artefact', artefact: 'experiment', field: 'why' }, ...offer('Problem', 'the problem (who has it and what it costs)') });
265
- // Goal: the hypothesis, else the record's description; with the goal or key result it serves, by name
266
- const hy = textOf(ex.fields.hypothesis), ds = v.desc && !importNote(v.desc) ? firstSentences(v.desc, 2) : '';
269
+ else lines.push({ id: 'problem', k: 'Problem', text: '', edit: { to: 'artefact', artefact: 'experiment', field: 'why' }, ...offer('Problem', 'the problem (who has it and what it costs)', 'experiment', 'why') });
270
+ // Goal: the hypothesis, else the record's Goal section, else the record's description; with the goal or key result it serves, by name
271
+ const hy = textOf(ex.fields.hypothesis), hc = carriedPath(ex, 'hypothesis'), ds = v.desc && !importNote(v.desc) ? firstSentences(v.desc, 2) : '';
267
272
  const serves = o.goal ? 'It serves ' + o.goal.replace(/\.$/, '') + '.' : '';
268
273
  if (hy) lines.push({ id: 'goal', k: 'Goal', text: hy, serves, src: 'the Experiment', edit: { to: 'artefact', artefact: 'experiment', field: 'hypothesis' } });
274
+ else if (hc && hc.text) lines.push({ id: 'goal', k: 'Goal', text: String(hc.text), serves, src: hc.title || 'the record', path: hc.path || '', edit: { to: 'artefact', artefact: 'experiment', field: 'hypothesis' } });
269
275
  else if (ds) lines.push({ id: 'goal', k: 'Goal', text: ds, serves, src: 'the record', edit: { to: 'desc' } });
270
- else lines.push({ id: 'goal', k: 'Goal', text: '', serves, edit: { to: 'artefact', artefact: 'experiment', field: 'hypothesis' }, ...offer('Goal', 'what we are trying to achieve') });
271
- // Done when: the done test's checks
276
+ else lines.push({ id: 'goal', k: 'Goal', text: '', serves, edit: { to: 'artefact', artefact: 'experiment', field: 'hypothesis' }, ...offer('Goal', 'what we are trying to achieve', 'experiment', 'hypothesis') });
277
+ // Done when: the done test's checks, else the checks the record's done test file or Done test section holds
272
278
  const ck = Array.isArray(dt.fields.check) ? dt.fields.check.filter((x) => x && x.text) : [];
273
- if (ck.length) lines.push({ id: 'done', k: 'Done when', text: ck[0].text + (ck.length > 1 ? ' (and ' + plural(ck.length - 1, 'more check', 'more checks') + ')' : ''), src: 'the Done test', edit: null });
274
- else lines.push({ id: 'done', k: 'Done when', text: '', edit: { to: 'artefact', artefact: 'done-test', field: 'check' }, ...offer('Done when', 'the done test (how we will know it worked, and when we check)') });
279
+ const cc = (dt.carried || []).filter((c) => c.field === 'check' && c.text);
280
+ const more = (n) => (n > 1 ? ' (and ' + plural(n - 1, 'more check', 'more checks') + ')' : '');
281
+ if (ck.length) lines.push({ id: 'done', k: 'Done when', text: ck[0].text + more(ck.length), src: 'the Done test', edit: null });
282
+ else if (cc.length) lines.push({ id: 'done', k: 'Done when', text: String(cc[0].text) + more(cc.length), src: cc[0].title || 'the record', path: cc[0].path || '', edit: null });
283
+ else lines.push({ id: 'done', k: 'Done when', text: '', edit: { to: 'artefact', artefact: 'done-test', field: 'check' }, ...offer('Done when', 'the done test (how we will know it worked, and when we check)', 'done-test', 'check') });
275
284
  const sm = summaryOf(r, v, o);
276
285
  const status = sm.status.replace(/^It is in /, 'In ');
277
286
  return { lines, status, reading: o.art == null };
@@ -471,6 +480,9 @@ const whenOf = (w, t) => { const s = String(w || ''); return day(s) ? dayText(s,
471
480
 
472
481
  /* ── what PMOS suggests from the record itself (board 3, 25), next to what lib/proposals.js proposes ── */
473
482
  const andList = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
483
+ /** Where a drafted gate document is saved so the Artefacts list and the gate read it (initiative chat-saves-to-cards): the ask used to name no
484
+ * place, so a draft could land where nothing looks. */
485
+ const docSave = (id) => (id ? ' When I say yes, save each one where the Artefacts list reads it: a PRD as a file the record names in `prd_path:`, a rubric in `rubric_path:`, the done test with `pmos artefacts set experiment:' + id + ' done-test check --text "<one check>"` once for each check, and any other document with `pmos coredoc write --scope initiative:' + id + ' --key <key> --file <path>`.' : '');
474
486
  /** derivedOf(r, v, o, bd, arts) → { top: [s], rows: Map(uid → s) }. Each s: { id, derived: true, say, why, ask?, move?, direct? }. ask: the words ✓
475
487
  * sends to Ask PMOS, which does it in a real session; move: { uid, to, name } ✓ puts a task in a stage. direct: { act, to? } ✓ (or a choice)
476
488
  * writes at once through POST /api/boards/ini-<act>, with Undo, and sends `ask` only when the route answers ask: true (bet 1f). o.dropped: the
@@ -493,7 +505,7 @@ export function derivedOf(r, v, o, bd, arts) {
493
505
  const n = (arts || []).filter((a) => !a.missing).length, what = andList(miss.map((m) => 'the ' + m));
494
506
  top.push({ id: 'd:draft', derived: true, say: 'Let me draft ' + what + (n ? ' from the ' + plural(n, 'document', 'documents') : '') + ', for you to read.',
495
507
  why: 'The gate to the next stage needs ' + what + ', and ' + (miss.length === 1 ? 'it is' : 'they are') + ' not written.',
496
- ask: 'Draft ' + what + ' for ' + title + (n ? ' from its ' + plural(n, 'document', 'documents') : '') + ', for me to read.' });
508
+ ask: 'Draft ' + what + ' for ' + title + (n ? ' from its ' + plural(n, 'document', 'documents') : '') + ', for me to read.' + docSave(o.id || v.id || v.key || r.id) });
497
509
  }
498
510
  // honest state (round 3 point 13): closed or done, with open tasks, is a contradiction PMOS asks about
499
511
  const nOpen = (v.tasks || {}).open || 0;
@@ -523,7 +535,7 @@ export function workOf(r, v, o = {}) {
523
535
  }
524
536
 
525
537
  /* ── one level up: a program or a product (boards 26, 27) ── */
526
- /** L: { kind: 'program' | 'product', title, summary, facts: [{ k, v, warn?, note? }], rows: [{ id, kind, title, stage, start, end, done, sub? }],
538
+ /** L: { kind: 'program' | 'product', id?, title, summary, why?, goal?, done?, facts: [{ k, v, warn?, note? }], rows: [{ id, kind, title, stage, start, end, done, sub? }],
527
539
  * docs: [{ title, kind, when, path?, url? }], props? }. The rows one level down keep their own dates; a row with none has no bar. */
528
540
  export function levelOf(L, o = {}) {
529
541
  const t = todayOf(o);
@@ -533,12 +545,15 @@ export function levelOf(L, o = {}) {
533
545
  });
534
546
  const span = spanOf(rows.flatMap((x) => [x.start, x.end]).filter(Boolean), o.mode || 'full', t);
535
547
  const late = rows.filter((x) => x.late).length;
536
- // the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; a line with no source offers a draft
548
+ // the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; a line with no source offers a draft.
549
+ // A program reads its charter's why and goal, and Done when from its last milestone and target (initiative chat-saves-to-cards). A draft is
550
+ // offered only where a command saves it (`pmos program charter`): a product has no store for its goal yet, so its line offers none.
537
551
  const nm = L.kind === 'product' ? 'product' : 'program', who = L.title || 'this ' + nm;
538
- const line = (id, k, text, what) => (text ? { id, k, text: String(text), edit: null } : { id, k, text: '', edit: null, miss: k + ' is not written. Draft it with you?',
539
- ask: 'Draft ' + what + ' for the ' + nm + ' ' + who + ', in two short sentences, for me to read. Say what you read. Do not invent anything the records do not say.' });
540
- const sum = L.summary && !importNote(L.summary) ? firstSentences(L.summary, 2) : '';
541
- const overview = { lines: [line('for', 'For', sum, 'what the ' + nm + ' is for'), line('goal', 'Goal', L.goal || '', 'the goal of the ' + nm), line('done', 'Done when', L.done || '', 'how we will know the ' + nm + ' worked')], status: L.status || '' };
552
+ const save = (f) => (L.kind === 'program' && L.id ? ' When I say yes, save it with `pmos program charter ' + L.id + ' --' + f + ' "<the text>"`, so the program card shows it.' : '');
553
+ const line = (id, k, text, what, f) => (text ? { id, k, text: String(text), edit: null } : { id, k, text: '', edit: null, ...(f && save(f) ? { miss: k + ' is not written. Draft it with you?',
554
+ ask: 'Draft ' + what + ' for the ' + nm + ' ' + who + ', in two short sentences, for me to read. Say what you read. Do not invent anything the records do not say.' + save(f) } : {}) });
555
+ const sum = L.why ? firstSentences(L.why, 2) : L.summary && !importNote(L.summary) ? firstSentences(L.summary, 2) : '';
556
+ const overview = { lines: [line('for', 'For', sum, 'what the ' + nm + ' is for', 'why'), line('goal', 'Goal', L.goal || '', 'the goal of the ' + nm, 'goal'), line('done', 'Done when', L.done || '', 'how we will know the ' + nm + ' worked', '')], status: L.status || '' };
542
557
  return { kind: L.kind, title: L.title, summary: L.summary || '', overview, facts: L.facts || [], rows, span, today: iso(t), late, artefacts: (L.docs || []).map((d) => ({ ...d, when: whenOf(d.when, t) })),
543
558
  suggests: suggestsOf({ props: L.props || null }).top };
544
559
  }
@@ -191,7 +191,15 @@ async function load() {
191
191
  }
192
192
 
193
193
  /* ── presses ── */
194
- const ctxOf = (ws) => { const p = S.list.find((x) => x.ws === ws) || S.list[0]; return { model: p.model, ws: p.ws, today: todayIso(), ns: p.ns, keepNs: (row) => keepNs(p, row), dropNs: (row) => dropNs(p, row) }; };
194
+ const ctxOf = (ws) => { const p = S.list.find((x) => x.ws === ws) || S.list[0]; return { model: p.model, ws: p.ws, today: todayIso(), ns: p.ns, keepNs: (row) => keepNs(p, row), dropNs: (row) => dropNs(p, row), startNs: () => startNs(p) }; };
195
+ /** Draft the North Star: the page's own metric draft run (POST /api/metric-drafts/start), whose draft waits here for the ✓. The chat could not
196
+ * file it: `pmos metrics draft` writes only inside that run (initiative chat-saves-to-cards). → true when the run started or was going. */
197
+ async function startNs(p) {
198
+ const r = await pmPost('/api/metric-drafts/start', { ws: p.ws, scope: 'product', id: p.ws }).catch(() => null);
199
+ if (!r || r.ok === false) { undoToast((r && r.error) || 'PMOS could not start the draft.', () => {}, 4000); return false; }
200
+ undoToast(r.already ? 'PMOS is already drafting the North Star.' : 'PMOS is drafting the North Star. It shows here for your tick.', () => {}, 4000);
201
+ return true;
202
+ }
195
203
  async function keepNs(p, row) {
196
204
  const base = { ws: p.ws, scope: 'product', id: p.ws, row };
197
205
  const r = await pmPost('/api/metric-drafts/keep', base).catch(() => null);
@@ -233,7 +241,7 @@ body.onclick = (e) => {
233
241
  if (d.glLink) { say(d.glSay, false); return; }
234
242
  if (d.glNskeep) { const p = S.list.find((x) => x.ws === d.glNskeep); if (p && p.ns.row) { t.disabled = true; keepNs(p, p.ns.row); } return; }
235
243
  if (d.glNsdrop) { const p = S.list.find((x) => x.ws === d.glNsdrop); if (p && p.ns.row) { t.disabled = true; dropNs(p, p.ns.row); } return; }
236
- if (d.glSetup) { GO.openSetup(ctxOf(d.glSetup)); setTimeout(() => GO.toChat('Draft a North Star for this product from its key results. I approve it with a tick.'), 150); }
244
+ if (d.glSetup) { const c = ctxOf(d.glSetup); GO.openSetup(c); if (c.ns && c.ns.state === 'none') startNs(S.list.find((x) => x.ws === c.ws) || S.list[0]); }
237
245
  };
238
246
  /* the tabs move with the arrow keys (the system's Tabs part) */
239
247
  body.addEventListener('keydown', (e) => {
@@ -9699,6 +9699,11 @@ async function handleRequest(req, res) {
9699
9699
  const r = kitUpdate.upgradeApp(w.root, { version: body.version, logFile: path.join(STATE, 'app-update.log') });
9700
9700
  if (!r.ok) return json(res, { ok: false, error: r.error }, 400);
9701
9701
  kitBusy = 'app';
9702
+ // phone-update: a press from the phone's Settings names its place, so the health number can count them.
9703
+ if (body.place === 'phone') {
9704
+ console.log(`[phone-update] ${APP_VERSION} -> ${body.version}`);
9705
+ try { require('./lib/use-log.js').record(STATE, [{ kind: 'use', page: 'phone-settings', control: 'phone-update', device: 'phone' }]); } catch { /* the count misses one */ }
9706
+ }
9702
9707
  return json(res, { ok: true, ws: w.id, from: APP_VERSION, to: body.version, log: r.log });
9703
9708
  }
9704
9709
  /* ── page-starts-agent: a console3 press starts an agent session (a draft, a spike, an early gate), shown in Sessions ── */
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "What the chat writes shows on the workspace cards (initiative chat-saves-to-cards, done test C1-C9): one reader for the case card, pmos why and pmos ready check; the save commands in each ask; pmos program charter. Pure checks on a scratch repository. No server, model or network.",
3
+ "modules": [
4
+ "case-lines.test.js"
5
+ ],
6
+ "seconds": {
7
+ "case-lines.test.js": 3
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "phone-update: phone Settings' Update button asks the computer to install the newer PMOS (pure markup + source checks, node, no browser).",
3
+ "modules": [
4
+ "phone-update.test.js"
5
+ ],
6
+ "seconds": {
7
+ "phone-update.test.js": 1
8
+ }
9
+ }