create-pmos 0.826.0 → 0.827.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.826.0",
3
+ "version": "0.827.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -34,31 +34,63 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.826.0",
38
- "at": "2026-11-25T11:36:40.845Z",
37
+ "v": "0.827.0",
38
+ "at": "2026-11-25T12:10:57.880Z",
39
39
  "f": 4,
40
40
  "prs": [
41
41
  {
42
- "n": 1973,
43
- "t": "What PMOS can do lists every pmos verb (A540)",
44
- "s": "What PMOS can do lists every pmos verb (A540)",
42
+ "n": 1947,
43
+ "t": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
44
+ "s": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
45
45
  "k": "new",
46
- "i": "directory-all-verbs",
46
+ "h": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
47
47
  "try": {
48
48
  "steps": [
49
- "On Today, open the menu and press What PMOS can do.",
50
- "Type pick in Find a feature, then press /pick to put it in the chat box.",
51
- "On Work, type / in the chat and find /line in the list."
49
+ "Set up a new product from Today (the setup chat) with a folder whose README or tickets name goals",
50
+ "Under the fundamentals card, read the Starter goals block: each row names its source",
51
+ "Press ✓ on one row, then Undo in the toast"
52
52
  ],
53
- "see": "Every pmos command PMOS has is listed with one plain line; /pick and /line put the command in the chat box.",
53
+ "see": "Up to 3 drafts appear, each with 'from: <source>'. ✓ writes the goal to planning/okrs/okrs-starter.md and the row leaves the block; Undo puts the row back and takes the line out again. A product…",
54
54
  "open": "/today.html"
55
+ },
56
+ "i": "starter-goals"
57
+ },
58
+ {
59
+ "n": 1984,
60
+ "t": "One warning when an initiative names risky code (A54)",
61
+ "s": "One warning when an initiative names risky code (A54)",
62
+ "k": "new",
63
+ "i": "arch-warns",
64
+ "try": {
65
+ "steps": [
66
+ "On Work, open an initiative of a product whose repository PMOS has read, whose record names a part the Code panel tints as risky",
67
+ "Read the ✦ line above the plan: it names the part and why it is risky",
68
+ "Press ✓ to add the test task, then Undo in the toast; press ✕ for Not now"
69
+ ],
70
+ "see": "One ✦ line at most, naming the risky part and its reason in the code map's own words. ✓ adds the task 'Add tests for <part>' to the initiative and the toast's Undo removes it. ✕ hides the line for…",
71
+ "open": "/work.html"
55
72
  }
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "v": "0.826.0",
78
+ "at": "2026-11-25T11:36:40.845Z",
79
+ "f": 4,
80
+ "prs": [
81
+ {
82
+ "n": 1973,
83
+ "t": "What PMOS can do lists every pmos verb (A540)",
84
+ "s": "What PMOS can do lists every pmos verb (A540)",
85
+ "k": "new",
86
+ "i": "directory-all-verbs"
56
87
  },
57
88
  {
58
89
  "n": 1944,
59
90
  "t": "A map of the product's code on Work, one box per main part (job #1900, A176)",
60
91
  "s": "A map of the product's code on Work, one box per main part (job #1900, A176)",
61
92
  "k": "new",
93
+ "i": "code-map",
62
94
  "h": "A map of the product's code on Work, one box per main part (job #1900, A176)",
63
95
  "try": {
64
96
  "steps": [
@@ -68,14 +100,14 @@
68
100
  ],
69
101
  "see": "One box per main folder of the product's repository, each with what it is, how it is tested and who changed it last. A part with no tests or many recent fixes is tinted and says why. After the chat…",
70
102
  "open": "/premium-board.html"
71
- },
72
- "i": "code-map"
103
+ }
73
104
  },
74
105
  {
75
106
  "n": 1969,
76
107
  "t": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
77
108
  "s": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
78
109
  "k": "new",
110
+ "i": "today-order",
79
111
  "h": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
80
112
  "try": {
81
113
  "steps": [
@@ -85,8 +117,7 @@
85
117
  ],
86
118
  "see": "The same blocks show in a different order, and one line says why (for example 'Ordered for Monday · from your calendar'). After the pin the line says the order is pinned and the order stays the same…",
87
119
  "open": "/today.html"
88
- },
89
- "i": "today-order"
120
+ }
90
121
  },
91
122
  {
92
123
  "n": 1972,
@@ -100,6 +131,7 @@
100
131
  "t": "Settings opens again; features rows for code and connectors",
101
132
  "s": "Settings opens again; features rows for code and connectors",
102
133
  "k": "fix",
134
+ "i": "connector-data",
103
135
  "h": "Settings opens again; features rows for code and connectors",
104
136
  "try": {
105
137
  "steps": [
@@ -108,8 +140,7 @@
108
140
  "Open What PMOS can do and find Code map"
109
141
  ],
110
142
  "see": "Settings opens, and Connectors and What PMOS does alone both show; Code map and What connectors read and write are listed"
111
- },
112
- "i": "connector-data"
143
+ }
113
144
  }
114
145
  ]
115
146
  },
@@ -588,25 +619,6 @@
588
619
  "k": "fix"
589
620
  }
590
621
  ]
591
- },
592
- {
593
- "v": "0.797.0",
594
- "at": "2026-11-24T23:00:19.305Z",
595
- "f": 4,
596
- "prs": [
597
- {
598
- "n": 1776,
599
- "t": "Pmos mcp gives PMOS cards to another agent as A2UI v1.0 (a2ui-mcp-outbound, job #1751) — WAITS FOR WAWAN",
600
- "s": "Pmos mcp gives PMOS cards to another agent as A2UI v1.0 (a2ui-mcp-outbound, job #1751) — WAITS FOR WAWAN",
601
- "k": "new"
602
- },
603
- {
604
- "n": 1781,
605
- "t": "The chat draws another agent's A2UI surface (job #1752) — WAITS FOR WAWAN",
606
- "s": "The chat draws another agent's A2UI surface (job #1752) — WAITS FOR WAWAN",
607
- "k": "new"
608
- }
609
- ]
610
622
  }
611
623
  ]
612
624
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@a8ace0d29
1
+ kernel-source: pmos@8e47b1e6a
2
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-25T11:36:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T12:10:54Z"}
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-25T11:36:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T12:10:54Z"}
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-25T11:36:37Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T12:10:54Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,30 +1,62 @@
1
1
  [
2
2
  {
3
- "v": "0.826.0",
4
- "at": "2026-11-25T11:36:40.845Z",
3
+ "v": "0.827.0",
4
+ "at": "2026-11-25T12:10:57.880Z",
5
5
  "f": 4,
6
6
  "prs": [
7
7
  {
8
- "n": 1973,
9
- "t": "What PMOS can do lists every pmos verb (A540)",
10
- "s": "What PMOS can do lists every pmos verb (A540)",
8
+ "n": 1947,
9
+ "t": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
10
+ "s": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
11
11
  "k": "new",
12
- "i": "directory-all-verbs",
12
+ "h": "Starter goals from your own product, under the fundamentals card (job #1916, A84)",
13
13
  "try": {
14
14
  "steps": [
15
- "On Today, open the menu and press What PMOS can do.",
16
- "Type pick in Find a feature, then press /pick to put it in the chat box.",
17
- "On Work, type / in the chat and find /line in the list."
15
+ "Set up a new product from Today (the setup chat) with a folder whose README or tickets name goals",
16
+ "Under the fundamentals card, read the Starter goals block: each row names its source",
17
+ "Press ✓ on one row, then Undo in the toast"
18
18
  ],
19
- "see": "Every pmos command PMOS has is listed with one plain line; /pick and /line put the command in the chat box.",
19
+ "see": "Up to 3 drafts appear, each with 'from: <source>'. ✓ writes the goal to planning/okrs/okrs-starter.md and the row leaves the block; Undo puts the row back and takes the line out again. A product…",
20
20
  "open": "/today.html"
21
+ },
22
+ "i": "starter-goals"
23
+ },
24
+ {
25
+ "n": 1984,
26
+ "t": "One warning when an initiative names risky code (A54)",
27
+ "s": "One warning when an initiative names risky code (A54)",
28
+ "k": "new",
29
+ "i": "arch-warns",
30
+ "try": {
31
+ "steps": [
32
+ "On Work, open an initiative of a product whose repository PMOS has read, whose record names a part the Code panel tints as risky",
33
+ "Read the ✦ line above the plan: it names the part and why it is risky",
34
+ "Press ✓ to add the test task, then Undo in the toast; press ✕ for Not now"
35
+ ],
36
+ "see": "One ✦ line at most, naming the risky part and its reason in the code map's own words. ✓ adds the task 'Add tests for <part>' to the initiative and the toast's Undo removes it. ✕ hides the line for…",
37
+ "open": "/work.html"
21
38
  }
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "v": "0.826.0",
44
+ "at": "2026-11-25T11:36:40.845Z",
45
+ "f": 4,
46
+ "prs": [
47
+ {
48
+ "n": 1973,
49
+ "t": "What PMOS can do lists every pmos verb (A540)",
50
+ "s": "What PMOS can do lists every pmos verb (A540)",
51
+ "k": "new",
52
+ "i": "directory-all-verbs"
22
53
  },
23
54
  {
24
55
  "n": 1944,
25
56
  "t": "A map of the product's code on Work, one box per main part (job #1900, A176)",
26
57
  "s": "A map of the product's code on Work, one box per main part (job #1900, A176)",
27
58
  "k": "new",
59
+ "i": "code-map",
28
60
  "h": "A map of the product's code on Work, one box per main part (job #1900, A176)",
29
61
  "try": {
30
62
  "steps": [
@@ -34,14 +66,14 @@
34
66
  ],
35
67
  "see": "One box per main folder of the product's repository, each with what it is, how it is tested and who changed it last. A part with no tests or many recent fixes is tinted and says why. After the chat…",
36
68
  "open": "/premium-board.html"
37
- },
38
- "i": "code-map"
69
+ }
39
70
  },
40
71
  {
41
72
  "n": 1969,
42
73
  "t": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
43
74
  "s": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
44
75
  "k": "new",
76
+ "i": "today-order",
45
77
  "h": "Today rearranges to the day, with a quiet line and a pin (job #1914, A310)",
46
78
  "try": {
47
79
  "steps": [
@@ -51,8 +83,7 @@
51
83
  ],
52
84
  "see": "The same blocks show in a different order, and one line says why (for example 'Ordered for Monday · from your calendar'). After the pin the line says the order is pinned and the order stays the same…",
53
85
  "open": "/today.html"
54
- },
55
- "i": "today-order"
86
+ }
56
87
  },
57
88
  {
58
89
  "n": 1972,
@@ -66,6 +97,7 @@
66
97
  "t": "Settings opens again; features rows for code and connectors",
67
98
  "s": "Settings opens again; features rows for code and connectors",
68
99
  "k": "fix",
100
+ "i": "connector-data",
69
101
  "h": "Settings opens again; features rows for code and connectors",
70
102
  "try": {
71
103
  "steps": [
@@ -74,8 +106,7 @@
74
106
  "Open What PMOS can do and find Code map"
75
107
  ],
76
108
  "see": "Settings opens, and Connectors and What PMOS does alone both show; Code map and What connectors read and write are listed"
77
- },
78
- "i": "connector-data"
109
+ }
79
110
  }
80
111
  ]
81
112
  },
@@ -379,6 +379,18 @@ Write the press release before the build ("working backwards"). Run it in the pr
379
379
  - The draft uses one agent run with no tools. `--no-ai`, `pmos ai off press-release` or `PMOS_AI=off` makes a draft from the record's own lines only. A failed run does the same and says why.
380
380
  - `pmos press-release count [--days 7]` prints how many drafts were written in the last days. Its last line is the number.
381
381
 
382
+ ### pmos goals: starter goals from your own product
383
+
384
+ Right after setup, PMOS drafts up to three starter goals from the product's own files and shows them under the fundamentals card. `pmos goals` reads and changes the same drafts. Run it in the product's repository, or pass `--root <dir>`, or ask the chat.
385
+
386
+ - The drafts come only from the product's own sources: the Goals line and the Purpose of `project-context.md`, a Goals, Objectives or Success section of the README, and a word that 3 or more of the first 40 tickets read during setup name ("Fewer tickets about refunds"). PMOS invents no target number. A draft with no source is never offered.
387
+ - PMOS drafts once, and only when the product has no goals beyond the setup draft (`okrs-draft.md`).
388
+ - `pmos goals starter` lists the open drafts, each with its source.
389
+ - `pmos goals draft` drafts them, when they were not drafted yet.
390
+ - `pmos goals keep <n>` writes draft n as key result `KR-S<n>` in `planning/okrs/okrs-starter.md` (`pmos/planning/okrs/` in a kit). A draft counts in no report until you keep it.
391
+ - `pmos goals drop <n>` drops draft n. It writes no goal.
392
+ - `pmos goals undo` undoes the newest keep or drop. When you edited the kept line since, PMOS leaves it.
393
+
382
394
  ### pmos hire: draft the next hire from the work that waits
383
395
 
384
396
  Show where the team is short before you ask for headcount. Run it in the product's repository, or pass `--root <dir>`, or ask the chat to "draft the next hire". No running workspace is needed.
@@ -483,6 +495,7 @@ The same map as the Code panel on Work: one line per main part of the product's
483
495
  - `pmos code map` draws the map again now.
484
496
  - `pmos code describe --part <name> --text "<what it is>"` says what a part is in your words. The panel shows your words in place of PMOS's. `--text ""` puts PMOS's words back. A part the map does not have is refused.
485
497
  - `pmos code count` prints the number of parts in the map.
498
+ - `pmos code warns [<initiative>]` says which initiatives name a risky part, and the test task to add for each. An initiative's record names a part when it names the folder's path, or the folder's last word; a folder whose name says nothing about the product (`lib`, `src`, `api`, …) counts only when the record names its path. Work that is closed or done is left out. The same reading is the ✦ line above the plan on the initiative, where one press adds the task.
486
499
 
487
500
  ### pmos declined: asks you said no to, with a kind reply
488
501
 
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+ /* arch-warns.js — one warning when an initiative is planned against risky code (idea A54, factory job #1978; board BatchMoreBDS panel 15).
3
+ *
4
+ * namesOf(map, text) PURE → the map's parts the text names, in the map's own order
5
+ * warnOf(map, text) PURE → { part, dir, what, tested, why, at, more } | null (the riskiest named part, or nothing)
6
+ * sayOf(w) PURE → "This initiative touches Payments, a risky part: no tests, 6 fixes in 30 days. Add a test task first?"
7
+ * whyOf(w, { path }) PURE → the second line: where the name was read and when the map was read
8
+ * taskOf(w) PURE → "Add tests for Payments", the one step the ✦ offers
9
+ * read(root, dir, id, o) → the warning for one initiative, from its record and the stored map; null when there is nothing to say
10
+ * warnsOf(root, dir, o) → [{ id, warn }] for every initiative that has one (`pmos code warns`)
11
+ *
12
+ * WHAT IS RISKY IS THE CODE MAP'S CALL, never this file's: a part is risky only when lib/code-map.js riskOf gave it a reason (no tests, or
13
+ * many recent fixes), and the warning says that reason in those words. A part that is fine is never named, so most initiatives see nothing
14
+ * (zero is silence).
15
+ *
16
+ * WHAT COUNTS AS TOUCHING: the initiative's own record (planning/initiatives/<id>.md, or pmos/state/initiatives/ in a kit) names the part —
17
+ * its folder path anywhere in the record, or the folder's last word as a whole word. A folder whose name says nothing about the product
18
+ * (lib, src, api, …) counts only when the record names its path, so "the api" in a sentence does not warn about a folder called api.
19
+ * A record that is closed, cancelled, killed or done warns about nothing.
20
+ *
21
+ * READS ONLY. It opens the stored map (code-map.json) and the record, and writes no file: the test task is written by the PM's own press,
22
+ * through the task routes, and the use-log lines are the page's (pm/cozy-pop-work.js). */
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+ const CM = require('./code-map.js');
26
+ const IW = require('./item-why.js');
27
+
28
+ const TAG = '[arch-warns]';
29
+ /* a folder name that says nothing about this product: it warns only when the record names the path itself */
30
+ const PLAIN = new Set(['lib', 'src', 'app', 'apps', 'api', 'web', 'www', 'code', 'core', 'main', 'bin', 'cli', 'ui', 'test', 'tests', 'doc', 'docs',
31
+ 'public', 'static', 'assets', 'scripts', 'script', 'tools', 'util', 'utils', 'common', 'shared', 'server', 'client', 'packages', 'pkg', 'internal', 'build']);
32
+ const STOPPED = /^(closed|cancell?ed|killed|done|accepted)\b/i;
33
+ const MIN_WORD = 4;
34
+ const say = (s) => { try { console.log(TAG + ' ' + s); } catch { /* no console */ } };
35
+
36
+ const lastSeg = (dir) => String(dir || '').split('/').filter(Boolean).pop() || '';
37
+ const esc = (s) => String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
38
+ /** Does `text` name this part? Its folder path anywhere, else the folder's last word as a whole word. PURE. */
39
+ function named(p, text) {
40
+ const t = String(text || '');
41
+ if (!t) return false;
42
+ const dir = String(p.dir || '');
43
+ if (dir && dir.includes('/') && new RegExp(esc(dir), 'i').test(t)) return true;
44
+ if (dir && new RegExp('(^|[\\s`"\'(/])' + esc(dir) + '/', 'i').test(t)) return true;
45
+ const w = lastSeg(dir) || String(p.name || '');
46
+ if (!w || w.length < MIN_WORD || PLAIN.has(w.toLowerCase())) return false;
47
+ return new RegExp('(^|[^A-Za-z0-9])' + esc(w) + 's?([^A-Za-z0-9]|$)', 'i').test(t);
48
+ }
49
+
50
+ /** The parts of the map that this text names, in the map's own order. PURE. */
51
+ function namesOf(map, text) {
52
+ const parts = (map && Array.isArray(map.parts) ? map.parts : []);
53
+ return parts.filter((p) => p && named(p, text));
54
+ }
55
+
56
+ /** The one warning for this text, or null. The part with no tests comes first, then the one with the most fixes. PURE. */
57
+ function warnOf(map, text) {
58
+ const risky = namesOf(map, text).filter((p) => p.risky && p.why);
59
+ if (!risky.length) return null;
60
+ const rank = (p) => (p.tests ? 1 : 0) * 1e6 - (p.fixes || 0);
61
+ const list = risky.slice().sort((a, b) => rank(a) - rank(b));
62
+ const p = list[0];
63
+ return { part: p.name, dir: p.dir || '', what: p.note || p.kind || '', tested: p.tested || '', why: p.why, at: (map && map.at) || '', more: list.length - 1 };
64
+ }
65
+
66
+ /** The ✦ line. PURE. */
67
+ function sayOf(w) {
68
+ if (!w) return '';
69
+ return 'This initiative touches ' + w.part + ', a risky part: ' + w.why + '. Add a test task first?';
70
+ }
71
+ /** Under it: where the name was read, when the code was read, and the other risky parts it names. PURE. */
72
+ function whyOf(w, o = {}) {
73
+ if (!w) return '';
74
+ const where = o.path ? 'Its record (' + o.path + ') names ' + w.part : 'Its record names ' + w.part;
75
+ const dir = w.dir && w.dir !== w.part ? ' (' + w.dir + ')' : '';
76
+ const when = w.at ? ' PMOS read the code on ' + String(w.at).slice(0, 10) + ': ' + w.why + '.' : ' The code map says: ' + w.why + '.';
77
+ const more = w.more > 0 ? ' It names ' + w.more + ' other risky ' + (w.more === 1 ? 'part' : 'parts') + ' too.' : '';
78
+ return where + dir + '.' + when + more;
79
+ }
80
+ /** The one step the ✦ offers. PURE. */
81
+ const taskOf = (w) => (w ? 'Add tests for ' + w.part : '');
82
+
83
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
84
+
85
+ /** The warning for one initiative: its record and the stored map, nothing else. o: { map } to read the map once for many. */
86
+ function read(root, dir, id, o = {}) {
87
+ const map = o.map !== undefined ? o.map : CM.view(dir);
88
+ if (!map || !Array.isArray(map.parts) || !map.parts.length) return null; // no repository, or not read yet: silence
89
+ const f = IW.recordPathOf(root, id);
90
+ if (!f) return null;
91
+ const text = readText(f);
92
+ if (!text) return null;
93
+ const fm = IW.frontOf(text);
94
+ if (STOPPED.test(String(fm.status || '')) || String(fm.state || '').toLowerCase() === 'done') return null; // done work gets no advice
95
+ const w = warnOf(map, text);
96
+ if (!w) return null;
97
+ return Object.assign(w, { id, path: path.relative(root, f).split(path.sep).join('/') });
98
+ }
99
+
100
+ /** Every initiative with a warning, newest record first. o: { ids } to read only some. */
101
+ function warnsOf(root, dir, o = {}) {
102
+ const map = o.map !== undefined ? o.map : CM.view(dir);
103
+ if (!map) return [];
104
+ let ids = o.ids;
105
+ if (!Array.isArray(ids)) { try { ids = IW.activeIds(root); } catch { ids = []; } }
106
+ const out = [];
107
+ for (const id of ids || []) { const w = read(root, dir, id, { map }); if (w) out.push(w); }
108
+ return out;
109
+ }
110
+
111
+ /** `pmos code warns [<id>]`: one line per initiative with a warning. → 0, or 1 when there is no map. */
112
+ function runWarns(root, dir, id, out = (s) => console.log(s)) {
113
+ const map = CM.view(dir);
114
+ if (!map) { out('There is no code map yet. Run `pmos code map` first.'); return 1; }
115
+ const list = id ? [read(root, dir, id, { map })].filter(Boolean) : warnsOf(root, dir, { map });
116
+ if (!list.length) { out(id ? id + ' names no risky part of the code.' : 'No initiative names a risky part of the code.'); return 0; }
117
+ for (const w of list) out(w.id + ': ' + sayOf(w).replace(/ Add a test task first\?$/, '') + ' — ' + taskOf(w));
118
+ return 0;
119
+ }
120
+
121
+ module.exports = { TAG, PLAIN, MIN_WORD, named, namesOf, warnOf, sayOf, whyOf, taskOf, read, warnsOf, runWarns, say };
@@ -6,6 +6,7 @@
6
6
  * pmos code map [--json] draw the map again now from the default branch (read-only git)
7
7
  * pmos code describe --part <name> --text "<…>" say what a part is in your own words (the chat writes it for the PM); "" puts PMOS's back
8
8
  * pmos code count the number of parts in the map, on the last line
9
+ * pmos code warns [<initiative>] which initiatives name a risky part, and the test task to add (lib/arch-warns.js)
9
10
  * every command: [--root <dir>] (default: this repository)
10
11
  *
11
12
  * Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent, and nothing in the repository is written. */
@@ -13,16 +14,17 @@ const path = require('path');
13
14
  const fs = require('fs');
14
15
  const CM = require('./code-map.js');
15
16
 
16
- const COMMANDS = { code: ['show', 'map', 'describe', 'count'] };
17
+ const COMMANDS = { code: ['show', 'map', 'describe', 'count', 'warns'] };
17
18
  const USAGE = [
18
19
  'usage: pmos code show|map|describe|count — the product\'s code map: one line per main part',
19
20
  ' pmos code show [--json] what each part is, how it is tested, who changed it last; ! marks a risky part',
20
21
  ' pmos code map [--json] draw the map again now from the default branch',
21
22
  ' pmos code describe --part api --text "<what it is>" say what a part is; --text "" puts PMOS\'s words back',
22
23
  ' pmos code count the number of parts in the map',
24
+ ' pmos code warns [<initiative>] which initiatives name a risky part, and the test task to add',
23
25
  'Run it in the product\'s repository, or pass --root <dir>.',
24
26
  ];
25
- const ALLOWED = { show: ['json', 'root'], map: ['json', 'root'], describe: ['json', 'root', 'part', 'text'], count: ['json', 'root'] };
27
+ const ALLOWED = { show: ['json', 'root'], map: ['json', 'root'], describe: ['json', 'root', 'part', 'text'], count: ['json', 'root'], warns: ['json', 'root'] };
26
28
  const BOOL = new Set(['json']);
27
29
 
28
30
  function parse(args) {
@@ -63,7 +65,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
63
65
  if (!COMMANDS.code.includes(sub)) { say(`unknown code command "${sub}". Use one of: ${COMMANDS.code.join(', ')}`); return 2; }
64
66
  const { pos, flags } = parse(args.slice(1));
65
67
  for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos code ${sub}`); return 2; }
66
- if (pos.length) { say(`✗ pmos code ${sub} takes options, not an argument (pmos code help)`); return 2; }
68
+ if (pos.length && sub !== 'warns') { say(`✗ pmos code ${sub} takes options, not an argument (pmos code help)`); return 2; }
69
+ if (pos.length > 1) { say('✗ pmos code warns takes one initiative id at most (pmos code help)'); return 2; }
67
70
  const root = path.resolve(flags.root || repoRoot(cwd));
68
71
  const dir = recordsDirOf(root);
69
72
  const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
@@ -77,6 +80,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
77
80
  for (const p of CM.view(dir).parts) say(lineOf(p));
78
81
  return 0;
79
82
  }
83
+ if (sub === 'warns') {
84
+ const AW = require('./arch-warns.js');
85
+ if (flags.json) { const m = CM.view(dir); say(JSON.stringify({ ok: true, warns: pos[0] ? [AW.read(root, dir, pos[0], { map: m })].filter(Boolean) : AW.warnsOf(root, dir, { map: m }) })); return 0; }
86
+ return AW.runWarns(root, dir, pos[0] || '', say);
87
+ }
80
88
  const map = CM.view(dir);
81
89
  if (sub === 'count') { say(flags.json ? JSON.stringify({ ok: true, parts: map ? map.parts.length : 0 }) : String(map ? map.parts.length : 0)); return 0; }
82
90
  if (sub === 'show') {
@@ -56,6 +56,7 @@
56
56
  {"id": "rules", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Rules PMOS learned", "say": "The standing rules PMOS learned from your corrections, and edit or retire one.", "cmd": "/rules", "verb": "rules"},
57
57
  {"id": "line", "audience": "user", "status": "ga", "group": "Catch up", "name": "Where each initiative stands", "say": "Days in its stage, what is missing, the next move, and whether it is stuck.", "cmd": "/line", "verb": "line", "hint": "<initiative>"},
58
58
  {"id": "hire", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The next hire", "say": "The role your open work most needs, and a one-page role brief to edit.", "cmd": "/hire", "verb": "hire"},
59
+ {"id": "goals", "audience": "user", "status": "ga", "group": "Your product", "name": "Starter goals", "say": "Up to three goals drafted from your own product, each with its source; keep one and it becomes a goal.", "cmd": "/goals", "verb": "goals"},
59
60
  {"id": "approver", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What an approver asks", "say": "What each approver asked or objected to before, ahead of the next sign-off.", "cmd": "/approver", "verb": "approver", "hint": "<name>"},
60
61
  {"id": "balance", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The mix of a list", "say": "Feature, fix, debt or discovery in one line, with a note when one kind is over your line.", "cmd": "/balance", "verb": "balance"},
61
62
  {"id": "declined", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Asks you declined", "say": "Asks closed without being done, each with a kind reply draft PMOS never sends.", "cmd": "/declined", "verb": "declined"},
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+ /* goals-cli.js — `pmos goals …`: the starter goals PMOS drafts from your own product (initiative starter-goals, job #1916, A84).
3
+ * The logic and the store are lib/starter-goals.js; this file is only the verb, so the verb table names a *-cli.js module. */
4
+ const SG = require('./starter-goals.js');
5
+ module.exports = { run: SG.run, COMMANDS: SG.COMMANDS, USAGE: SG.USAGE };
@@ -158,6 +158,9 @@ const VERBS = Object.freeze({
158
158
  why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
159
159
  help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
160
160
  // Not a pm-os-absorb verb (run: null): initiative next-hire-draft (job #1876, A75) added it through the same table.
161
+ // Not a pm-os-absorb verb (run: null): initiative starter-goals (job #1916, A84) added it through the same table.
162
+ goals: Object.freeze({ module: 'goals-cli.js', run: null, guide: 'cli.md',
163
+ help: 'pmos goals [starter|draft|keep <n>|drop <n>|undo] — starter goals PMOS drafts from your own product, each with its source; keep one and it becomes a goal (pmos goals help)' }),
161
164
  hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
162
165
  help: 'pmos hire [draft|show|count] — the role your open work most needs, per person, and a one-page role brief PMOS drafts for you to edit (pmos hire help)' }),
163
166
  // Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
@@ -152,6 +152,7 @@ const MODULES = Object.freeze([
152
152
  'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
153
153
  'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
154
154
  'routes-code-map', // idea A176: the product's code map on Work, redrawn when the default branch moves (records code-map.json; read-only)
155
+ 'routes-arch-warns', // idea A54: one warning when an initiative names a risky part of the code (reads code-map.json; read-only)
155
156
  'routes-live-rows', // bet A458: chat-made task changes streamed to open pages (runtime live-events.jsonl; read-only event stream)
156
157
  'routes-connector-data', // connector-data (A150): what each connector reads and writes, from lib/connector-data.js (read only)
157
158
  ]);
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ /* routes-arch-warns.js — the architecture warning of one initiative over HTTP (idea A54, initiative arch-warns). The reading and its rules
3
+ * are lib/arch-warns.js; the code map it reads is code-map.json in the product's records folder (lib/records-dir.js), drawn by
4
+ * lib/routes-code-map.js.
5
+ *
6
+ * GET /api/arch-warns?ini=<id>&ws=<id> → { ok, warn } warn: { part, dir, what, tested, why, at, more, id, path } or null
7
+ *
8
+ * `warn` is null for everything that is not worth a line: no repository, no map yet, no such record, a record that names no part, a part
9
+ * the code map does not call risky, and work that is closed or done. A missing initiative is not an error, because the page asks for every
10
+ * initiative it opens.
11
+ *
12
+ * READ ONLY. It writes nothing, starts no code-map draw and sends nothing anywhere. The test task the ✦ offers is written by the PM's own
13
+ * press, through POST /api/boards/tasks/add. */
14
+ const path = require('path');
15
+ const AW = require('./arch-warns.js');
16
+ const { recordsDirFor } = require('./records-dir.js');
17
+
18
+ const CHECKOUT = path.join(__dirname, '..', '..');
19
+ const ID_RE = /^[a-z0-9][a-z0-9-]{0,80}$/;
20
+ function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
21
+ const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
22
+
23
+ function handle(req, res, url, ctx) {
24
+ if (url.pathname !== '/api/arch-warns') return false;
25
+ const send = (status, body) => { ctx.json(res, body, status); return true; };
26
+ if (req.method !== 'GET') return send(405, { ok: false, error: 'GET' });
27
+ const ws = url.searchParams.get('ws') || null;
28
+ const ini = String(url.searchParams.get('ini') || '').trim();
29
+ if (!ID_RE.test(ini)) return send(400, { ok: false, error: 'ini is an initiative id' });
30
+ const dir = recordsDirFor(ctx, ws), root = rootFor(ctx, wsOf(ctx, ws));
31
+ let warn = null;
32
+ try { warn = AW.read(root, dir, ini); } catch { warn = null; } // an unreadable map or record says nothing
33
+ if (!warn) return send(200, { ok: true, warn: null });
34
+ AW.say('warned ' + ini + ': ' + warn.part + ' (' + warn.why + ')');
35
+ // the words live in lib/arch-warns.js, so the page, the terminal and the test all say the same thing
36
+ return send(200, { ok: true, warn: Object.assign({}, warn, { say: AW.sayOf(warn), note: AW.whyOf(warn, { path: warn.path }), task: AW.taskOf(warn) }) });
37
+ }
38
+
39
+ module.exports = { prefixes: ['/api/arch-warns'], handle };
@@ -16,6 +16,7 @@
16
16
  * POST /api/onboard/review { fields, jira } the PM's edits to the draft
17
17
  * POST /api/onboard/init initialize or reuse, register, settle the fundamentals (resumable)
18
18
  * POST /api/onboard/fundamental { key } the one-press change of one fundamentals line (lib/onboard-fundamentals.js)
19
+ * POST /api/onboard/starter { act, n } keep, drop or undo one starter goal (lib/starter-goals.js, job #1916); act: keep|drop|undo
19
20
  * POST /api/onboard/reset start again (the folder and anything written stay)
20
21
  */
21
22
  const fs = require('fs');
@@ -84,12 +85,14 @@ function view(ctx) {
84
85
  }
85
86
 
86
87
  async function handle(req, res, url, ctx) {
87
- const m = /^\/api\/onboard\/(state|own|login|check|project|folder|discover|search|review|init|fundamental|reset)$/.exec(url.pathname);
88
+ const m = /^\/api\/onboard\/(state|own|login|check|project|folder|discover|search|review|init|fundamental|starter|reset)$/.exec(url.pathname);
88
89
  if (!m) return false;
89
90
  const send = (body, code = 200) => { ctx.json(res, body, code); return true; };
90
91
  if (!ctx.claudeSetup) return send({ ok: false, error: 'Claude setup is unavailable.' }, 503);
91
92
  const verb = m[1];
92
- if (verb === 'state') return req.method === 'GET' ? send(view(ctx)) : send({ ok: false, error: 'GET only' }, 405);
93
+ // starter goals (A84, lib/starter-goals.js): the drafts still open for the product set up here, drawn under the fundamentals card
94
+ const starterOf = () => { const s0 = read(ctx); const SG = require('./starter-goals.js'); try { return s0.done && s0.done.root && ctx.getWs(s0.done.ws) ? SG.view(s0.done.root) : null; } catch { return null; } };
95
+ if (verb === 'state') return req.method === 'GET' ? send({ ...view(ctx), starter: starterOf() }) : send({ ok: false, error: 'GET only' }, 405);
93
96
  if (req.method !== 'POST') return send({ ok: false, error: 'POST only' }, 405);
94
97
  const got = await ctx.readJson(req); if (!got.ok) return send({ ok: false, error: 'Invalid JSON.' }, 400);
95
98
  const b = got.body || {}, g = guard.requirePagePress(req, b);
@@ -99,6 +102,16 @@ async function handle(req, res, url, ctx) {
99
102
  try {
100
103
  if (verb === 'reset') { write(ctx, {}); try { fs.unlinkSync(journal(ctx)); } catch {} return send(view(ctx)); }
101
104
  if (verb === 'own') return send(ctx.claudeSetup.ensureOwn());
105
+ // A84: starter goals write only the product's own goal file, so they need no Claude login check (before the bound gate)
106
+ if (verb === 'starter') {
107
+ const ws = st.done && st.done.ws && ctx.getWs(st.done.ws);
108
+ if (!ws || !st.done.root) return send({ ok: false, error: 'Set up the project first.', need: 'init' }, 409);
109
+ const act = str(b.act, 8), n = Number(b.n);
110
+ const o = { runtimeDir: ctx.runtimeDir, useDir: ctx.runtimeDir };
111
+ const SG = require('./starter-goals.js');
112
+ const r = act === 'keep' ? SG.keep(st.done.root, n, o) : act === 'drop' ? SG.drop(st.done.root, n, o) : act === 'undo' ? SG.undo(st.done.root, o) : { ok: false, error: 'act is keep, drop or undo' };
113
+ return send({ ...view(ctx), starter: starterOf(), ok: !!r.ok, error: r.ok ? undefined : r.error, starter_did: r.ok ? { act: r.act || act, n: r.n, kr: r.kr || null, file: r.file || null } : null });
114
+ }
102
115
  if (verb === 'login') {
103
116
  const dir = path.join(ctx.runtimeDir, 'onboarding', 'signin'); fs.mkdirSync(dir, { recursive: true });
104
117
  const r = await ctx.claudeSetup.login(b.profile, null, 'login', dir);
@@ -219,9 +232,11 @@ async function handle(req, res, url, ctx) {
219
232
  try { fundamentals = F.settle({ root: r.root, ws: w.id, sources: (st.found && st.found.sources) || [], fresh: !!(r.journal.steps.kit && r.journal.steps.kit.detail === 'installed'), refresh: ctx.refreshSources ? ctx.refreshSources() : F.refreshAt(ctx.runtimeDir), ...(ctx.launcher !== undefined ? { launcher: ctx.launcher } : {}) }); }
220
233
  catch { fundamentals = { root: r.root, ws: w.id, lines: [], did: {}, error: 'Some fundamentals could not be settled. Change them in Settings.' }; }
221
234
  }
235
+ // A84: starter goals drafted once from the product's own sources, right after the fundamentals; a product with goals gets none
236
+ try { require('./starter-goals.js').draft(r.root, { runtimeDir: ctx.runtimeDir }); } catch { /* no starter goals, setup goes on */ }
222
237
  if (ctx.broadcast) ctx.broadcast({ t: 'focus', ws: w.id });
223
238
  write(ctx, { ...st, init: { ok: true, steps: r.journal.steps }, fundamentals, done: { ws: w.id, name, root: r.root, context: r.journal.steps.context && r.journal.steps.context.detail, at: new Date().toISOString() } });
224
- return send(view(ctx));
239
+ return send({ ...view(ctx), starter: starterOf() });
225
240
  }
226
241
  if (verb === 'fundamental') {
227
242
  if (!st.fundamentals) return send({ ok: false, error: 'Set up the project first.', need: 'init' }, 409);
@@ -0,0 +1,244 @@
1
+ 'use strict';
2
+ /* starter-goals.js — starter goals drafted from the product's own sources, offered once after setup (initiative starter-goals, job #1916,
3
+ * idea A84; board BatchMoreBDS panel 32, agreed 2026-11-25). `pmos goals …`.
4
+ *
5
+ * WHY. A new product ends setup with one drafted goal at most (lib/onboard-fundamentals.js). Generic industry packs would fill the list with
6
+ * goals that are not the PM's. The product's own files already say what it is for, so PMOS drafts from those and nothing else.
7
+ *
8
+ * sourcesOf(root, { runtimeDir }) → { name, goalsLine, purpose, readme, tickets, setupKr } what the drafts may come from
9
+ * draftsOf(sources) PURE → [{ n, kind: 'goal', text, source: { label, ref } }] at most MAX, each with a source
10
+ * draft(root, { runtimeDir, now }) → { ok, drafted, rows } | { ok: false, why } ONCE per product; refuses when goals exist already
11
+ * view(root) → { rows } the drafts still open (state 'draft'); none decided rows (zero is silence)
12
+ * keep(root, n) · drop(root, n) · undo(root) → { ok, … } every change of the store, from the page or `pmos goals`
13
+ * CLI: pmos goals [starter|draft|keep <n>|drop <n>|undo] [--json] [--root <dir>]
14
+ *
15
+ * WHERE THE DRAFTS COME FROM. Only the product's own files:
16
+ * - project-context.md: its "Goals and metrics" line (split into its items) and the Purpose sentence that names an aim (increase, reduce …);
17
+ * - the README: the bullets of a Goals / Objectives / Success section;
18
+ * - tickets: the "Sources read during setup" lines from a tracker (Jira, Atlassian, Linear, GitHub issues) and the product's tickets in the
19
+ * stored My work read (<runtime>/my-work/read.json, items whose key carries the product's Jira key). The first 40; a word that 3 or more of
20
+ * them name becomes "Fewer tickets about <word>", sourced as the count. No target number is ever invented (the proven-only rule).
21
+ * A candidate with no source label is never offered. None equals the setup draft's key result, and no two are alike.
22
+ *
23
+ * THE STORE. <state>/starter-goals.json (pmos/state in a kit): { drafted_at, rows: [{ n, kind, text, source, state, kr? }], undo: [...] }.
24
+ * The page and `pmos goals` read and write only this, so a chat write lands where the page reads (CHAT WRITES ALWAYS LAND).
25
+ * KEEP writes the draft as `- **KR-S<n>** <text>. Source: <label>.` under `## O-S — Starter goals` in planning/okrs/okrs-starter.md, which
26
+ * lib/okr-goals.js reads like any goal file. Until then a draft is in no goal file, so no report counts it. okrs-draft.md is never touched.
27
+ * Every log line carries [starter-goals]; each keep records the use-log control starterGoalKept (the health number). */
28
+ const fs = require('fs');
29
+ const path = require('path');
30
+
31
+ const TAG = '[starter-goals]';
32
+ const MAX = 3;
33
+ const TICKETS = 40;
34
+ const THEME_MIN = 3;
35
+ const STORE = 'starter-goals.json';
36
+ const FILE = 'okrs-starter.md';
37
+ const DRAFT_FILE = 'okrs-draft.md';
38
+ const TRACKER = /\b(jira|atlassian|linear|github issues?|tickets?)\b/i;
39
+ const AIM = /\b(increase|reduce|cut|grow|improve|raise|lower|double|halve|help|make|let|enable|get|reach|keep)\b/i;
40
+ const STOP = new Set(('a an the and or but for with from into onto over under about after before when where while this that these those '
41
+ + 'their there they them then than have has had will would could should must can not no yes all any some each more most less few many '
42
+ + 'make made does done doing being been were was are is its it’s it\'s our your you we us via per new add adds added update updates updated '
43
+ + 'fix fixes fixed bug bugs task tasks story stories epic issue issues ticket tickets page pages user users test tests use used using also '
44
+ + 'show shows when what which who why how first last next only just like into need needs should able').split(/\s+/));
45
+
46
+ const one = (s, n = 200) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
47
+ const clip = (s, n) => { s = one(s, 1000); return s.length > n ? s.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : s; };
48
+ const norm = (s) => one(s, 400).toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').replace(/\s+/g, ' ').trim();
49
+ const day = (t) => new Date(t).toISOString().slice(0, 10);
50
+ const log = (o, line) => { try { (o.log || ((s) => console.error(s)))(TAG + ' ' + line); } catch { /* a log line never fails a press */ } };
51
+
52
+ function pmosIn(root) { return require('./project-onboard.js').pmosIn(root); }
53
+ function planningOf(root) { const pm = pmosIn(root); return pm ? pm.planning : path.join(root, 'planning'); }
54
+ function stateDirOf(root) { const pm = pmosIn(root); return pm && pm.kit ? path.join(pm.kit, 'state') : path.join(root, 'pmos', 'state'); }
55
+ const storeFile = (root) => path.join(stateDirOf(root), STORE);
56
+ const goalFile = (root) => path.join(planningOf(root), 'okrs', FILE);
57
+ function readStore(root) { try { const v = JSON.parse(fs.readFileSync(storeFile(root), 'utf8')); return v && Array.isArray(v.rows) ? v : null; } catch { return null; } }
58
+ function writeStore(root, v) { const f = storeFile(root); fs.mkdirSync(path.dirname(f), { recursive: true }); const tmp = f + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(v, null, 1) + '\n'); fs.renameSync(tmp, f); return v; }
59
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
60
+
61
+ /* ── sources ── */
62
+ function readmeGoals(root) {
63
+ let names = []; try { names = fs.readdirSync(root); } catch { return null; }
64
+ const rn = names.find((n) => /^readme(\.md)?$/i.test(n)); if (!rn) return null;
65
+ const text = readText(path.join(root, rn)) || '';
66
+ const lines = text.split('\n');
67
+ const i = lines.findIndex((l) => /^#{1,3}\s+(goals?|objectives?|success( metrics| criteria)?|what success looks like)\b/i.test(l));
68
+ if (i < 0) return null;
69
+ const heading = one(lines[i].replace(/^#+\s*/, ''), 60);
70
+ const items = [];
71
+ for (let j = i + 1; j < lines.length && !/^#{1,3}\s/.test(lines[j]); j++) { const m = /^\s*[-*+]\s+(?:\[[ x]\]\s+)?(.+)$/.exec(lines[j]); if (m) items.push(one(m[1].replace(/\*\*|`/g, ''), 200)); }
72
+ return items.length ? { file: rn, heading, items: items.slice(0, 5) } : null;
73
+ }
74
+ function setupTickets(text) {
75
+ const out = []; const s = String(text || ''); const at = s.indexOf('## Sources read during setup'); if (at < 0) return out;
76
+ for (const m of s.slice(at).matchAll(/^- (.+?)(?: — (https:\S+))? \(([^)]+)\)$/gm)) if (TRACKER.test(m[3])) out.push({ title: one(m[1], 200), label: one(m[3], 40) });
77
+ return out;
78
+ }
79
+ function myWorkTickets(runtimeDir, key) {
80
+ if (!runtimeDir || !key) return [];
81
+ let r = null; try { r = JSON.parse(fs.readFileSync(path.join(runtimeDir, 'my-work', 'read.json'), 'utf8')); } catch { return []; }
82
+ const items = (r && (r.items || (r.read && r.read.items))) || [];
83
+ return items.filter((x) => x && new RegExp('^' + key + '-\\d+$').test(String(x.key || ''))).map((x) => ({ title: one(x.title, 200), label: 'Jira' }));
84
+ }
85
+ function sourcesOf(root, { runtimeDir = null } = {}) {
86
+ const P = require('./project-onboard.js');
87
+ const ctxText = readText(path.join(planningOf(root), 'project-context.md'));
88
+ const ctx = ctxText == null ? { name: '', fields: {}, jira: null, goal: null } : P.readContext(ctxText);
89
+ const f = ctx.fields || {};
90
+ const label = (v) => (v && v.source === 'finding' && v.source_label ? v.source_label + ' · project-context.md' : 'project-context.md');
91
+ const seen = new Set(), tickets = [];
92
+ for (const t of [...setupTickets(ctxText), ...myWorkTickets(runtimeDir, ctx.jira && ctx.jira.key)]) { const k = norm(t.title); if (!k || seen.has(k)) continue; seen.add(k); tickets.push(t); }
93
+ const draftText = readText(path.join(planningOf(root), 'okrs', DRAFT_FILE)) || '';
94
+ const setupKr = ((/\*\*KR1\*\*\s*(?:PROPOSED:\s*)?(.+?)\. Measure:/.exec(draftText) || [])[1]) || (ctx.goal && ctx.goal.kr) || '';
95
+ return { name: ctx.name || path.basename(root),
96
+ goalsLine: f.goals && f.goals.value ? { value: f.goals.value, label: label(f.goals) } : null,
97
+ purpose: f.purpose && f.purpose.value ? { value: f.purpose.value, label: 'purpose · ' + label(f.purpose) } : null,
98
+ readme: readmeGoals(root), tickets: tickets.slice(0, TICKETS), setupKr };
99
+ }
100
+
101
+ /* ── drafts (PURE) ── */
102
+ function themes(tickets) {
103
+ const count = new Map();
104
+ for (const t of tickets || []) {
105
+ const words = new Set(norm(t.title).split(' ').filter((w) => w.length >= 4 && !STOP.has(w) && !/^\d+$/.test(w)));
106
+ for (const w of words) count.set(w, (count.get(w) || 0) + 1);
107
+ }
108
+ return [...count].filter(([, n]) => n >= THEME_MIN).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 2);
109
+ }
110
+ function draftsOf(S = {}) {
111
+ const cands = [];
112
+ const add = (text, label, ref) => cands.push({ text: clip(String(text || '').replace(/[.;:]+$/, ''), 160), source: { label: one(label, 80), ref: one(ref, 120) } });
113
+ if (S.goalsLine) for (const item of String(S.goalsLine.value).split(/;|\s·\s|(?<=[a-z0-9%])\.\s+(?=[A-Z])/)) add(item, S.goalsLine.label, 'Goals and metrics');
114
+ if (S.readme) for (const item of S.readme.items) add(item, S.readme.file + ' · ' + S.readme.heading, S.readme.file);
115
+ const tickets = S.tickets || [];
116
+ for (const [w, n] of themes(tickets)) {
117
+ const where = [...new Set(tickets.map((t) => t.label))].join(', ') || 'tickets';
118
+ add('Fewer tickets about ' + w, `${n} of ${tickets.length} tickets in ${where} name “${w}”`, 'tickets read during setup');
119
+ }
120
+ if (S.purpose) { const s = String(S.purpose.value).split(/(?<=[.!?])\s+/).find((x) => AIM.test(x)); if (s) add(s, S.purpose.label, 'Purpose'); }
121
+ const out = [], seen = new Set([norm(S.setupKr)].filter(Boolean));
122
+ for (const c of cands) {
123
+ const k = norm(c.text);
124
+ if (!k || k.split(' ').length < 2 || seen.has(k)) continue;
125
+ if (!c.source.label || !c.source.ref) continue; // a draft without a source is never offered
126
+ seen.add(k); out.push({ n: out.length + 1, kind: 'goal', text: c.text, source: c.source });
127
+ if (out.length >= MAX) break;
128
+ }
129
+ return out;
130
+ }
131
+
132
+ /* ── the store ── */
133
+ /** Goal files other than the setup draft and this file: a product that has them gets no starter goals. */
134
+ function hasGoals(root) {
135
+ try { const r = require('./okr-goals.js').read(root); return (r.files || []).some((f) => ![DRAFT_FILE, FILE].includes(path.basename(f))) && (r.objectives || []).length > 0; }
136
+ catch { return false; }
137
+ }
138
+ function draft(root, o = {}) {
139
+ const now = o.now || Date.now();
140
+ const have = readStore(root);
141
+ if (have) return { ok: true, drafted: false, rows: have.rows.filter((r) => r.state === 'draft') };
142
+ if (hasGoals(root)) { log(o, `skipped root=${path.basename(root)} why=has-goals`); return { ok: false, why: 'has-goals', error: 'This product has goals already, so PMOS drafts no starter goals.' }; }
143
+ const rows = draftsOf(o.sources || sourcesOf(root, o)).map((r) => ({ ...r, state: 'draft' }));
144
+ if (!rows.length) { log(o, `none root=${path.basename(root)}`); return { ok: false, why: 'no-sources', rows: [] }; }
145
+ writeStore(root, { drafted_at: new Date(now).toISOString(), rows, undo: [] });
146
+ log(o, `drafted ${rows.length} root=${path.basename(root)} sources=${[...new Set(rows.map((r) => r.source.ref))].join('|')}`);
147
+ return { ok: true, drafted: true, rows };
148
+ }
149
+ function view(root) {
150
+ const s = readStore(root);
151
+ return { rows: s ? s.rows.filter((r) => r.state === 'draft').map(({ n, kind, text, source }) => ({ n, kind, text, source })) : [] };
152
+ }
153
+ const header = (name, today) => ['---', 'type: OKR', `title: "Starter goals: ${String(name).replace(/"/g, "'")}"`, `timestamp: ${today}`, '---', '',
154
+ `# Starter goals: ${name}`, '', `PMOS drafted these from ${name}'s own sources, and you kept each one. Change or remove a line here or in Goals.`, '',
155
+ '## O-S — Starter goals', ''].join('\n');
156
+ const krLine = (r) => `- **KR-S${r.n}** ${r.text.replace(/\n/g, ' ')}. Source: ${r.source.label}.`;
157
+ function rowOf(s, n) { return s && s.rows.find((r) => r.n === Number(n)); }
158
+
159
+ function keep(root, n, o = {}) {
160
+ const now = o.now || Date.now();
161
+ const s = readStore(root), r = rowOf(s, n);
162
+ if (!r) return { ok: false, error: 'There is no starter goal ' + n + '.' };
163
+ if (r.state !== 'draft') return { ok: false, error: 'Starter goal ' + n + ' was ' + (r.state === 'kept' ? 'kept' : 'dropped') + ' already.' };
164
+ const f = goalFile(root);
165
+ const before = readText(f);
166
+ const name = (o.sources && o.sources.name) || sourcesOf(root, o).name;
167
+ const line = krLine(r);
168
+ const after = (before == null ? header(name, day(now)) : before.replace(/\n*$/, '\n')) + line + '\n';
169
+ fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, after);
170
+ r.state = 'kept'; r.kr = 'KR-S' + r.n;
171
+ s.undo.push({ act: 'keep', n: r.n, line, made: before == null, at: new Date(now).toISOString() });
172
+ writeStore(root, s);
173
+ log(o, `kept n=${r.n} file=${path.relative(root, f)}`);
174
+ try { require('./use-log.js').record(o.useDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }), [{ kind: 'use', page: 'today', control: 'starterGoalKept', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
175
+ return { ok: true, n: r.n, kr: r.kr, file: path.relative(root, f), rows: view(root).rows };
176
+ }
177
+ function drop(root, n, o = {}) {
178
+ const s = readStore(root), r = rowOf(s, n);
179
+ if (!r) return { ok: false, error: 'There is no starter goal ' + n + '.' };
180
+ if (r.state !== 'draft') return { ok: false, error: 'Starter goal ' + n + ' was ' + (r.state === 'kept' ? 'kept' : 'dropped') + ' already.' };
181
+ r.state = 'dropped'; s.undo.push({ act: 'drop', n: r.n, at: new Date(o.now || Date.now()).toISOString() });
182
+ writeStore(root, s);
183
+ log(o, `dropped n=${r.n}`);
184
+ return { ok: true, n: r.n, rows: view(root).rows };
185
+ }
186
+ function undo(root, o = {}) {
187
+ const s = readStore(root);
188
+ const last = s && s.undo[s.undo.length - 1];
189
+ if (!last) return { ok: false, error: 'Nothing to undo.' };
190
+ const r = rowOf(s, last.n);
191
+ if (last.act === 'keep') {
192
+ const f = goalFile(root), text = readText(f);
193
+ if (text == null || !text.split('\n').includes(last.line)) { log(o, `undo-refused n=${last.n} why=edited`); return { ok: false, error: `${path.relative(root, f)} changed since, so PMOS leaves it. Remove the line yourself if you want.` }; }
194
+ const after = text.split('\n').filter((l) => l !== last.line).join('\n');
195
+ if (last.made && !/^\s*[-*]\s*\*\*KR-/m.test(after)) fs.unlinkSync(f); else fs.writeFileSync(f, after);
196
+ delete r.kr;
197
+ }
198
+ r.state = 'draft'; s.undo.pop(); writeStore(root, s);
199
+ log(o, `undone ${last.act} n=${last.n}`);
200
+ return { ok: true, act: last.act, n: last.n, rows: view(root).rows };
201
+ }
202
+
203
+ /* ── CLI ── */
204
+ const COMMANDS = { goals: ['starter', 'draft', 'keep', 'drop', 'undo'] };
205
+ const USAGE = [
206
+ 'pmos goals — starter goals PMOS drafts from your own product (its project context, README and tickets)',
207
+ ' pmos goals starter the open drafts, each with its source (the same rows as the setup page)',
208
+ ' pmos goals draft draft them once, when the product has no goals beyond the setup draft',
209
+ ' pmos goals keep <n> keep draft n: it becomes key result KR-S<n> in planning/okrs/okrs-starter.md',
210
+ ' pmos goals drop <n> drop draft n; it writes no goal',
211
+ ' pmos goals undo undo the newest keep or drop',
212
+ 'A draft counts in no report until you keep it. Nothing is sent.',
213
+ ];
214
+ function repoOf(cwd) {
215
+ let d = path.resolve(cwd);
216
+ for (;;) { if (fs.existsSync(path.join(d, '.git')) || pmosIn(d)) return d; const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
217
+ }
218
+ function run(argv, o = {}) {
219
+ const say = o.say || ((s) => console.log(s));
220
+ const args = argv[0] === 'goals' ? argv.slice(1) : argv.slice();
221
+ const pos = [], flags = {};
222
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root') flags.root = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
223
+ const cmd = pos[0] || 'starter';
224
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
225
+ if (!COMMANDS.goals.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos goals`); USAGE.forEach((l) => say(l)); return 2; }
226
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
227
+ const opts = { ...o, runtimeDir: o.runtimeDir || (() => { try { return require('./state-root.js').defaultRoot({ env: o.env || process.env }); } catch { return null; } })() };
228
+ const r = cmd === 'starter' ? { ok: true, ...view(root) } : cmd === 'draft' ? draft(root, opts) : cmd === 'undo' ? undo(root, opts)
229
+ : (pos[1] == null ? { ok: false, error: `Say which draft: pmos goals ${cmd} <n>` } : (cmd === 'keep' ? keep : drop)(root, pos[1], opts));
230
+ if (flags.json) { say(JSON.stringify(r)); return r.ok ? 0 : 1; }
231
+ if (!r.ok) { say('✗ ' + (r.error || (r.why === 'no-sources' ? 'No source of this product names a goal yet, so PMOS drafts none.' : 'That did not work.'))); return 1; }
232
+ if (cmd === 'keep') say(`✓ Kept as ${r.kr} in ${r.file}. pmos goals undo takes it out again.`);
233
+ if (cmd === 'drop') say(`✓ Dropped starter goal ${r.n}. pmos goals undo brings it back.`);
234
+ if (cmd === 'undo') say(`✓ Undid the ${r.act} of starter goal ${r.n}.`);
235
+ const rows = r.rows || [];
236
+ if (cmd === 'starter' || cmd === 'draft') {
237
+ if (!rows.length) { say('No starter goals are open.'); return 0; }
238
+ for (const x of rows) say(`${x.n}. ${x.text} (from: ${x.source.label})`);
239
+ say('pmos goals keep <n> or drop <n>.');
240
+ }
241
+ return 0;
242
+ }
243
+
244
+ module.exports = { TAG, MAX, TICKETS, THEME_MIN, FILE, sourcesOf, draftsOf, themes, draft, view, keep, drop, undo, hasGoals, run, COMMANDS, USAGE, storeFile, goalFile };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.826.0",
3
+ "version": "0.827.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.826.0",
9
+ "version": "0.827.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.826.0",
3
+ "version": "0.827.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",
@@ -89,3 +89,7 @@ body.ob-on #hmChat[hidden] { display: none; }
89
89
  .ob-fund li em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); overflow-wrap: anywhere; }
90
90
  .ob-fund li .ob-lk { align-self: flex-start; }
91
91
  @media (max-width: 760px) { .ob-fl { grid-template-columns: minmax(0, 1fr) auto; } .ob-fl em { grid-column: 1; } .ob-fl .ob-pen { grid-column: 2; } .ob-rv .ob-fld { grid-template-columns: minmax(0, 1fr); } }
92
+
93
+ /* starter goals under the fundamentals card (A84, board BatchMoreBDS panel 32): Keep and Drop stay in view, not only on hover */
94
+ .pm-ds .sg-block .pm-li .acts{display:flex}
95
+ .pm-ds .sg-said{margin:var(--space-12, 12px) 0 var(--space-8, 8px)}
@@ -7,11 +7,14 @@
7
7
  * 2. The first question is the product. The composer is open from the first screen; an answer typed before the check passes waits for it.
8
8
  * 3. ✦ one proposal for the folder, the read-only search and what needs a sign-in. ✓ runs it; ✕ asks what to change, in the composer.
9
9
  * 4. The findings as up to three source tiles, then ✦ "Set up PMOS in <folder> with this context". A missing line says so and has edit.
10
- * 5. After init: the fundamentals card (lib/onboard-fundamentals.js), each line with its source and one change; then ✦ the first initiative.
10
+ * 5. After init: the fundamentals card (lib/onboard-fundamentals.js), each line with its source and one change; under it the starter goals
11
+ * drafted from the product's own sources (pm/starter-goals.js, A84), each ✓ keep or ✕ drop with Undo in the toast; then ✦ the first initiative.
11
12
  * The calls to action are ✓ and ✕ only. Order is enforced by the server. Every press is the PM's (pmPost). Text from connectors is escaped. */
12
13
  import { pmGet, pmPost } from './http.js';
13
14
  import { adler } from './cozy-adler.js';
14
15
  import { signInTerminal } from './cozy-claude-setup.js';
16
+ import { starterBlock } from './starter-goals.js';
17
+ import { toast } from './primitives.js';
15
18
 
16
19
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
20
  const CHECK = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
@@ -170,6 +173,7 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
170
173
  return `<li data-key="${esc(l.key)}">${CHECK}<span><span>${esc(l.text)}</span>${meta ? `<em>${meta}</em>` : ''}</span></li>`; }).join('');
171
174
  return [{ mood: 'handled', body: `<p><b>${esc(d.name)}</b> is set up in <code>${esc(d.root)}</code>. I settled the basics for you:</p>`
172
175
  + `<ul class="ut-card ob-done ob-fund">${rows}</ul>${fd.error ? `<p class="ob-sub">${esc(fd.error)}</p>` : ''}`
176
+ + starterBlock(S.data.starter, { busy: !!S.busy })
173
177
  + prop('Draft the first initiative from the purpose, with its expected outcome', [], 'Nothing is final until you keep it.', 'first-yes', 'first-no', 'Draft the first initiative') }];
174
178
  }
175
179
 
@@ -282,6 +286,16 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
282
286
  } catch (e) { S.note = e.message || 'That did not finish. Try again.'; }
283
287
  S.busy = ''; draw();
284
288
  }
289
+ /** A84: keep, drop or undo one starter goal. The toast says what happened and carries Undo (the newest keep or drop). */
290
+ async function starter(a, n) {
291
+ S.busy = 'starter'; S.note = ''; draw();
292
+ const r = await post('starter', { act: a, n });
293
+ S.busy = ''; draw();
294
+ if (!r.ok) { S.note = r.error || 'That did not finish. Try again.'; draw(); return; }
295
+ const d = r.starter_did || {};
296
+ if (a === 'undo') { toast({ text: 'Undone.' }); return; }
297
+ toast({ text: a === 'keep' ? `Kept as a goal${d.file ? ' in ' + d.file : ''}.` : 'Dropped. It counts nowhere.', actionLabel: 'Undo', onAction: () => starter('undo') });
298
+ }
285
299
  function readReview() {
286
300
  const form = log.querySelector('form[data-ob-form="review"]'); if (!form) return null;
287
301
  const fields = {}; for (const [k] of FIELD_LABELS) { const i = form.querySelector(`input[name="${k}"]`); if (i) fields[k] = i.value; }
@@ -293,6 +307,8 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
293
307
  sec.addEventListener('click', (e) => {
294
308
  const ed = e.target.closest('[data-ob-edit]');
295
309
  if (ed) { S.editing.add(ed.dataset.obEdit); const keep = readReview(); draw(); if (keep) for (const [k, v] of Object.entries(keep.fields || {})) { const i = log.querySelector(`input[name="${k}"]`); if (i) i.value = v; } const i = log.querySelector(`input[name="${ed.dataset.obEdit}"]`); if (i) i.focus(); return; }
310
+ const sg = e.target.closest('[data-sg]');
311
+ if (sg) { if (!sg.disabled && !S.busy) starter(sg.dataset.sg, Number(sg.dataset.n)); return; }
296
312
  const b = e.target.closest('[data-ob]'); if (!b || b.disabled || S.busy) return;
297
313
  e.preventDefault(); act(b.dataset.ob);
298
314
  });
@@ -183,6 +183,19 @@ function artOf(id, ws) {
183
183
  }
184
184
  return ART.get(id);
185
185
  }
186
+ /* the architecture warning (arch-warns, A54): GET /api/arch-warns?ini=<id> once per initiative. null while reading or when there is nothing
187
+ * to say; the one shown is counted on this computer (control archWarnShown). */
188
+ const ARCH = new Map(); // id → warn | false (nothing to say) | null while reading
189
+ function archOf(id, ws) {
190
+ if (!id) return null;
191
+ if (!ARCH.has(id)) {
192
+ ARCH.set(id, null);
193
+ pmGet('/api/arch-warns?ini=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
194
+ .then((x) => { const w = (x && x.ok && x.warn) || false; ARCH.set(id, w); if (w) noteUse('archWarnShown'); if (artRedraw) artRedraw(); })
195
+ .catch(() => ARCH.set(id, false)); // an older server has no such route: Work stays as it was
196
+ }
197
+ return ARCH.get(id) || null;
198
+ }
186
199
  /* a product's name, never its id (round 3 point 4): GET /api/workspaces once */
187
200
  let WSN = null, wsnRedraw = null;
188
201
  function productName(p, ws) {
@@ -423,7 +436,7 @@ function model(r, v0, o) {
423
436
  const id0 = keyOf(v0, o), pd = PEND.get(id0), v = pd && pd.desc != null ? { ...v0, desc: pd.desc } : v0;
424
437
  const id = id0, S = stOf(id), it = ITEMS.get(id);
425
438
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
426
- const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
439
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), arch: archOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
427
440
  if (pd && W.overview) for (const L of W.overview.lines || []) if (pd.lines[L.id] != null) { L.text = pd.lines[L.id]; delete L.ask; delete L.miss; }
428
441
  if (W.overview) for (const L of W.overview.lines || []) if (!L.text && DRAFTING.has(id0 + ':' + L.id)) { L.drafting = true; delete L.ask; delete L.miss; }
429
442
  const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
@@ -722,7 +735,24 @@ async function draftDocs(s, x, h) {
722
735
  }
723
736
  /* a direct ✓ (bet 1f): the plan end, closing the open tasks, reopening. One press writes through POST /api/boards/ini-<act> with Undo; no chat
724
737
  * message, no session. Only when the route answers ask: true (the plain reading does not hold) do the words go to Ask PMOS, as before. */
738
+ /* the test task of an architecture warning (arch-warns, A54): one press adds the task to this initiative through the task route every other
739
+ * add uses, and the toast's Undo deletes it again. Nothing else is written, and the warning is read again after the add. */
740
+ async function testTask(d, x, h) {
741
+ const w = h.where ? h.where() : {}, id = x.o().id;
742
+ const res = await pmPost('/api/boards/tasks/add', { ws: w.ws, board: w.board, initiative: id, title: d.title }).catch(() => null);
743
+ if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'The task was not added.'); return; }
744
+ noteUse('archWarnTask');
745
+ const uid = (res.item && (res.item.uid || res.item.id)) || '';
746
+ ARCH.delete(id);
747
+ if (h.reload) await h.reload();
748
+ undoToast(d.title + ' added.', async () => {
749
+ const u = uid ? await pmPost('/api/boards/tasks/delete', { ws: w.ws, board: w.board, task: uid }).catch(() => null) : null;
750
+ if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
751
+ if (h.reload) await h.reload();
752
+ });
753
+ }
725
754
  async function direct(d, ask, x, h) {
755
+ if (d.act === 'test-task') return testTask(d, x, h);
726
756
  const w = h.where ? h.where() : {}, id = x.o().id;
727
757
  const res = await pmPost('/api/boards/ini-' + d.act, { ws: w.ws, board: w.board, id, ...(d.to ? { to: d.to } : {}) }).catch(() => null);
728
758
  // the words go to Ask PMOS when the plain reading does not hold (ask), or when the route cannot be reached: pmPost answers
@@ -533,6 +533,12 @@ export function derivedOf(r, v, o, bd, arts) {
533
533
  why: 'The gate to the next stage needs ' + what + ', and ' + (miss.length === 1 ? 'it is' : 'they are') + ' not written.',
534
534
  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) });
535
535
  }
536
+ // the initiative names a part of the code the code map calls risky (arch-warns, A54): one ✦ with that reason in the map's own words and
537
+ // one step, the test task. ✕ hides it for this initiative only (the dropped set). o.arch is GET /api/arch-warns, null when there is
538
+ // nothing to say; what is risky is never decided here.
539
+ const aw = o.arch || null;
540
+ if (live && aw && aw.part && aw.say) top.push({ id: 'd:arch:' + (o.id || v.id || v.key || r.id || '') + ':' + aw.part, derived: true,
541
+ say: aw.say, why: aw.note || '', direct: { act: 'test-task', title: aw.task || ('Add tests for ' + aw.part) } });
536
542
  // a document PMOS drafted waits to be issued (issue-from-chat): one ✦ per draft, ✓ issues it with Undo, ✎ opens it to read or edit, ✕ hides it.
537
543
  // Before, a draft the chat saved had no Issue anywhere on this page, and the chat sent the PM to a card that did not exist.
538
544
  for (const d of o.docs || []) {
@@ -0,0 +1,35 @@
1
+ /* pm/starter-goals.js — the Starter goals block under the fundamentals card after setup (initiative starter-goals, job #1916, idea A84;
2
+ * board BatchMoreBDS panel 32, agreed 2026-11-25).
3
+ *
4
+ * starterBlock(starter, { busy }) PURE → the block's HTML, or '' when no draft is open (zero is silence)
5
+ *
6
+ * Built from the system parts only: the ✦ line (pm-said), pm-block list, pm-li rows with the "No signal" state glyph (a draft reads nothing
7
+ * yet), and icon-only Keep (✓) and Drop (✕) buttons with an aria-label. Each row names its source: "from: <label>". The rows come from
8
+ * lib/starter-goals.js view() through GET /api/onboard/state; a press posts { act, n } to /api/onboard/starter (cozy-onboard.js), which
9
+ * answers with the Undo toast. Text from the product's files is escaped. */
10
+ import { stateGlyph } from './state-glyph.js';
11
+
12
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
13
+ const STAR = '<svg class="pm-ic pm-star" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z"/></svg>';
14
+ const KEEP = '<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
15
+ const DROP = '<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>';
16
+
17
+ /** What the drafts came from, said once: "From your product's README and 30 tickets, 3 starter goals, as drafts." PURE. */
18
+ export function starterSaid(rows) {
19
+ const refs = [...new Set(rows.map((r) => (r.source && r.source.ref) || ''))].filter(Boolean);
20
+ const n = rows.length;
21
+ return `From your product's own ${refs.length ? refs.join(', ').replace(/, ([^,]*)$/, ' and $1') : 'files'}: ${n} starter ${n === 1 ? 'goal' : 'goals'}, as drafts. A draft counts nowhere until you keep it.`;
22
+ }
23
+
24
+ export function starterBlock(starter, { busy = false } = {}) {
25
+ const rows = ((starter && starter.rows) || []).filter((r) => r && r.text && r.source && r.source.label); // a draft without a source is never shown
26
+ if (!rows.length) return '';
27
+ const dis = busy ? ' disabled' : '';
28
+ const li = rows.map((r) => `<div class="pm-li" data-sg-row="${esc(r.n)}">${stateGlyph('none', { why: 'a draft reads nothing yet' })}`
29
+ + `<span class="txt"><span class="t">${esc(r.text)}</span><span class="w">from: ${esc(r.source.label)}</span></span>`
30
+ + `<span class="acts sg-acts"><button type="button" class="pm-btn" data-sg="keep" data-n="${esc(r.n)}" aria-label="Keep" title="Keep"${dis}>${KEEP}</button>`
31
+ + `<button type="button" class="pm-btn" data-sg="drop" data-n="${esc(r.n)}" aria-label="Drop" title="Drop"${dis}>${DROP}</button></span></div>`).join('');
32
+ return `<p class="pm-said sg-said">${STAR}<span>${esc(starterSaid(rows))}</span></p>`
33
+ + `<section class="pm-block list sg-block" aria-label="Starter goals"><div class="head"><h3 class="pm-h-sm">Starter goals</h3><span class="sp"></span><span class="pm-meta">${rows.length}</span></div>`
34
+ + `<div class="rows">${li}</div></section>`;
35
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Architecture warnings when work touches risky code (initiative arch-warns, done test A1-A8, N1-N3): the reading over the stored code map, GET /api/arch-warns, the popup's one ✦ with its test-task step, and pmos code warns. No browser, model or network.",
3
+ "modules": [
4
+ "arch-warns.test.js"
5
+ ],
6
+ "seconds": {
7
+ "arch-warns.test.js": 2
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Starter goals from your own product (initiative starter-goals, done test S1-S9, N1-N3): drafts from the product's own files, keep/drop/undo, the onboarding route, the pmos goals verb and the block. No browser, model or network.",
3
+ "modules": [
4
+ "starter-goals.test.js"
5
+ ],
6
+ "seconds": {
7
+ "starter-goals.test.js": 2
8
+ }
9
+ }