create-pmos 0.797.0 → 0.799.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.797.0",
3
+ "version": "0.799.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,47 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.799.0",
38
+ "at": "2026-11-25T00:01:31.314Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1824,
43
+ "t": "Drafting the goal keeps the initiative page; one toast for one draft press",
44
+ "s": "Drafting the goal keeps the initiative page; one toast for one draft press",
45
+ "k": "fix",
46
+ "try": {
47
+ "steps": [
48
+ "On a phone, open Work and tap an initiative whose Problem or Goal is not written.",
49
+ "In Where it stands, tap the ✦ Draft the Problem and Goal line.",
50
+ "Wait for the drafts, then press Undo on the toast."
51
+ ],
52
+ "see": "the page stays on the initiative's work while PMOS drafts; one toast says 'Problem and Goal drafted.' and Undo takes both lines back. If the Dashboard is your chosen view, its list icon in the…",
53
+ "open": "/premium-board.html"
54
+ }
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "v": "0.798.0",
60
+ "at": "2026-11-24T23:17:36.353Z",
61
+ "f": 4,
62
+ "prs": [
63
+ {
64
+ "n": 1822,
65
+ "t": "The merge station runs the strict guardrail on every merge (A508)",
66
+ "s": "The merge station runs the strict guardrail on every merge (A508)",
67
+ "k": "new"
68
+ },
69
+ {
70
+ "n": 1823,
71
+ "t": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
72
+ "s": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
73
+ "k": "fix"
74
+ }
75
+ ]
76
+ },
36
77
  {
37
78
  "v": "0.797.0",
38
79
  "at": "2026-11-24T23:00:19.305Z",
@@ -423,50 +464,6 @@
423
464
  "k": "new"
424
465
  }
425
466
  ]
426
- },
427
- {
428
- "v": "0.779.0",
429
- "at": "2026-11-24T15:18:38.678Z",
430
- "f": 4,
431
- "prs": [
432
- {
433
- "n": 1743,
434
- "t": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
435
- "s": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
436
- "k": "new",
437
- "h": "PMOS reads each report draft as the CFO, engineer and sceptic, questions under the ✦",
438
- "try": {
439
- "steps": [
440
- "Open Library and draft a report (or ask the chat: draft the weekly report)",
441
- "Wait about a minute, then open Work and the ✦ on an initiative the report covers"
442
- ],
443
- "see": "The ✦ lists up to 6 questions such as 'CFO asks: What does a slip of the cutover cost?', each quoting the report, with the smallest fix as its next step"
444
- }
445
- }
446
- ]
447
- },
448
- {
449
- "v": "0.778.0",
450
- "at": "2026-11-24T14:17:30.065Z",
451
- "f": 4,
452
- "prs": [
453
- {
454
- "n": 1745,
455
- "t": "Every live initiative gets an expected outcome and a check date",
456
- "s": "Every live initiative gets an expected outcome and a check date",
457
- "k": "new",
458
- "h": "Every live initiative gets an expected outcome and a check date",
459
- "try": {
460
- "steps": [
461
- "Open Work and open an initiative that had no expected outcome",
462
- "Press its ✦ and find Expected outcome",
463
- "Press Undo on it if it is wrong"
464
- ],
465
- "see": "The initiative shows an expected outcome and a check date that PMOS drafted, with the line it came from, and Undo takes it back",
466
- "open": "/premium-board.html"
467
- }
468
- }
469
- ]
470
467
  }
471
468
  ]
472
469
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@be523cf59
2
- assembled: 2026-11-24
1
+ kernel-source: pmos@5ab2efffc
2
+ assembled: 2026-11-25
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-24T23:00:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T00:01:27Z"}
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-24T23:00:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T00:01:27Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -37,6 +37,8 @@
37
37
  * [--github --pr <number>] in GitHub Actions only: write verdict to GITHUB_OUTPUT and the step summary; on auto run
38
38
  * `gh pr ready` and `gh pr merge --auto --squash` with the workflow's own token; on human turn
39
39
  * auto-merge off. The agent never runs this: the Builder has no node, gh or push.
40
+ * node scripts/factory-guardrail.js --line --base origin/main --head <pr head> [--job <id>] [--body-file <f>] [--json]
41
+ * the in-repo factory line's merge station (factory/stations/merge.md): lineVerdict below.
40
42
  * Exit 0 for every verdict (the check reports, it does not block). A failure to read anything is `human`, never `auto`.
41
43
  */
42
44
  const fs = require('fs');
@@ -321,7 +323,62 @@ function classify({ cwd = process.cwd(), base, head, branch = '', body = '', led
321
323
  return { factory: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
322
324
  }
323
325
 
326
+ /* ---- the in-repo factory line (factory/, A508). Its jobs are GitHub issues and its pull requests carry `Initiative: <id>` or
327
+ * `Factory-Job: <id>`, not a pmos/<item> branch, so classify() answered `none` for every one of them. The merge station runs this
328
+ * on every merge instead. It keeps the irreversible list strict: migrations and data deletion, auth/payments/personal data/secrets,
329
+ * CI and gates, a new dependency, a public API, anything sent outward, a new agent path, agent rules and decision records, and the
330
+ * improvement loop. Any one of them → `human`: the merge waits for Wawan. It leaves out the D108 conditions that only a product
331
+ * repository's work-item ledger can answer (scope, flag, verified, pmos-review): on this line the merge station merges on green CI.
332
+ * It also leaves out changed tests and done tests (every build adds a done test and may fix a test; the Checker grades them) and the
333
+ * D11 history flags (an L2 flag, not an irreversible kind).
334
+ * lineVerdict({ cwd, base, head, body, job }) → { factory: true, item: job, verdict: 'auto'|'human', reasons, files } */
335
+ const LINE_SKIP = new Set(['eval-files']);
336
+ function jobOf(body) {
337
+ const m = /^(?:Factory-Job|Initiative):\s*([a-z0-9][a-z0-9-]*)\s*$/mi.exec(String(body || ''));
338
+ return m ? m[1].toLowerCase() : null;
339
+ }
340
+ function lineVerdict({ cwd = process.cwd(), base, head, body = '', job = null } = {}) {
341
+ const item = job || jobOf(body);
342
+ const reasons = [];
343
+ const human = (rule, detail) => reasons.push({ rule, detail });
344
+ if (/^PMOS-Merge:\s*human\s*$/mi.test(String(body || ''))) human('pmos-merge-human', 'the pull request asks for a person (PMOS-Merge: human)');
345
+ if (!base || !head) { human('unreadable', 'no base or head to compare'); return { factory: true, line: true, item, verdict: 'human', reasons, files: [] }; }
346
+ const d = diffOf(cwd, base, head);
347
+ if (d.error) { human('unreadable', d.error); return { factory: true, line: true, item, verdict: 'human', reasons, files: [] }; }
348
+ const files = d.files, all = [];
349
+ if (!files.length) human('empty', 'the pull request changes nothing');
350
+ for (const f of files) {
351
+ const p = f.path, l = p.toLowerCase(), base_ = path.posix.basename(l);
352
+ all.push(...(d.added.get(p) || []).map((t) => [p, t]));
353
+ if (CI.test(l) || GUARD_NAME.test(l)) human('ci-gates', `${p} is CI, a gate, the guardrail, a PMOS record or branch protection`);
354
+ if (AGENT_FILES.test(l) || segHas(p, AGENT_PATH)) human('agent-path', `${p} is an agent rule, prompt or skill (a new agent path)`);
355
+ if (segHas(p, MIGRATION) || /schema\.prisma$|(^|\/)db\/schema\./.test(l)) human('migration', `${p} is a migration or a schema`);
356
+ if (segHas(p, SENSITIVE) || /(^|\/)\.env(\.|$)|\.(pem|key|p12|pfx|jks)$/.test(l)) human('sensitive', `${p} touches auth, permissions, payments, personal data or secrets`);
357
+ if (segHas(p, API) || /(^|\/)index\.d\.ts$/.test(l)) human('public-api', `${p} is a public API or contract`);
358
+ if (LOCKS.includes(base_)) human('dependency', `${p} changes a lock file (a dependency may be new)`);
359
+ if (MANIFESTS.includes(base_) && (d.added.get(p) || []).some((t) => t.trim())) human('dependency', `${p} changes a dependency manifest`);
360
+ if (base_ === 'package.json') {
361
+ const before = git(cwd, ['show', `${base}:${f.from || p}`]), after = git(cwd, ['show', `${head}:${p}`]);
362
+ const a = before.ok ? depsOf(before.out) : new Set(), b = after.ok ? depsOf(after.out) : null;
363
+ if (!a || !b) human('dependency', `${p} could not be read`);
364
+ else { const added = [...b].filter((x) => !a.has(x)); if (added.length) human('dependency', `${p} adds ${added.map((x) => x.split(':')[1]).join(', ')}`); }
365
+ }
366
+ }
367
+ for (const r of harnessTriggers(files, { body })) if (!LINE_SKIP.has(r.rule)) human(r.rule, r.detail);
368
+ const code = all.filter(([p]) => !/\.(md|mdx|txt|rst|adoc)$/i.test(p) && !TEST_FILE.test(p.toLowerCase()) && !TEST_NAME.test(p.toLowerCase()));
369
+ for (const t of ADDED) {
370
+ const hit = code.find(([, line]) => t.re.test(line));
371
+ if (hit) human(t.rule, `${hit[0]} ${t.why}: "${one(hit[1], 100)}"`);
372
+ }
373
+ const seen = new Set();
374
+ const uniq = reasons.filter((r) => { const k = r.rule + '|' + r.detail; if (seen.has(k)) return false; seen.add(k); return true; });
375
+ return { factory: true, line: true, item, verdict: uniq.length ? 'human' : 'auto', reasons: uniq, files: files.map((f) => f.path) };
376
+ }
377
+
324
378
  function summaryOf(v) {
379
+ if (v.line) return v.verdict === 'auto'
380
+ ? `pmos-guardrail (factory line): MERGE ${v.item || 'this pull request'} when required CI is green. Nothing on the irreversible list.`
381
+ : [`pmos-guardrail (factory line): WAIT FOR WAWAN on ${v.item || 'this pull request'}, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
325
382
  if (v.verdict === 'none') return 'pmos-guardrail: not a factory pull request. Nothing to do.';
326
383
  if (v.verdict === 'auto') return `pmos-guardrail: AUTO for ${v.item}. The pmos-review check passed. Auto-merge is on: GitHub merges when every required check is green. The change reaches users only through its flag.`;
327
384
  return [`pmos-guardrail: HUMAN for ${v.item || 'this revert'}. A person merges this pull request, because:`, ...v.reasons.map((r) => `- ${r.detail}`)].join('\n');
@@ -342,14 +399,18 @@ function actOnGitHub(v, { pr, env = process.env } = {}) {
342
399
  function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd() } = {}) {
343
400
  const opt = (k) => { const i = argv.indexOf(k); return i !== -1 && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
344
401
  const base = opt('--base'), head = opt('--head');
345
- if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--review-state <s>] [--json] [--github --pr <n>]'); return 2; }
402
+ if (!base || !head) { say('usage: node factory-guardrail.js --base <ref> --head <ref> [--branch <name>] [--body-file <f>] [--review-state <s>] [--json] [--github --pr <n>] | --line [--job <id>]'); return 2; }
346
403
  let body = '';
347
404
  if (opt('--body-file')) { try { body = fs.readFileSync(opt('--body-file'), 'utf8'); } catch { body = 'PMOS-Merge: human'; } }
348
405
  let v;
349
406
  // the CLI always judges the review: an absent --review-state (or an empty one) is "no review", never a pass
350
407
  const review = opt('--review-state') || null;
351
- try { v = classify({ cwd, base, head, branch: opt('--branch') || '', body, headRepo: opt('--head-repo') || null, baseRepo: opt('--base-repo') || null, review }); }
352
- catch (e) { v = { factory: true, item: null, verdict: 'human', reasons: [{ rule: 'unreadable', detail: 'the guardrail failed: ' + one(e.message, 200) }], files: [] }; }
408
+ // --line: the in-repo factory line (factory/stations/merge.md), job from --job or the body's Initiative:/Factory-Job: line (A508)
409
+ const line = argv.includes('--line');
410
+ try {
411
+ v = line ? lineVerdict({ cwd, base, head, body, job: opt('--job') || null })
412
+ : classify({ cwd, base, head, branch: opt('--branch') || '', body, headRepo: opt('--head-repo') || null, baseRepo: opt('--base-repo') || null, review });
413
+ } catch (e) { v = { factory: true, line, item: null, verdict: 'human', reasons: [{ rule: 'unreadable', detail: 'the guardrail failed: ' + one(e.message, 200) }], files: [] }; }
353
414
  say(argv.includes('--json') ? JSON.stringify(v) : summaryOf(v));
354
415
  if (argv.includes('--github')) {
355
416
  for (const r of actOnGitHub(v, { pr: opt('--pr'), env })) say(`gh ${r.args.join(' ')} → ${r.status}${r.out ? ' ' + r.out : ''}`);
@@ -357,5 +418,5 @@ function cliMain(argv, { say = (s) => console.log(s), env = process.env, cwd = p
357
418
  return 0;
358
419
  }
359
420
 
360
- module.exports = { classify, harnessTriggers, HARNESS, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS, MANIFESTS, LOCKS };
421
+ module.exports = { classify, lineVerdict, jobOf, harnessTriggers, HARNESS, summaryOf, actOnGitHub, cliMain, REVERT_DAYS, STALE_DAYS, MANIFESTS, LOCKS };
361
422
  if (require.main === module) process.exitCode = cliMain(process.argv.slice(2));
@@ -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-24T23:00:15Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T00:01:27Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  Newest first, ISO dates.
4
4
 
5
- ## 2026-11-24
5
+ ## 2026-11-25
6
6
 
7
7
  - Adopted OKF v0.2 (D73).
@@ -1,4 +1,45 @@
1
1
  [
2
+ {
3
+ "v": "0.799.0",
4
+ "at": "2026-11-25T00:01:31.314Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1824,
9
+ "t": "Drafting the goal keeps the initiative page; one toast for one draft press",
10
+ "s": "Drafting the goal keeps the initiative page; one toast for one draft press",
11
+ "k": "fix",
12
+ "try": {
13
+ "steps": [
14
+ "On a phone, open Work and tap an initiative whose Problem or Goal is not written.",
15
+ "In Where it stands, tap the ✦ Draft the Problem and Goal line.",
16
+ "Wait for the drafts, then press Undo on the toast."
17
+ ],
18
+ "see": "the page stays on the initiative's work while PMOS drafts; one toast says 'Problem and Goal drafted.' and Undo takes both lines back. If the Dashboard is your chosen view, its list icon in the…",
19
+ "open": "/premium-board.html"
20
+ }
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "v": "0.798.0",
26
+ "at": "2026-11-24T23:17:36.353Z",
27
+ "f": 4,
28
+ "prs": [
29
+ {
30
+ "n": 1822,
31
+ "t": "The merge station runs the strict guardrail on every merge (A508)",
32
+ "s": "The merge station runs the strict guardrail on every merge (A508)",
33
+ "k": "new"
34
+ },
35
+ {
36
+ "n": 1823,
37
+ "t": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
38
+ "s": "Use it in the status editor keeps the whole text in the log (job #1817, A505)",
39
+ "k": "fix"
40
+ }
41
+ ]
42
+ },
2
43
  {
3
44
  "v": "0.797.0",
4
45
  "at": "2026-11-24T23:00:19.305Z",
@@ -189,7 +189,7 @@ On a computer the popup is built from the parts of the PMOS design system. The t
189
189
  **Overview** is one block across the top. Press its name to fold it, and press it again to open it. PMOS keeps your choice for every initiative, on each device you use. When it is folded, it shows one line of **Where it stands**, and **1 suggestion** (or more) when PMOS has one; press that to open it. When it is open, it shows three parts side by side:
190
190
 
191
191
  - **Where it stands.** What is happening, in a few sentences. Then **Next**: the next three dates, a milestone as a diamond and the outcome check as a circle; press a milestone to open it. Then one suggestion from PMOS with **Why**, **PMOS will** and **Based on**. The pencil opens it so you can change it first, ✓ does it and ✕ drops it. Other suggestions are one link under it.
192
- - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records. Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself. When the chat saves a line, the case shows it as soon as the chat's turn ends, with no reload and no commit. It also reads its lines again when you come back to the page.
192
+ - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records. Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself. When PMOS drafts several lines from one press, one message names them ("Problem and Goal drafted."), and its **Undo** takes back every line it wrote. When the chat saves a line, the case shows it as soon as the chat's turn ends, with no reload and no commit. It also reads its lines again when you come back to the page.
193
193
  - **Details.** The facts: dates, the next milestone, product, program, workflow and what is open.
194
194
 
195
195
  Under it, two blocks use the full width of the popup:
@@ -487,7 +487,7 @@ The shape is before the title on Work, Goals and the phone rows, in the Status c
487
487
 
488
488
  Where a status shows (a card on Work, the top of an initiative, a row on Home and a row on the phone), you see the state shape, the stage, and one line of at most 12 words. PMOS sets the stage from the work itself, so the line says only what is new.
489
489
 
490
- To write a status, press the status line at the top of an initiative. A count shows how many words you have used, for example "9 of 12 words". Past 12 words, the count turns red and PMOS suggests a short line from your text. Select **Use it** to keep that line, or edit it. When you save, the whole text goes to the initiative's log with its date and author, and the short line becomes the status. Nothing is lost.
490
+ To write a status, press the status line at the top of an initiative. A count shows how many words you have used, for example "9 of 12 words". Past 12 words, the count turns red and PMOS suggests a short line from your text. Select **Use it** to keep that line, or edit it. When you save, the whole text goes to the initiative's log with its date and author, and the short line becomes the status. Nothing is lost, also when you edit the line after **Use it**. If you then write past 12 words again, your new text is the whole text.
491
491
 
492
492
  From a terminal or the chat, `pmos initiative status <id>` shows the line and the log, and `pmos initiative status <id> "<text>"` saves a status.
493
493
 
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Reports and dashboards: set up, shape, design, draft and issue"
4
4
  description: "Set up a report by asking, shape what it says, design how it looks, draft and issue a cadence report, and the ready-made dashboards."
5
- timestamp: 2026-11-22
5
+ timestamp: 2026-11-24
6
6
  ---
7
7
 
8
8
  # Reports and dashboards
@@ -417,7 +417,7 @@ PMOS puts only a few of these on a schedule by itself. The others draft when the
417
417
 
418
418
  ### Where the dashboard shows
419
419
 
420
- - **Program and initiative.** One icon in the header switches between **Work** and **Dashboard**. The page remembers your last choice for each program and initiative. Until you choose, a Work row opens on Work. The charter is still under the **Milestones** pencil and in **Documents**.
420
+ - **Program and initiative.** One icon in the header switches between **Work** and **Dashboard**. The page remembers your last choice for each program and initiative. Until you choose, a Work row opens on Work. The charter is still under the **Milestones** pencil and in **Documents**. When you press something on Work before the dashboard has loaded, the page stays on Work, even when your last choice was Dashboard. On a phone, the icon that brings back Work stays in the header while the dashboard shows.
421
421
  - **Product.** The product page is the dashboard. Its reports are in **This week**.
422
422
 
423
423
  The dashboard shows these blocks, in this order:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.797.0",
3
+ "version": "0.799.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.797.0",
9
+ "version": "0.799.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.797.0",
3
+ "version": "0.799.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",
@@ -21,6 +21,7 @@ import * as M from './pop-work-model.js';
21
21
  import * as CB from './cozy-bar.js';
22
22
  import { openPop, closePop, undoToast } from './hi-pop.js';
23
23
  import { pmGet, pmPost } from './http.js';
24
+ import * as SE from './status-edit.js';
24
25
  import * as LE from './live-edit.js'; // an edit shows at once: this popup is drawn again the moment a task write is sent, and after each read
25
26
  import * as VW from './cozy-viewer.js';
26
27
  import * as ED from './ini-edit.js';
@@ -638,14 +639,29 @@ function toAsk(text, h) {
638
639
  * job (pm/star-draft.js, POST /api/star-drafts) with no chat and no session of the PM's. The line says PMOS is drafting it; the draft then
639
640
  * lands on the line itself through the line's own save, with Undo. A job that fails says why, with Try again. */
640
641
  const DRAFTING = new Set(); // '<popup key>:<line id>' while its job runs
641
- async function draftLine(L, x, h) {
642
+ /* o.quiet: no toast of its own; the line's saved ref comes back so one press that drafts several lines says it once (draftLines) */
643
+ async function draftLine(L, x, h, o = {}) {
642
644
  const w = h.where ? h.where() : {}, kid = keyOf(x.v(), x.o()), k = kid + ':' + L.id;
643
- if (DRAFTING.has(k)) return;
645
+ if (DRAFTING.has(k)) return null;
644
646
  DRAFTING.add(k); if (h.redraw) h.redraw();
645
647
  const r = await SD.run(L.ask, { ws: w.ws || x.o().ws, pmPost, pmGet });
646
648
  DRAFTING.delete(k);
647
- if (!r.ok) { if (h.redraw) h.redraw(); undoToast(r.why, () => draftLine(L, x, h), 12000, 'Try again'); return; }
648
- await saveLine(L, r.text.replace(/\s+/g, ' ').trim().slice(0, 600), x, h);
649
+ if (!r.ok) { if (h.redraw) h.redraw(); undoToast(L.k + ': ' + r.why, () => draftLine(L, x, h), 12000, 'Try again'); return null; }
650
+ return saveLine(L, r.text.replace(/\s+/g, ' ').trim().slice(0, 600), x, h, { quiet: o.quiet, said: L.k + ' drafted.' });
651
+ }
652
+ /** One press that drafts several lines ("Draft the Problem and Goal"): the drafts run side by side and land with ONE toast that names every
653
+ * line drafted and ONE Undo for all of them. Before, each line's own toast replaced the last, so "Problem saved." stood for a press about the
654
+ * goal and Undo took back only one line. */
655
+ async function draftLines(Ls, x, h) {
656
+ if (Ls.length === 1) { await draftLine(Ls[0], x, h); return; }
657
+ const got = await Promise.all(Ls.map((L) => draftLine(L, x, h, { quiet: true }).then((ref) => (typeof ref === 'string' && ref ? { L, ref } : null))));
658
+ const ok = got.filter(Boolean); if (!ok.length) return;
659
+ const w = h.where ? h.where() : {}, o = x.o(), ws = w.ws || o.ws, names = ok.map((g) => g.L.k);
660
+ undoToast((names.length === 2 ? names.join(' and ') : names.length + ' lines') + ' drafted.', async () => {
661
+ let bad = '';
662
+ for (const g of ok) { const u = await pmPost('/api/artefacts/undo', { ws, ref: g.ref }).catch(() => null); if (!u || u.ok === false) bad = (u && u.error) || 'The undo did not land.'; }
663
+ ART.delete(o.id); if (bad && h.toast) h.toast(bad); if (h.redraw) h.redraw();
664
+ });
649
665
  }
650
666
  /* a program's line (its charter's why or goal): the same job, saved with POST /api/programs/save, and Undo saves the line as it was */
651
667
  const LV_FIELD = { for: 'why', goal: 'goal' };
@@ -785,9 +801,7 @@ async function saveDesc(text, x, h) {
785
801
  * The editor counts the words ("9 of 12 words"); past 12 the count turns red and PMOS offers a short line from the text (POST
786
802
  * /api/initiative/status-suggest, a normal session, else the first 12 words). Use it puts the line in; Save keeps the whole text in the
787
803
  * item's log and the line as the status (POST /api/initiative/status). Escape leaves it as it was. */
788
- const SL_MAX = 12;
789
804
  let SLED = null; // the open status editor's Use it and Save
790
- const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
791
805
  function editStatus(btn, W, x, h) {
792
806
  const p = btn.closest('.pw-ostat');
793
807
  if (!p || p.querySelector('textarea')) return;
@@ -796,36 +810,36 @@ function editStatus(btn, W, x, h) {
796
810
  + `<span class="pw-swb"><button type="button" class="pw-lk" data-sw-save>Save</button></span>`;
797
811
  const ta = p.querySelector('textarea'), wc = p.querySelector('.pw-swc'), sg = p.querySelector('.pw-sws');
798
812
  ta.value = was; ta.focus();
799
- let line = '', tm = null, asked = '';
813
+ const st = SE.slState(was); // Use it keeps the whole text, so Save logs it (job #1817)
814
+ let tm = null, asked = '';
800
815
  const count = () => {
801
- const n = slWords(ta.value);
802
- wc.textContent = n + ' of ' + SL_MAX + ' words'; wc.classList.toggle('over', n > SL_MAX);
803
- if (n <= SL_MAX) { line = ''; sg.innerHTML = ''; return; }
816
+ const n = SE.slWords(ta.value);
817
+ st.input(ta.value);
818
+ wc.textContent = n + ' of ' + SE.SL_MAX + ' words'; wc.classList.toggle('over', n > SE.SL_MAX);
819
+ if (n <= SE.SL_MAX) { sg.innerHTML = ''; return; }
804
820
  clearTimeout(tm);
805
821
  tm = setTimeout(async () => {
806
822
  const text = ta.value; if (text === asked) return; asked = text;
807
823
  const w = h.where ? h.where() : {};
808
824
  const r = await pmPost('/api/initiative/status-suggest', { ws: w.ws, id: x.o().id, text }).catch(() => null);
809
825
  if (!r || r.ok === false || ta.value !== text) return;
810
- line = r.line;
811
- sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
826
+ st.suggest(r.line);
827
+ sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${SE.slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
812
828
  }, 600);
813
829
  };
814
830
  ta.addEventListener('input', count); count();
815
831
  let done = false;
816
832
  const leave = async (save) => {
817
833
  if (done) return; done = true; clearTimeout(tm); SLED = null;
818
- const text = ta.value.replace(/\s+/g, ' ').trim();
819
- if (!save || !text || text === was) { if (h.redraw) h.redraw(); return; }
834
+ const b = save ? st.save(ta.value) : null;
835
+ if (!b) { if (h.redraw) h.redraw(); return; }
820
836
  const w = h.where ? h.where() : {};
821
- const body = { ws: w.ws, id: x.o().id, text };
822
- if (slWords(text) > SL_MAX && line) body.line = line;
823
- const res = await pmPost('/api/initiative/status', body).catch(() => null);
837
+ const res = await pmPost('/api/initiative/status', { ws: w.ws, id: x.o().id, ...b }).catch(() => null);
824
838
  if (!res || res.ok === false) { if (h.redraw) h.redraw(); if (h.toast) h.toast((res && res.error) || 'The status was not saved.'); return; }
825
- if (h.toast) h.toast(slWords(text) > SL_MAX ? 'Saved. The whole text is in the log.' : 'Saved.');
839
+ if (h.toast) h.toast(b.line ? 'Saved. The whole text is in the log.' : 'Saved.');
826
840
  if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
827
841
  };
828
- SLED = { use: () => { ta.value = line; count(); ta.focus(); }, save: () => leave(true) }; // the presses come through wire()'s one listener
842
+ SLED = { use: () => { ta.value = st.use(ta.value); count(); ta.focus(); }, save: () => leave(true) }; // the presses come through wire()'s one listener
829
843
  ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); leave(true); } });
830
844
  }
831
845
  const findSug = (W, id) => W.suggests.find((s) => s.id === id) || [...W.rowSuggests.values()].find((s) => s.id === id) || null;
@@ -896,7 +910,7 @@ export function wire(body, h0, x0) {
896
910
  if ('swSave' in d) { if (SLED) SLED.save(); return; }
897
911
  if (d.pwLine) { const L = W.overview.lines.find((q) => q.id === d.pwLine); if (L && L.edit) editLine(b, L, c, x, h); return; }
898
912
  // a phone asks for several lines in one proposal: "problem,done"
899
- if (d.pwLkeep) { const ls = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask); for (const L of ls) { if (L.edit) draftLine(L, x, h); else toAsk(L.ask, h); } return; }
913
+ if (d.pwLkeep) { const ls = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask); for (const L of ls) if (!L.edit) toAsk(L.ask, h); draftLines(ls.filter((L) => L.edit), x, h); return; }
900
914
  if (d.pwLdrop) { const dd = dropped(); for (const k of d.pwLdrop.split(',')) dd.add(k); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
901
915
  if ('pwPdocs' in d) { if (PH_ARTS.has(c.id)) PH_ARTS.delete(c.id); else PH_ARTS.add(c.id); redraw(); return; }
902
916
  if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
@@ -1051,7 +1065,7 @@ function editLine(el, L, c, x, h) {
1051
1065
  ta.addEventListener('blur', () => leave(true));
1052
1066
  ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ta.blur(); } });
1053
1067
  }
1054
- async function saveLine(L, text, x, h) {
1068
+ async function saveLine(L, text, x, h, opt = {}) {
1055
1069
  if (L.edit.to === 'desc') return saveDesc(text, x, h);
1056
1070
  const w = h.where ? h.where() : {}, o = x.o(), id = o.id, ws = w.ws || o.ws, kid = keyOf(x.v(), o);
1057
1071
  // shown at once (Wawan, 2026-11-23); the next read of the artefacts replaces it
@@ -1066,13 +1080,13 @@ async function saveLine(L, text, x, h) {
1066
1080
  }
1067
1081
  const ref = res.line.id;
1068
1082
  ART.delete(id);
1069
- undoToast(L.k + ' saved.', async () => {
1083
+ if (!opt.quiet) undoToast(opt.said || L.k + ' saved.', async () => {
1070
1084
  const u = await pmPost('/api/artefacts/undo', { ws, ref }).catch(() => null);
1071
1085
  if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
1072
1086
  ART.delete(id); if (h.redraw) h.redraw();
1073
1087
  });
1074
1088
  if (h.redraw) h.redraw();
1075
- return true;
1089
+ return ref;
1076
1090
  }
1077
1091
  function rename(btn, uid, h) {
1078
1092
  const inp = document.createElement('input');
@@ -281,10 +281,16 @@ export function wireDash(body, h0) {
281
281
  * menu (on a phone the toggle sits in ⋯) }
282
282
  * → { presses(), shows(), html(work), read(via), toggle(), wire(body) } */
283
283
  export function dashHost(o) {
284
- const x = { view: 'work', d: null, read: false, open: new Set() };
284
+ // used: the PM pressed or typed in the Work view before the first read landed (drafting the goal, ticking a task). That read may still bring
285
+ // the PM's Dashboard choice or the server's opening view, but it never swaps the page from under a press in progress: the view the PM is
286
+ // using stays, and ⋯ › Show the dashboard is one press away. Before, a phone that read the dashboard slowly opened it seconds after a press
287
+ // on Work, and ← then left the initiative.
288
+ const x = { view: 'work', d: null, read: false, used: false, open: new Set() };
285
289
  const W = () => (typeof o.ws === 'function' ? o.ws() : o.ws) || '', B = () => (typeof o.board === 'function' ? o.board() : o.board) || '';
286
290
  // o.menu: on a phone the toggle goes into ⋯ (the initiative's page, batch 18 item 1)
287
- const presses = () => (x.d ? [{ ...togglePress(x.view), menu: !!o.menu }] : []);
291
+ // while the Dashboard shows, its way back to the work stays in the header on a phone too: ← leaves the initiative, so "Show the work" must
292
+ // not hide in ⋯ (drafting the goal from a phone, 2026-11-24)
293
+ const presses = () => (x.d ? [{ ...togglePress(x.view), menu: !!o.menu && x.view !== 'dash' }] : []);
288
294
  const shows = () => x.view === 'dash' && !!x.d;
289
295
  // the body is drawn again only when it shows the dashboard, before or after: a read that lands on the Work view only adds the header icon,
290
296
  // so the focus (a stage picker, a task being typed) stays where the PM left it
@@ -292,7 +298,7 @@ export function dashHost(o) {
292
298
  async function read(via) {
293
299
  const was = shows();
294
300
  const d = await readDash(W(), o.scope, via);
295
- if (!d) { x.d = null; if (x.view === 'dash') x.view = 'work'; } else { const first = !x.read; x.d = d; if (first) x.view = viewOf(o.page, d.opens); }
301
+ if (!d) { x.d = null; if (x.view === 'dash') x.view = 'work'; } else { const first = !x.read; x.d = d; if (first && !x.used) x.view = viewOf(o.page, d.opens); }
296
302
  x.read = true; sync(was);
297
303
  }
298
304
  function toggle() {
@@ -302,6 +308,9 @@ export function dashHost(o) {
302
308
  }
303
309
  const html = (work) => (shows() ? dashHtml(x.d, { open: x.open, mdHtml: o.mdHtml ? o.mdHtml() : '' }) : work());
304
310
  function wire(body) {
311
+ // a press or a key in the Work view before the first read lands: the PM is using this page (x.used above). Once per body, like wireDash.
312
+ body._dbHost = x;
313
+ if (!body._dbUse) { body._dbUse = true; const use = () => { const h = body._dbHost; if (h && !h.read && h.view === 'work') h.used = true; }; body.addEventListener('pointerdown', use, true); body.addEventListener('keydown', use, true); }
305
314
  // ✎ on Needs you: the work shows (this once, not kept as the PM's choice) and Claude proposes opens on the decision (pm/ini-props.js)
306
315
  const editNeeds = o.editNeeds || (() => { x.view = 'work'; sync(); setTimeout(() => { const c = document.querySelector('#czViewer [data-cz-vw="chip"]'); if (c) c.click(); }, 0); });
307
316
  wireDash(body, { d: () => { const c = o.VW.current && o.VW.current(); return shows() && c && c.id === o.vid ? x.d : null; }, open: x.open, get ws() { return W(); }, get board() { return B(); }, toast: o.toast, redraw: o.redraw, reload: () => read(), openReport: o.openReport, editNeeds });
@@ -0,0 +1,30 @@
1
+ /* status-edit.js — the item header's status editor, without the page (status-line, A505; fix job #1817).
2
+ * The editor counts words; past 12 PMOS offers a short line. Use it puts the line in the box and keeps the whole text, so Save logs the
3
+ * whole text and records the line the person sees. Writing past 12 words again makes that new text the whole text.
4
+ *
5
+ * const s = slState(was)
6
+ * s.input(text) on each edit
7
+ * s.suggest(line) PMOS's line for the text now in the box ('' clears it)
8
+ * s.use(text) → line Use it: the box gets the line; the whole text is kept
9
+ * s.save(text) → { text, line? } | null the body for POST /api/initiative/status (null: nothing to save) */
10
+ export const SL_MAX = 12;
11
+ export const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
12
+ const clean = (t) => String(t || '').replace(/\s+/g, ' ').trim();
13
+
14
+ export function slState(was = '') {
15
+ let line = '', kept = '';
16
+ return {
17
+ get line() { return line; },
18
+ get kept() { return kept; },
19
+ input(text) { if (slWords(text) > SL_MAX) kept = ''; else line = ''; },
20
+ suggest(l) { line = clean(l); },
21
+ use(text) { if (!line) return text; kept = clean(text); const l = line; line = ''; return l; },
22
+ save(text0) {
23
+ const text = clean(text0);
24
+ if (!text) return null;
25
+ if (kept && slWords(text) <= SL_MAX) return { text: kept, line: text };
26
+ if (text === clean(was)) return null;
27
+ return slWords(text) > SL_MAX && line ? { text, line } : { text };
28
+ },
29
+ };
30
+ }