create-pmos 0.814.0 → 0.816.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.814.0",
3
+ "version": "0.816.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,44 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.816.0",
38
+ "at": "2026-11-25T07:54:58.764Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1874,
43
+ "t": "File a typed Today line to its initiative (job #1870)",
44
+ "s": "File a typed Today line to its initiative (job #1870)",
45
+ "k": "new",
46
+ "h": "File a typed Today line to its initiative (job #1870)",
47
+ "try": {
48
+ "steps": [
49
+ "Open Today",
50
+ "In the capture line type 'Draft checkout redesign copy', with words from one of your initiatives, and press Enter",
51
+ "Press the arrow beside the new chip and pick Not filed"
52
+ ],
53
+ "see": "The line shows a chip with the initiative and its stage, and a toast says where it was filed with Undo. A typed task also appears as a task on that initiative in Work. Picking Not filed removes the…",
54
+ "open": "/today.html"
55
+ },
56
+ "i": "capture-to-initiative"
57
+ },
58
+ {
59
+ "n": 1856,
60
+ "t": "Away days, a handover note drafted in the Library, and what moved while you were away (job #1841, A152)",
61
+ "s": "Away days, a handover note drafted in the Library, and what moved while you were away (job #1841, A152)",
62
+ "k": "new",
63
+ "i": "away-handover"
64
+ },
65
+ {
66
+ "n": 1865,
67
+ "t": "Unblock CI on main — answer cache watches folders one by one on Linux; pmos commands wait for a busy server",
68
+ "s": "Unblock CI on main — answer cache watches folders one by one on Linux; pmos commands wait for a busy server",
69
+ "k": "fix",
70
+ "i": "ci-main-unblock"
71
+ }
72
+ ]
73
+ },
36
74
  {
37
75
  "v": "0.814.0",
38
76
  "at": "2026-11-25T07:02:21.301Z",
@@ -372,19 +410,6 @@
372
410
  "k": "new"
373
411
  }
374
412
  ]
375
- },
376
- {
377
- "v": "0.790.0",
378
- "at": "2026-11-24T18:34:00.454Z",
379
- "f": 4,
380
- "prs": [
381
- {
382
- "n": 1797,
383
- "t": "Copies, shared links and the notepad read in the Reading layout; Work and Library on pm-layout-open (A334)",
384
- "s": "Copies, shared links and the notepad read in the Reading layout; Work and Library on pm-layout-open (A334)",
385
- "k": "new"
386
- }
387
- ]
388
413
  }
389
414
  ]
390
415
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@51dedb0aa
1
+ kernel-source: pmos@429d3abde
2
2
  assembled: 2026-11-25
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-25T07:02:18Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T07:54:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-25T07:02:18Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T07:54:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-25T07:02:18Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T07:54:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -82,11 +82,15 @@ function probe(port, ms = PROBE_MS) {
82
82
  req.on('timeout', () => { req.destroy(); res(null); });
83
83
  });
84
84
  }
85
+ // How long a `pmos` command waits for the workspace server to answer. A server that is not running refuses at once, so this only
86
+ // matters when it is busy: while several agent sessions start in tmux at once, a request on a 2-CPU machine took over 5 s, and the
87
+ // old 5 s limit made `pmos proactive day show` say the server was not running (day-run D8b, 2026-11-25).
88
+ const API_TIMEOUT_MS = 30000;
85
89
  function api(port, method, pathname, body, extraHeaders) {
86
90
  return new Promise((res) => {
87
91
  const data = body ? JSON.stringify(body) : null;
88
92
  const req = http.request(`${urlOf(port)}${pathname}`, {
89
- method, timeout: 5000,
93
+ method, timeout: API_TIMEOUT_MS,
90
94
  headers: { ...(data ? { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) } : {}), ...(extraHeaders || {}) },
91
95
  }, (r) => { let b = ''; r.on('data', (c) => (b += c)); r.on('end', () => { try { res(JSON.parse(b)); } catch { res(null); } }); });
92
96
  req.on('error', () => res(null));
@@ -1,4 +1,42 @@
1
1
  [
2
+ {
3
+ "v": "0.816.0",
4
+ "at": "2026-11-25T07:54:58.764Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1874,
9
+ "t": "File a typed Today line to its initiative (job #1870)",
10
+ "s": "File a typed Today line to its initiative (job #1870)",
11
+ "k": "new",
12
+ "h": "File a typed Today line to its initiative (job #1870)",
13
+ "try": {
14
+ "steps": [
15
+ "Open Today",
16
+ "In the capture line type 'Draft checkout redesign copy', with words from one of your initiatives, and press Enter",
17
+ "Press the arrow beside the new chip and pick Not filed"
18
+ ],
19
+ "see": "The line shows a chip with the initiative and its stage, and a toast says where it was filed with Undo. A typed task also appears as a task on that initiative in Work. Picking Not filed removes the…",
20
+ "open": "/today.html"
21
+ },
22
+ "i": "capture-to-initiative"
23
+ },
24
+ {
25
+ "n": 1856,
26
+ "t": "Away days, a handover note drafted in the Library, and what moved while you were away (job #1841, A152)",
27
+ "s": "Away days, a handover note drafted in the Library, and what moved while you were away (job #1841, A152)",
28
+ "k": "new",
29
+ "i": "away-handover"
30
+ },
31
+ {
32
+ "n": 1865,
33
+ "t": "Unblock CI on main — answer cache watches folders one by one on Linux; pmos commands wait for a busy server",
34
+ "s": "Unblock CI on main — answer cache watches folders one by one on Linux; pmos commands wait for a busy server",
35
+ "k": "fix",
36
+ "i": "ci-main-unblock"
37
+ }
38
+ ]
39
+ },
2
40
  {
3
41
  "v": "0.814.0",
4
42
  "at": "2026-11-25T07:02:21.301Z",
@@ -288,6 +288,14 @@ The idle lab run uses only the first three commands:
288
288
  - `pmos lab critic checks [--root <dir>]`: the checks the critic uses for the product in that folder. No server is needed.
289
289
  - `pmos lab critic label <run> <n> real|noise`: your word on finding `n` of a critic run. `pmos lab critic stats` counts the runs, the findings, and how many you called real or noise.
290
290
 
291
+ ### pmos away: away days and the handover note
292
+
293
+ - `pmos away set <YYYY-MM-DD> [--cover "<name>"]` sets you as away from today until that day. PMOS drafts a handover note as `planning/handovers/away-<from>.md` (kind Handover). The Library lists it once you commit it. PMOS runs no git command for it. The note has who covers, the open asks, and the dates that fall while you are away. It is a draft: read it, change it and share it yourself. PMOS sends nothing.
294
+ - `pmos away note` drafts the note again when there is none. A note you edited is kept as it is.
295
+ - `pmos away` (or `pmos away status`) says whether you are set as away, until when and who covers.
296
+ - `pmos away back` ends the away days and lists what moved while you were away: each date and scope change of those days, with its source or the person to ask. `pmos away while` lists it again.
297
+ - Ask for any of these in the chat, and PMOS runs them.
298
+
291
299
  ### pmos try: try what your updates brought
292
300
 
293
301
  On a computer that follows the beta line, each update brings a short list of changes to try. Today shows one row for it, and Settings › Updates shows the list.
@@ -52,6 +52,7 @@ Today, Work, Insights and the Viewer use one typeface, Plus Jakarta Sans, with t
52
52
  - **The dashed line.** Your move ends with one dashed line, for example "9 more move in the line by themselves · none stuck" (or "· 1 stuck"). It counts the live initiatives of your products that do not wait on you. Press it to open the Line on Work. With nothing on the line there is no dashed line.
53
53
  - **The weekly digest.** On a Monday the Overview sentence ends with "Last week's digest is ready to read." Press it to read last week in the Viewer: one sentence on the line, What moved (each initiative that reached a new station, and what put it there), What PMOS did by itself (with what you undid and what the Checker sampled), Not sent (drafts that lapsed after 7 days) and Next week (initiatives that reach their station's limit). A section with nothing is left out. The digest is only to read: anything that needs you is already in Your move. The switch in its header, or **Weekly digest** in Settings › General, turns it off; off means PMOS does not make it.
54
54
  - **Where your week went.** From Friday to Sunday, Your move shows one quiet row, for example "Where your week went: 9 h in 12 meetings, 3 decisions". Open it to see your week by kind, most first: meetings and their hours (from your calendar), decisions, reviews of what PMOS proposed, notes you typed and tasks you moved to Done. One line says what moved: the tasks done, the initiative with the most of them, and the dates or scope changes. It reads only what PMOS already holds. It calls no model, sends nothing and writes nothing. A week with nothing in it gives no row, and the row is gone once you open it that week.
55
+ - **A line filed to its initiative.** When a line you type on Today clearly names one open initiative (it shares at least 2 words with its title, and no other initiative shares as many), PMOS files it there. The line shows a chip with the initiative and its stage, for example "↳ Checkout redesign · Discovery", and a toast says where it went, with Undo. A task line also becomes a task on that initiative in Work, in the stage in progress. A note or an event keeps only the chip. Press the arrow beside the chip to file it to another initiative or to Not filed; the task follows. A line that is not clear is not filed. It calls no model and sends nothing.
55
56
  - **When a product drifts from Jira.** When fewer than 95% of a product's tasks that name a Jira ticket match the last Jira read, the Overview says so in one ✦ row: "idpf differs from Jira on 7 of 128 tasks (94%). Take Jira's value on all 7". What differs is a value someone set by hand in PMOS: an owner, a done day or a state. Press ✓ to make PMOS say what Jira says for all of them, or press the arrow to see each difference and ✓ only the ones you want. The message that shows has Undo, which puts back what PMOS said. Press ✕ to keep what PMOS says; the row comes back only when the number changes. A product at 95% or more shows no row. PMOS changes nothing in Jira.
56
57
  - **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
57
58
  - **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
@@ -90,21 +90,32 @@ function idle() { lastReq = Date.now(); }
90
90
  * the server. The folders the records live in are watched: planning/ and pmos/ of each workspace, each with every folder under it, and
91
91
  * the workspace folder itself (so a planning/ or pmos/ made later is watched from then on). .git and node_modules are never watched. */
92
92
  const SKIP = /(^|[\\/])(\.git|node_modules)([\\/]|$)/;
93
+ // Linux has no native recursive watch: Node 20 emulates `recursive: true` in JavaScript by watching every FILE under the folder, which
94
+ // on a checkout with thousands of records took hundreds of MB and ran CI's 2-CPU runners out of memory (kind-workflows.test.js died in
95
+ // V8's RegExpCompiler, day-run's server reset its connections, Home's chat box never showed: ci-dynamic-shards, 2026-11-25). There each
96
+ // folder is watched on its own, without `recursive`, and a folder made later is watched when it appears. macOS and Windows watch natively.
97
+ const NATIVE_RECURSIVE = process.platform === 'darwin' || process.platform === 'win32';
93
98
  const watched = new Map(); // folder → FSWatcher | 'none' (not there) | 'blind' (there, but it cannot be watched)
94
99
  let blind = false;
95
100
  function watchDir(dir, recursive) {
96
101
  if (watched.has(dir) && watched.get(dir) !== 'none') return;
97
102
  let there = false; try { there = fs.statSync(dir).isDirectory(); } catch { there = false; }
98
- if (!there) { watched.set(dir, 'none'); return; }
103
+ if (!there) { if (!recursive) watched.set(dir, 'none'); return; }
104
+ const tree = recursive && !NATIVE_RECURSIVE; // one folder of a tree: its sub-folders get their own watchers
99
105
  try {
100
- const w = fs.watch(dir, { recursive, persistent: false }, (ev, f) => {
106
+ const w = fs.watch(dir, { recursive: recursive && !tree, persistent: false }, (ev, f) => {
101
107
  if (f && SKIP.test(String(f))) return;
102
108
  n.outside++; drop();
103
109
  if (!recursive && (f === 'planning' || f === 'pmos')) watchDir(path.join(dir, f), true);
110
+ else if (tree && f) watchDir(path.join(dir, String(f)), true); // a new sub-folder (a file is not a folder: it is skipped)
104
111
  });
105
112
  w.on('error', () => { try { w.close(); } catch { /* closed */ } watched.set(dir, 'blind'); blind = true; drop(); });
106
113
  watched.set(dir, w);
107
- } catch { watched.set(dir, 'blind'); blind = true; }
114
+ } catch { watched.set(dir, 'blind'); blind = true; return; }
115
+ if (tree) {
116
+ let subs = []; try { subs = fs.readdirSync(dir, { withFileTypes: true }); } catch { /* read again on the next event */ }
117
+ for (const d of subs) if (d.isDirectory() && !SKIP.test(d.name)) watchDir(path.join(dir, d.name), true);
118
+ }
108
119
  }
109
120
  function watch(roots) {
110
121
  for (const root of roots || []) {
@@ -0,0 +1,202 @@
1
+ 'use strict';
2
+ /* away-handover.js — away and back (away-handover, job #1841, idea A152). `pmos away …`.
3
+ *
4
+ * Before the PM is away, PMOS drafts a handover note: the open asks that wait on the PM, the dates that fall while the PM is away, and who
5
+ * covers. The note is a DRAFT in the Library (a Handover document the PM reads, edits and shares by hand). Nothing is sent, and nobody is
6
+ * told. When the PM is back, PMOS shows one "while you were away" list: the date and scope moves of the away days (lib/week-moves.js).
7
+ * No model call; every line comes from a record.
8
+ *
9
+ * THE LEDGER. <state>/away.jsonl, append-only, one line per press: { at, kind: 'away', from, until, cover? } | { at, kind: 'back' }.
10
+ * stateOf(lines, today) PURE → { away: { from, until, cover } | null, back: { from, until } | null }
11
+ * away the latest away line not ended by a back line, while today ≤ until
12
+ * back the latest away that ended (a back line, or today past until): the window "while you were away" reads
13
+ * noteOf({ from, until, cover, asks, tasks, today }) PURE → Markdown, the handover note (frontmatter type: Handover)
14
+ * asks open-questions register lines (lib/open-questions.js read): one row per person and initiative, the PM's first
15
+ * tasks [{ id, title, due, owner, initiative, done }]: the open ones due from `from` to `until` (and the late ones), by date
16
+ * whileAway(root, { from, until }) → the week-moves rows of the away days (lib/week-moves.js movesOf)
17
+ * set(dir, { until, cover }, { now }) · back(dir, { now }) · draft(root, dir, { now, sources }) → { ok, file }
18
+ * CLI: pmos away [status] | pmos away set <YYYY-MM-DD> [--cover "<name>"] | pmos away note | pmos away back | pmos away while
19
+ * The note is a plain file: PMOS runs no git command and leaves the git index alone. The Library lists it once the PM commits it.
20
+ * Each command records one use-log line (control awayHandover), the count the kill reads. */
21
+ const fs = require('fs');
22
+ const path = require('path');
23
+
24
+ const TAG = '[away]';
25
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
26
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
27
+ const short = (d) => (DAY_RE.test(String(d || '')) ? (+d.slice(8, 10)) + ' ' + MON[+d.slice(5, 7) - 1] : '');
28
+ const one = (s, n = 200) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
29
+ const localDay = (t = Date.now()) => { const d = new Date(t); return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 10); };
30
+ const ledgerFile = (dir) => path.join(String(dir || ''), 'away.jsonl');
31
+
32
+ function readLines(dir) {
33
+ try { return fs.readFileSync(ledgerFile(dir), 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); }
34
+ catch { return []; }
35
+ }
36
+ function append(dir, line) {
37
+ fs.mkdirSync(dir, { recursive: true });
38
+ fs.appendFileSync(ledgerFile(dir), JSON.stringify(line) + '\n');
39
+ }
40
+
41
+ function stateOf(lines, today) {
42
+ let cur = null, last = null;
43
+ for (const l of lines || []) {
44
+ if (!l || typeof l !== 'object') continue;
45
+ if (l.kind === 'away' && DAY_RE.test(String(l.from || '')) && DAY_RE.test(String(l.until || ''))) cur = { from: l.from, until: l.until, cover: one(l.cover, 80) };
46
+ else if (l.kind === 'back' && cur) { last = { from: cur.from, until: String(l.at || '').slice(0, 10) || cur.until }; cur = null; }
47
+ }
48
+ if (cur && today > cur.until) { last = { from: cur.from, until: cur.until }; cur = null; }
49
+ return { away: cur, back: cur ? null : last };
50
+ }
51
+
52
+ function set(dir, { until, cover } = {}, { now = Date.now() } = {}) {
53
+ if (!dir) return { ok: false, error: 'this computer has no PMOS state folder' };
54
+ const from = localDay(now);
55
+ if (!DAY_RE.test(String(until || '')) || until < from) return { ok: false, error: 'until is a day from today on, YYYY-MM-DD' };
56
+ const line = { at: new Date(now).toISOString(), kind: 'away', from, until, ...(one(cover, 80) ? { cover: one(cover, 80) } : {}) };
57
+ append(dir, line);
58
+ console.log(`${TAG} away ${from}..${until}`);
59
+ return { ok: true, line };
60
+ }
61
+ function back(dir, { now = Date.now() } = {}) {
62
+ if (!dir) return { ok: false, error: 'this computer has no PMOS state folder' };
63
+ const S = stateOf(readLines(dir), localDay(now));
64
+ if (!S.away) return { ok: false, error: 'you are not set as away' };
65
+ const line = { at: new Date(now).toISOString(), kind: 'back' };
66
+ append(dir, line);
67
+ console.log(`${TAG} back`);
68
+ return { ok: true, line, window: { from: S.away.from, until: localDay(now) } };
69
+ }
70
+
71
+ /** The tasks of the PM's products as the records say now: the last due, owner and state of each. */
72
+ function tasksNow(root) {
73
+ try {
74
+ const Facts = require('./drift-facts.js');
75
+ const stateDir = require('./driver.js').stateDirOf(root);
76
+ let storeFile = null; try { const s = require('./task-store.js').storeFor(root); storeFile = s && s.file; } catch { storeFile = null; }
77
+ const T = Facts.tasksOf(root, stateDir ? path.join(stateDir, 'boards.jsonl') : null, storeFile, []).tasks;
78
+ const out = [];
79
+ for (const t of (T instanceof Map ? T.values() : T || [])) {
80
+ let due, owner, state, gone = false;
81
+ for (const l of t.lines || []) {
82
+ if (l.kind === 'task-remove') gone = true; else if (l.kind === 'task-restore') gone = false;
83
+ if (l.due !== undefined) due = l.due; if (l.owner !== undefined) owner = l.owner; if (l.state !== undefined) state = l.state;
84
+ }
85
+ if (!gone) out.push({ id: t.id, title: t.title, initiative: t.initiative, due: due || '', owner: owner || '', done: /^done$/i.test(String(state || '')) });
86
+ }
87
+ return out;
88
+ } catch { return []; }
89
+ }
90
+
91
+ function noteOf({ from, until, cover = '', asks = [], tasks = [], today = from } = {}) {
92
+ const T = (tasks || []).filter((t) => t && !t.done && DAY_RE.test(String(t.due || '')) && t.due <= until)
93
+ .sort((a, b) => a.due.localeCompare(b.due) || String(a.title).localeCompare(String(b.title)));
94
+ const A = (asks || []).filter((l) => l && (l.n || (l.ids || []).length || (l.parts || []).length)).sort((a, b) => (b.toPm ? 1 : 0) - (a.toPm ? 1 : 0));
95
+ const out = ['---', 'type: Handover', `title: "Handover: away ${short(from)} to ${short(until)}"`, `timestamp: ${today}`, '---', '',
96
+ `# Handover: away ${short(from)} to ${short(until)}`, '',
97
+ `PMOS drafted this note from the records on ${short(today)}. It is a draft: read it, change it, and share it yourself. PMOS sends nothing.`, '',
98
+ '## Who covers', '', cover ? `${cover} covers while I am away.` : 'Nobody is named yet. Write who covers here.', '',
99
+ '## Open asks', ''];
100
+ if (A.length) for (const l of A.slice(0, 20)) out.push(`- **${one(l.title || l.ini, 100)}**: ${l.toPm ? 'waits on me' : 'waits on ' + one(l.owner, 60)}${(l.parts || []).length ? ': ' + one(l.parts[0], 160) : ''}.`);
101
+ else out.push('Nothing waits on an answer.');
102
+ out.push('', '## Dates while I am away', '');
103
+ if (T.length) for (const t of T.slice(0, 30)) out.push(`- ${t.due < from ? '**Late**, was ' : ''}${short(t.due)}: ${one(t.title, 120)}${t.owner ? ' (' + one(t.owner, 60) + ')' : ''}${t.initiative ? ', ' + t.initiative : ''}.`);
104
+ else out.push('No task is due while I am away.');
105
+ return out.join('\n') + '\n';
106
+ }
107
+
108
+ /** The handover note's file: planning/handovers/away-<from>.md (a kit layout: pmos/planning/…), where the Library reads documents. */
109
+ function noteFile(root, from) {
110
+ const kit = fs.existsSync(path.join(root, 'pmos', 'state'));
111
+ return path.join(root, ...(kit ? ['pmos', 'planning'] : ['planning']), 'handovers', `away-${from}.md`);
112
+ }
113
+ function draft(root, dir, { now = Date.now(), sources = {} } = {}) {
114
+ const S = stateOf(readLines(dir), localDay(now));
115
+ if (!S.away) return { ok: false, error: 'set the away days first: pmos away set <YYYY-MM-DD>' };
116
+ let asks = sources.asks; if (!Array.isArray(asks)) { try { asks = require('./open-questions.js').read(root, { now }).lines; } catch { asks = []; } }
117
+ const tasks = Array.isArray(sources.tasks) ? sources.tasks : tasksNow(root);
118
+ const file = noteFile(root, S.away.from);
119
+ if (fs.existsSync(file)) return { ok: true, file, kept: true }; // the PM may have edited it: a draft is never written over
120
+ fs.mkdirSync(path.dirname(file), { recursive: true });
121
+ fs.writeFileSync(file, noteOf({ ...S.away, asks, tasks, today: localDay(now) }));
122
+ // the Library lists tracked markdown (lib/kg-cli.js loadFiles), so the note shows there once the PM commits it; PMOS leaves the git index alone
123
+ console.log(`${TAG} note drafted ${path.basename(file)}`);
124
+ return { ok: true, file };
125
+ }
126
+
127
+ function whileAway(root, { from, until }, { facts } = {}) {
128
+ const WM = require('./week-moves.js');
129
+ const F = facts || (() => { const Dr = require('./driver.js'); return require('./drift-facts.js').factsOf({ id: Dr.wsIdOf(root), name: path.basename(root), root }, { stateDir: Dr.stateDirOf(root) }); })();
130
+ const ms = (d) => { const [y, m, dd] = d.split('-').map(Number); return new Date(y, m - 1, dd).getTime(); };
131
+ return WM.movesOf(F, { from: ms(from), to: ms(until) + 864e5 });
132
+ }
133
+
134
+ /* ── pmos away ─────────────────────────────────────────────────────────────────────────────────────────── */
135
+ const COMMANDS = { away: ['status', 'set', 'note', 'back', 'while'] };
136
+ const USAGE = [
137
+ 'usage: pmos away [status|set|note|back|while] — away days, the handover note and what moved while you were away',
138
+ ' pmos away whether you are set as away, until when and who covers',
139
+ ' pmos away set <YYYY-MM-DD> [--cover "<name>"] you are away from today until that day; PMOS drafts the handover note',
140
+ ' pmos away note draft the handover note again into the Library (an edited note is kept as it is)',
141
+ ' pmos away back you are back: the list of what moved while you were away',
142
+ ' pmos away while that list again, for the last away days',
143
+ 'The note is a draft for you to read and share. Nothing is sent.',
144
+ ];
145
+ function stateDirOf(o) { return o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); }
146
+ /** The nearest folder up from cwd that has a .git entry (a folder, or a worktree's file); cwd when there is none. No git command runs. */
147
+ function repoOf(cwd) {
148
+ let d = path.resolve(cwd);
149
+ for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* unreadable: look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
150
+ }
151
+ function used(dir, now) { try { require('./use-log.js').record(dir, [{ kind: 'use', page: 'today', control: 'awayHandover', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ } }
152
+ function sayMoves(say, M, w) {
153
+ if (!M.moves.length) { say(`Nothing moved while you were away (${short(w.from)} to ${short(w.until)}).`); return; }
154
+ say(`While you were away (${short(w.from)} to ${short(w.until)}): ${M.total} ${M.total === 1 ? 'change' : 'changes'}${M.unsourced ? `, ${M.unsourced} with no source` : ''}.`);
155
+ for (const m of M.moves.slice(0, 20)) say(`- ${m.say || m.title}${m.sourced ? '' : ' · No source: ask ' + (m.owner || 'the owner')}`);
156
+ }
157
+
158
+ function run(argv, o = {}) {
159
+ const say = o.say || ((s) => console.log(s)), now = o.now || Date.now();
160
+ const args = argv[0] === 'away' ? argv.slice(1) : argv.slice();
161
+ const pos = [], flags = {};
162
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--cover' || a === '--root') flags[a.slice(2)] = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
163
+ const [cmd = 'status', arg] = pos;
164
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
165
+ if (!COMMANDS.away.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos away`); USAGE.forEach((l) => say(l)); return 2; }
166
+ const dir = stateDirOf(o), root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd())), today = localDay(now);
167
+ used(dir, now);
168
+ const S = stateOf(readLines(dir), today);
169
+ if (cmd === 'status') {
170
+ say(S.away ? `Away from ${short(S.away.from)} until ${short(S.away.until)}${S.away.cover ? '; ' + S.away.cover + ' covers' : ''}.` : 'You are not set as away.');
171
+ return 0;
172
+ }
173
+ if (cmd === 'set') {
174
+ const r = set(dir, { until: arg, cover: flags.cover }, { now });
175
+ if (!r.ok) { say('✗ ' + r.error); return arg ? 1 : 2; }
176
+ const d = draft(root, dir, { now, sources: o.sources || {} });
177
+ say(`✓ Away until ${short(arg)}${flags.cover ? '; ' + flags.cover + ' covers' : ''}. Undo: pmos away back`);
178
+ if (d.ok) say(`The handover note is a draft: ${path.relative(root, d.file)}. The Library lists it once you commit it. Read it and share it yourself; PMOS sends nothing.`);
179
+ return 0;
180
+ }
181
+ if (cmd === 'note') {
182
+ const d = draft(root, dir, { now, sources: o.sources || {} });
183
+ if (!d.ok) { say('✗ ' + d.error); return 1; }
184
+ say(d.kept ? `The handover note is already there, and PMOS keeps your edits: ${path.relative(root, d.file)}.` : `The handover note is a draft: ${path.relative(root, d.file)}. The Library lists it once you commit it.`);
185
+ return 0;
186
+ }
187
+ if (cmd === 'back') {
188
+ const r = back(dir, { now });
189
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
190
+ say('✓ Welcome back.');
191
+ const M = whileAway(root, r.window, { facts: o.facts });
192
+ flags.json ? say(JSON.stringify({ ok: true, window: r.window, ...M })) : sayMoves(say, M, r.window);
193
+ return 0;
194
+ }
195
+ const w = S.back;
196
+ if (!w) { say(S.away ? 'You are still away. pmos away back ends the away days.' : 'No away days yet.'); return 0; }
197
+ const M = whileAway(root, w, { facts: o.facts });
198
+ flags.json ? say(JSON.stringify({ ok: true, window: w, ...M })) : sayMoves(say, M, w);
199
+ return 0;
200
+ }
201
+
202
+ module.exports = { TAG, COMMANDS, USAGE, ledgerFile, readLines, stateOf, set, back, noteOf, noteFile, draft, tasksNow, whileAway, run };
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+ /* capture-file.js — file a typed Today line to the initiative it is about (initiative capture-to-initiative, idea A537). Local only.
3
+ *
4
+ * openOf(ctx) → [{ ws, product, id, title }] the open initiatives of every product (lib/notes-links.js initiativesOf)
5
+ * suggest(text, open) PURE → { pick: { ws, product, id, title, shared } | null, ranked: [...] (at most 12, for the picker) }
6
+ * The words of the line are compared with the id and the title of each initiative (lib/notes-links.js terms: short and common words do
7
+ * not count). The pick is the initiative that shares the most distinct words, when it shares 2 or more and no other shares as many.
8
+ * Otherwise there is no pick, and the line is not filed.
9
+ * file(ctx, { ws, ini, title, bullet }, g) → { ok, filed: { ws, product, ini, title, stage, board, task } } | { ok: false, status, error }
10
+ * The stage is the initiative's stage in progress (lib/routes-boards.js initiativeWorkflow). Only a task line (bullet `task`) becomes a
11
+ * task on the initiative's board, by the boards' own Add a task (taskAdd); a note or an event keeps the chip only.
12
+ * unfile(ctx, filed, g) → { ok } the task the filing added is deleted again (taskDelete; tasks/restore is the boards' Undo)
13
+ *
14
+ * WHAT IT NEVER DOES. It calls no model, sends nothing and opens no network module. Every log line carries [capture-file]. */
15
+ const NL = require('./notes-links.js');
16
+
17
+ const TAG = '[capture-file]';
18
+ const MIN_SHARED = 2;
19
+ const MAX_RANKED = 12;
20
+
21
+ function openOf(ctx) {
22
+ const out = [], roots = new Set();
23
+ for (const w of (ctx && ctx.workspaceList ? ctx.workspaceList() : []) || []) {
24
+ if (!w || !w.root || roots.has(w.root)) continue; // one repository listed twice is one set of initiatives
25
+ roots.add(w.root);
26
+ for (const i of NL.initiativesOf(w.root)) out.push({ ws: w.id, product: w.name || w.id, id: i.id, title: i.title || i.id });
27
+ }
28
+ return out;
29
+ }
30
+
31
+ /** PURE. */
32
+ function suggest(text, open) {
33
+ const mine = NL.terms(text);
34
+ const ranked = (open || []).map((i) => {
35
+ let shared = 0;
36
+ for (const t of NL.terms(String(i.id).replace(/[-_.]/g, ' ') + ' ' + (i.title || ''))) if (mine.has(t)) shared += 1;
37
+ return { ws: i.ws, product: i.product, id: i.id, title: i.title, shared };
38
+ }).sort((a, b) => b.shared - a.shared || String(a.title).localeCompare(String(b.title)));
39
+ const top = ranked[0];
40
+ const pick = top && top.shared >= MIN_SHARED && !(ranked[1] && ranked[1].shared === top.shared) ? top : null;
41
+ return { pick, ranked: ranked.slice(0, MAX_RANKED) };
42
+ }
43
+
44
+ function file(ctx, { ws, ini, title, bullet } = {}, g) {
45
+ const RB = require('./routes-boards.js');
46
+ const w = ctx.getWs(ws || null);
47
+ if (!w || w.id !== ws) return { ok: false, status: 404, error: 'no such product' };
48
+ const wf = RB.initiativeWorkflow(ctx, w, ini);
49
+ if (!wf.ok) return { ok: false, status: wf.status || 500, error: wf.error };
50
+ const st = wf.row && wf.row.wfStage;
51
+ const filed = { ws: w.id, product: w.name || w.id, ini, title: (wf.row && wf.row.title) || ini, stage: st ? st.name || st.key : '', board: wf.board ? wf.board.id : '', task: null };
52
+ if (bullet === 'task' && filed.board) {
53
+ const r = RB.taskAdd(ctx, { ws: w.id, board: filed.board, initiative: ini, title: String(title || '').replace(/\s+/g, ' ').trim().slice(0, 200) }, g);
54
+ if (!r.body || !r.body.ok) return { ok: false, status: r.status || 500, error: (r.body && r.body.error) || 'the task could not be added' };
55
+ filed.task = r.body.item && (r.body.item.uid || r.body.item.id) || null;
56
+ }
57
+ console.info(TAG + ' filed ws=' + w.id + ' ini=' + ini + (filed.task ? ' task=' + filed.task : ''));
58
+ return { ok: true, filed };
59
+ }
60
+
61
+ function unfile(ctx, filed, g) {
62
+ if (!filed || !filed.task) return { ok: true };
63
+ const r = require('./routes-boards.js').taskDelete(ctx, { ws: filed.ws, board: filed.board, task: filed.task, why: 'filed elsewhere from Today' }, g);
64
+ console.info(TAG + ' unfiled ws=' + filed.ws + ' ini=' + filed.ini + ' task=' + filed.task + (r.body && r.body.ok ? '' : ' (already gone)'));
65
+ return { ok: true };
66
+ }
67
+
68
+ module.exports = { TAG, MIN_SHARED, openOf, suggest, file, unfile };
@@ -92,7 +92,7 @@ const VERBS = Object.freeze({
92
92
  blueprint: Object.freeze({ module: 'blueprint-cli.js', run: null, guide: 'cli.md',
93
93
  help: 'pmos blueprint [list|show|unplaced|check] — every feature of the product with a status worked out from its evidence (pmos blueprint help)' }),
94
94
  program: Object.freeze({ module: 'program-cli.js', run: null, guide: 'cli.md',
95
- help: 'pmos program new|charter|join|leave|milestone|check|task|archive|line|draft|order|capacity|decide|outcome|suggest — make and change programs from the chat, the program line (Charter, Sequence, Track, Land) and the milestone suggestions (pmos program help)' }),
95
+ help: 'pmos program new|charter|join|leave|milestone|check|task|archive|line|draft|order|capacity|decide|outcome|steering|suggest — make and change programs from the chat, the program line (Charter, Sequence, Track, Land), the steering pack and the milestone suggestions (pmos program help)' }),
96
96
  // Not a pm-os-absorb verb (run: null): c3-meet-extension added it through the same table.
97
97
  extension: Object.freeze({ module: 'extension-cli.js', run: null, guide: 'cli.md',
98
98
  help: 'pmos extension — the folder of the Chrome extension for Google Meet, and the three steps to load it' }),
@@ -139,6 +139,9 @@ const VERBS = Object.freeze({
139
139
  // Not a pm-os-absorb verb (run: null): initiative open-questions-register (bet A420) added it through the same table.
140
140
  questions: Object.freeze({ module: 'questions-cli.js', run: null, guide: 'cli.md',
141
141
  help: 'pmos questions [age] — every unanswered question across initiatives, oldest first, with who can answer, its age and its default (pmos questions help)' }),
142
+ // Not a pm-os-absorb verb (run: null): initiative away-handover (job #1841, A152) added it through the same table.
143
+ away: Object.freeze({ module: 'away-handover.js', run: null, guide: 'cli.md',
144
+ help: 'pmos away [set|note|back|while] — your away days, the handover note PMOS drafts in the Library, and what moved while you were away (pmos away help)' }),
142
145
  // Not a pm-os-absorb verb (run: null): initiative try-what-shipped added it through the same table.
143
146
  try: Object.freeze({ module: 'try-it.js', run: null, guide: 'cli.md',
144
147
  help: 'pmos try [works|broken|note|undo|later|count] — the changes your recent updates brought, how to try each, and your answer (beta only; pmos try help)' }),
@@ -6,6 +6,10 @@
6
6
  * POST /api/today-log/mark { key, act, day, until?, snap? } → { ok } done, undone, later (until a later day), now (back to today), drop, undrop, keep
7
7
  * POST /api/today-log/fix { day, ws, keys } → { ok } quiet-rows: the line rows Your move shows that day for one product
8
8
  * (at most 3); GET returns them as `fixed: { [ws]: keys }`
9
+ * GET /api/today-log/choices?text= → { ok, pick, ranked } capture-to-initiative: where a line could be filed (the picker)
10
+ * POST /api/today-log/file { key, day, ws, ini } → { ok, filed } file a typed line to another initiative, or ini null: Not filed
11
+ * An added line that clearly names one open initiative is filed there by itself (lib/capture-file.js): the answer's entry carries
12
+ * `filed`, and a task line also becomes a task on that initiative's board. A change deletes the task the earlier filing added.
9
13
  *
10
14
  * The day is the PM's local day, sent by the page. Every POST passes pm-guard requirePagePress: the page only. A mark changes only the
11
15
  * log: done on a task or an item of the PM is sent to that record's own route by the page, and the mark is the log's line beside it.
@@ -14,10 +18,52 @@ const path = require('path');
14
18
  const crypto = require('crypto');
15
19
  const guard = require('./pm-guard.js');
16
20
  const TL = require('./today-log.js');
21
+ const CF = require('./capture-file.js');
17
22
 
18
23
  const fileOf = (ctx) => path.join(ctx.runtimeDir, 'today-log', 'log.jsonl');
19
24
  const localDay = (now = new Date()) => new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 10);
20
25
 
26
+ /** A clear line is filed by itself; an unclear one, or one PMOS cannot place, is left as it is (nothing is said). */
27
+ function autoFile(ctx, e, g) {
28
+ let S;
29
+ try { S = CF.suggest(e.typed || e.text, CF.openOf(ctx)); } catch { return null; }
30
+ if (!S.pick) return null;
31
+ const r = CF.file(ctx, { ws: S.pick.ws, ini: S.pick.id, title: e.text, bullet: e.bullet }, g);
32
+ if (!r.ok) { console.info(CF.TAG + ' not filed ini=' + S.pick.id + ': ' + r.error); return null; }
33
+ const f = TL.fileEvent({ key: 'own:' + e.id, ...r.filed, title: S.pick.title || r.filed.title }, e.day, 'pmos');
34
+ if (f.error) return null;
35
+ TL.appendLine(fileOf(ctx), f.event);
36
+ return TL.filedOf([f.event], f.event.key);
37
+ }
38
+
39
+ /** The PM's choice of where a line is filed: the earlier filing's task is deleted, then the new one is made. */
40
+ async function fileRoute(req, res, ctx) {
41
+ const got = await ctx.readJson(req);
42
+ if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
43
+ const body = got.body || {};
44
+ const g = guard.requirePagePress(req, body);
45
+ if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
46
+ const day = String(body.day || '');
47
+ const check = TL.fileEvent({ key: body.key, ws: body.ws, ini: body.ini }, day);
48
+ if (check.error) { ctx.json(res, { ok: false, error: check.error }, 400); return true; }
49
+ const lines = TL.readLines(fileOf(ctx));
50
+ const e = TL.addedOf(lines, String(body.key).slice(4));
51
+ if (!e) { ctx.json(res, { ok: false, error: 'no line ' + body.key + ' in Today’s log' }, 404); return true; }
52
+ const prev = TL.filedOf(lines, check.event.key);
53
+ if (prev && body.ini && prev.ws === body.ws && prev.ini === body.ini) { ctx.json(res, { ok: true, filed: prev }); return true; }
54
+ let filed = null;
55
+ if (body.ini) {
56
+ const r = CF.file(ctx, { ws: body.ws, ini: body.ini, title: e.typed || e.text, bullet: e.bullet }, g);
57
+ if (!r.ok) { ctx.json(res, { ok: false, error: r.error }, r.status || 500); return true; }
58
+ filed = r.filed;
59
+ }
60
+ if (prev) CF.unfile(ctx, prev, g);
61
+ const f = TL.fileEvent({ key: check.event.key, ...(filed || {}), ini: filed ? filed.ini : null }, day, 'pm');
62
+ TL.appendLine(fileOf(ctx), f.event);
63
+ ctx.json(res, { ok: true, filed: filed ? TL.filedOf([f.event], f.event.key) : null });
64
+ return true;
65
+ }
66
+
21
67
  module.exports = {
22
68
  prefixes: ['/api/today-log'],
23
69
  fileOf,
@@ -31,6 +77,12 @@ module.exports = {
31
77
  ctx.json(res, { ok: true, day, entries: f.entries, marks: f.marks, fixed: f.fixed });
32
78
  return true;
33
79
  }
80
+ if (p === '/api/today-log/choices' && req.method === 'GET') {
81
+ const S = CF.suggest(String(url.searchParams.get('text') || '').slice(0, 400), CF.openOf(ctx));
82
+ ctx.json(res, { ok: true, pick: S.pick, ranked: S.ranked });
83
+ return true;
84
+ }
85
+ if (req.method === 'POST' && p === '/api/today-log/file') return fileRoute(req, res, ctx);
34
86
  if (req.method !== 'POST' || (p !== '/api/today-log/add' && p !== '/api/today-log/mark' && p !== '/api/today-log/fix')) return false;
35
87
  const got = await ctx.readJson(req);
36
88
  if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
@@ -44,7 +96,8 @@ module.exports = {
44
96
  if (p === '/api/today-log/fix') console.info('[quiet-rows] fixed day=' + day + ' rows=' + r.event.keys.length);
45
97
  if (p === '/api/today-log/add') {
46
98
  const e = r.event;
47
- ctx.json(res, { ok: true, entry: { id: e.id, key: 'own:' + e.id, bullet: e.bullet, text: e.text, first: e.first, time: e.time, day: e.day, done: false } });
99
+ const filed = autoFile(ctx, e, g);
100
+ ctx.json(res, { ok: true, entry: { id: e.id, key: 'own:' + e.id, bullet: e.bullet, text: e.text, first: e.first, time: e.time, day: e.day, done: false, ...(filed ? { filed } : {}) } });
48
101
  } else ctx.json(res, { ok: true });
49
102
  return true;
50
103
  },
@@ -246,7 +246,10 @@ function fold(lines, day) {
246
246
  // a done mark of an earlier day is history: the row is gone from today's log (an own entry), or it is back as its source says
247
247
  for (const k of Object.keys(marks)) { const m = marks[k]; if (m.done && m.done !== d) { m.doneBefore = m.done; delete m.done; delete m.snap; } if (!Object.keys(m).length) delete marks[k]; }
248
248
  const entries = [];
249
+ const filed = new Map();
250
+ for (const ev of lines || []) if (ev && ev.event === 'file' && typeof ev.key === 'string') filed.set(ev.key, ev);
249
251
  for (const e of own.values()) {
252
+ if (filed.has(e.key)) { const f = filedOf([filed.get(e.key)], e.key); if (f) e.filed = f; }
250
253
  const m = marks[e.key] || {};
251
254
  if (m.dropped) continue;
252
255
  if (m.doneBefore && !m.done) continue;
@@ -258,6 +261,32 @@ function fold(lines, day) {
258
261
  return { entries, marks, fixed };
259
262
  }
260
263
 
264
+ /** capture-to-initiative: the line POST /api/today-log/file and a filed add append. body: { key, ws, ini (null: not filed), title, stage,
265
+ * board, task, product }; by is 'pmos' (filed by itself) or 'pm' (the PM's choice). The latest line of a key wins in fold. */
266
+ const INI_RE = /^[a-z0-9][a-z0-9._-]{0,120}$/;
267
+ function fileEvent(body, day, by = 'pm') {
268
+ const b = body || {};
269
+ if (!DAY_RE.test(String(day || ''))) return { error: 'day is YYYY-MM-DD' };
270
+ if (!/^own:/.test(String(b.key || '')) || !KEY_RE.test(String(b.key))) return { error: 'key names a line you typed' };
271
+ if (b.ini != null && !INI_RE.test(String(b.ini))) return { error: 'ini is an initiative id, or null for Not filed' };
272
+ if (b.ini != null && (!b.ws || !WS_RE.test(String(b.ws)))) return { error: 'ws names the product' };
273
+ const one = (v, n) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim().slice(0, n);
274
+ const ev = { event: 'file', key: String(b.key), day, by: by === 'pmos' ? 'pmos' : 'pm', ini: b.ini == null ? null : String(b.ini) };
275
+ if (ev.ini) Object.assign(ev, { ws: String(b.ws), product: one(b.product, 80), title: one(b.title, MAX_TEXT), stage: one(b.stage, 80), board: one(b.board, 120), task: b.task ? one(b.task, 120) : null });
276
+ return { event: ev };
277
+ }
278
+ /** The latest filing of one line, or null (never filed, or Not filed). */
279
+ function filedOf(lines, key) {
280
+ let f = null;
281
+ for (const ev of lines || []) if (ev && ev.event === 'file' && ev.key === key) f = ev.ini ? ev : null;
282
+ return f ? { ws: f.ws, product: f.product || f.ws, ini: f.ini, title: f.title || f.ini, stage: f.stage || '', board: f.board || '', task: f.task || null, by: f.by } : null;
283
+ }
284
+ /** The added line of an own entry by its id, or null. */
285
+ function addedOf(lines, id) {
286
+ for (const ev of lines || []) if (ev && ev.event === 'added' && ev.id === id) return ev;
287
+ return null;
288
+ }
289
+
261
290
  function readLines(file) {
262
291
  let raw = '';
263
292
  try { raw = fs.readFileSync(file, 'utf8'); } catch { return []; }
@@ -268,4 +297,4 @@ function appendLine(file, line, now = new Date()) {
268
297
  fs.appendFileSync(file, JSON.stringify({ ...line, at: now.toISOString() }) + '\n');
269
298
  }
270
299
 
271
- module.exports = { DAY_RE, KEY_RE, BULLETS, ACTS, FIX_MAX, READ, parseEntry, readWords, dateWords, timeWords, ownerWords, addEvent, markEvent, fixEvent, fold, readLines, appendLine };
300
+ module.exports = { DAY_RE, KEY_RE, BULLETS, ACTS, FIX_MAX, READ, parseEntry, readWords, dateWords, timeWords, ownerWords, addEvent, markEvent, fixEvent, fold, fileEvent, filedOf, addedOf, readLines, appendLine };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.814.0",
3
+ "version": "0.816.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.814.0",
9
+ "version": "0.816.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.814.0",
3
+ "version": "0.816.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",
@@ -453,6 +453,49 @@ export function mountToday(ctx) {
453
453
  try { i.showPicker(); } catch { /* the field itself is the chooser */ }
454
454
  }
455
455
 
456
+ /* capture-to-initiative (A537): a line PMOS filed by itself is said once, with Undo (Not filed). The chip's press lists where else it
457
+ * could go, the clearest first, and Not filed. Each filing is one captureFiled line in the local use log; a change is captureRefiled. */
458
+ const fileTo = async (key, ws, ini) => {
459
+ const r = await ctx.pmPost('/api/today-log/file', { key, day: day(), ws: ws || null, ini: ini || null }).catch(() => null);
460
+ if (!r || !r.ok) { ctx.toast((r && r.error) || 'Where it is filed did not change.'); return null; }
461
+ const e = X.log.entries.find((x) => x.key === key);
462
+ if (e) { if (r.filed) e.filed = r.filed; else delete e.filed; }
463
+ draw();
464
+ return r;
465
+ };
466
+ function filedSay(key, f) {
467
+ noteUse('captureFiled');
468
+ ctx.toastUndo('Filed to ' + f.title + (f.stage ? ' · ' + f.stage : '') + '.', async () => { const u = await fileTo(key, null, null); return u || { ok: false }; });
469
+ }
470
+ async function chooseFile(r, btn) {
471
+ document.querySelectorAll('.td-dp').forEach((x) => x.remove());
472
+ const cur = r.ref && r.ref.filed;
473
+ const got = await ctx.pmGet('/api/today-log/choices?text=' + encodeURIComponent(r.title || '')).catch(() => null);
474
+ const list = ((got && got.ranked) || []).filter((c) => !(cur && c.ws === cur.ws && c.id === cur.ini));
475
+ const box = document.createElement('div');
476
+ box.className = 'td-dp td-fp'; box.setAttribute('role', 'dialog'); box.setAttribute('aria-label', 'Where this line is filed: ' + r.title);
477
+ box.innerHTML = list.map((c) => `<button type="button" class="pm-btn ghost" data-ws="${TP.esc(c.ws)}" data-ini="${TP.esc(c.id)}">${TP.esc(c.title)}</button>`).join('')
478
+ + (cur ? '<button type="button" class="pm-btn ghost" data-ini="">Not filed</button>' : '');
479
+ if (!box.innerHTML) { ctx.toast('PMOS found no open initiative to file it to.'); return; }
480
+ document.body.appendChild(box);
481
+ const b = btn.getBoundingClientRect();
482
+ box.style.top = Math.min(innerHeight - box.offsetHeight - 12, b.bottom + 6) + 'px'; box.style.left = Math.max(12, b.right - box.offsetWidth) + 'px';
483
+ const close = () => { box.remove(); removeEventListener('pointerdown', out, true); if (btn.isConnected) btn.focus(); };
484
+ const out = (e) => { if (!box.contains(e.target)) close(); };
485
+ addEventListener('pointerdown', out, true);
486
+ box.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); close(); } });
487
+ box.addEventListener('click', async (e) => {
488
+ const c = e.target.closest('button'); if (!c) return;
489
+ close();
490
+ const res = await fileTo(r.key, c.dataset.ws, c.dataset.ini);
491
+ if (!res) return;
492
+ noteUse('captureRefiled');
493
+ const back = cur ? () => fileTo(r.key, cur.ws, cur.ini) : () => fileTo(r.key, null, null);
494
+ ctx.toastUndo(res.filed ? 'Filed to ' + res.filed.title + (res.filed.stage ? ' · ' + res.filed.stage : '') + '.' : 'Not filed.', async () => (await back()) || { ok: false });
495
+ });
496
+ const f = box.querySelector('button'); if (f) f.focus();
497
+ }
498
+
456
499
  // j k with any Today row's item open in the popup: the next or previous row opens in its place (↑ ↓ too in the one-mention popup)
457
500
  document.addEventListener('keydown', (e) => {
458
501
  if (!on() || !X.last || e.metaKey || e.ctrlKey || e.altKey || (e.key !== 'j' && e.key !== 'k')) return;
@@ -558,6 +601,7 @@ export function mountToday(ctx) {
558
601
  if (act === 'q-remind') { remindQuestion(r.ref); return; }
559
602
  if (act === 'open') { open(r); return; }
560
603
  if (act === 'date') { chooseDate(r, b); return; }
604
+ if (act === 'file') { chooseFile(r, b); return; } // capture-to-initiative: the filed chip's change
561
605
  if (X.busy.has(key)) return;
562
606
  X.busy.add(key); b.disabled = true;
563
607
  try {
@@ -585,6 +629,7 @@ export function mountToday(ctx) {
585
629
  i.value = '';
586
630
  draw();
587
631
  const j = document.getElementById('tdCap'); if (j) j.focus();
632
+ if (r.entry.filed) filedSay(r.entry.key, r.entry.filed);
588
633
  });
589
634
  }
590
635
  /* The capture box's mic on a phone (PhoneTodayDS: "type or speak"): the browser's own speech recognition, where it has one, writes the
@@ -82,6 +82,7 @@ button.td-ev:focus-visible { outline: none; box-shadow: var(--glow); }
82
82
  /* the date chooser beside a row (set a date) */
83
83
  .td-dp { position: fixed; z-index: 80; display: flex; align-items: center; gap: 6px; padding: var(--space-8); border-radius: var(--radius-md); background: var(--card); box-shadow: var(--lift); }
84
84
  .td-dp input { font: inherit; color: var(--ink); background: var(--well); border: 0; border-radius: var(--radius-sm); padding: 6px var(--space-8); color-scheme: light dark; }
85
+ .td-fp { flex-direction: column; align-items: stretch; max-height: 50vh; overflow-y: auto; }
85
86
 
86
87
  /* ── Today on a phone (phone design, boards Ph2_today, Ph2_todayzero, Ph2_recdone; pm/cozy-today-view.js phonePageHtml) ──
87
88
  * One column on the white page, a 16 px gutter, no cards and no boxes: hairlines between the parts. Home's list is not drawn on today.html;
@@ -87,7 +87,7 @@ export function rowHtml(r, o = {}) {
87
87
  const title = opens ? `<button type="button" class="t td-t" data-td="open" data-key="${esc(r.key)}"${r.members ? ` aria-expanded="${!!o.sopen}"` : ''}>${esc(t)}${r.members ? ic(I.more, 14) : ''}</button>` : `<span class="t td-t">${esc(t)}</span>`;
88
88
  const first = r.first && !r.done && r.src === 'own' ? '<span class="pm-badge blue">First</span>' : '';
89
89
  // capture-words-to-fields: what the words gave, as chips, with the one press that takes the reading off
90
- const chips = readChips(r);
90
+ const chips = readChips(r) + fileChip(r);
91
91
  // what PMOS did on it, from records (round 3 point 13): a small ✦ with the count; its words on hover and for a screen reader
92
92
  const did = r.did && r.did.length && !r.done ? `<span class="td-did" title="${esc('PMOS did: ' + r.did.join('; '))}" aria-label="${esc('PMOS did: ' + r.did.join('; '))}"><b aria-hidden="true">✦</b>${r.did.length}</span>` : '';
93
93
  const why = r.member ? '' : whyLine(r);
@@ -119,6 +119,16 @@ function readChips(r) {
119
119
  + ib('plain', 'Undo what PMOS read: keep the line as you typed it', I.undo, r.key, '', 'outline') + '</span>';
120
120
  }
121
121
 
122
+ /** capture-to-initiative: where PMOS filed a line you typed, as a chip (the initiative and its stage), with the one press that changes it
123
+ * (another initiative, or Not filed). '' for a line not filed. r.ref.filed: lib/today-log.js filedOf. */
124
+ export function fileChip(r) {
125
+ const f = r && r.src === 'own' && !r.done && r.ref && r.ref.filed;
126
+ if (!f || !f.ini) return '';
127
+ const say = '↳ ' + f.title + (f.stage ? ' · ' + f.stage : '');
128
+ return `<span class="td-rd td-fl" role="group" aria-label="${esc('Filed to ' + f.title + (f.stage ? ', ' + f.stage : ''))}"><span class="pm-badge">${esc(say)}</span>`
129
+ + ib('file', 'Change where this line is filed', I.more, r.key, ' aria-haspopup="dialog"', 'outline') + '</span>';
130
+ }
131
+
122
132
  /** A tracker sync Suggestion (tracker-sync-on-today, board TrackerSyncDesk): ✓ takes Jira's value on all, ✕ keeps PMOS's, the arrow opens
123
133
  * the differences, each with its own ✓. x: cozy-today-model.js syncSuggest()[i]. */
124
134
  function syncHtml(x) {
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "away-handover (job #1841, A152): away days, the handover note PMOS drafts in the Library, and what moved while the PM was away. No browser, no network.",
3
+ "modules": [
4
+ "away-handover.test.js"
5
+ ],
6
+ "seconds": {
7
+ "away-handover.test.js": 3
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "A typed Today line filed to its initiative (initiative capture-to-initiative, done test C1-C5, N1-N3): the pure pick, the fold, the page's chip and picker, and the add/file/choices routes on a scratch server. No browser, model or network.",
3
+ "modules": [
4
+ "capture-file.test.js"
5
+ ],
6
+ "seconds": {
7
+ "capture-file.test.js": 25
8
+ }
9
+ }