create-pmos 0.724.0 → 0.726.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.724.0",
3
+ "version": "0.726.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.726.0",
38
+ "at": "2026-11-23T04:24:12.361Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1604,
43
+ "t": "What the chat writes shows on the workspace cards",
44
+ "s": "What the chat writes shows on the workspace cards",
45
+ "k": "fix"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.725.0",
51
+ "at": "2026-11-23T03:46:31.972Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1602,
56
+ "t": "Jira sprint read and account lookup work with the Atlassian MCP connector",
57
+ "s": "Jira sprint read and account lookup work with the Atlassian MCP connector",
58
+ "k": "fix"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.724.0",
38
64
  "at": "2026-11-23T02:49:31.191Z",
@@ -428,50 +454,6 @@
428
454
  "k": "new"
429
455
  }
430
456
  ]
431
- },
432
- {
433
- "v": "0.697.0",
434
- "at": "2026-11-22T09:56:23.025Z",
435
- "f": 4,
436
- "prs": [
437
- {
438
- "n": 1516,
439
- "t": "Your move's question list derives the rows once, not once per initiative",
440
- "s": "Your move's question list derives the rows once, not once per initiative",
441
- "k": "fix"
442
- },
443
- {
444
- "n": 1513,
445
- "t": "No \"Waiting for design\" tag or card reaches a user (A460)",
446
- "s": "No \"Waiting for design\" tag or card reaches a user (A460)",
447
- "k": "new"
448
- },
449
- {
450
- "n": 1498,
451
- "t": "One Komorebi token change reaches every page (token-first step 1)",
452
- "s": "One Komorebi token change reaches every page (token-first step 1)",
453
- "k": "new"
454
- }
455
- ]
456
- },
457
- {
458
- "v": "0.693.0",
459
- "at": "2026-11-22T09:36:04.094Z",
460
- "f": 4,
461
- "prs": [
462
- {
463
- "n": 1515,
464
- "t": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
465
- "s": "Show who raised each initiative (Raised by column, group, sort and filter on Work)",
466
- "k": "new"
467
- },
468
- {
469
- "n": 1490,
470
- "t": "Delete Home's desk page, its fold and its rail card (home-page-retire slice 1b)",
471
- "s": "Delete Home's desk page, its fold and its rail card (home-page-retire slice 1b)",
472
- "k": "imp"
473
- }
474
- ]
475
457
  }
476
458
  ]
477
459
  }
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@a232108d
1
+ kernel-source: pmos@bf09ceab
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-23T02:49:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:24:09Z"}
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-23T02:49:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:24:09Z"}
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-23T02:49:27Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T04:24:09Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.726.0",
4
+ "at": "2026-11-23T04:24:12.361Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1604,
9
+ "t": "What the chat writes shows on the workspace cards",
10
+ "s": "What the chat writes shows on the workspace cards",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.725.0",
17
+ "at": "2026-11-23T03:46:31.972Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1602,
22
+ "t": "Jira sprint read and account lookup work with the Atlassian MCP connector",
23
+ "s": "Jira sprint read and account lookup work with the Atlassian MCP connector",
24
+ "k": "fix"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.724.0",
4
30
  "at": "2026-11-23T02:49:31.191Z",
@@ -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
 
@@ -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 };
@@ -8,12 +8,16 @@ const WRITE_VERBS = new Set(['create', 'update', 'delete', 'add', 'post', 'send'
8
8
  'clear', 'fork', 'enable', 'disable', 'untrash', 'unmark', 'unlabel', 'cancel', 'install', 'import', 'export', 'generate', 'use', 'push', 'request', 'rename']);
9
9
  const words = (s) => String(s).replace(/([a-z0-9])([A-Z])/g, '$1 $2').split(/[^A-Za-z0-9]+/).filter(Boolean).map((w) => w.toLowerCase());
10
10
 
11
+ // Read tools whose name has no read verb. The Atlassian MCP connector's account lookup (2026-11-23): without it the Jira mentions read
12
+ // cannot find the PM's account and saves "not reached".
13
+ const READ_NAMES = new Set(['atlassianUserInfo']);
11
14
  /** A tool may be granted only when its own name (after the server prefix) leads with a read verb and holds no write verb. */
12
15
  function readTool(toolName, prefix) {
13
16
  const own = prefix && toolName.startsWith(prefix) ? toolName.slice(prefix.length) : toolName.replace(/^mcp__[^_]+(?:_[^_]+)*?__/, '');
17
+ if (READ_NAMES.has(own)) return true;
14
18
  const w = words(own);
15
19
  if (!w.length || w.some((x) => WRITE_VERBS.has(x))) return false;
16
20
  return w.slice(0, 3).some((x) => READ_VERBS.has(x));
17
21
  }
18
22
 
19
- module.exports = { readTool, READ_VERBS, WRITE_VERBS };
23
+ module.exports = { readTool, READ_VERBS, WRITE_VERBS, READ_NAMES };
@@ -281,7 +281,7 @@ const CONNECTOR_READ_SEED = Object.freeze([
281
281
  // The official Atlassian MCP connector (2026-11-23) is named "Atlassian MCP", so Claude Code names its tools `mcp__claude_ai_Atlassian_MCP__…`
282
282
  // and has fewer, broader ones. Both prefixes are seeded: a PM may have either connector, and an unknown name is harmless.
283
283
  ...['getAccessibleAtlassianResources', 'searchJiraIssuesUsingJql', 'getJiraIssue', 'listJiraIssueComments', 'getConfluenceContent',
284
- 'searchConfluence', 'search'].map((t) => 'mcp__claude_ai_Atlassian_MCP__' + t),
284
+ 'searchConfluence', 'search', 'atlassianUserInfo'].map((t) => 'mcp__claude_ai_Atlassian_MCP__' + t),
285
285
  ...['slack_read_channel', 'slack_read_thread', 'slack_read_canvas', 'slack_read_user_profile', 'slack_search_public', 'slack_search_public_and_private',
286
286
  'slack_search_channels', 'slack_search_users', 'slack_list_user_channels'].map((t) => 'mcp__claude_ai_Slack__' + t),
287
287
  ...['list_events', 'get_event', 'search_events', 'list_calendars'].map((t) => 'mcp__claude_ai_Google_Calendar__' + t),
@@ -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.724.0",
3
+ "version": "0.726.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.724.0",
9
+ "version": "0.726.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.724.0",
3
+ "version": "0.726.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 };
@@ -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) => {
@@ -40,7 +40,7 @@ Procedure:
40
40
  The shape Jira returned (`{"issues": [{"key", "self", "fields": {...}}]}`) is also accepted, as it is: you do not need to rewrite it.
41
41
  WHEN A SEARCH RESULT IS SAVED TO A FILE (the tool says the output was too large and names a file): do not open, parse or copy that file. Give the file as it is to `pmos jira sync --from <that file>`. For several pages, give one file per page, separated by commas: `--from <page 1>,<page 2>`. You can also write each page's result to the scratch folder with Write exactly as Jira returned it.
42
42
  4. Run `pmos jira sync <initiative> --from <the file> --query "<the JQL>"`. It prints the snapshot it saved. If it refuses, read the reason, fix the file and run it once more. A read that saves no snapshot has failed: never finish with "Checked" for an initiative whose sync did not print "snapshot …".
43
- 4a. Read the whole sprints, after every initiative is synced. Run `pmos jira query --sprints`. It prints one Jira search for every issue in the sprints the tickets above are in, whoever the issue is assigned to. Do this even when the task names one initiative. If it prints "no Jira reading has a sprint yet" or "every sprint is closed and summarised once", skip to step 4b. Otherwise run that search with the same fields as step 2, fetch every page, save the result in the scratch folder in the same shape as step 3 (for example `<scratch>/jira-sprints.json`), run `pmos jira sync --sprints --from <the file> --query "<the JQL>"`. Do not record people from this search (step 5 is for the initiatives' own issues).
43
+ 4a. Read the whole sprints, after every initiative is synced. Run `pmos jira query --sprints`. It prints one Jira search for every issue in the sprints the tickets above are in, whoever the issue is assigned to. Do this even when the task names one initiative. If it prints "no Jira reading has a sprint yet" or "every sprint is closed and summarised once", skip to step 4b. Otherwise run that search with the same fields as step 2, at most 20 issues per page (a sprint holds many issues, and a larger page is too long to keep), fetch every page. When a page is saved to a file, give the saved files to `pmos` as they are (`--from <page 1>,<page 2>,…`) instead of copying them. Otherwise save the result in the scratch folder in the same shape as step 3 (for example `<scratch>/jira-sprints.json`), run `pmos jira sync --sprints --from <the file> --query "<the JQL>"`. Do not record people from this search (step 5 is for the initiatives' own issues).
44
44
  4b. Write each sprint's goal and summary, after step 4a. Run `pmos jira summary`. Each line is a sprint that needs one: its name, its state, its number of issues and Jira's goal. A closed sprint that is already summarised is listed as kept: do not write it again. If it prints "no sprint needs a summary", skip this step. For each listed sprint, read its issues in the sprint search result of step 4a and write:
45
45
  - `goal`: `{"text": "<the goal>", "jira": "<Jira's goal, or null>"}`. Always write the goal yourself from the sprint's tickets, in one sentence of at most 240 characters: what the sprint delivers when its tickets are done, naming the two or three largest outcomes. Do not copy Jira's sprint goal: it is often empty, too broad or incomplete. Put Jira's own goal in `"jira"` only as a reference, exactly as Jira writes it.
46
46
  - `summary`: two to four plain sentences on what the team is working on: what is done, what is moving, what is blocked. For a closed sprint, say if the goal was met and what moved to the next sprint.
@@ -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
+ }