create-pmos 0.737.0 → 0.739.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.737.0",
3
+ "version": "0.739.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,38 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.739.0",
38
+ "at": "2026-11-23T07:58:34.158Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1649,
43
+ "t": "Ctrl K answers a question from your own files, with its sources",
44
+ "s": "Ctrl K answers a question from your own files, with its sources",
45
+ "k": "new"
46
+ },
47
+ {
48
+ "n": 1651,
49
+ "t": "Open questions styles use tokens (open-questions-today, Checker C6)",
50
+ "s": "Open questions styles use tokens (open-questions-today, Checker C6)",
51
+ "k": "fix"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "v": "0.738.0",
57
+ "at": "2026-11-23T07:20:29.240Z",
58
+ "f": 4,
59
+ "prs": [
60
+ {
61
+ "n": 1639,
62
+ "t": "Every edit shows at once, and a failed save says so",
63
+ "s": "Every edit shows at once, and a failed save says so",
64
+ "k": "fix"
65
+ }
66
+ ]
67
+ },
36
68
  {
37
69
  "v": "0.737.0",
38
70
  "at": "2026-11-23T06:47:33.938Z",
@@ -410,104 +442,6 @@
410
442
  "k": "new"
411
443
  }
412
444
  ]
413
- },
414
- {
415
- "v": "0.714.0",
416
- "at": "2026-11-22T18:31:53.842Z",
417
- "f": 4,
418
- "prs": [
419
- {
420
- "n": 1578,
421
- "t": "One key each for approve, open, next sprint, park and Undo, plus a ? list (job #1577)",
422
- "s": "One key each for approve, open, next sprint, park and Undo, plus a ?",
423
- "k": "new"
424
- },
425
- {
426
- "n": 1579,
427
- "t": "One next step on a page that has nothing in it yet (A474)",
428
- "s": "One next step on a page that has nothing in it yet (A474)",
429
- "k": "new"
430
- }
431
- ]
432
- },
433
- {
434
- "v": "0.713.0",
435
- "at": "2026-11-22T15:29:37.584Z",
436
- "f": 4,
437
- "prs": [
438
- {
439
- "n": 1568,
440
- "t": "Undo right on the item PMOS changed, for 24 hours (A456)",
441
- "s": "Undo right on the item PMOS changed, for 24 hours (A456)",
442
- "k": "new"
443
- },
444
- {
445
- "n": 1564,
446
- "t": "Offer to hide buttons not pressed in 14 days, with Undo and Show all (A454)",
447
- "s": "Offer to hide buttons not pressed in 14 days, with Undo and Show all (A454)",
448
- "k": "new"
449
- },
450
- {
451
- "n": 1571,
452
- "t": "Back restores your place (scroll and open sections)",
453
- "s": "Back restores your place (scroll and open sections)",
454
- "k": "new"
455
- },
456
- {
457
- "n": 1567,
458
- "t": "View preferences follow the person (job #1555)",
459
- "s": "View preferences follow the person (job #1555)",
460
- "k": "new"
461
- },
462
- {
463
- "n": 1570,
464
- "t": "Product switcher row with a quiet dot on products that need you (job #1547)",
465
- "s": "Product switcher row with a quiet dot on products that need you (job #1547)",
466
- "k": "new"
467
- },
468
- {
469
- "n": 1575,
470
- "t": "Set up a routine from one typed sentence (job #1546)",
471
- "s": "Set up a routine from one typed sentence (job #1546)",
472
- "k": "new"
473
- },
474
- {
475
- "n": 1566,
476
- "t": "Work breakdown follow-ups: drag to nest, hold to select, Gantt bars by days, grouping ✦, Jira column, Source filter, Set epic",
477
- "s": "Work breakdown follow-ups: drag to nest, hold to select, Gantt bars by days, grouping ✦, Jira column, Source filter, Set epic",
478
- "k": "new"
479
- },
480
- {
481
- "n": 1572,
482
- "t": "Launch tiers set what happens at full rollout (job #1548)",
483
- "s": "Launch tiers set what happens at full rollout (job #1548)",
484
- "k": "new"
485
- },
486
- {
487
- "n": 1565,
488
- "t": "One shared empty, loading and error block; the Viewer draws every state from it (job #1553)",
489
- "s": "One shared empty, loading and error block; the Viewer draws every state from it (job #1553)",
490
- "k": "new"
491
- },
492
- {
493
- "n": 1569,
494
- "t": "Five-line strategy above each product's Board, with a gentle note on new work that doesn't fit (job #1550)",
495
- "s": "Five-line strategy above each product's Board, with a gentle note on new work that doesn't fit (job #1550)",
496
- "k": "new"
497
- },
498
- {
499
- "n": 1573,
500
- "t": "Parked work keeps a reason and a way back (job #1552)",
501
- "s": "Parked work keeps a reason and a way back (job #1552)",
502
- "k": "new"
503
- },
504
- {
505
- "n": 1574,
506
- "t": "Phone initiative ask box no longer covers the page (release check 0.711.0)",
507
- "s": "Phone initiative ask box no longer covers the page (release check 0.711.0)",
508
- "k": "fix"
509
- }
510
- ]
511
445
  }
512
446
  ]
513
447
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@c595a5b1
1
+ kernel-source: pmos@869d46c3
2
2
  assembled: 2026-11-23
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-23T06:47:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
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-23T06:47:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
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-23T06:47:30Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,36 @@
1
1
  [
2
+ {
3
+ "v": "0.739.0",
4
+ "at": "2026-11-23T07:58:34.158Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1649,
9
+ "t": "Ctrl K answers a question from your own files, with its sources",
10
+ "s": "Ctrl K answers a question from your own files, with its sources",
11
+ "k": "new"
12
+ },
13
+ {
14
+ "n": 1651,
15
+ "t": "Open questions styles use tokens (open-questions-today, Checker C6)",
16
+ "s": "Open questions styles use tokens (open-questions-today, Checker C6)",
17
+ "k": "fix"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "v": "0.738.0",
23
+ "at": "2026-11-23T07:20:29.240Z",
24
+ "f": 4,
25
+ "prs": [
26
+ {
27
+ "n": 1639,
28
+ "t": "Every edit shows at once, and a failed save says so",
29
+ "s": "Every edit shows at once, and a failed save says so",
30
+ "k": "fix"
31
+ }
32
+ ]
33
+ },
2
34
  {
3
35
  "v": "0.737.0",
4
36
  "at": "2026-11-23T06:47:33.938Z",
@@ -2,13 +2,19 @@
2
2
  type: Guide
3
3
  title: "An initiative's tasks"
4
4
  description: "Where an initiative's tasks show in the workspace, how an agent adds tasks, and who made a change."
5
- timestamp: 2026-11-22
5
+ timestamp: 2026-11-23
6
6
  ---
7
7
 
8
8
  # An initiative's tasks
9
9
 
10
10
  An initiative owns its task breakdown. In the workspace, its tasks show under the initiative in Home's list (the 3 most urgent, then **Show N more tasks**) and on the initiative's page in the Viewer. Press **+** at the top of Home's list, then **Task**, to add one. A check box is a task: amber when it is late. [Home](home.md) explains the list.
11
11
 
12
+ ## Changes show at once
13
+
14
+ A change you make shows right away, on every page that shows the task: its status, dates, owner, priority, sprint, name, stage or parent, a new task, a deleted task, and a move of several tasks. The case lines and the summary of an initiative show right away too. You do not have to wait for the save, and you do not have to open the popup again.
15
+
16
+ If the save fails, the change goes back and a message tells you why, for example "Not saved, so it is back as it was: the start is after the due day." Select **Try again** to send it again.
17
+
12
18
  ## Subtasks
13
19
 
14
20
  A task can sit under another task, at any depth. To add a subtask, type `under <parent>: <title>` in the add box of the Work breakdown, for example `under Batch 2: TM web`. To move a task, open its **More** menu and select **Make subtask of…** or **Move out of …**. With a mouse you can also drag a task in the List:
@@ -86,7 +86,7 @@ What you do not finish is carried to the next day, and the badge says for how lo
86
86
 
87
87
  Findings that fit no initiative (the Lab) are ✦ rows in the log. ✓ keeps one and starts an initiative from it. ✕ drops it.
88
88
 
89
- **Open questions in Decide.** The **Decide** tab also lists every question that is not answered yet, across all initiatives, in two groups. **Waiting on you · n · oldest first** has the questions only you can answer: a plan change PMOS holds for want of a source, a drafted ticket's open gaps, a sign-off, and the drafts PMOS filed that nobody kept or dropped (one row per initiative, for example "4 drafts on Faster checkout wait on you"). **Waiting on others · n** has the questions a teammate must answer, each starting with their name. Each row says its initiative and its kind, and under it what PMOS does if nobody answers ("If nobody answers by 7 Dec, PMOS drops the drafts; nothing on the plan changes.") or why it has no default ("No default: …"). The badge says how many days it waited; it turns red after 14 days. Press a row, or its arrow, to open the initiative and answer there. On a teammate's row, the speech icon writes a short reminder in the chat for you to read and send; nothing is sent by itself. A question whose default is due today is also a row in the log. The Overview says how many wait on you and the oldest. When nothing waits, there is no group, and the Decide tab shows only when it has lines. The phone shows the same groups in the Decide filter. `pmos questions` prints the same list in a terminal (see the [Command reference](cli.md)).
89
+ **Open questions in Decide.** The **Decide** tab also lists every question that is not answered yet, across all initiatives, in two groups. **Waiting on you · n · oldest first** has the questions only you can answer: a plan change PMOS holds for want of a source, a drafted ticket's open gaps, a sign-off, and the drafts PMOS filed that nobody kept or dropped (one row per initiative, for example "4 drafts on Faster checkout wait on you"). **Waiting on others · n** has the questions a teammate must answer, each starting with their name. Each row says its initiative and its kind, and under it what PMOS does if nobody answers ("If nobody answers by 7 Dec, PMOS drops the drafts; nothing on the plan changes.") or why it has no default ("No default: …"). The badge says how many days it waited; it turns red after 14 days. Press a row, or its arrow, to open the initiative and answer there. On a teammate's row, the speech icon writes a short reminder in the chat for you to read and send; nothing is sent by itself. A question whose default is due today is also a row in the log. The Overview says how many wait on you and the oldest. When nothing waits, there is no group, and the Decide tab shows only when it has lines. The phone shows the same groups in the Decide filter, each headed in small capitals like the log's own heading. `pmos questions` prints the same list in a terminal (see the [Command reference](cli.md)).
90
90
 
91
91
  The agenda lists the day's events in time order, each with its start time, and a red line with the time now between the past and the next ones. Past events are dashed. The next event says how soon it starts ("in 20 min"). A meeting with a call has a play button: one press joins the call and starts the recording. It shows your meetings, the reports that go out today at their time, your own events, and focus time: the free time from now until the next meeting, held for the first row of your log, in a dashed box. Focus time is only ever a gap before a meeting: it never runs past the last one. Press the focus time to open that row. A day with no meeting or event shows one quiet line, for example "No events today · 9 h free". **Events** at the top right opens the Events page. "PMOS did" is not on Today; it moves to Routine.
92
92
 
@@ -278,6 +278,8 @@ The Board shows initiatives by stage, with programs, a timeline and a list. Inte
278
278
 
279
279
  When the words you type in Search point clearly to one thing, the first row is the answer: one sentence from your own files, then where it came from. Type an initiative's name and the answer is its goal, with its check date. Ask "when is the pilot launch" and the answer is the sentence in your plan that holds the date. Press Enter on the answer to open its source. PMOS copies the sentence as it is written and does not write it. When no one sentence holds all your words, or two initiatives match equally, there is no answer row, and the matches show as before.
280
280
 
281
+ When you type a question, such as "why do some customers still use a spreadsheet instead of the app?", and no one sentence holds all your words, the first row says "Finding an answer in your work…". After a few seconds it shows a short answer, written only from passages of your own files, and the names of the files it used. Press Enter on the answer to open the first of them. To go deeper, pick "Ask PMOS" in the next row. When your files do not answer the question, the row goes away and the matches stay.
282
+
281
283
  ## Keys
282
284
 
283
285
  | Key | What it does |
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * GET /api/find?q=<words>&ws=<id>&wt=<id,id> → { ok, q, worktrees, counts, results, more, answer? } wt: the worktrees to search (none: all)
5
5
  * answer: one sentence from the user's own files with its source (lib/search-answer.js); absent when nothing is clear
6
+ * GET /api/search-ask?q=<question>&ws=<id> → { ok, answer, why? } a question's answer (lib/search-ask.js): the copied sentence when there is
7
+ * one, else one written by a read-only PMOS session from passages of the user's files, with those files as its sources (search-answers-questions)
6
8
  * GET /api/find/file?ws=<id>&wt=<id>&path=<p> → { ok, wt, branch, main, path, text, mtime } one file of a listed worktree, for the Viewer
7
9
  *
8
- * Read-only: nothing here writes or calls anything outside this machine. The repository is the workspace's own (ws, else the home one). */
10
+ * Read-only: nothing here writes. Only /api/search-ask starts a session (the existing read-only ask kind); nothing else calls anything outside this machine. The repository is the workspace's own (ws, else the home one). */
9
11
  const Search = require('./search-index.js');
10
12
  const Answer = require('./search-answer.js'); // the answer first, with its source (search-answers-first)
11
13
 
@@ -15,10 +17,10 @@ function wsOf(ctx, id) {
15
17
  }
16
18
 
17
19
  module.exports = {
18
- prefixes: ['/api/find'],
20
+ prefixes: ['/api/find', '/api/search-ask'],
19
21
  handle: async (req, res, url, ctx) => {
20
22
  const p = url.pathname;
21
- if (p !== '/api/find' && p !== '/api/find/file') return false;
23
+ if (p !== '/api/find' && p !== '/api/find/file' && p !== '/api/search-ask') return false;
22
24
  if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
23
25
  const w = wsOf(ctx, url.searchParams.get('ws'));
24
26
  if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
@@ -27,6 +29,13 @@ module.exports = {
27
29
  ctx.json(res, r.ok ? r : { ok: false, error: r.error }, r.ok ? 200 : r.status || 400);
28
30
  return true;
29
31
  }
32
+ if (p === '/api/search-ask') {
33
+ let r;
34
+ try { r = await require('./search-ask.js').answer(ctx, { root: w.root, q: url.searchParams.get('q') || '' }); }
35
+ catch (e) { r = { ok: true, answer: null, why: 'the answer could not be made' }; }
36
+ ctx.json(res, { ws: w.id, q: String(url.searchParams.get('q') || '').trim(), ...r });
37
+ return true;
38
+ }
30
39
  let notes = [];
31
40
  try { const l = ctx.runtimeDir ? require('./notes.js').list(ctx.runtimeDir) : null; notes = l && l.ok ? l.notes : []; } catch { notes = []; }
32
41
  const only = (url.searchParams.get('wt') || '').split(',').map((x) => x.trim()).filter(Boolean);
@@ -0,0 +1,174 @@
1
+ 'use strict';
2
+ /* search-ask.js — Search answers questions (initiative search-answers-questions; done test planning/done-tests/search-answers-questions.md).
3
+ *
4
+ * isQuestion(q) → true when q ends with "?" or starts with a question word, and has 3 words or more PURE
5
+ * passages({ root, q }) → [{ n, path, title, kind, text }] READ-ONLY. The lines of the main checkout's tracked Markdown
6
+ * files that hold the most key words of q (git grep), best 2 per file, at most 10 in all.
7
+ * promptOf(q, list) · parse(text, list) the session's prompt, and its answer read back ({ text, used: [passage] } | null) PURE
8
+ * answer(ctx, { root, q }) → { ok: true, answer: { text, facts, made: true, source, sources } } | { ok: true, answer: null, why }
9
+ *
10
+ * Search answers first (lib/search-answer.js) answers only with a sentence that holds EVERY key word, so a "why" or "how" question is
11
+ * almost never answered there. This is the next step for a question: one normal PMOS session (`claude -p`, the existing read-only
12
+ * `briefing-ask:` ask kind, no tools, the same path as the Library's find by meaning) reads the question and the passages, and answers in
13
+ * at most two sentences from the passages only, naming the ones it used. The sources are those passages' files, so every answer says where
14
+ * it came from. The passages say nothing about it: no answer (zero is silence). Answers are kept 10 minutes. Nothing is written or sent.
15
+ * Tests inject ctx.askClaude(prompt, { job, key }) → Promise<string|null>. */
16
+ const { execFileSync } = require('child_process');
17
+ const crypto = require('crypto');
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ const Search = require('./search-index.js');
21
+ const { wordsOf } = require('./library-find.js');
22
+
23
+ const QWORDS = /^\s*(why|how|what|whats|what's|who|whom|whose|when|where|which|is|are|was|were|do|does|did|can|could|should|would|will|has|have|had)\b/i;
24
+ /** A question: it ends with "?" or starts with a question word, and has 3 words or more. Pure. */
25
+ function isQuestion(q) {
26
+ const s = String(q || '').trim();
27
+ if (s.split(/\s+/).filter(Boolean).length < 3) return false;
28
+ return /\?\s*$/.test(s) || QWORDS.test(s);
29
+ }
30
+
31
+ const MAX = 10, PER_FILE = 2;
32
+ const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
33
+ const plain = (l) => String(l || '').replace(/^\s*\|\s*|\s*\|\s*$/g, '').replace(/\s*\|\s*/g, ' · ').replace(/^\s*(?:#+|[-*+>]|\d+[.)])\s*/, '').replace(/\*\*|__|`|\[([^\]]*)\]\([^)]*\)/g, (m, a) => a || '').trim();
34
+ const reOf = (w) => new RegExp('(^|[^a-z0-9])' + w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
35
+
36
+ function grep(root, words) {
37
+ const args = ['grep', '-I', '-i', '-n', '--no-color'];
38
+ for (const w of words) args.push('-e', w);
39
+ args.push('--', '*.md');
40
+ try { return execFileSync('git', args, { cwd: root, encoding: 'utf8', timeout: 8000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] }); }
41
+ catch (e) { return (e && typeof e.stdout === 'string') ? e.stdout : ''; } // git grep exits 1 when nothing matches
42
+ }
43
+ /** The front matter of a file ends at this line (0 when it has none). */
44
+ function fmEnd(root, rel, cache) {
45
+ if (cache.has(rel)) return cache.get(rel);
46
+ let end = 0;
47
+ try {
48
+ const head = fs.readFileSync(path.join(root, rel), 'utf8').slice(0, 8192).split('\n');
49
+ if (head[0] === '---') { const i = head.indexOf('---', 1); end = i > 0 ? i + 1 : 0; }
50
+ } catch { end = 0; }
51
+ cache.set(rel, end);
52
+ return end;
53
+ }
54
+ function titleOf(root, rel) {
55
+ try { return Search.titleOf(fs.readFileSync(path.join(root, rel), 'utf8').slice(0, 8192), path.basename(rel)); } catch { return path.basename(rel, '.md'); }
56
+ }
57
+
58
+ /** The best passages for q in the main checkout, best first. READ-ONLY. */
59
+ function passages({ root, q } = {}) {
60
+ const words = wordsOf(q);
61
+ if (!root || !words.length) return [];
62
+ const need = Math.min(2, words.length);
63
+ const fm = new Map(), hits = [], df = new Map(); // df: the files a word is in, so a rare word ("scarlet") weighs more than a common one ("user")
64
+ for (const raw of grep(root, words).split('\n')) {
65
+ const m = /^(.+?):(\d+):(.*)$/.exec(raw); if (!m) continue;
66
+ const [, rel, ln, line] = m;
67
+ if (Number(ln) <= fmEnd(root, rel, fm)) continue; // a frontmatter line is not a passage
68
+ const t = plain(line);
69
+ if (t.length < 20) continue;
70
+ const have = words.filter((w) => reOf(w).test(t));
71
+ if (have.length < need) continue;
72
+ hits.push({ rel, t, have });
73
+ for (const w of have) { let s = df.get(w); if (!s) { s = new Set(); df.set(w, s); } s.add(rel); }
74
+ }
75
+ const nFiles = new Set(hits.map((h) => h.rel)).size || 1;
76
+ const weight = (w) => 1 + Math.log((nFiles + 1) / ((df.get(w) || new Set()).size + 0.5));
77
+ const byFile = new Map();
78
+ for (const h of hits) {
79
+ const score = h.have.reduce((a, w) => a + weight(w), 0) * 100 - Math.min(h.t.length, 400) / 10;
80
+ let f = byFile.get(h.rel); if (!f) { f = { rel: h.rel, lines: [], best: 0 }; byFile.set(h.rel, f); }
81
+ f.lines.push({ t: h.t, score }); f.best = Math.max(f.best, score);
82
+ }
83
+ const files = [...byFile.values()].sort((a, b) => (b.best - a.best) || a.rel.localeCompare(b.rel));
84
+ const out = [];
85
+ for (const f of files) {
86
+ const seen = new Set();
87
+ for (const l of f.lines.sort((a, b) => b.score - a.score)) {
88
+ if (out.length >= MAX || seen.size >= PER_FILE) break;
89
+ const text = clip(l.t, 320); if (seen.has(text)) continue;
90
+ seen.add(text);
91
+ out.push({ n: out.length + 1, path: f.rel, title: titleOf(root, f.rel), kind: Search.kindOf(f.rel), text });
92
+ }
93
+ if (out.length >= MAX) break;
94
+ }
95
+ return out;
96
+ }
97
+
98
+ function promptOf(q, list) {
99
+ return [
100
+ 'You answer a product manager\'s question from passages of their own files. Do not use any tool. Answer with JSON only.',
101
+ `The question: "${clip(q, 300)}"`,
102
+ 'The passages, each with the file it comes from:',
103
+ list.map((p) => `${p.n}. [${clip(p.title, 100)}] ${p.text}`).join('\n'),
104
+ 'Answer the question in one or two short, plain sentences, using ONLY what the passages say. Do not guess and do not add facts.',
105
+ 'Name the numbers of the passages you used. If the passages do not answer the question, answer null.',
106
+ 'Answer: {"answer":"<one or two sentences>","used":[<passage numbers>]} or {"answer":null}',
107
+ ].join('\n\n');
108
+ }
109
+ /** The session's answer read back: { text, used: [passage] } with only passages of the list, or null. Pure. */
110
+ function parse(text, list) {
111
+ const t = String(text || '');
112
+ const at = t.indexOf('{'), end = t.lastIndexOf('}');
113
+ if (at < 0 || end < at) return null;
114
+ let o; try { o = JSON.parse(t.slice(at, end + 1)); } catch { return null; }
115
+ const a = o && typeof o.answer === 'string' ? o.answer.replace(/\s+/g, ' ').trim() : '';
116
+ if (!a) return null;
117
+ const used = [];
118
+ for (const k of Array.isArray(o.used) ? o.used : []) { const p = list.find((x) => x.n === Number(k)); if (p && !used.includes(p)) used.push(p); }
119
+ if (!used.length) return null; // an answer that names no passage has no source: it is not shown
120
+ return { text: clip(a, 400), used };
121
+ }
122
+
123
+ /* ── the session ── */
124
+ const MODEL = 'claude-sonnet-5-5';
125
+ const LEAN = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
126
+ const TIMEOUT_MS = 60000;
127
+ const KEEP_MS = 10 * 60000;
128
+ const kept = new Map(); // key → { at, value }
129
+
130
+ function viaSession(ctx, prompt, key) {
131
+ if (typeof ctx.askClaude === 'function') return Promise.resolve(ctx.askClaude(prompt, { job: 'search-ask', key })).catch(() => null);
132
+ const headless = require('./headless.js');
133
+ const origin = 'briefing-ask:search-ask:' + key;
134
+ if (typeof ctx.spawnSession !== 'function' || headless.kindFor({ agent: 'claude', origin }) !== 'ask') return Promise.resolve(null);
135
+ return new Promise((resolve) => {
136
+ let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(t); resolve(v); };
137
+ const t = setTimeout(() => done(null), TIMEOUT_MS);
138
+ let s = null;
139
+ try {
140
+ s = ctx.spawnSession({ name: 'search: answer a question', agent: 'claude', origin, initialInput: prompt,
141
+ modelAsk: { explicit: { model: MODEL, effort: 'low' } }, launchFlags: LEAN.map((f) => ({ ...f })),
142
+ onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
143
+ } catch { s = null; }
144
+ if (!s || s.state === 'exited') done(null);
145
+ });
146
+ }
147
+ const log = (given) => { try { console.log(given ? '[search-ask] given' : '[search-ask] none'); } catch { /* no console */ } };
148
+ const none = (why) => { log(false); return { ok: true, answer: null, why }; };
149
+
150
+ /** The answer to a question: the copied sentence when there is one (no session), else one written from the passages, with its sources. */
151
+ async function answer(ctx, { root, q } = {}) {
152
+ q = String(q || '').slice(0, 300).trim();
153
+ if (!isQuestion(q)) return none('not a question');
154
+ let copied = null;
155
+ try { const A = require('./search-answer.js'); copied = A.find({ root, q }).answer || null; } catch { copied = null; }
156
+ if (copied) { log(true); return { ok: true, answer: copied }; }
157
+ const list = passages({ root, q });
158
+ if (!list.length) return none('nothing in your files holds these words');
159
+ const key = crypto.createHash('sha1').update(root + '\n' + q + '\n' + list.map((p) => p.path + p.text).join('\n')).digest('hex').slice(0, 12);
160
+ const k = kept.get(key);
161
+ if (k && Date.now() - k.at < KEEP_MS) { log(!!k.value.answer); return k.value; }
162
+ const text = await viaSession(ctx || {}, promptOf(q, list), key);
163
+ if (text == null) return none('PMOS could not start a session to answer');
164
+ const p = parse(text, list);
165
+ const value = p ? { ok: true, answer: { text: p.text, facts: [], made: true, source: srcOf(p.used[0]), sources: dedupe(p.used).map(srcOf) } } : { ok: true, answer: null, why: 'your files do not answer this' };
166
+ kept.set(key, { at: Date.now(), value });
167
+ if (kept.size > 50) kept.delete(kept.keys().next().value);
168
+ log(!!value.answer);
169
+ return value;
170
+ }
171
+ const srcOf = (p) => ({ kind: p.kind, title: p.title, path: p.path, wt: 'main', main: true });
172
+ const dedupe = (used) => { const seen = new Set(); return used.filter((p) => !seen.has(p.path) && seen.add(p.path)).slice(0, 3); };
173
+
174
+ module.exports = { isQuestion, passages, promptOf, parse, answer, _kept: kept };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.737.0",
3
+ "version": "0.739.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.737.0",
9
+ "version": "0.739.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.737.0",
3
+ "version": "0.739.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",
@@ -19,6 +19,7 @@ import { productName } from './scope-chip.js'; // the product's display name (
19
19
  import * as SP from './bd-sprint.js';
20
20
  import * as WS from './work-select.js'; // the bulk move with one Undo, shared with the initiative popup and This sprint (WorkBulkDS)
21
21
  import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
22
+ import * as LE from './live-edit.js'; // a task's status or days show at once in the list, before it is read again; a failed save is put back
22
23
  import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
23
24
 
24
25
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
@@ -85,10 +86,12 @@ async function readOne(s, tries = 0) {
85
86
  if (status === 202 && tries < 8) { await new Promise((f) => setTimeout(f, 1500)); return readOne(s, tries + 1); }
86
87
  return r && r.ok ? r : null;
87
88
  }
89
+ LE.source({ model: () => DATA, redraw: () => { if (host && DATA && on()) draw(); } });
88
90
  export async function load() {
89
91
  if (SC) { if (SC.api.reload) await SC.api.reload(); return; } // an embedded list reads again through its own page
90
92
  if (!A || loading) return;
91
93
  loading = true;
94
+ const since = Date.now();
92
95
  const S = A.scope();
93
96
  const got = await Promise.all(S.map((s) => readOne(s)));
94
97
  loading = false; loadedAt = Date.now();
@@ -109,6 +112,7 @@ export async function load() {
109
112
  // ticks that left the list go with them
110
113
  const ids = new Set(DATA.tasks.map(uidOf)); for (const k of [...SEL]) if (!ids.has(k)) SEL.delete(k);
111
114
  drawSwitch(); if (on()) draw();
115
+ LE.loaded({ since }); // a change still saving stays on the new read
112
116
  }
113
117
 
114
118
  /* ── the switch in Work's header ──────────────────────────────────────────────────────────────────────────────── */