create-pmos 0.539.0 → 0.541.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 (89) hide show
  1. package/package.json +39 -27
  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/README.md +1 -1
  7. package/workspace/changelog.json +38 -0
  8. package/workspace/fixtures/doc-category-labelled.json +1 -1
  9. package/workspace/guide/agent-capabilities.md +238 -28
  10. package/workspace/guide/breakdown.md +5 -20
  11. package/workspace/guide/claude-proposes.md +269 -37
  12. package/workspace/guide/cli.md +603 -0
  13. package/workspace/guide/home.md +160 -12
  14. package/workspace/guide/index.md +23 -59
  15. package/workspace/guide/initiatives-and-next-steps.md +235 -5
  16. package/workspace/guide/intelligence-okr-goals.md +121 -4
  17. package/workspace/guide/jira.md +2 -15
  18. package/workspace/guide/knowledge-graph.md +143 -18
  19. package/workspace/guide/layout.md +209 -4
  20. package/workspace/guide/notes.md +74 -6
  21. package/workspace/guide/proactive-engine.md +3 -14
  22. package/workspace/guide/programs.md +199 -4
  23. package/workspace/guide/reports.md +405 -41
  24. package/workspace/guide/scheduled-tasks-and-cli.md +6 -28
  25. package/workspace/guide/settings-and-switches.md +396 -0
  26. package/workspace/guide/statuses.md +141 -4
  27. package/workspace/ini-workflow-test.js +1 -1
  28. package/workspace/lib/ai-cli.js +12 -1
  29. package/workspace/lib/headless.js +75 -1
  30. package/workspace/lib/job-graph.js +2 -0
  31. package/workspace/lib/pmos-verbs.js +41 -40
  32. package/workspace/lib/run-tokens.js +70 -0
  33. package/workspace/lib/today-cli.js +57 -4
  34. package/workspace/lib/verify-work-cli.js +1 -1
  35. package/workspace/package-lock.json +2 -2
  36. package/workspace/package.json +1 -1
  37. package/workspace/public/pm/cozy-news.js +1 -1
  38. package/workspace/public/pm/cozy-onboard.js +2 -2
  39. package/workspace/public/pm/cozy-settings.js +42 -11
  40. package/workspace/public/pm/home-app.js +10 -1
  41. package/workspace/public/pm/ini-wf.js +3 -3
  42. package/workspace/public/pm/wf-page.css +26 -15
  43. package/workspace/public/pm/wf-page.js +96 -72
  44. package/workspace/public/premium-workflows.html +8 -23
  45. package/workspace/replaced-tests.json +19 -1
  46. package/workspace/server.js +7 -2
  47. package/workspace/workflows-setup-test.js +50 -50
  48. package/workspace/guide/adler.md +0 -71
  49. package/workspace/guide/agents-act.md +0 -68
  50. package/workspace/guide/ask-the-past.md +0 -46
  51. package/workspace/guide/board.md +0 -58
  52. package/workspace/guide/briefing-premium.md +0 -14
  53. package/workspace/guide/console-calendar.md +0 -24
  54. package/workspace/guide/core-documents.md +0 -58
  55. package/workspace/guide/data-freshness.md +0 -164
  56. package/workspace/guide/descriptions.md +0 -43
  57. package/workspace/guide/docs.md +0 -39
  58. package/workspace/guide/forecast.md +0 -66
  59. package/workspace/guide/horizon-scan.md +0 -82
  60. package/workspace/guide/idle-lab.md +0 -46
  61. package/workspace/guide/initiative-driver.md +0 -102
  62. package/workspace/guide/initiatives-roadmap.md +0 -131
  63. package/workspace/guide/integrated-work.md +0 -93
  64. package/workspace/guide/launcher.md +0 -39
  65. package/workspace/guide/lifecycle.md +0 -64
  66. package/workspace/guide/metric-drafts.md +0 -75
  67. package/workspace/guide/moments.md +0 -43
  68. package/workspace/guide/my-work.md +0 -40
  69. package/workspace/guide/next-prompt.md +0 -64
  70. package/workspace/guide/outcomes.md +0 -39
  71. package/workspace/guide/people.md +0 -48
  72. package/workspace/guide/pm-only-acts.md +0 -88
  73. package/workspace/guide/pm-only-lines.md +0 -61
  74. package/workspace/guide/present-in-a-meeting.md +0 -57
  75. package/workspace/guide/published-board.md +0 -116
  76. package/workspace/guide/ready-made-dashboards.md +0 -62
  77. package/workspace/guide/rehearse.md +0 -52
  78. package/workspace/guide/report-design.md +0 -126
  79. package/workspace/guide/report-slides.md +0 -43
  80. package/workspace/guide/report-structure.md +0 -91
  81. package/workspace/guide/reports-needs-you.md +0 -34
  82. package/workspace/guide/reports-set-up.md +0 -68
  83. package/workspace/guide/settings.md +0 -67
  84. package/workspace/guide/today.md +0 -40
  85. package/workspace/guide/validate-with-typesafe.md +0 -144
  86. package/workspace/guide/welcome.md +0 -90
  87. package/workspace/guide/what-you-missed.md +0 -42
  88. package/workspace/guide/workflows.md +0 -105
  89. package/workspace/guide/your-impact.md +0 -57
@@ -8,6 +8,8 @@
8
8
  * for the skill kind, the folders the run may write in, from skillWriteDirs)
9
9
  * skillWriteDirs(skill, { root, scratch }) → the absolute folders a background skill run may write in: its scratch folder and the state folders its skill writes
10
10
  * parseResult(stdout) → { ok, text, isError, turns, durationMs, costUsd, denied[] }
11
+ * usageOf(stdout) → { tokens, model } | null the token counts of the same result line, for lib/run-tokens.js
12
+ * leanOf(kind, env) · builtinsOf(tools) · userModelOf(env) the lean launch (argsFor lean: true), see LEAN LAUNCH
11
13
  * streamLines(line) → { log: [lines], result: object|null } one stream-json event, for the live log
12
14
  * logLines(result, exitCode) → the lines the read-only log pane shows at the end
13
15
  * outcomeOf(result, { code, signal, timedOut, stopped, timeoutMin }) → { ok, headline, why, turns, durationMs, denied } what the run card says
@@ -364,7 +366,47 @@ function kindFor({ agent, origin, skill, env } = {}) {
364
366
  return null;
365
367
  }
366
368
 
367
- function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [], budgetUsd = null, connectorTools = [], team = null } = {}) {
369
+ /* LEAN LAUNCH (token efficiency build, Wawan 2026-11-08). A plain `claude -p` loads about 63k tokens of fixed context on every turn: every
370
+ * built-in tool, every MCP server's tools, the skills and slash commands, the user and project settings and CLAUDE.md. A background run
371
+ * needs none of that beyond its own tools. Measured in the cloud: 63.0k → 15.7k tokens per turn, a 3-turn task 196k → 45k, same answer.
372
+ * The four flags only pay together: `--tools` alone, with the MCP servers still on, went UP to 66k.
373
+ * --tools <the kind's built-ins> only the built-in tools its --allowedTools names (Bash for `Bash(pmos *)`), never Task, Skill or TodoWrite
374
+ * --disable-slash-commands no skills or commands in the prompt
375
+ * --setting-sources= no user, project or local settings, and no CLAUDE.md (one argv token: an empty "" can be lost on Windows)
376
+ * --strict-mcp-config no MCP server, for every kind that reads no connector
377
+ * Because the PM's user settings no longer load, the server passes the model of those settings explicitly (userModelOf) when no tier chose one.
378
+ * A kind that reads the PM's connectors (CONNECTOR_READ_KINDS) stays on the full launch until a run on the PM's own computer shows its connector
379
+ * tools still load without the settings. PMOS_LEAN_JOBS: off = every kind on the full launch; all = connector kinds lean too, without
380
+ * --strict-mcp-config (for that check); anything else = the default. */
381
+ const LEAN_FLAGS = Object.freeze(['--disable-slash-commands', '--setting-sources=']);
382
+ /** Does this kind launch lean? (PMOS_LEAN_JOBS in env, see above) */
383
+ function leanOf(kind, env) {
384
+ const v = String(((env || {}).PMOS_LEAN_JOBS) || '').trim().toLowerCase();
385
+ if (/^(off|0|false|no)$/.test(v)) return false;
386
+ if (!TOOLS[kind]) return false;
387
+ return v === 'all' || !CONNECTOR_READ_KINDS.includes(kind);
388
+ }
389
+ /** The built-in tool names in an --allowedTools list: `Bash(pmos *)` → Bash, `Write(/x/**)` → Write; connector tools are not built-ins. */
390
+ function builtinsOf(tools) {
391
+ const out = [];
392
+ for (const t of tools || []) {
393
+ const m = /^([A-Z][A-Za-z]+)(?:\(|$)/.exec(String(t || ''));
394
+ if (m && !out.includes(m[1])) out.push(m[1]);
395
+ }
396
+ return out;
397
+ }
398
+ /** The model in the PM's Claude Code user settings (<CLAUDE_CONFIG_DIR or ~/.claude>/settings.json), or null. A lean run loads no settings, so
399
+ * the server passes this one explicitly and the run keeps the model it had. */
400
+ function userModelOf(env) {
401
+ const e = env || process.env;
402
+ const dir = e.CLAUDE_CONFIG_DIR ? String(e.CLAUDE_CONFIG_DIR) : path.join(e.HOME || require('os').homedir(), '.claude');
403
+ try {
404
+ const m = JSON.parse(fs.readFileSync(path.join(dir, 'settings.json'), 'utf8')).model;
405
+ return typeof m === 'string' && /^[\w.\[\]:-]{1,80}$/.test(m.trim()) ? m.trim() : null;
406
+ } catch { return null; }
407
+ }
408
+
409
+ function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [], budgetUsd = null, connectorTools = [], team = null, lean = false } = {}) {
368
410
  if (!TOOLS[kind]) throw new Error('unknown headless kind: ' + kind);
369
411
  let tools = TOOLS[kind].slice();
370
412
  // A role run: the role's own tools. Its writable paths (auto mode only) are each a folder ("/" at the end: it and what is under it) or one file.
@@ -405,6 +447,10 @@ function argsFor(kind, { modelArgs = [], addDirs = [], writePaths = [], budgetUs
405
447
  // report draft stopped after reading ("Plan mode is on, and the draft step writes files") and wrote nothing. dontAsk runs the list above and denies
406
448
  // the rest, which is what this file already promises; it is not a bypass.
407
449
  const argv = ['-p', '--output-format', 'stream-json', '--verbose', '--no-session-persistence', '--permission-mode', 'dontAsk', '--append-system-prompt', DENIED_RULE, ...modelArgs, '--allowedTools', tools.join(',')];
450
+ if (lean) {
451
+ argv.push('--tools', builtinsOf(tools).join(','), ...LEAN_FLAGS);
452
+ if (!CONNECTOR_READ_KINDS.includes(kind)) argv.push('--strict-mcp-config');
453
+ }
408
454
  // A run with a budget (a grill run, lib/grill.js budgetFor) stops at it, so the monthly credit cap holds
409
455
  const b = Number(budgetUsd);
410
456
  if (budgetUsd != null && Number.isFinite(b) && b > 0) argv.push('--max-budget-usd', String(b));
@@ -439,6 +485,32 @@ function jsonOf(line) {
439
485
  try { const o = JSON.parse(t); return o && typeof o === 'object' ? o : null; } catch { return null; }
440
486
  }
441
487
 
488
+ /** The token counts of a result's `usage`: { input, cacheCreate, cacheRead, output }, or null when it has none. Context read per run =
489
+ * input + cacheCreate + cacheRead (summed over every turn by Claude Code). */
490
+ function tokensOf(u) {
491
+ if (!u || typeof u !== 'object') return null;
492
+ const n = (v) => (Number.isFinite(v) && v >= 0 ? v : 0);
493
+ const t = { input: n(u.input_tokens), cacheCreate: n(u.cache_creation_input_tokens), cacheRead: n(u.cache_read_input_tokens), output: n(u.output_tokens) };
494
+ return t.input + t.cacheCreate + t.cacheRead + t.output > 0 ? t : null;
495
+ }
496
+ /** The model that did most of a run's work (`modelUsage`, by output tokens), or null. */
497
+ function modelOf(mu) {
498
+ if (!mu || typeof mu !== 'object') return null;
499
+ let best = null, top = -1;
500
+ for (const [k, v] of Object.entries(mu)) { const out = v && Number.isFinite(v.outputTokens) ? v.outputTokens : 0; if (out > top) { best = k; top = out; } }
501
+ return best;
502
+ }
503
+
504
+ /** The token counts and model of the result on stdout (the same line parseResult reads), or null. */
505
+ function usageOf(stdout) {
506
+ const lines = String(stdout || '').trim().split('\n');
507
+ for (let i = lines.length - 1; i >= 0; i--) {
508
+ const o = jsonOf(lines[i]);
509
+ if (o && (o.type === 'result' || (!o.type && o.usage))) { const tokens = tokensOf(o.usage); return tokens ? { tokens, model: modelOf(o.modelUsage) } : null; }
510
+ }
511
+ return null;
512
+ }
513
+
442
514
  /** The result object on stdout: the whole of it (`--output-format json`), else the last line whose type is `result`
443
515
  * (`stream-json`), else the last line that parses. Anything unreadable is not a result. */
444
516
  function parseResult(stdout) {
@@ -560,3 +632,5 @@ function runEnvOf(extra) {
560
632
  }
561
633
 
562
634
  module.exports = { CONNECTOR_READ_KINDS, CONNECTOR_READ_SEED, DENIED_RULE, HEADLESS_ENV, headlessEnv, connectorReads, initTools, denialGuard, HEADLESS_SKILLS, HEADLESS_ORIGINS, ASK_ORIGINS, DRIVE_ORIGINS, SCAN_WEB_ORIGINS, SCAN_REPO_ORIGINS, SCAN_RESEARCH_WEB_ORIGINS, SCAN_RESEARCH_REPO_ORIGINS, WEB_KINDS, REPORT_SETUP_ORIGINS, REPORT_FIND_ORIGINS, CORE_DOC_ORIGINS, REPORT_DESIGN_ORIGINS, REPORT_SAMPLE_FETCH_ORIGINS, REPORT_STRUCTURE_ORIGINS, REPORT_STRUCTURE_DRY_ORIGINS, METRIC_DRAFT_ORIGINS, IMPACT_ORIGINS, TOOLS, SKILL_WRITE_DIRS, DEFAULT_TIMEOUT_MS, kindFor, argsFor, skillWriteDirs, timeoutMs, parseResult, streamLines, outcomeOf, signedOut, SIGNED_OUT_WHY, logLines, switchedOff, RUN_ENV, runEnvOf };
635
+ // the lean launch and the token counts (token efficiency build, 2026-11-08)
636
+ const LEAN_API = Object.assign(module.exports, { LEAN_FLAGS, leanOf, builtinsOf, userModelOf, tokensOf, modelOf, usageOf });
@@ -38,6 +38,8 @@ const LEDGERS = Object.freeze({
38
38
  r('lib/proposal-runs.js', 'PR.lessonsOf', "the task checks' next run: dropped proposals and the PM's reasons")] },
39
39
  [`<runtime>/${audit}`]: { concept: 'ai-audit', owner: 'lib/ai-guard.js', readers: [
40
40
  r('lib/ai-cli.js', 'AG.readAudit', '`pmos ai log` and `pmos ai status`')] },
41
+ '<runtime>/run-tokens.jsonl': { concept: 'run-tokens', owner: 'lib/run-tokens.js', readers: [
42
+ r('lib/ai-cli.js', 'run-tokens.js', '`pmos ai status`: tokens read per background run, lean and full')] },
41
43
  '<runtime>/bg-queue.jsonl': { concept: 'background-turns', owner: 'lib/bg-queue.js', readers: [
42
44
  r('lib/routes-lab.js', 'bgQueue.record', 'Intelligence › Lab: what Claude did in the background')] },
43
45
  '<runtime>/grill-runs.jsonl': { concept: 'grill-spend', owner: 'lib/grill.js', readers: [
@@ -14,7 +14,8 @@
14
14
  * Exit codes: 0 done, 1 refused, 2 usage.
15
15
  *
16
16
  * guide.test.js G24 reads COMMANDS of every module present and requires each `pmos <verb> <sub>` in the `guide` page
17
- * named here, so a verb cannot ship without its guide text.
17
+ * named here, so a verb cannot ship without its guide text. Every verb names cli.md, the guide's one Command reference
18
+ * (guide-trim): the feature pages say what a feature does, and cli.md says how to drive it from a terminal.
18
19
  *
19
20
  * A listed verb is a verb from now on, built or not: `pmos board` no longer opens a folder named board (R24 says a
20
21
  * path with a verb's name needs `./`). A verb whose module is not on disk yet says which run brings it and exits 2.
@@ -22,115 +23,115 @@
22
23
  const path = require('path');
23
24
 
24
25
  const VERBS = Object.freeze({
25
- initiative: Object.freeze({ module: 'initiative-cli.js', run: 2, guide: 'initiatives-roadmap.md',
26
+ initiative: Object.freeze({ module: 'initiative-cli.js', run: 2, guide: 'cli.md',
26
27
  help: 'pmos initiative new|now|next|later|list|export … — initiatives and their place on the Roadmap (pmos initiative help)' }),
27
- measure: Object.freeze({ module: 'measure-cli.js', run: 2, guide: 'initiatives-roadmap.md',
28
+ measure: Object.freeze({ module: 'measure-cli.js', run: 2, guide: 'cli.md',
28
29
  help: 'pmos measure … — record a measured value of a KR or a health budget, with its source (pmos measure help)' }),
29
- today: Object.freeze({ module: 'today-cli.js', run: 3, guide: 'today.md',
30
+ today: Object.freeze({ module: 'today-cli.js', run: 3, guide: 'cli.md',
30
31
  help: 'pmos today — what needs you, ranked as Today shows it' }),
31
- board: Object.freeze({ module: 'board-cli.js', run: 4, guide: 'board.md',
32
+ board: Object.freeze({ module: 'board-cli.js', run: 4, guide: 'cli.md',
32
33
  help: 'pmos board [--mine] [--init <id>] — the items of every initiative, by column' }),
33
- 'verify-work': Object.freeze({ module: 'verify-work-cli.js', run: 4, guide: 'integrated-work.md',
34
+ 'verify-work': Object.freeze({ module: 'verify-work-cli.js', run: 4, guide: 'cli.md',
34
35
  help: 'pmos verify-work — mark work items integrated from the default branch (local refs only)' }),
35
- report: Object.freeze({ module: 'report-cli.js', run: 5, guide: 'reports.md',
36
+ report: Object.freeze({ module: 'report-cli.js', run: 5, guide: 'cli.md',
36
37
  help: 'pmos report draft|issue|list … — draft and issue reports (pmos report help)' }),
37
38
  // Not a pm-os-absorb verb (run: null): initiative jira-wbs added it through the same table.
38
- jira: Object.freeze({ module: 'jira-cli.js', run: null, guide: 'jira.md',
39
+ jira: Object.freeze({ module: 'jira-cli.js', run: null, guide: 'cli.md',
39
40
  help: 'pmos jira draft|show|epic|approve|pending|record|query|sync|which … — Jira tickets drafted from the PRD, and their status (pmos jira help)' }),
40
41
  // Not a pm-os-absorb verb (run: null): the workspace-launcher initiative added it through the same table.
41
42
  // Not a pm-os-absorb verb (run: null): docs-three-way-sync added it through the same table.
42
- docs: Object.freeze({ module: 'docs-cli.js', run: null, guide: 'docs.md',
43
+ docs: Object.freeze({ module: 'docs-cli.js', run: null, guide: 'cli.md',
43
44
  help: 'pmos docs [list|link|unlink|find] … — is each linked document the same as, ahead of or behind its Google Docs and Confluence copy, and record a sync (pmos docs help)' }),
44
45
  // Not a pm-os-absorb verb (run: null): people-directory added it through the same table.
45
- people: Object.freeze({ module: 'people-cli.js', run: null, guide: 'people.md',
46
+ people: Object.freeze({ module: 'people-cli.js', run: null, guide: 'cli.md',
46
47
  help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
47
48
  // Not a pm-os-absorb verb (run: null): initiative my-work added it through the same table.
48
- 'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'my-work.md',
49
+ 'my-work': Object.freeze({ module: 'my-work-cli.js', run: null, guide: 'cli.md',
49
50
  help: 'pmos my-work list|show|submit … — the Jira tickets and WBS items assigned to you, ranked (pmos my-work help)' }),
50
51
  // Not a pm-os-absorb verb (run: null): workspace-data-freshness added it through the same table.
51
- calendar: Object.freeze({ module: 'calendar-cli.js', run: null, guide: 'data-freshness.md',
52
+ calendar: Object.freeze({ module: 'calendar-cli.js', run: null, guide: 'cli.md',
52
53
  help: 'pmos calendar import|status — the calendar events an agent session read, saved for Briefing and Calendar (pmos calendar help)' }),
53
54
  // Not a pm-os-absorb verb (run: null): tracker-read-freshness added it through the same table.
54
- tracker: Object.freeze({ module: 'tracker-cli.js', run: null, guide: 'data-freshness.md',
55
+ tracker: Object.freeze({ module: 'tracker-cli.js', run: null, guide: 'cli.md',
55
56
  help: 'pmos tracker done|status — record when the tracker-refresh skill finished a read of this repository (pmos tracker help)' }),
56
57
  // Not a pm-os-absorb verb (run: null): briefing-source-flow added it through the same table.
57
- source: Object.freeze({ module: 'source-cli.js', run: null, guide: 'data-freshness.md',
58
+ source: Object.freeze({ module: 'source-cli.js', run: null, guide: 'cli.md',
58
59
  help: 'pmos source save|status|show — the stored read of each tool the Briefing uses: Mail, Slack, Confluence and the rest (pmos source help)' }),
59
60
  // Not a pm-os-absorb verb (run: null): smart refresh (step 2, ask first) added it through the same table.
60
- refresh: Object.freeze({ module: 'refresh-cli.js', run: null, guide: 'data-freshness.md',
61
+ refresh: Object.freeze({ module: 'refresh-cli.js', run: null, guide: 'cli.md',
61
62
  help: 'pmos refresh since|same <source> — ask the tool what changed since the last read first, and keep the stored read when nothing did (pmos refresh help)' }),
62
63
  // Not a pm-os-absorb verb (run: null): ask-the-past added it through the same table.
63
- past: Object.freeze({ module: 'past-cli.js', run: null, guide: 'ask-the-past.md',
64
+ past: Object.freeze({ module: 'past-cli.js', run: null, guide: 'cli.md',
64
65
  help: 'pmos past ask|check|verify|sources … — why did we decide or drop something: the records that say so, each with its line (pmos past help)' }),
65
66
  // Not a pm-os-absorb verb (run: null): Home's Mentions A+ (premium-agreed-design) added it through the same table.
66
- mention: Object.freeze({ module: 'mention-cli.js', run: null, guide: 'home.md',
67
+ mention: Object.freeze({ module: 'mention-cli.js', run: null, guide: 'cli.md',
67
68
  help: 'pmos mention list|draft — Home\'s Mentions: what waits on you, and the proposed reply Claude changes from a chat (pmos mention help)' }),
68
69
  // Not a pm-os-absorb verb (run: null): the popup context work (premium-chat-session slice 7) added it through the same table.
69
- lead: Object.freeze({ module: 'lead-cli.js', run: null, guide: 'briefing-premium.md',
70
+ lead: Object.freeze({ module: 'lead-cli.js', run: null, guide: 'cli.md',
70
71
  help: 'pmos lead put|show|due — Claude\'s short lead for a popup, written ahead from stored reads (pmos lead help)' }),
71
72
  // Not a pm-os-absorb verb (run: null): workflows-per-initiative (D99) added it through the same table.
72
- workflow: Object.freeze({ module: 'workflow-cli.js', run: null, guide: 'workflows.md',
73
+ workflow: Object.freeze({ module: 'workflow-cli.js', run: null, guide: 'cli.md',
73
74
  help: 'pmos workflow list|show|draft|show-draft|judge|of|move|switch … — the workflows of this repository, the New workflow draft, a reading of an Only-when stage, and an initiative\'s workflow stage (pmos workflow help)' }),
74
75
  // Not a pm-os-absorb verb (run: null): feedback batch 4 (Wawan, 2026-10-25) added it through the same table.
75
- task: Object.freeze({ module: 'task-cli.js', run: null, guide: 'workflows.md',
76
+ task: Object.freeze({ module: 'task-cli.js', run: null, guide: 'cli.md',
76
77
  help: 'pmos task add|list|state|set … — an initiative\'s tasks: add one, list them, set their state or group them under a stage when the PM asks (pmos task help)' }),
77
78
  // Not a pm-os-absorb verb (run: null): feedback batch 4 item 6 (Claude suggests program milestones) added it through the same table.
78
- program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'programs.md',
79
+ program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'cli.md',
79
80
  help: 'pmos program suggest — Claude\'s milestone suggestions for a program, filed by its review run (pmos program help)' }),
80
81
  // Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
81
- extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'console-calendar.md',
82
+ extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'cli.md',
82
83
  help: 'pmos extension — the folder of the Chrome extension for Google Meet, and the three steps to load it' }),
83
84
  // Not a pm-os-absorb verb (run: null): initiative initiative-driver added it through the same table.
84
85
  // Not a pm-os-absorb verb (run: null): feedback batch 12 items 2, 3 and 4 (Claude proposes, the one ✦) added it through the same table.
85
- propose: Object.freeze({ module: 'propose-cli.js', run: null, guide: 'claude-proposes.md',
86
+ propose: Object.freeze({ module: 'propose-cli.js', run: null, guide: 'cli.md',
86
87
  help: 'pmos propose look|found|date|done|name|status … — what Claude\'s run files under an initiative\'s ✦ for the PM to keep or drop (pmos propose help)' }),
87
88
  // Not a pm-os-absorb verb (run: null): the AI-ideas round (2026-11-03) added it through the same table: the kill switch and audit of lib/ai-guard.js.
88
89
  // Not a pm-os-absorb verb (run: null): the role-agent team (brief agent-team, 2026-11-08) added it through the same table.
89
- team: Object.freeze({ module: 'team-cli.js', run: null, guide: 'agent-capabilities.md',
90
+ team: Object.freeze({ module: 'team-cli.js', run: null, guide: 'cli.md',
90
91
  help: 'pmos team roles|dispatch|status|pause|resume — the role agents under the chief of staff: who owns what, who works on what (pmos team help)' }),
91
- ai: Object.freeze({ module: 'ai-cli.js', run: null, guide: 'claude-proposes.md',
92
+ ai: Object.freeze({ module: 'ai-cli.js', run: null, guide: 'cli.md',
92
93
  help: 'pmos ai status|off|on|log … — the AI jobs: their kill switch, replay state and audit (pmos ai help)' }),
93
94
  // Not a pm-os-absorb verb (run: null): the AI-ideas round (2026-11-03, feature 5, plan-rehearsal) added it through the same table.
94
- rehearse: Object.freeze({ module: 'rehearse-cli.js', run: null, guide: 'rehearse.md',
95
+ rehearse: Object.freeze({ module: 'rehearse-cli.js', run: null, guide: 'cli.md',
95
96
  help: 'pmos rehearse move|end|cut|log … — what a change would break or help in other initiatives, goals and dates, before the PM approves it (pmos rehearse help)' }),
96
97
  // Not a pm-os-absorb verb (run: null): Grill and Forecast part G-A (Claude grills an initiative by itself) added it through the same table.
97
- grill: Object.freeze({ module: 'grill-cli.js', run: null, guide: 'claude-proposes.md',
98
+ grill: Object.freeze({ module: 'grill-cli.js', run: null, guide: 'cli.md',
98
99
  help: 'pmos grill find|voices|status|mode|cap|spend … — what Claude\'s grill run files under an initiative\'s ✦, and when it grills and what it may spend (pmos grill help)' }),
99
100
  // Not a pm-os-absorb verb (run: null): the idle lab engine (idle-lab build E, 2026-11-04) added it through the same table.
100
- lab: Object.freeze({ module: 'lab-cli.js', run: null, guide: 'agent-capabilities.md',
101
+ lab: Object.freeze({ module: 'lab-cli.js', run: null, guide: 'cli.md',
101
102
  help: 'pmos lab page|file|status … — the idle lab: what its runs read and file while you are away, and this month\'s runs (pmos lab help)' }),
102
103
  // Not a pm-os-absorb verb (run: null): batch 15 item 1 (Claude drafts metrics without being asked) added it through the same table.
103
- metrics: Object.freeze({ module: 'metrics-cli.js', run: null, guide: 'metric-drafts.md',
104
+ metrics: Object.freeze({ module: 'metrics-cli.js', run: null, guide: 'cli.md',
104
105
  help: 'pmos metrics draft read|step|row|fix|end|status … — what Claude\'s metric-draft run files for the PM to keep or drop; pmos metrics reading … — what Claude\'s reading run reads (pmos metrics help)' }),
105
106
  // Not a pm-os-absorb verb (run: null): batch 16 item 7 (Your impact) added it through the same table.
106
- impact: Object.freeze({ module: 'impact-cli.js', run: null, guide: 'your-impact.md',
107
+ impact: Object.freeze({ module: 'impact-cli.js', run: null, guide: 'cli.md',
107
108
  help: 'pmos impact add|end|status … — what Claude\'s impact run files for you to check, ✓ real or ✕ not real (pmos impact help)' }),
108
109
  // Not a pm-os-absorb verb (run: null): initiative weekly-drift-check added it through the same table.
109
- drift: Object.freeze({ module: 'drift-cli.js', run: null, guide: 'what-you-missed.md',
110
+ drift: Object.freeze({ module: 'drift-cli.js', run: null, guide: 'cli.md',
110
111
  help: 'pmos drift show|replay|status — the weekly check for quiet drift: what it would show, its replay on your real records, and its last result (pmos drift help)' }),
111
112
  // Not a pm-os-absorb verb (run: null): initiative outcome-for-every-initiative added it through the same table.
112
- outcomes: Object.freeze({ module: 'outcomes-cli.js', run: null, guide: 'outcomes.md',
113
+ outcomes: Object.freeze({ module: 'outcomes-cli.js', run: null, guide: 'cli.md',
113
114
  help: 'pmos outcomes list|propose|declare|record — every initiative\'s expected outcome and check date: Claude\'s cited drafts, the PM\'s yes, and the verdict when a check is due (pmos outcomes help)' }),
114
- driver: Object.freeze({ module: 'driver-cli.js', run: null, guide: 'initiative-driver.md',
115
+ driver: Object.freeze({ module: 'driver-cli.js', run: null, guide: 'cli.md',
115
116
  help: 'pmos driver propose|status|keep|return|drop|undo|pause|resume|mode … — the Initiative Driver: class A and B changes apply with Undo, the rest wait for you (pmos driver help)' }),
116
117
  // D106 (Full autonomy now): what agents do by themselves, and the goals they work on until done
117
- autonomy: Object.freeze({ module: 'autonomy-cli.js', run: null, guide: 'agents-act.md',
118
+ autonomy: Object.freeze({ module: 'autonomy-cli.js', run: null, guide: 'cli.md',
118
119
  help: 'pmos autonomy status|restore — what agents applied by themselves (with Undo) and the jobs back to propose (pmos autonomy help)' }),
119
- loop: Object.freeze({ module: 'loop-cli.js', run: null, guide: 'agents-act.md',
120
+ loop: Object.freeze({ module: 'loop-cli.js', run: null, guide: 'cli.md',
120
121
  help: 'pmos loop start|status|checkpoint|resume|stop — a goal agents work on until it is done (pmos loop help)' }),
121
122
  // Not a pm-os-absorb verb (run: null): initiative horizon-scan added it through the same table; horizon-scan-portfolio added section, propose, setting and --boards.
122
- scan: Object.freeze({ module: 'scan-cli.js', run: null, guide: 'horizon-scan.md',
123
+ scan: Object.freeze({ module: 'scan-cli.js', run: null, guide: 'cli.md',
123
124
  help: 'pmos scan file|section|propose|list [--sections]|match|suggest [--boards]|status|setting|cadence|watch [--boards] … — the Horizon scan: the portfolio watch list, the findings, the report sections and the proposals the PM approves, changes or dismisses (pmos scan help)' }),
124
125
  // Not a pm-os-absorb verb (run: null): initiative core-documents added it through the same table.
125
- coredoc: Object.freeze({ module: 'coredoc-cli.js', run: null, guide: 'core-documents.md',
126
+ coredoc: Object.freeze({ module: 'coredoc-cli.js', run: null, guide: 'cli.md',
126
127
  help: 'pmos coredoc write --scope <scope> --key <key> --file <path|-> — write one draft of a core document; the PM issues it on the page (pmos coredoc help)' }),
127
128
  // Not a pm-os-absorb verb (run: null): the Grill and Forecast build (F-A) added it through the same table.
128
- forecast: Object.freeze({ module: 'forecast-cli.js', run: null, guide: 'forecast.md',
129
+ forecast: Object.freeze({ module: 'forecast-cli.js', run: null, guide: 'cli.md',
129
130
  help: 'pmos forecast baseline|baseline-off|turned … — a goal forecast\'s kept baseline, and the forecasts that turned (pmos forecast help)' }),
130
131
  // Not a pm-os-absorb verb (run: null): feedback batch 25 item 1 added it through the same table.
131
- 'git-identity': Object.freeze({ module: 'git-identity-cli.js', run: null, guide: 'launcher.md',
132
+ 'git-identity': Object.freeze({ module: 'git-identity-cli.js', run: null, guide: 'cli.md',
132
133
  help: 'pmos git-identity [set --name <n> --email <e> --login <gh>] — which git identity and GitHub login this repository uses; save your choice for it' }),
133
- launcher: Object.freeze({ module: 'launcher-cli.js', run: null, guide: 'launcher.md',
134
+ launcher: Object.freeze({ module: 'launcher-cli.js', run: null, guide: 'cli.md',
134
135
  help: 'pmos launcher on|off|status — a PMOS app and a login item, so the workspace starts without a terminal' }),
135
136
  });
136
137
 
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+ /* run-tokens.js — the token log of background runs (token efficiency build, Wawan 2026-11-08).
3
+ *
4
+ * PMOS did not keep what a background run cost: lib/headless.js parseResult read the cost and dropped the token counts. Each finished
5
+ * headless run now writes one line to <state>/run-tokens.jsonl:
6
+ * { at, kind, origin, model, lean, turns, input, cacheCreate, cacheRead, output, costUsd, ok }
7
+ * origin is the part of the session origin before its first ':' (`propose`, `grill`, `schedule`), never an id or a prompt. No line holds
8
+ * a prompt, an answer or a key.
9
+ *
10
+ * record(stateDir, { kind, origin, lean, result, ok }) → the line written, or null (no tokens in the result: nothing is written)
11
+ * read(stateDir, { sinceMs?, limit? }) → [line]
12
+ * summary(stateDir, { now?, days? }) → { days, runs, rows: [{ kind, lean, runs, turns, context, output, costUsd, perRun }] }
13
+ * context = input + cacheCreate + cacheRead, the tokens the runs read; perRun = context / runs, rounded. One row per kind and launch
14
+ * (lean or full), so the before and after of the lean launch sit side by side. `pmos ai status` shows it.
15
+ *
16
+ * The log never stops a run: a failed append is lost, never thrown. */
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+
20
+ const FILE = 'run-tokens.jsonl';
21
+ const DAY = 86400000;
22
+ const num = (v) => (Number.isFinite(v) && v >= 0 ? v : 0);
23
+
24
+ function record(stateDir, { kind, origin, lean = false, result, ok = null } = {}) {
25
+ const t = result && result.tokens;
26
+ if (!stateDir || !t) return null;
27
+ const line = {
28
+ at: new Date().toISOString(),
29
+ kind: String(kind || ''),
30
+ origin: String(origin || '').split(':')[0].slice(0, 40) || null,
31
+ model: result.model || null,
32
+ lean: !!lean,
33
+ turns: Number.isFinite(result.turns) ? result.turns : null,
34
+ input: num(t.input), cacheCreate: num(t.cacheCreate), cacheRead: num(t.cacheRead), output: num(t.output),
35
+ costUsd: Number.isFinite(result.costUsd) ? Math.round(result.costUsd * 10000) / 10000 : null,
36
+ ok: ok == null ? null : !!ok,
37
+ };
38
+ try {
39
+ fs.mkdirSync(stateDir, { recursive: true });
40
+ fs.appendFileSync(path.join(stateDir, FILE), JSON.stringify(line) + '\n', { mode: 0o600 });
41
+ } catch { return null; }
42
+ return line;
43
+ }
44
+
45
+ function read(stateDir, { sinceMs = 0, limit = 5000 } = {}) {
46
+ let text = '';
47
+ try { text = fs.readFileSync(path.join(stateDir, FILE), 'utf8'); } catch { return []; }
48
+ const out = [];
49
+ for (const s of text.split('\n')) {
50
+ if (!s.trim()) continue;
51
+ try { const o = JSON.parse(s); if (o && (!sinceMs || Date.parse(o.at) >= sinceMs)) out.push(o); } catch { /* a torn line */ }
52
+ }
53
+ return out.slice(-limit);
54
+ }
55
+
56
+ function summary(stateDir, { now = Date.now(), days = 7 } = {}) {
57
+ const lines = read(stateDir, { sinceMs: now - days * DAY });
58
+ const by = new Map();
59
+ for (const l of lines) {
60
+ const k = `${l.kind}\u0000${l.lean ? 1 : 0}`;
61
+ const r = by.get(k) || { kind: l.kind, lean: !!l.lean, runs: 0, turns: 0, context: 0, output: 0, costUsd: 0 };
62
+ r.runs++; r.turns += num(l.turns); r.context += num(l.input) + num(l.cacheCreate) + num(l.cacheRead); r.output += num(l.output); r.costUsd += num(l.costUsd);
63
+ by.set(k, r);
64
+ }
65
+ const rows = [...by.values()].map((r) => ({ ...r, costUsd: Math.round(r.costUsd * 100) / 100, perRun: Math.round(r.context / r.runs) }))
66
+ .sort((a, b) => b.context - a.context || a.kind.localeCompare(b.kind) || Number(a.lean) - Number(b.lean));
67
+ return { days, runs: lines.length, rows };
68
+ }
69
+
70
+ module.exports = { FILE, record, read, summary };
@@ -19,9 +19,12 @@ const COMMANDS = { today: [] };
19
19
  const USAGE = [
20
20
  'usage: pmos today [--ws <id>] [--json]',
21
21
  ' pmos today --root <dir> [--json] [--wait]',
22
- 'Prints what needs you, ranked as Today shows it: the kind first (1 a gate is owed, 2 a session is waiting, 3 a step was',
23
- 'returned to you, 4 work to check, 5 a breakdown to keep, 6 a capture, 7 a cycle review, 8 needs repair), then the card.',
24
- 'With a workspace server running it asks the server. Without one it reads the repository and does not read sessions.',
22
+ 'With a workspace server running, prints Your move: the list Home shows, in the same order (public/pm/move-rank.js rankMove):',
23
+ 'an overdue outcome verdict, a grill finding on shipped work, a meeting change, a finding on work ahead, a key result with no',
24
+ 'reading, then the rest Claude proposes, one row per initiative. Rows older than 14 days fold under "Older".',
25
+ 'Without a server it reads the repository and prints the Today cards, ranked by kind (1 a gate is owed, 2 a session is',
26
+ 'waiting, 3 a step was returned to you, 4 work to check, 5 a breakdown to keep, 6 a capture, 7 a cycle review, 8 needs',
27
+ 'repair). It does not read sessions then.',
25
28
  'Without a server the Cycle review and missing-anchor cards need the initiative records read, which takes time: they show',
26
29
  'as pending. Add --wait to read them now (about a quarter of a second per record).',
27
30
  ];
@@ -35,6 +38,46 @@ function repoRoot(cwd) {
35
38
  catch { return cwd; }
36
39
  }
37
40
 
41
+ /* YOUR MOVE (UI grill item 9, "one truth for what needs me"): with a server, `pmos today` ranks with the function Home's Your move uses,
42
+ * on the answers Home reads: the board with its ✦ (GET /api/board-premium), the programs (GET /api/programs) and the product's GET
43
+ * /api/your-move. The board derives in the background (202 "reading"): it asks again for up to WAIT_MS, then falls back to the cards. */
44
+ const WAIT_MS = 8000;
45
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
46
+ async function moveOf(call, ws, { wait = WAIT_MS } = {}) {
47
+ const q = '?ws=' + encodeURIComponent(ws);
48
+ let b = null;
49
+ for (const t0 = Date.now(); ;) {
50
+ b = await call('GET', '/api/board-premium' + q);
51
+ if (!b || b.ok === false || b.state !== 'reading' || Date.now() - t0 >= wait) break;
52
+ await sleep(500);
53
+ }
54
+ if (!b || !b.ok || !b.model) return null;
55
+ const M = b.model, I = M.initiatives || {};
56
+ const rows = (I.list && I.list.rows) || M.rows || [];
57
+ const pg = await call('GET', '/api/programs');
58
+ const ym = await call('GET', '/api/your-move' + q);
59
+ const MR = await import(require('url').pathToFileURL(path.join(__dirname, '..', 'public', 'pm', 'move-rank.js')).href);
60
+ const r = MR.rankMove({
61
+ products: [{ ws, name: M.name || '', board: (M.board && M.board.id) || '', rows }],
62
+ programs: (pg && pg.ok && pg.programs) || [],
63
+ move: ym && ym.ok ? { [ws]: { verdicts: ym.verdicts || [], kr: ym.kr || null } } : {},
64
+ calls: [], now: Date.now(),
65
+ });
66
+ const slim = (x) => ({ key: x.key, rank: x.rank, kind: x.kind, title: x.title, sub: x.sub || '', tag: x.tag || '', age: x.age || '', ini: x.ini || null, yes: x.yes || '', alt: x.alt || '' });
67
+ return { ok: true, ws, source: 'your-move', count: r.rows.length, rows: r.rows.map(slim), older: r.older.map(slim) };
68
+ }
69
+
70
+ function printMove(say, mv, cards) {
71
+ const waiting = ((cards && cards.cards) || []).filter((c) => c.kind === 2);
72
+ const n = mv.count + waiting.length;
73
+ say(`${n} ${n === 1 ? 'needs' : 'need'} you`);
74
+ for (const r of mv.rows) say(`· ${r.title}${r.sub ? ' — ' + r.sub : ''}${r.age ? ' · ' + r.age : ''}${r.ini ? ' · ' + r.ini : ''}`);
75
+ for (const c of waiting) say(`· ${c.cause}${c.initiative_id ? ' · ' + c.initiative_id : ''}`);
76
+ if (mv.older.length) say(`Older: ${mv.older.length} more, filed more than 14 days ago.`);
77
+ for (const bn of (cards && cards.banner) || []) say(`! ${bn.source}: ${bn.error}`);
78
+ if (!n) say(mv.older.length ? 'Nothing new needs you.' : 'Nothing needs you.');
79
+ }
80
+
38
81
  function print(say, out, { sessions }) {
39
82
  say(`${out.count} ${out.count === 1 ? 'needs' : 'need'} you`);
40
83
  for (const c of out.cards) {
@@ -91,9 +134,19 @@ async function run(argv, { say, call }) {
91
134
  } finally { rowsLib.setBackground(was); }
92
135
  }
93
136
  if (!out.ok) { say('✗ ' + out.error); return 1; }
137
+ if (sessions) {
138
+ let mv = null;
139
+ try { mv = await moveOf(call, out.ws); } catch { mv = null; }
140
+ if (mv) {
141
+ const waiting = (out.cards || []).filter((c) => c.kind === 2);
142
+ if (f.json) say(JSON.stringify({ ...mv, sessions: waiting, banner: out.banner || [] }));
143
+ else printMove(say, mv, out);
144
+ return 0;
145
+ }
146
+ }
94
147
  if (f.json) say(JSON.stringify(out));
95
148
  else print(say, out, { sessions });
96
149
  return 0;
97
150
  }
98
151
 
99
- module.exports = { run, COMMANDS, USAGE };
152
+ module.exports = { run, COMMANDS, USAGE, moveOf };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /* verify-work-cli.js — `pmos verify-work`: mark work items integrated from the default branch (pm-os-absorb Run 4,
3
- * PRD R7 and R24, map-spec X26, D70). Guide page: guide/integrated-work.md.
3
+ * PRD R7 and R24, map-spec X26, D70). Guide page: guide/cli.md.
4
4
  *
5
5
  * pmos verify-work [--branch <ref>] [--dry-run] [--json] [--root <dir>]
6
6
  *
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.539.0",
3
+ "version": "0.541.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.539.0",
9
+ "version": "0.541.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.539.0",
3
+ "version": "0.541.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",
@@ -251,7 +251,7 @@ function openBridge(it, o = {}) {
251
251
  return true;
252
252
  };
253
253
  vwOpen({ id, kind: 'Claude proposes', title: it.title || 'Move to the new workflow', icon: SPARK, sub: ['Claude noticed', it.at ? ago(new Date(it.at).toISOString()) : ''].filter(Boolean).join(' · '), fresh: !!o.fresh,
254
- more: [{ label: 'Change the bridge in Settings', on: () => location.assign('/premium-workflows.html?wf=' + encodeURIComponent(it.wf.id) + (wsParam() ? '&ws=' + encodeURIComponent(wsParam()) : '')) }],
254
+ more: [{ label: 'Change the bridge in Settings', on: () => import('./cozy-settings.js').then((M) => M.openSettings('workflows', { wf: it.wf.id })) }], // Settings › Workspaces › Workflows, in place (UI grill U1)
255
255
  render: (body) => {
256
256
  body.classList.add('ev-card-b');
257
257
  draw(body);
@@ -274,9 +274,9 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
274
274
  } else if (a.startsWith('f:')) {
275
275
  const r = await post('fundamental', { key: a.slice(2) });
276
276
  if (!r.ok) S.note = r.error;
277
- else if (r.follow === 'settings') location.assign('/premium-workflows.html?ws=' + encodeURIComponent(p.done.ws));
277
+ else if (r.follow === 'settings') location.assign('/premium.html?settings=workflows&ws=' + encodeURIComponent(p.done.ws)); // Settings › Workspaces › Workflows (UI grill U1)
278
278
  else if (r.follow === 'context') { home('Walk me through the project context you saved, and change what I say'); return; }
279
- } else if (a === 'wf-new') { location.assign('/premium-workflows.html?new=1&ws=' + encodeURIComponent(p.done.ws)); return; }
279
+ } else if (a === 'wf-new') { location.assign('/premium.html?settings=workflows&new=1&ws=' + encodeURIComponent(p.done.ws)); return; } // Home's chat on New workflow
280
280
  else if (a === 'first-yes') { go('&first=draft'); return; }
281
281
  else if (a === 'first-no') { go('&first=none'); return; } // B2: the reveal with no draft, and nothing written
282
282
  } catch (e) { S.note = e.message || 'That did not finish. Try again.'; }