create-pmos 0.825.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.
Files changed (47) hide show
  1. package/package.json +119 -49
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +118 -16
  7. package/workspace/guide/agent-capabilities.md +1 -0
  8. package/workspace/guide/cli.md +36 -0
  9. package/workspace/guide/home.md +1 -0
  10. package/workspace/guide/layout.md +1 -1
  11. package/workspace/guide/settings-and-switches.md +2 -0
  12. package/workspace/lib/arch-warns.js +121 -0
  13. package/workspace/lib/code-map-cli.js +108 -0
  14. package/workspace/lib/code-map.js +247 -0
  15. package/workspace/lib/features.json +59 -1
  16. package/workspace/lib/goals-cli.js +5 -0
  17. package/workspace/lib/pmos-verbs.js +6 -0
  18. package/workspace/lib/route-modules.js +2 -0
  19. package/workspace/lib/routes-arch-warns.js +39 -0
  20. package/workspace/lib/routes-code-map.js +66 -0
  21. package/workspace/lib/routes-onboard.js +18 -3
  22. package/workspace/lib/routes-today.js +2 -1
  23. package/workspace/lib/starter-goals.js +244 -0
  24. package/workspace/lib/today-cli.js +4 -2
  25. package/workspace/lib/today-order.js +120 -0
  26. package/workspace/package-lock.json +2 -2
  27. package/workspace/package.json +1 -1
  28. package/workspace/public/pm/code-map.js +60 -0
  29. package/workspace/public/pm/cozy-board.css +8 -0
  30. package/workspace/public/pm/cozy-onboard.css +4 -0
  31. package/workspace/public/pm/cozy-onboard.js +17 -1
  32. package/workspace/public/pm/cozy-pop-work.js +31 -1
  33. package/workspace/public/pm/cozy-settings.js +0 -1
  34. package/workspace/public/pm/cozy-today-app.js +41 -2
  35. package/workspace/public/pm/cozy-today-page.css +3 -0
  36. package/workspace/public/pm/cozy-today-view.js +20 -5
  37. package/workspace/public/pm/pop-cap.js +5 -2
  38. package/workspace/public/pm/pop-work-model.js +6 -0
  39. package/workspace/public/pm/premium-board.js +2 -0
  40. package/workspace/public/pm/starter-goals.js +35 -0
  41. package/workspace/public/pm/today-order.js +88 -0
  42. package/workspace/public/premium-board.html +2 -0
  43. package/workspace/test-lists/arch-warns.json +9 -0
  44. package/workspace/test-lists/code-map.json +9 -0
  45. package/workspace/test-lists/directory-all-verbs.json +9 -0
  46. package/workspace/test-lists/starter-goals.json +9 -0
  47. package/workspace/test-lists/today-order.json +9 -0
@@ -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 };
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+ /* code-map-cli.js — `pmos code`: the product's code map, the same map the Code panel on Work shows (idea A176, initiative code-map).
3
+ * The store is lib/code-map.js (code-map.json and code-map-notes.jsonl in the product's records folder).
4
+ *
5
+ * pmos code show [--json] one line per main part: what it is, how tested, who changed it last; ! marks a risky part
6
+ * pmos code map [--json] draw the map again now from the default branch (read-only git)
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
+ * 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)
10
+ * every command: [--root <dir>] (default: this repository)
11
+ *
12
+ * Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent, and nothing in the repository is written. */
13
+ const path = require('path');
14
+ const fs = require('fs');
15
+ const CM = require('./code-map.js');
16
+
17
+ const COMMANDS = { code: ['show', 'map', 'describe', 'count', 'warns'] };
18
+ const USAGE = [
19
+ 'usage: pmos code show|map|describe|count — the product\'s code map: one line per main part',
20
+ ' pmos code show [--json] what each part is, how it is tested, who changed it last; ! marks a risky part',
21
+ ' pmos code map [--json] draw the map again now from the default branch',
22
+ ' pmos code describe --part api --text "<what it is>" say what a part is; --text "" puts PMOS\'s words back',
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',
25
+ 'Run it in the product\'s repository, or pass --root <dir>.',
26
+ ];
27
+ const ALLOWED = { show: ['json', 'root'], map: ['json', 'root'], describe: ['json', 'root', 'part', 'text'], count: ['json', 'root'], warns: ['json', 'root'] };
28
+ const BOOL = new Set(['json']);
29
+
30
+ function parse(args) {
31
+ const pos = [], flags = {};
32
+ for (let i = 0; i < args.length; i++) {
33
+ const a = args[i];
34
+ if (!a.startsWith('--')) { pos.push(a); continue; }
35
+ const k = a.slice(2);
36
+ if (BOOL.has(k)) { flags[k] = true; continue; }
37
+ flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
38
+ }
39
+ return { pos, flags };
40
+ }
41
+ /** The nearest folder at or above `cwd` that holds a .git entry, read from the disk with no git run; `cwd` when there is none. */
42
+ function repoRoot(cwd) {
43
+ let dir = path.resolve(cwd);
44
+ for (let i = 0; i < 64; i++) {
45
+ if (fs.existsSync(path.join(dir, '.git'))) return dir;
46
+ const up = path.dirname(dir); if (up === dir) break; dir = up;
47
+ }
48
+ return cwd;
49
+ }
50
+ function recordsDirOf(root) {
51
+ try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
52
+ }
53
+ const dayOf = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' }); };
54
+ /** One part as one line. */
55
+ function lineOf(p) {
56
+ const what = p.note || [p.kind, p.code + (p.code === 1 ? ' file' : ' files')].filter(Boolean).join(' · ');
57
+ const who = p.last && p.last.by ? ` · ${p.last.by} last, ${dayOf(p.last.at)}` : '';
58
+ return `${p.risky ? '!' : ' '} ${p.name}: ${what} · ${p.tested}${p.risky && p.why !== 'no tests' ? ' · ' + p.why.replace(/^no tests, /, '') : ''}${who}`;
59
+ }
60
+
61
+ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now() } = {}) {
62
+ const args = argv[0] === 'code' ? argv.slice(1) : argv.slice();
63
+ const sub = args[0];
64
+ if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
65
+ if (!COMMANDS.code.includes(sub)) { say(`unknown code command "${sub}". Use one of: ${COMMANDS.code.join(', ')}`); return 2; }
66
+ const { pos, flags } = parse(args.slice(1));
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; }
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; }
70
+ const root = path.resolve(flags.root || repoRoot(cwd));
71
+ const dir = recordsDirOf(root);
72
+ const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
73
+
74
+ if (sub === 'map') {
75
+ const map = await CM.build(root, { now });
76
+ if (!map) return fail('no code map: this folder is not a git repository, or it holds no code');
77
+ CM.save(dir, map);
78
+ if (flags.json) { say(JSON.stringify({ ok: true, map: CM.view(dir) })); return 0; }
79
+ say(`Drew ${map.parts.length} parts from ${map.ref} ${map.head.slice(0, 7)}.`);
80
+ for (const p of CM.view(dir).parts) say(lineOf(p));
81
+ return 0;
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
+ }
88
+ const map = CM.view(dir);
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; }
90
+ if (sub === 'show') {
91
+ if (flags.json) { say(JSON.stringify({ ok: true, map })); return 0; }
92
+ if (!map) { say('No code map yet. Run pmos code map, or open Work on this product.'); return 0; }
93
+ say(`Code map, read from ${map.ref} ${map.head.slice(0, 7)} on ${dayOf(map.at)}:`);
94
+ for (const p of map.parts) say(lineOf(p));
95
+ if (map.more) say(` and ${map.more} smaller part${map.more === 1 ? '' : 's'}`);
96
+ return 0;
97
+ }
98
+ // describe
99
+ if (!flags.part) return fail('--part <name> is needed (pmos code show lists the parts)', 2);
100
+ if (flags.text === undefined) return fail('--text "<what it is>" is needed ("" puts PMOS\'s words back)', 2);
101
+ const r = CM.describe(dir, flags.part, flags.text, now);
102
+ if (!r.ok) return fail(r.error);
103
+ const p = CM.findPart(r.map, flags.part);
104
+ say(flags.json ? JSON.stringify({ ok: true, part: p }) : `${p.name}: ${p.note || "PMOS's words again"}`);
105
+ return 0;
106
+ }
107
+
108
+ module.exports = { run, COMMANDS, USAGE, lineOf };
@@ -0,0 +1,247 @@
1
+ 'use strict';
2
+ /* code-map.js — a map of a product's code: one box per main part, what it is, how it is tested, who changed it last (idea A176,
3
+ * initiative code-map, agreed board BatchCodeDS panel 13).
4
+ *
5
+ * partsOf(files) → { parts: [{ name, dir, files, code, tests, langs, testsOutside }], more } PURE
6
+ * summarize({ files, log, last, pkgs, now }) → map without head/at PURE: the parts with kind, tested, bugs, last, risky, why
7
+ * riskOf(part) → null | 'no tests' | 'N fixes in 30 days' | both joined PURE
8
+ * build(root, { now, git }) → Promise<map | null> reads the default branch with read-only git verbs; null: not a repo / no code
9
+ * headOf(root, { git }) → Promise<{ ref, sha } | null> the default branch: origin/HEAD, origin/main, origin/master, main, master, HEAD
10
+ * read(dir) · save(dir, map) the stored map: <records>/code-map.json (derived, rewritten on each draw)
11
+ * describe(dir, part, text, now) → { ok, map } | { ok: false, error } the PM's own words for what a part is; '' puts PMOS's back
12
+ * view(dir) → the stored map with the PM's words on top (what `pmos code show` and the panel read)
13
+ *
14
+ * WHAT IT NEVER DOES. It runs only `git rev-parse`, `git ls-tree`, `git log` and `git show <sha>:<path>` (read-only); it never checks out,
15
+ * fetches, or writes inside the repository. The only files it writes are the two in the product's records folder.
16
+ *
17
+ * RULES (said once, here):
18
+ * · A part is a top-level folder holding code. A container folder (packages, apps, services, libs, modules, src, cmd, internal, components,
19
+ * crates, projects) opens one level down. node_modules, vendor, dist, build, coverage and dot folders are never parts.
20
+ * · A folder that is mostly tests (tests/, test/, spec/ …) is not a part; each test file in it counts for the part whose name appears
21
+ * in its path. Code files at the top level form a part "(top level)" when there are 3 or more.
22
+ * · At most MAX_PARTS parts, most code files first; the rest are counted in `more`.
23
+ * · Risky: no test files, or RISKY_FIXES or more fix commits touching the part in the last 30 days that are at least half of its
24
+ * commits there (a busy, well-kept part is not risky only for being busy). */
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+ const { execFile } = require('child_process');
28
+
29
+ const MAP_FILE = 'code-map.json';
30
+ const NOTES_FILE = 'code-map-notes.jsonl';
31
+ const MAX_PARTS = 12;
32
+ const RISKY_FIXES = 5;
33
+ const FIX_DAYS = 30;
34
+ const FIX_SHARE = 0.5; // fixes must be at least half the part's commits in the window, so a busy part is not risky only for being busy
35
+ const MAX_TEXT = 120;
36
+ const DAY = 86400000;
37
+ const CONTAINERS = new Set(['packages', 'apps', 'services', 'libs', 'modules', 'src', 'cmd', 'internal', 'components', 'crates', 'projects']);
38
+ const SKIP = new Set(['node_modules', 'vendor', 'dist', 'build', 'coverage', 'out', 'target', 'tmp', '__pycache__', 'bower_components', 'third_party']);
39
+ const TEST_DIRS = new Set(['test', 'tests', '__tests__', 'spec', 'specs', 'e2e', 'testing']);
40
+ const LANG = { js: 'JavaScript', jsx: 'JavaScript', mjs: 'JavaScript', cjs: 'JavaScript', ts: 'TypeScript', tsx: 'TypeScript', py: 'Python', rb: 'Ruby',
41
+ go: 'Go', rs: 'Rust', java: 'Java', kt: 'Kotlin', swift: 'Swift', php: 'PHP', cs: 'C#', c: 'C', h: 'C', cc: 'C++', cpp: 'C++', hpp: 'C++',
42
+ scala: 'Scala', vue: 'Vue', svelte: 'Svelte', sh: 'Shell', sql: 'SQL', ex: 'Elixir', exs: 'Elixir', dart: 'Dart', m: 'Objective-C', lua: 'Lua' };
43
+ const FRAMEWORKS = [['next', 'Next.js'], ['react', 'React'], ['vue', 'Vue'], ['svelte', 'Svelte'], ['@angular/core', 'Angular'], ['@nestjs/core', 'NestJS'],
44
+ ['express', 'Express'], ['fastify', 'Fastify'], ['koa', 'Koa'], ['electron', 'Electron'], ['react-native', 'React Native']];
45
+ const FIX_RE = /\b(fix|fixes|fixed|bug|bugfix|hotfix|regression|revert)\b/i;
46
+ const say = (s) => { try { console.log('[code-map] ' + s); } catch { /* no console */ } };
47
+
48
+ const extOf = (f) => { const b = f.slice(f.lastIndexOf('/') + 1); const i = b.lastIndexOf('.'); return i > 0 ? b.slice(i + 1).toLowerCase() : ''; };
49
+ const isCode = (f) => !!LANG[extOf(f)];
50
+ function isTest(f) {
51
+ const segs = f.split('/');
52
+ const base = segs[segs.length - 1];
53
+ if (segs.slice(0, -1).some((s) => TEST_DIRS.has(s.toLowerCase()))) return true;
54
+ return /[._-](test|spec)\.[a-z0-9]+$/i.test(base) || /^test_.+\.py$/i.test(base) || /_test\.(go|py|rb|exs)$/i.test(base);
55
+ }
56
+ const skipped = (f) => f.split('/').slice(0, -1).some((s) => s.startsWith('.') || SKIP.has(s));
57
+
58
+ /** The key of the part a file belongs to: 'a', 'packages/api', or '' for a top-level file. */
59
+ function keyOf(f, open) {
60
+ const segs = f.split('/');
61
+ if (segs.length === 1) return '';
62
+ if (open.has(segs[0]) && segs.length > 2) return segs[0] + '/' + segs[1];
63
+ return segs[0];
64
+ }
65
+
66
+ /** Group a repository's files into its main parts. PURE. */
67
+ function partsOf(files) {
68
+ const list = (Array.isArray(files) ? files : []).map(String).filter((f) => f && !skipped(f) && !f.split('/').pop().startsWith('.'));
69
+ // a container opens only when it has sub-folders with code (a flat src/ stays one part)
70
+ const open = new Set();
71
+ for (const f of list) { const s = f.split('/'); if (CONTAINERS.has(s[0]) && s.length > 2 && isCode(f)) open.add(s[0]); }
72
+ const by = new Map();
73
+ for (const f of list) {
74
+ const k = keyOf(f, open);
75
+ if (!by.has(k)) by.set(k, { name: k || '(top level)', dir: k, files: 0, code: 0, tests: 0, langs: {}, testsOutside: 0, _tests: [] });
76
+ const p = by.get(k);
77
+ p.files++;
78
+ if (!isCode(f)) continue;
79
+ if (isTest(f)) { p.tests++; p._tests.push(f); continue; }
80
+ p.code++;
81
+ const l = LANG[extOf(f)]; p.langs[l] = (p.langs[l] || 0) + 1;
82
+ }
83
+ let parts = [...by.values()];
84
+ // a folder that is mostly tests is not a part: its tests count for the part they name
85
+ const testOnly = parts.filter((p) => p.dir && TEST_DIRS.has(p.dir.split('/').pop().toLowerCase()) && p.tests > 0 && p.tests >= p.code * 4);
86
+ parts = parts.filter((p) => !testOnly.includes(p) && p.code > 0 && (p.dir || p.code >= 3));
87
+ for (const t of testOnly) for (const f of t._tests) {
88
+ const segs = f.toLowerCase().replace(/\.[a-z0-9]+$/, '').split(/[/._-]+/);
89
+ const hit = parts.find((p) => p.dir && segs.includes(p.dir.split('/').pop().toLowerCase()));
90
+ if (hit) { hit.tests++; hit.testsOutside++; }
91
+ }
92
+ parts.sort((a, b) => b.code - a.code || a.name.localeCompare(b.name));
93
+ const more = Math.max(0, parts.length - MAX_PARTS);
94
+ return { parts: parts.slice(0, MAX_PARTS).map(({ _tests, ...p }) => p), more };
95
+ }
96
+
97
+ /** Why a part is risky, or null. PURE. */
98
+ function riskOf(p) {
99
+ const why = [];
100
+ if (!p.tests) why.push('no tests');
101
+ if ((p.fixes || 0) >= RISKY_FIXES && (p.fixes || 0) >= (p.commits || 0) * FIX_SHARE) why.push(p.fixes + ' fixes in ' + FIX_DAYS + ' days');
102
+ return why.length ? why.join(', ') : null;
103
+ }
104
+
105
+ const mainLang = (langs) => Object.entries(langs || {}).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0] || '';
106
+ function frameworkOf(pkg) {
107
+ if (!pkg || typeof pkg !== 'object') return '';
108
+ const deps = Object.assign({}, pkg.dependencies || {}, pkg.devDependencies || {}, pkg.peerDependencies || {});
109
+ const hit = FRAMEWORKS.find(([n]) => Object.prototype.hasOwnProperty.call(deps, n));
110
+ return hit ? hit[1] : '';
111
+ }
112
+
113
+ /** The parts with what they are, how tested, who changed them last and their risk. PURE.
114
+ * log: [{ at, files: [path] , fix: bool }] (commits, newest first) · last: { <dir>: { by, at } } · pkgs: { <dir>: parsed package.json } */
115
+ function summarize({ files, log = [], last = {}, pkgs = {}, now = Date.now() } = {}) {
116
+ const { parts, more } = partsOf(files);
117
+ if (!parts.length) return null;
118
+ const since = now - FIX_DAYS * DAY;
119
+ const inPart = (p, f) => (p.dir ? f === p.dir || f.startsWith(p.dir + '/') : !f.includes('/'));
120
+ const out = parts.map((p) => {
121
+ let fixes = 0, commits = 0;
122
+ for (const c of log) if (Date.parse(c.at) >= since && (c.files || []).some((f) => inPart(p, f))) { commits++; if (c.fix) fixes++; }
123
+ const lang = mainLang(p.langs), fw = frameworkOf(pkgs[p.dir]);
124
+ const kind = [lang, fw].filter(Boolean).join(' · ');
125
+ const tested = p.tests ? p.tests + (p.tests === 1 ? ' test file' : ' test files') : 'no tests';
126
+ const l = last[p.dir] || null;
127
+ const q = { name: p.name, dir: p.dir, kind, code: p.code, tests: p.tests, tested, fixes, commits, last: l ? { by: l.by, at: l.at } : null };
128
+ q.why = riskOf(q);
129
+ q.risky = !!q.why;
130
+ return q;
131
+ });
132
+ return { parts: out, more };
133
+ }
134
+
135
+ function gitRun(root, args) {
136
+ return new Promise((resolve) => {
137
+ execFile('git', args, { cwd: root, maxBuffer: 64 << 20, timeout: 30000, encoding: 'utf8' }, (err, out) => resolve(err ? null : out));
138
+ });
139
+ }
140
+ const READ_VERBS = new Set(['rev-parse', 'ls-tree', 'log', 'show']);
141
+ /** Only read-only verbs pass (N2): anything else is refused before git runs. */
142
+ const guarded = (git) => (root, args) => (READ_VERBS.has(args[0]) ? git(root, args) : Promise.resolve(null));
143
+
144
+ /** The default branch's commit: origin/HEAD, origin/main, origin/master, main, master, then HEAD. */
145
+ async function headOf(root, { git = gitRun } = {}) {
146
+ if (!root) return null;
147
+ const g = guarded(git);
148
+ const top = await g(root, ['rev-parse', '--show-toplevel']);
149
+ if (!top) return null;
150
+ for (const ref of ['origin/HEAD', 'origin/main', 'origin/master', 'main', 'master', 'HEAD']) {
151
+ const sha = await g(root, ['rev-parse', '--verify', '-q', ref + '^{commit}']);
152
+ if (sha && /^[0-9a-f]{7,64}$/.test(sha.trim())) return { ref, sha: sha.trim(), top: top.trim() };
153
+ }
154
+ return null;
155
+ }
156
+
157
+ /** Draw the map from the default branch. null when `root` is not a git repository or holds no code (N1). */
158
+ async function build(root, { now = Date.now(), git = gitRun } = {}) {
159
+ const g = guarded(git);
160
+ const head = await headOf(root, { git });
161
+ if (!head) return null;
162
+ const top = head.top;
163
+ const ls = await g(top, ['ls-tree', '-r', '--name-only', '-z', head.sha]);
164
+ if (ls == null) return null;
165
+ const files = ls.split('\0').filter(Boolean);
166
+ const { parts } = partsOf(files);
167
+ if (!parts.length) return null;
168
+ // fix commits in the window, with their files
169
+ const sinceIso = new Date(now - FIX_DAYS * DAY).toISOString();
170
+ const raw = (await g(top, ['log', head.sha, '--no-merges', '--since=' + sinceIso, '-n', '3000', '--format=%x1e%aI%x1f%s', '--name-only'])) || '';
171
+ const log = [];
172
+ for (const chunk of raw.split('\x1e')) {
173
+ if (!chunk.trim()) continue;
174
+ const [first, ...rest] = chunk.split('\n');
175
+ const [at, subject] = first.split('\x1f');
176
+ log.push({ at, fix: FIX_RE.test(subject || ''), files: rest.map((s) => s.trim()).filter(Boolean) });
177
+ }
178
+ // who changed each part last
179
+ const last = {};
180
+ for (const p of parts) {
181
+ const out = await g(top, ['log', '-1', '--format=%an%x1f%aI', head.sha, '--', p.dir || '.']);
182
+ if (out && out.trim()) { const [by, at] = out.trim().split('\x1f'); last[p.dir] = { by, at }; }
183
+ }
184
+ // a framework the part's own package.json names
185
+ const pkgs = {};
186
+ const have = new Set(files);
187
+ for (const p of parts) {
188
+ const f = p.dir ? p.dir + '/package.json' : 'package.json';
189
+ if (!have.has(f)) continue;
190
+ const txt = await g(top, ['show', head.sha + ':' + f]);
191
+ try { pkgs[p.dir] = JSON.parse(txt); } catch { /* not JSON */ }
192
+ }
193
+ const map = summarize({ files, log, last, pkgs, now });
194
+ if (!map) return null;
195
+ const out = Object.assign({ at: new Date(now).toISOString(), ref: head.ref, head: head.sha }, map);
196
+ say(`drew ${out.parts.length} parts (${out.parts.filter((p) => p.risky).length} risky) from ${head.ref} ${head.sha.slice(0, 7)}`);
197
+ return out;
198
+ }
199
+
200
+ const fileIn = (dir, f) => (dir ? path.join(dir, f) : null);
201
+ function read(dir) {
202
+ try { const m = JSON.parse(fs.readFileSync(fileIn(dir, MAP_FILE), 'utf8')); return m && Array.isArray(m.parts) ? m : null; } catch { return null; }
203
+ }
204
+ function save(dir, map) {
205
+ if (!dir || !map) return false;
206
+ fs.mkdirSync(dir, { recursive: true });
207
+ const f = fileIn(dir, MAP_FILE), tmp = f + '.' + process.pid + '.tmp';
208
+ fs.writeFileSync(tmp, JSON.stringify(map, null, 1) + '\n');
209
+ fs.renameSync(tmp, f);
210
+ return true;
211
+ }
212
+ /** The PM's words per part: the latest line for each part wins; '' means PMOS's words again. */
213
+ function notesOf(dir) {
214
+ const out = {};
215
+ let txt = '';
216
+ try { txt = fs.readFileSync(fileIn(dir, NOTES_FILE), 'utf8'); } catch { return out; }
217
+ for (const l of txt.split('\n')) {
218
+ if (!l.trim()) continue;
219
+ try { const o = JSON.parse(l); if (o && typeof o.part === 'string') { if (o.text) out[o.part] = o.text; else delete out[o.part]; } } catch { /* a torn line */ }
220
+ }
221
+ return out;
222
+ }
223
+ const oneLine = (v) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > MAX_TEXT ? s.slice(0, MAX_TEXT - 1).trimEnd() + '…' : s; };
224
+ /** Find a part by its name, its folder or the folder's last segment (case does not matter). */
225
+ function findPart(map, name) {
226
+ const n = String(name || '').trim().toLowerCase();
227
+ if (!map || !n) return null;
228
+ return map.parts.find((p) => p.name.toLowerCase() === n || (p.dir || '').toLowerCase() === n)
229
+ || map.parts.find((p) => (p.dir || '').split('/').pop().toLowerCase() === n) || null;
230
+ }
231
+ function view(dir) {
232
+ const map = read(dir);
233
+ if (!map) return null;
234
+ const notes = notesOf(dir);
235
+ return Object.assign({}, map, { parts: map.parts.map((p) => (notes[p.dir] ? Object.assign({}, p, { note: notes[p.dir] }) : p)) });
236
+ }
237
+ function describe(dir, name, text, now = Date.now()) {
238
+ const map = read(dir);
239
+ if (!map) return { ok: false, error: 'there is no code map yet: run pmos code map first' };
240
+ const p = findPart(map, name);
241
+ if (!p) return { ok: false, error: `the map has no part "${name}". Parts: ${map.parts.map((x) => x.name).join(', ')}` };
242
+ fs.mkdirSync(dir, { recursive: true });
243
+ fs.appendFileSync(fileIn(dir, NOTES_FILE), JSON.stringify({ at: new Date(now).toISOString(), part: p.dir, text: oneLine(text) }) + '\n');
244
+ return { ok: true, part: p.name, map: view(dir) };
245
+ }
246
+
247
+ module.exports = { partsOf, summarize, riskOf, build, headOf, read, save, view, describe, findPart, isTest, MAP_FILE, NOTES_FILE, MAX_PARTS, RISKY_FIXES, FIX_DAYS, FIX_SHARE };
@@ -16,6 +16,8 @@
16
16
  {"id": "parked", "audience": "user", "status": "ga", "group": "Catch up", "name": "Parked work", "say": "Each initiative on hold, why it is parked and what brings it back.", "cmd": "/parked", "verb": "parked", "sub": "list", "phrases": ["parked work", "what is on hold", "what is parked", "paused initiatives"], "since": "0.700.0"},
17
17
  {"id": "people", "audience": "user", "status": "ga", "group": "Catch up", "name": "People you work with", "say": "Each person with their role, how often you talk and their tone.", "cmd": "/people", "verb": "people", "sub": "list", "phrases": ["who do I work with", "stakeholders list", "people on this", "who is involved"], "since": "0.610.0"},
18
18
  {"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0"},
19
+ {"id": "code", "audience": "user", "status": "ga", "group": "Your product", "name": "Code map", "say": "One line per main part of the code: what it is, how it is tested, who changed it last.", "cmd": "/code", "verb": "code", "sub": "show", "place": "board", "since": "0.826.0"},
20
+ {"id": "connectors", "audience": "user", "status": "ga", "group": "Your product", "name": "What connectors read and write", "say": "What PMOS reads and writes through each connector, and what leaves this computer.", "cmd": "/connectors", "verb": "connectors", "sub": "data", "since": "0.825.0"},
19
21
  {"id": "positioning", "audience": "user", "status": "ga", "group": "Your product", "name": "Positioning and key messages", "say": "A positioning statement and key messages, each citing a strategy line.", "cmd": "/positioning", "verb": "positioning", "sub": "list", "phrases": ["positioning statement", "key messages", "messaging for"], "since": "0.740.0"},
20
22
  {"id": "principles", "audience": "user", "status": "ga", "group": "Your product", "name": "Product principles", "say": "Four to six principles drafted from your past decisions, each citing them.", "cmd": "/principles", "verb": "principles", "sub": "list", "phrases": ["product principles", "our principles", "design principles for"], "since": "0.720.0"},
21
23
  {"id": "glossary", "audience": "user", "status": "ga", "group": "Your product", "name": "Glossary", "say": "The product's own words; every page shows a word's meaning on hover.", "cmd": "/glossary", "verb": "glossary", "sub": "list", "hint": "<word>", "phrases": ["define the word", "glossary", "add to glossary", "meaning of the word"], "since": "0.690.0"},
@@ -26,6 +28,62 @@
26
28
  {"id": "describe", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Task descriptions", "say": "What, why and done-when for each task, drafted from its sources.", "cmd": "/describe", "verb": "task", "sub": "describe", "hint": "<task>", "place": "board", "phrases": ["describe this task", "task description", "write the description", "what is this task about"], "since": "0.770.0"},
27
29
  {"id": "search", "audience": "user", "status": "ga", "group": "Find your way", "name": "Search and ask", "say": "Ctrl+K finds work, pages and features, and answers questions from your files.", "keys": "Ctrl K", "since": "0.737.0"},
28
30
  {"id": "action-keys", "audience": "user", "status": "ga", "group": "Find your way", "name": "Keys for the five common actions", "say": "Yes, open, next sprint, park and undo, one key each. Press ? to see them.", "keys": "?", "since": "0.730.0"},
29
- {"id": "guide", "audience": "user", "status": "ga", "group": "Find your way", "name": "The Guide", "say": "How each part of PMOS works, page by page.", "action": "guide", "since": "0.500.0"}
31
+ {"id": "guide", "audience": "user", "status": "ga", "group": "Find your way", "name": "The Guide", "say": "How each part of PMOS works, page by page.", "action": "guide", "since": "0.500.0"},
32
+ {"id": "initiative", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Make and order initiatives", "say": "Start an initiative and put it in Now, Next or Later on the roadmap.", "cmd": "/initiative", "verb": "initiative", "hint": "<title>"},
33
+ {"id": "measure", "audience": "user", "status": "ga", "group": "Your product", "name": "Record a measured value", "say": "Write down a KR or health number with where it came from.", "cmd": "/measure", "verb": "measure", "hint": "<kr> <value>"},
34
+ {"id": "today", "audience": "user", "status": "ga", "group": "Catch up", "name": "What needs you today", "say": "The asks that need you, in the order Today shows them.", "cmd": "/today", "verb": "today"},
35
+ {"id": "pick", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Pick one thing for the time you have", "say": "Say how many minutes you have; PMOS picks the one ask that fits and unblocks the most.", "cmd": "/pick", "verb": "pick", "hint": "--minutes <n>"},
36
+ {"id": "board", "audience": "user", "status": "ga", "group": "Catch up", "name": "Every initiative's items", "say": "The items of every initiative by column, or only yours.", "cmd": "/board", "verb": "board"},
37
+ {"id": "report", "audience": "user", "status": "ga", "group": "Your product", "name": "Draft and issue a report", "say": "Draft a cadence report with every number filled in, then issue it.", "cmd": "/report", "verb": "report", "hint": "<cadence>"},
38
+ {"id": "jira", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Jira tickets from the spec", "say": "Draft Jira tickets from the PRD, approve them and see their status.", "cmd": "/jira", "verb": "jira"},
39
+ {"id": "docs", "audience": "user", "status": "ga", "group": "Your product", "name": "Linked documents in step", "say": "Is each linked document the same as, ahead of or behind its Google Docs or Confluence copy.", "cmd": "/docs", "verb": "docs"},
40
+ {"id": "signoff", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Sign-offs", "say": "Ask for, answer and list the sign-offs an initiative waits on.", "cmd": "/signoff", "verb": "signoff", "hint": "<initiative>"},
41
+ {"id": "my-work", "audience": "user", "status": "ga", "group": "Catch up", "name": "Your assigned work", "say": "The Jira tickets and plan items assigned to you, ranked.", "cmd": "/my-work", "verb": "my-work"},
42
+ {"id": "tracker", "audience": "user", "status": "ga", "group": "Catch up", "name": "When the tracker was last read", "say": "When tracker items were last read and how much matches the last Jira read.", "cmd": "/tracker", "verb": "tracker"},
43
+ {"id": "mention", "audience": "user", "status": "ga", "group": "Catch up", "name": "Mentions that wait on you", "say": "What waits on you in your tools, with a reply PMOS drafts for you to send.", "cmd": "/mention", "verb": "mention"},
44
+ {"id": "workflow", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Workflows", "say": "The workflows of this product, a new workflow draft, and moving an initiative to another one.", "cmd": "/workflow", "verb": "workflow"},
45
+ {"id": "blueprint", "audience": "user", "status": "ga", "group": "Your product", "name": "Every feature and its state", "say": "Every feature of the product with a status worked out from its evidence.", "cmd": "/blueprint", "verb": "blueprint"},
46
+ {"id": "program", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Programs", "say": "Make and change programs: charter, milestones, order, capacity and steering.", "cmd": "/program", "verb": "program"},
47
+ {"id": "extension", "audience": "user", "status": "ga", "group": "Find your way", "name": "Google Meet extension", "say": "The folder of the Chrome extension for Google Meet and the three steps to load it.", "cmd": "/extension", "verb": "extension"},
48
+ {"id": "team", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "The role agents", "say": "Who owns what among the role agents, what each works on, and pause or resume them.", "cmd": "/team", "verb": "team"},
49
+ {"id": "improve", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "What PMOS learned", "say": "What the improvement loop found, what it learned and what waits for you.", "cmd": "/improve", "verb": "improve"},
50
+ {"id": "ai", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "AI jobs and their switch", "say": "Each AI job, its off switch and what it did.", "cmd": "/ai", "verb": "ai"},
51
+ {"id": "grill", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Grill settings", "say": "When PMOS grills a spec and what it may spend.", "cmd": "/grill", "verb": "grill"},
52
+ {"id": "design", "audience": "user", "status": "ga", "group": "Your product", "name": "Design drift", "say": "Which pages are built from your design system and which drift from it.", "cmd": "/design", "verb": "design"},
53
+ {"id": "pages", "audience": "user", "status": "ga", "group": "Your product", "name": "Pages that keep breaking", "say": "Each page's fixes, reverts and restores in the last 14 days.", "cmd": "/pages", "verb": "pages"},
54
+ {"id": "away", "audience": "user", "status": "ga", "group": "Catch up", "name": "Away days", "say": "Set your away days, read the handover note and see what moved while you were away.", "cmd": "/away", "verb": "away"},
55
+ {"id": "try", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Try what shipped", "say": "The changes your recent updates brought, how to try each, and your answer.", "cmd": "/try", "verb": "try"},
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
+ {"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
+ {"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"},
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>"},
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"},
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"},
63
+ {"id": "sprint", "audience": "user", "status": "ga", "group": "Catch up", "name": "Sprint retro", "say": "A closed sprint's retro from its close numbers, and its one tracked change.", "cmd": "/sprint", "verb": "sprint"},
64
+ {"id": "quiet", "audience": "user", "status": "ga", "group": "Catch up", "name": "Quiet initiatives", "say": "The weekly sweep of initiatives quiet 30 days or more: keep, park or close each.", "cmd": "/quiet", "verb": "quiet"},
65
+ {"id": "units", "audience": "user", "status": "ga", "group": "Your product", "name": "Programs, products and projects", "say": "Who owns each initiative, and each owner's brief.", "cmd": "/units", "verb": "units"},
66
+ {"id": "owner", "audience": "user", "status": "ga", "group": "Your product", "name": "An owner's brief", "say": "A unit owner's daily brief now.", "cmd": "/owner", "verb": "owner", "hint": "<unit>"},
67
+ {"id": "driver", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "The Initiative Driver", "say": "What the Driver changed with Undo and what waits for you.", "cmd": "/driver", "verb": "driver"},
68
+ {"id": "setup", "audience": "user", "status": "ga", "group": "Find your way", "name": "Set up a new product", "say": "The tracker read, an agreed goal and an owner for a new product.", "cmd": "/setup", "verb": "setup"},
69
+ {"id": "loop", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "A goal agents work on", "say": "Start, check and stop a goal agents work on until it is done.", "cmd": "/loop", "verb": "loop"},
70
+ {"id": "scan", "audience": "user", "status": "ga", "group": "Catch up", "name": "Horizon scan", "say": "The portfolio watch list and what the scan found.", "cmd": "/scan", "verb": "scan"},
71
+ {"id": "artefacts", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The seven artefacts", "say": "Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons of an initiative.", "cmd": "/artefacts", "verb": "artefacts", "hint": "<initiative>"},
72
+ {"id": "forecast", "audience": "user", "status": "ga", "group": "Your product", "name": "Goal forecasts", "say": "A goal forecast's kept baseline, and the forecasts that turned.", "cmd": "/forecast", "verb": "forecast"},
73
+ {"id": "git-identity", "audience": "user", "status": "ga", "group": "Find your way", "name": "Your git identity", "say": "Which git identity and GitHub login this repository uses.", "cmd": "/git-identity", "verb": "git-identity"},
74
+ {"id": "signal", "audience": "user", "status": "ga", "group": "Your product", "name": "Customer signals", "say": "The customer signals behind each roadmap item.", "cmd": "/signal", "verb": "signal", "hint": "<item>"},
75
+ {"id": "launcher", "audience": "user", "status": "ga", "group": "Find your way", "name": "Start without a terminal", "say": "A PMOS app and a login item, so the workspace starts by itself.", "cmd": "/launcher", "verb": "launcher"},
76
+ {"id": "verify-work", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "Mark integrated work", "say": "A build run marks work items integrated from the default branch.", "cmd": "/verify-work", "verb": "verify-work"},
77
+ {"id": "build", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "The Builder", "say": "A declared work item becomes a pull request; the factory's runs use it.", "cmd": "/build", "verb": "build"},
78
+ {"id": "calendar", "audience": "agent", "status": "ga", "group": "Catch up", "name": "Saved calendar events", "say": "An agent session saves the calendar events it read for Briefing.", "cmd": "/calendar", "verb": "calendar"},
79
+ {"id": "source", "audience": "agent", "status": "ga", "group": "Catch up", "name": "Stored tool reads", "say": "An agent session saves its read of a tool for the Briefing.", "cmd": "/source", "verb": "source"},
80
+ {"id": "refresh", "audience": "agent", "status": "ga", "group": "Catch up", "name": "Read only what changed", "say": "An agent session asks a tool what changed since the last read.", "cmd": "/refresh", "verb": "refresh"},
81
+ {"id": "lead", "audience": "agent", "status": "ga", "group": "Catch up", "name": "A popup's lead", "say": "PMOS writes a popup's short lead ahead, from stored reads.", "cmd": "/lead", "verb": "lead"},
82
+ {"id": "propose", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "File a suggestion", "say": "A PMOS run files what it found under an initiative's ✦ for you to keep or drop.", "cmd": "/propose", "verb": "propose"},
83
+ {"id": "lab", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "The idle lab", "say": "What the idle lab's runs read and filed while you were away.", "cmd": "/lab", "verb": "lab"},
84
+ {"id": "metrics", "audience": "agent", "status": "ga", "group": "Your product", "name": "Metric drafts", "say": "A metric-draft run files a metric for you to keep or drop.", "cmd": "/metrics", "verb": "metrics"},
85
+ {"id": "impact", "audience": "agent", "status": "ga", "group": "Your product", "name": "Impact findings", "say": "An impact run files a finding for you to check.", "cmd": "/impact", "verb": "impact"},
86
+ {"id": "coredoc", "audience": "agent", "status": "ga", "group": "Plan and decide", "name": "Core document drafts", "say": "A run writes one draft of a core document; you issue it on the page.", "cmd": "/coredoc", "verb": "coredoc"},
87
+ {"id": "mcp", "audience": "agent", "status": "ga", "group": "Find your way", "name": "PMOS cards for other agents", "say": "PMOS cards for another agent, over MCP.", "cmd": "/mcp-cards", "verb": "mcp"}
30
88
  ]
31
89
  }
@@ -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.
@@ -184,6 +187,9 @@ const VERBS = Object.freeze({
184
187
  // Not a pm-os-absorb verb (run: null): initiative positioning-draft (idea A328) added it through the same table.
185
188
  positioning: Object.freeze({ module: 'positioning-cli.js', run: null, guide: 'cli.md',
186
189
  help: 'pmos positioning strategy|list|keep|drop — the product\'s positioning and key messages, each citing its strategy lines (pmos positioning help)' }),
190
+ // Not a pm-os-absorb verb (run: null): initiative code-map (idea A176) added it through the same table.
191
+ code: Object.freeze({ module: 'code-map-cli.js', run: null, guide: 'cli.md',
192
+ help: 'pmos code show|map|describe|count — the product\'s code map: one line per main part, what it is, how it is tested, who changed it last (pmos code help)' }),
187
193
  // Not a pm-os-absorb verb (run: null): initiative strategy-draft (Wawan 2026-11-24) added it through the same table.
188
194
  strategy: Object.freeze({ module: 'strategy-cli.js', run: null, guide: 'cli.md',
189
195
  help: 'pmos strategy show|sources|draft|set|undo — the product\'s five-line strategy; PMOS drafts blank lines from the product\'s files, each citing them (pmos strategy help)' }),