create-pmos 0.738.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.738.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,25 @@
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
+ },
36
55
  {
37
56
  "v": "0.738.0",
38
57
  "at": "2026-11-23T07:20:29.240Z",
@@ -423,25 +442,6 @@
423
442
  "k": "new"
424
443
  }
425
444
  ]
426
- },
427
- {
428
- "v": "0.714.0",
429
- "at": "2026-11-22T18:31:53.842Z",
430
- "f": 4,
431
- "prs": [
432
- {
433
- "n": 1578,
434
- "t": "One key each for approve, open, next sprint, park and Undo, plus a ? list (job #1577)",
435
- "s": "One key each for approve, open, next sprint, park and Undo, plus a ?",
436
- "k": "new"
437
- },
438
- {
439
- "n": 1579,
440
- "t": "One next step on a page that has nothing in it yet (A474)",
441
- "s": "One next step on a page that has nothing in it yet (A474)",
442
- "k": "new"
443
- }
444
- ]
445
445
  }
446
446
  ]
447
447
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@ee1d6712
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-23T07:20:25Z"}
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-23T07:20:25Z"}
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-23T07:20:25Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T07:58:30Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,23 @@
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
+ },
2
21
  {
3
22
  "v": "0.738.0",
4
23
  "at": "2026-11-23T07:20:29.240Z",
@@ -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.738.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.738.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.738.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",
@@ -8,6 +8,9 @@
8
8
  * Esc closes. On a phone it is the whole screen.
9
9
  * Above everything, when the words clearly point to one thing, one answer: a sentence copied from the user's own files, with its source
10
10
  * and the check date when it is an initiative (search-answers-first, lib/search-answer.js). ↵ on it opens the source. No answer: no row.
11
+ * A question with no such sentence (search-answers-questions): the first row says "Finding an answer in your work…" while
12
+ * GET /api/search-ask runs (one read-only PMOS session answers from passages of the user's files, lib/search-ask.js), then shows that
13
+ * answer and the files it came from. "Ask PMOS" stays the next row, to go deeper. No answer: the row goes away.
11
14
  * openSearch({ go?, q?, scope? }) go: the page's own opener ({ ini } | { ses } | { doc }), used before a page change
12
15
  * scope: the page Search opens from (UI grill U2: one search; the Board's and Intelligence's own find boxes are gone). { name, hits(q) }
13
16
  * where hits returns [{ label, rows: [{ id?, title, sub?, tag?, icon?, open() }] }]: the page's own groups, drawn first ("On this Board ·
@@ -25,8 +28,11 @@ import { adler } from './cozy-adler.js'; // session names A: the PM's name win
25
28
 
26
29
  const PHONE = 760;
27
30
  const isPhone = () => innerWidth <= PHONE;
28
- const S = { el: null, q: '', kind: 'all', scope: null, at: 0, rows: [], res: null, busy: false, err: '', wt: null, back: null, go: null, seq: 0, boards: null, sessions: null, t: 0 };
31
+ const S = { ask: null, el: null, q: '', kind: 'all', scope: null, at: 0, rows: [], res: null, busy: false, err: '', wt: null, back: null, go: null, seq: 0, boards: null, sessions: null, t: 0 };
29
32
  const KIND_ICON = { initiative: ICON.flag, document: ICON.doc, slides: ICON.slides, report: ICON.report, artifact: ICON.design, file: ICON.file, meeting: ICON.meet, session: ICON.session };
33
+ /** A question: it ends with "?" or starts with a question word, and has 3 words or more (the same rule as lib/search-ask.js isQuestion). */
34
+ const QW = /^\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;
35
+ const isQuestion = (q) => String(q || '').trim().split(/\s+/).filter(Boolean).length >= 3 && (/\?\s*$/.test(String(q).trim()) || QW.test(q));
30
36
  async function getj(p) { try { const r = await fetch(p, { credentials: 'same-origin' }); const j = await r.json().catch(() => null); return j || { ok: false, error: 'the server did not answer' }; } catch { return { ok: false, error: 'the server did not answer' }; } }
31
37
 
32
38
  function mount() {
@@ -92,6 +98,13 @@ async function run() {
92
98
  S.busy = false;
93
99
  if (!r.ok) { S.err = r.error || 'the server did not answer'; draw(); return; }
94
100
  S.res = r; draw();
101
+ // search-answers-questions: a question the copied sentence did not answer gets an answer written from the user's own files
102
+ if (!r.answer && isQuestion(q) && !(S.ask && S.ask.q === q)) {
103
+ S.ask = { q, busy: true, answer: null }; draw();
104
+ const a = await getj('/api/search-ask?q=' + encodeURIComponent(q) + wsQ('&'));
105
+ if (!S.ask || S.ask.q !== q) return;
106
+ S.ask = { q, busy: false, answer: a && a.ok && a.answer && a.answer.source ? a.answer : null }; draw();
107
+ }
95
108
  }
96
109
 
97
110
  /** Every row the palette shows for the query: the search's results, the board's initiatives and the sessions that match, each once. */
@@ -145,8 +158,11 @@ function drawList() {
145
158
  const groups = own.concat(searchGroups(rows, { phone: isPhone() }));
146
159
  const ask = q.length >= 2 ? { kind: 'ask', title: q } : null;
147
160
  // search-answers-first: the answer, with its source, is the first row; only for the words it answered and on All
148
- const A = S.res && S.res.answer && S.kind === 'all' && q.length >= 2 && String(S.res.q || '').trim() === q ? S.res.answer : null;
161
+ const A0 = S.res && S.res.answer && S.kind === 'all' && q.length >= 2 && String(S.res.q || '').trim() === q ? S.res.answer : null;
162
+ const made = !A0 && S.kind === 'all' && S.ask && S.ask.q === q ? S.ask : null; // search-answers-questions: the written answer, or its wait
163
+ const A = A0 || (made && made.answer);
149
164
  const ansRow = A && A.source ? { kind: 'answer', answer: A } : null;
165
+ const waiting = !ansRow && made && made.busy;
150
166
  // chief-of-staff C5: the one chat is the first row of Search; a page's own find (U2 scope) keeps its own hits first, then the chat
151
167
  const ownRows = own.flatMap((g) => g.rows);
152
168
  S.rows = (ansRow ? [ansRow] : []).concat(ownRows, ask ? [ask] : [], groups.slice(own.length).flatMap((g) => g.rows));
@@ -154,6 +170,7 @@ function drawList() {
154
170
  let h = '', i = 0;
155
171
  const askHtml = () => `<button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}">${svg(ICON.chat, 18)}<span class="ev-t">Ask PMOS: <b>“${esc(q)}”</b></span><span class="ev-k">${onHome() ? 'In the chat' : 'Opens the chat here'}</span></button>`;
156
172
  if (ansRow && !S.err) { h += answerHtml(ansRow.answer, i); i++; }
173
+ else if (waiting && !S.err) h += `<p class="ev-sp-empty" role="status">Finding an answer in your work…</p>`;
157
174
  // the page's own groups first (UI grill U2): what Search itself could not read is said after them
158
175
  own.forEach((g) => { h += `<p class="ev-mlbl">${esc(g.label)}</p>` + g.rows.map((r) => rowHtml(r, i++)).join(''); });
159
176
  if (ask) { h += askHtml(); i++; }
@@ -182,7 +199,9 @@ const dayOf = (iso) => { const d = new Date(String(iso) + 'T00:00:00'); return i
182
199
  function answerHtml(a, i) {
183
200
  const src = a.source, kind = { initiative: 'initiative', document: 'document', report: 'report', slides: 'slides' }[src.kind] || 'file';
184
201
  const facts = (a.facts || []).filter((f) => f.key === 'check' && dayOf(f.date)).map((f) => 'Check ' + dayOf(f.date));
185
- const from = 'From ' + (src.title || src.path) + ' (' + kind + (src.main === false ? ', draft in ' + (src.branch || src.wt) : '') + ')';
202
+ const from = a.made && Array.isArray(a.sources) && a.sources.length
203
+ ? 'From ' + a.sources.map((x) => x.title || x.path).join(', ') // written from these files (search-answers-questions)
204
+ : 'From ' + (src.title || src.path) + ' (' + kind + (src.main === false ? ', draft in ' + (src.branch || src.wt) : '') + ')';
186
205
  // the plain wrapper keeps the row as tall as its lines: the list is a flex column and would squeeze the button to its min-height
187
206
  return `<div role="none"><button type="button" class="ev-mi${i === S.at ? ' hl' : ''}" role="option" id="evo${i}" data-ev-i="${i}" aria-selected="${i === S.at}" aria-label="${esc(a.text + ' ' + facts.concat(from).join(' · '))}">${svg(KIND_ICON[src.kind] || ICON.doc, 18)}<span><b>${esc(a.text)}</b><br><span class="ev-small ev-mut">${esc(facts.concat(from).join(' · '))}</span></span></button></div>`;
188
207
  }
@@ -116,7 +116,7 @@ button.td-ev:focus-visible { outline: none; box-shadow: var(--glow); }
116
116
  .tdp-rec i { width: 9px; height: 9px; border-radius: 50%; background: var(--cz-dot-red); }
117
117
  /* Today's log */
118
118
  .tdp-lh { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); padding: 18px 0 10px; border-bottom: 1px solid var(--cz-hair); }
119
- .tdp-lh h2 { font-size: var(--fs-label); font-weight: var(--fw-strong); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink2); line-height: var(--lh-label); }
119
+ .tdp-lh h2, .tdp-gh { font-size: var(--fs-label); font-weight: var(--fw-strong); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink2); line-height: var(--lh-label); }
120
120
  .tdp-f { position: relative; display: inline-flex; align-items: center; gap: 2px; color: var(--cz-ink3); }
121
121
  .tdp-f select { appearance: none; -webkit-appearance: none; border: 0; background: none; font: inherit; font-size: var(--fs-row); color: var(--cz-ink3); padding: 6px 18px 6px 6px; min-height: 36px; text-align: right; }
122
122
  .tdp-f svg { position: absolute; right: 0; pointer-events: none; }
@@ -176,8 +176,8 @@ button.td-ev:focus-visible { outline: none; box-shadow: var(--glow); }
176
176
  }
177
177
  /* open-questions-today (A420, board QuestionsA): the Decide tab's two groups; the line under a row says what PMOS does if nobody answers */
178
178
  .oq-r .oq-u { display: flex; align-items: flex-start; gap: var(--space-4); }
179
- .oq-r .oq-u .pm-ic { flex: none; margin-top: 2px; }
179
+ .oq-r .oq-u .pm-ic { flex: none; margin-top: calc(var(--space-4) / 2); }
180
180
  @media (max-width: 760px) {
181
- .tdp-gh { padding: 18px 0 10px; font-size: var(--fs-label); font-weight: var(--fw-strong); letter-spacing: .08em; text-transform: uppercase; color: var(--cz-ink2); line-height: var(--lh-label); }
181
+ .tdp-gh { padding: var(--space-16) 0 var(--space-8); }
182
182
  .tdp-m.oq-u.d { color: var(--cz-blueink); }
183
183
  }
@@ -224,6 +224,19 @@ async function pure() {
224
224
  ok('D4 the second tap sets the due day and closes the picker', await until(() => last(A, '/api/boards/tasks/edit').body.due === '2026-11-01') && await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)));
225
225
  await p.click(C + ' [data-tkc="dates"]');
226
226
  await until(() => p.evaluate((c) => !!document.querySelector(c + ' .tkc-dp'), C));
227
+ // the keys: one day of the grid takes the focus (the start), the arrows move it, Enter picks it
228
+ await p.focus(C + ' .tkc-dp .rp-g [tabindex="0"]');
229
+ const kf = await p.evaluate(() => (document.activeElement || {}).dataset && document.activeElement.dataset.rpDay);
230
+ await p.keyboard.press('ArrowLeft'); await p.keyboard.press('ArrowUp');
231
+ const km = await p.evaluate(() => (document.activeElement || {}).dataset && document.activeElement.dataset.rpDay);
232
+ await p.keyboard.press('Enter');
233
+ ok('D4 the keys: the start day has the focus, the arrows move it a day and a week, Enter sets the start and the due day is next', kf === '2026-10-31' && km === '2026-10-23'
234
+ && await until(() => last(A, '/api/boards/tasks/edit').body.start === '2026-10-23') && await until(() => p.evaluate((c) => { const e = document.querySelector(c + ' .tkc-dp [data-rp-end="due"]'); return !!e && e.classList.contains('on'); }, C)), JSON.stringify({ kf, km, last: last(A, '/api/boards/tasks/edit') }));
235
+ // typing: a day written in an end's field, then Enter, sets that end
236
+ await p.fill(C + ' .tkc-dp [data-rp-end="due"] .rp-in', '5 Nov'); await p.keyboard.press('Enter');
237
+ ok('D4 a day typed in Due ("5 Nov") and Enter sets the due day and closes the picker', await until(() => last(A, '/api/boards/tasks/edit').body.due === '2026-11-05') && await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)), JSON.stringify(last(A, '/api/boards/tasks/edit')));
238
+ await p.click(C + ' [data-tkc="dates"]');
239
+ await until(() => p.evaluate((c) => !!document.querySelector(c + ' .tkc-dp'), C));
227
240
  await p.mouse.click(5, 5);
228
241
  ok('D4 a press outside closes the picker', await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)));
229
242
  // owner
@@ -339,6 +352,9 @@ async function pure() {
339
352
  await p.click(C + ' [data-tkc="dates"]');
340
353
  const dp = await until(() => p.evaluate((c) => { const pop = document.querySelector(c + ' .tkc-dp'); if (!pop) return null; const r = pop.getBoundingClientRect(); return r.right <= innerWidth + 1 && r.left >= -1; }, C));
341
354
  ok('D12 the picker stays on the screen', dp === true);
355
+ // on a phone the days are thumb-sized: each day's mark at least 42 px, the grid with no sideways scroll
356
+ const ph = await p.evaluate((c) => { const d = [...document.querySelectorAll(c + ' .tkc-dp .rp-g .rp-d span')]; const r = d.map((x) => x.getBoundingClientRect()); return { n: d.length, w: Math.min(...r.map((x) => x.width)), h: Math.min(...r.map((x) => x.height)), over: document.documentElement.scrollWidth > innerWidth + 1 }; }, C);
357
+ ok('D12 the phone: every day is at least 42 px, and nothing scrolls sideways', ph.n >= 28 && ph.w >= 42 && ph.h >= 42 && !ph.over, JSON.stringify(ph));
342
358
  await shot(p, 'task-phone-390-dark');
343
359
  ok('D12 the page raised no error', A.errors.length === 0, A.errors.join(' | '));
344
360
  await A.ctx.close();
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Initiative search-answers-questions: a question typed in Search gets a short answer written from passages of the user's files, with its sources. The passages, the route and the silence run in node with a made-up session; the row in pm/cozy-search.js has no browser test (TESTS rule: no new browser tests).",
3
+ "modules": [
4
+ "search-ask.test.js"
5
+ ],
6
+ "seconds": {
7
+ "search-ask.test.js": 2
8
+ }
9
+ }