create-pmos 0.391.0 → 0.393.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 +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +3 -2
- package/workspace/lib/chat-file-locate.js +28 -2
- package/workspace/lib/goal-chat.js +15 -3
- package/workspace/lib/routes-briefing-premium.js +10 -0
- package/workspace/lib/transcript-read.js +14 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/chat-ask.js +35 -0
- package/workspace/public/pm/premium-shell.js +35 -4
- package/workspace/public/pm/premium.css +6 -0
- package/workspace/server.js +25 -5
- package/workspace/test-files.json +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.393.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": {
|
|
@@ -32,6 +32,30 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.393.0",
|
|
37
|
+
"at": "2026-10-22T04:08:26.227Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1007,
|
|
42
|
+
"t": "Show Claude's questions in the chat as a card, not a picker the panel cannot show",
|
|
43
|
+
"s": "Show Claude's questions in the chat as a card, not a picker the panel cannot show"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"v": "0.392.0",
|
|
49
|
+
"at": "2026-10-22T04:00:27.581Z",
|
|
50
|
+
"f": 2,
|
|
51
|
+
"prs": [
|
|
52
|
+
{
|
|
53
|
+
"n": 1006,
|
|
54
|
+
"t": "Files Claude wrote in a git worktree open in the chat viewer",
|
|
55
|
+
"s": "Files Claude wrote in a git worktree open in the chat viewer"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
35
59
|
{
|
|
36
60
|
"v": "0.391.0",
|
|
37
61
|
"at": "2026-10-22T03:35:32.308Z",
|
|
@@ -272,30 +296,6 @@
|
|
|
272
296
|
"s": "The item keeps its whole conversation after the session ends, in the item dialog and in the session's own view, with a line saying the session ended."
|
|
273
297
|
}
|
|
274
298
|
]
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
"v": "0.373.0",
|
|
278
|
-
"at": "2026-10-21T03:11:16.462Z",
|
|
279
|
-
"f": 2,
|
|
280
|
-
"prs": [
|
|
281
|
-
{
|
|
282
|
-
"n": 982,
|
|
283
|
-
"t": "Calmer Briefing first screen: mic, calendar ⋯, pin on hover (calmer first screen 5/5)",
|
|
284
|
-
"s": "Calmer Briefing first screen: mic, calendar ⋯, pin on hover (calmer first screen 5/5)"
|
|
285
|
-
}
|
|
286
|
-
]
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"v": "0.372.0",
|
|
290
|
-
"at": "2026-10-21T02:53:20.808Z",
|
|
291
|
-
"f": 2,
|
|
292
|
-
"prs": [
|
|
293
|
-
{
|
|
294
|
-
"n": 981,
|
|
295
|
-
"t": "The Board's first screen has quiet chips, not two segmented rows (calmer first screen 4/5)",
|
|
296
|
-
"s": "The Board's first screen has quiet chips, not two segmented rows (calmer first screen 4/5)"
|
|
297
|
-
}
|
|
298
|
-
]
|
|
299
299
|
}
|
|
300
300
|
]
|
|
301
301
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T04:08:23Z"}
|
|
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-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T04:08:23Z"}
|
|
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-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-22T04:08:23Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.393.0",
|
|
4
|
+
"at": "2026-10-22T04:08:26.227Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1007,
|
|
9
|
+
"t": "Show Claude's questions in the chat as a card, not a picker the panel cannot show",
|
|
10
|
+
"s": "Show Claude's questions in the chat as a card, not a picker the panel cannot show"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"v": "0.392.0",
|
|
16
|
+
"at": "2026-10-22T04:00:27.581Z",
|
|
17
|
+
"f": 2,
|
|
18
|
+
"prs": [
|
|
19
|
+
{
|
|
20
|
+
"n": 1006,
|
|
21
|
+
"t": "Files Claude wrote in a git worktree open in the chat viewer",
|
|
22
|
+
"s": "Files Claude wrote in a git worktree open in the chat viewer"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
2
26
|
{
|
|
3
27
|
"v": "0.391.0",
|
|
4
28
|
"at": "2026-10-22T03:35:32.308Z",
|
|
@@ -432,10 +432,11 @@ Every popup has this chat, including the ones that have no row of their own: a t
|
|
|
432
432
|
- **The message box** takes several lines. **Enter** sends; **Shift+Enter** starts a new line. The box grows as you type, up to about eight lines, and then scrolls. The send button stays at its foot, also with a phone keyboard open.
|
|
433
433
|
- **Later messages** in the same dialog go to the same session. Write `/compact`, `/clear` or any other slash command, and Claude Code runs it.
|
|
434
434
|
- **What it may do** is set by your own Claude Code settings. Claude can change files and run commands. When your settings say to ask first, the question shows in the panel with its options; press one to answer.
|
|
435
|
-
- **
|
|
435
|
+
- **Claude's questions** show as a card in the conversation. Claude Code's question picker cannot show in the panel, so the session does not open it: the card shows each question with its options as buttons. Press an option to answer a single question. When Claude asks several questions, or a question takes more than one answer, press the options and then **Send answers**. You can also write your own answer in the box. A session that started before this change still opens the picker: end it in the session list, and your next message resumes the same conversation without it.
|
|
436
|
+
- **Stop** shows while Claude works. It presses Esc in the session. If Claude was stopped, the conversation shows a grey "Stopped" line.
|
|
436
437
|
- **The conversation** is Claude Code's own record, word for word. Claude's answers are formatted as Claude Code formats them: headings, bold, lists, code, tables, quotes and links (links open in a new tab). Your messages keep their line breaks, and a paste shows without the tags Claude Code wraps around it. A run of tool calls shows as one small grey line, for example "Used Read ×2, slack_read_thread". A connector tool shows its short name.
|
|
437
438
|
- **While a session runs**, the panel reads it again every 2 seconds and changes only when there is something new. The messages already on screen stay still, so nothing blinks beside the viewer.
|
|
438
|
-
- **A file Claude names** (a path such as `briefs/drafts/plan.md`, or a link to one) is underlined. Press it to read the file beside the conversation, as a tab in the viewer; on a phone, the Detail side shows it (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file
|
|
439
|
+
- **A file Claude names** (a path such as `briefs/drafts/plan.md`, or a link to one) is underlined. Press it to read the file beside the conversation, as a tab in the viewer; on a phone, the Detail side shows it (on the Chat page, the viewer opens over the conversation). Markdown shows as a page, an HTML file shows as the page it draws (press **Source** for its code), and other text files show as code. An HTML page runs its own scripts, so its toggles and charts work, but it cannot reach PMOS or the internet: a web font falls back to the system font. It is read-only. While the tab is open it shows the newest version, so a file Claude is still writing stays current. A file in a workspace PMOS serves, in a git worktree of one, or in the folder a session runs in opens here. Any other file says "Not in a workspace" and is not read.
|
|
439
440
|
- **Download a file** with the download icon at the right of its name in the viewer. An HTML file saves as **HTML** (as it is) or **PDF**. A markdown file saves as **Markdown**, **Word .docx** or **PDF**. Other text files save at once as they are, with no menu. PDF opens your browser's print window: choose **Save as PDF** there. An HTML page prints with no access to PMOS or the internet, as in the viewer. Word holds the note's headings, paragraphs, lists and tables.
|
|
440
441
|
- **Share a file** with the share icon beside download. On a phone, **Send a copy** comes first: it opens the phone's share sheet with the file, and no link is made. **Public link** makes a link to a copy of the file as it is now, for someone with no PMOS or Cloudflare login. The password is on, with a generated one you can change or turn off. The link ends after 7 days; press **1 day** or **30 days** to change it. Press **Create link**, then **Copy link and password**, and send the password in a different message. The same popover lists your **open links** with their end date and views; **Turn off** (pressed twice) deletes the copy at once. A file with a key or token in it is not shared. Links need Online and one more tunnel rule: see REMOTE.md, "Share links".
|
|
441
442
|
- **What an answer worked with** shows as buttons under it: the files Claude wrote, changed or read, the Jira tickets and Slack channels it used, and the links it named. The first one is the main one: a file Claude wrote comes first, then what it named in its words, then what it only read. When an answer finishes while the chat is open, its main one opens in the viewer by itself, once; answers that were there when you opened the chat open nothing. On a phone a bar over the message box offers it instead (**View**), so the conversation stays in view. A Jira ticket shows what PMOS last read from Jira for a board or initiative it syncs, with **Open in Jira**; a ticket PMOS has not read says so. A Slack channel or message opens with **Open in Slack**, as PMOS keeps no copy of Slack messages.
|
|
@@ -9,9 +9,16 @@
|
|
|
9
9
|
* base the session's own workspace id: a relative path resolves against its root.
|
|
10
10
|
* home the user's home folder, for ~/.
|
|
11
11
|
* reason: 'outside' (no served workspace holds the path), 'missing' (no such file), 'not-file' (a folder), 'bad' (no path).
|
|
12
|
-
* Both the path and each root are resolved to their real paths, so a symlink inside a workspace cannot lead out of it.
|
|
12
|
+
* Both the path and each root are resolved to their real paths, so a symlink inside a workspace cannot lead out of it.
|
|
13
|
+
*
|
|
14
|
+
* extraRoots({ workspaces, worktreesOf, sessionDirs, home }) -> [{ id, root }]
|
|
15
|
+
* The folders an agent session writes in that are not served workspaces (PM, 2026-10-22: files Claude wrote in a git worktree of pmos-idpf showed
|
|
16
|
+
* "Not in a workspace"). Two kinds only, so no other file on the machine becomes readable: the linked git worktrees of a served workspace's
|
|
17
|
+
* repository (the same repository, checked out in another folder) and the working folders of live sessions. Each gets a stable id `wt-<hash>`
|
|
18
|
+
* that GET /api/doc reads under the same root guard as a workspace. */
|
|
13
19
|
const fs = require('fs');
|
|
14
20
|
const path = require('path');
|
|
21
|
+
const crypto = require('crypto');
|
|
15
22
|
|
|
16
23
|
const inside = (root, p) => p === root || p.startsWith(root.endsWith(path.sep) ? root : root + path.sep);
|
|
17
24
|
const real = (p) => { try { return fs.realpathSync(p); } catch { return null; } };
|
|
@@ -46,4 +53,23 @@ function locate({ path: raw, roots = [], base = null, home = null } = {}) {
|
|
|
46
53
|
return { ok: true, ws: w.id, rel, abs: path.join(w.root, rel), name: path.basename(r), size: st.size, mtime: st.mtimeMs };
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
/** The id a non-workspace root is read under. Pure. */
|
|
57
|
+
const extraId = (root) => 'wt-' + crypto.createHash('sha1').update(path.resolve(root)).digest('hex').slice(0, 12);
|
|
58
|
+
|
|
59
|
+
/** Worktrees of the served repositories and live session folders, minus the served workspaces themselves. worktreesOf(root) -> [dir]. */
|
|
60
|
+
function extraRoots({ workspaces = [], worktreesOf = () => [], sessionDirs = [], home = null } = {}) {
|
|
61
|
+
const served = new Set(workspaces.filter((w) => w && w.root).map((w) => path.resolve(w.root)));
|
|
62
|
+
const seen = new Set(), out = [];
|
|
63
|
+
const add = (d) => {
|
|
64
|
+
if (!d || typeof d !== 'string' || !path.isAbsolute(d)) return;
|
|
65
|
+
const r = path.resolve(d);
|
|
66
|
+
if (served.has(r) || seen.has(r) || r === path.parse(r).root) return; // never the filesystem root
|
|
67
|
+
if (home && (r === path.resolve(home) || inside(r, path.resolve(home)))) return; // never the home folder or a folder above it
|
|
68
|
+
seen.add(r); out.push({ id: extraId(r), root: r });
|
|
69
|
+
};
|
|
70
|
+
for (const w of workspaces) { if (!w || !w.root) continue; let ds = []; try { ds = worktreesOf(w.root) || []; } catch { ds = []; } ds.forEach(add); }
|
|
71
|
+
sessionDirs.forEach(add);
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { locate, cleanPath, extraRoots, extraId };
|
|
@@ -192,9 +192,21 @@ function withGoalRows(model, rows) {
|
|
|
192
192
|
const count = (model.list.count || 0) + add.length;
|
|
193
193
|
return { ...model, list: { ...model.list, rows: list, count }, dock: model.dock && model.dock.needs != null ? { ...model.dock, needs: count, label: count === 1 ? 'needs you' : 'need you', next: list[0].title } : model.dock };
|
|
194
194
|
}
|
|
195
|
-
/** The Claude Code --settings for a chat session:
|
|
195
|
+
/** The Claude Code --settings for a chat session: a Stop hook and an AskUserQuestion hook, each posting to this workspace with the session's token. */
|
|
196
196
|
function hookSettings(port, host = '127.0.0.1') {
|
|
197
|
-
|
|
197
|
+
const hook = (route) => ({ type: 'http', url: 'http://' + host + ':' + port + '/api/briefing-premium/' + route, headers: { 'x-pmos-session': '$PMOS_SESSION' }, allowedEnvVars: ['PMOS_SESSION'], timeout: 10 });
|
|
198
|
+
return { hooks: { Stop: [{ hooks: [hook('goal-stop')] }], PreToolUse: [{ matcher: ASK_TOOL, hooks: [hook('ask-tool')] }] } };
|
|
199
|
+
}
|
|
200
|
+
/* chat-ask-card (bug 2026-10-22): Claude Code's question tool draws a picker in the terminal, and the chat panel cannot show it. The panel
|
|
201
|
+
* showed "Claude is working", the PM pressed Stop (Esc) and the question ended as "[Request interrupted by user for tool use]", again and
|
|
202
|
+
* again. Now the PreToolUse hook refuses the picker with this reason: the panel draws the questions from the transcript as a card with
|
|
203
|
+
* answer buttons, and the PM's answer comes back as their next message. */
|
|
204
|
+
const ASK_TOOL = 'AskUserQuestion';
|
|
205
|
+
const ASK_REASON = 'The PM is in the PMOS chat panel, not a terminal. The panel already shows these questions and their options as buttons, '
|
|
206
|
+
+ 'and the PM\'s answer comes as their next message. Do not ask again and do not guess the answer: end your turn now with one short line. '
|
|
207
|
+
+ 'If you are working on a /goal, end with a pmos-goal progress block whose state is needs-you.';
|
|
208
|
+
function askToolReply() {
|
|
209
|
+
return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: ASK_REASON } };
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
/** chat() hands a `/goal` message here: { error } or { id, prompt } with the grilling line already on record. */
|
|
@@ -229,4 +241,4 @@ function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new
|
|
|
229
241
|
return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
|
|
230
242
|
}
|
|
231
243
|
|
|
232
|
-
module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
244
|
+
module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
@@ -191,6 +191,16 @@ module.exports = {
|
|
|
191
191
|
ctx.json(res, key ? Goal.onStop({ runtimeDir: ctx.runtimeDir, key, message: body.last_assistant_message }) : {});
|
|
192
192
|
return true;
|
|
193
193
|
}
|
|
194
|
+
if (url.pathname === '/api/briefing-premium/ask-tool') {
|
|
195
|
+
// chat-ask-card: Claude Code's PreToolUse hook for AskUserQuestion in a chat session. The panel draws the question; the picker is refused.
|
|
196
|
+
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
197
|
+
await ctx.readJson(req);
|
|
198
|
+
const tok = req.headers && req.headers['x-pmos-session'];
|
|
199
|
+
const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
|
|
200
|
+
if (!who) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
|
|
201
|
+
ctx.json(res, Goal.askToolReply());
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
194
204
|
if (url.pathname === '/api/briefing-premium/seen') {
|
|
195
205
|
// popup context slice 3b: a popup the PM opened, with what it showed, so the leads session after a refresh writes its lead. Starts nothing.
|
|
196
206
|
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
@@ -438,6 +438,16 @@ function callTarget(input, root) {
|
|
|
438
438
|
return t.length > TARGET_MAX ? t.slice(0, TARGET_MAX - 1) + '…' : t;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
/* The questions of one AskUserQuestion call, as the chat panel draws them: [{ question, header, multi, options:[{ label, detail }] }].
|
|
442
|
+
* At most 4 questions of at most 6 options; a question with fewer than 2 options is dropped. Every string goes through `clean`. */
|
|
443
|
+
function askQuestions(input, clean = (x) => x) {
|
|
444
|
+
const s = (v, n) => clean(String(v == null ? '' : v).replace(/\s+/g, ' ').trim()).slice(0, n);
|
|
445
|
+
return (input && Array.isArray(input.questions) ? input.questions : []).slice(0, 4).map((q) => ({
|
|
446
|
+
question: s(q && q.question, 300), header: s(q && q.header, 40), multi: !!(q && q.multiSelect),
|
|
447
|
+
options: (q && Array.isArray(q.options) ? q.options : []).slice(0, 6).map((o) => ({ label: s(o && o.label, 120), detail: s(o && o.description, 240) })).filter((o) => o.label),
|
|
448
|
+
})).filter((q) => q.question && q.options.length >= 2);
|
|
449
|
+
}
|
|
450
|
+
|
|
441
451
|
function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = null) {
|
|
442
452
|
let raw;
|
|
443
453
|
try {
|
|
@@ -466,6 +476,8 @@ function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = nul
|
|
|
466
476
|
if (last.calls.length < CALLS_MAX) last.calls.push(call);
|
|
467
477
|
last.at = at || last.at;
|
|
468
478
|
} else out.push({ role: 'tool', tools: { [n]: 1 }, calls: [call], at: at || null });
|
|
479
|
+
// chat-ask-card: Claude Code's question tool keeps its questions, so the chat panel can draw them as a card with answer buttons
|
|
480
|
+
if (name === 'AskUserQuestion') { const q = askQuestions(input, clean); if (q.length) out[out.length - 1].ask = q; }
|
|
469
481
|
};
|
|
470
482
|
for (const line of raw.split('\n')) {
|
|
471
483
|
if (!line) continue;
|
|
@@ -492,7 +504,7 @@ function readConversation(file, clean = (x) => x, limit = CONV_LIMIT, root = nul
|
|
|
492
504
|
}
|
|
493
505
|
}
|
|
494
506
|
const messages = out.slice(-limit).map((x) => (x.role === 'tool'
|
|
495
|
-
? { role: 'tool', tools: x.tools, calls: x.calls, at: x.at }
|
|
507
|
+
? { role: 'tool', tools: x.tools, calls: x.calls, at: x.at, ...(x.ask ? { ask: x.ask } : {}) }
|
|
496
508
|
: { role: x.role, text: x.text, at: x.at }));
|
|
497
509
|
return { messages };
|
|
498
510
|
}
|
|
@@ -518,5 +530,5 @@ function permissionAsk(screen, clean = (x) => x) {
|
|
|
518
530
|
return options.length >= 2 ? { question: clean(lines[at]).slice(0, 200), options } : null;
|
|
519
531
|
}
|
|
520
532
|
|
|
521
|
-
module.exports = { permissionAsk, claudeHomes, callTarget, findTranscript, readHarness, readConversation, CONV_LIMIT, prettyTool, slugFor, resolvePid, descendants,
|
|
533
|
+
module.exports = { permissionAsk, askQuestions, claudeHomes, callTarget, findTranscript, readHarness, readConversation, CONV_LIMIT, prettyTool, slugFor, resolvePid, descendants,
|
|
522
534
|
MAX_BYTES, MAX_WALK_DEPTH, PS_SNAPSHOT_MS, defaultChildren };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.393.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.393.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* chat-ask — Claude Code's question tool (AskUserQuestion) as a card in the chat panel (bug 2026-10-22, chat-ask-card).
|
|
2
|
+
* The terminal picker cannot be shown in the panel, so a chat session's hook refuses it (lib/goal-chat.js askToolReply) and the panel draws
|
|
3
|
+
* the questions from the transcript here. One question with one answer: each option is a button that sends it. Several questions, or a
|
|
4
|
+
* question that takes several answers: the options toggle, and Send answers sends them all as one message. Pure: no DOM, so Node tests it. */
|
|
5
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
6
|
+
|
|
7
|
+
/** True when one press answers the whole card: one question that takes one answer. */
|
|
8
|
+
export const oneTap = (ask) => Array.isArray(ask) && ask.length === 1 && !ask[0].multi;
|
|
9
|
+
|
|
10
|
+
/** The PM's answer as one message. picked: { '<q>': [option index, …] }. Empty when a question has no answer yet. */
|
|
11
|
+
export function answerText(ask, picked) {
|
|
12
|
+
const qs = Array.isArray(ask) ? ask : [];
|
|
13
|
+
const parts = qs.map((q, i) => (picked && picked[i] || []).map((k) => q.options[k] && q.options[k].label).filter(Boolean));
|
|
14
|
+
if (!qs.length || parts.some((p) => !p.length)) return '';
|
|
15
|
+
if (qs.length === 1) return parts[0].join(', ');
|
|
16
|
+
return qs.map((q, i) => (q.header || q.question) + ': ' + parts[i].join(', ')).join('; ');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The card. live: the PM can still answer (nothing was written after the question); picked: the toggled options of a multi card. */
|
|
20
|
+
export function askCardHtml(ask, { live = false, picked = {}, at = '' } = {}) {
|
|
21
|
+
const qs = Array.isArray(ask) ? ask : [];
|
|
22
|
+
if (!qs.length) return '';
|
|
23
|
+
const one = oneTap(qs);
|
|
24
|
+
const body = qs.map((q, i) => {
|
|
25
|
+
const opts = q.options.map((o, k) => {
|
|
26
|
+
const on = (picked[i] || []).includes(k);
|
|
27
|
+
const act = one ? `data-chat-say="${esc(o.label)}"` : `data-ask-pick="${i}:${k}" aria-pressed="${on}"`;
|
|
28
|
+
return `<button type="button" class="chip${on ? ' on' : ''}" ${act}${o.detail ? ` title="${esc(o.detail)}"` : ''}${live ? '' : ' disabled'}>${esc(o.label)}</button>`;
|
|
29
|
+
}).join('');
|
|
30
|
+
return `<div class="askq">${q.header ? `<p class="askh">${esc(q.header)}${q.multi ? ' · pick any' : ''}</p>` : ''}<p class="tt"><b>${esc(q.question)}</b></p><div class="chips">${opts}</div></div>`;
|
|
31
|
+
}).join('');
|
|
32
|
+
const send = !one && live ? `<div class="chatopts"><button type="button" class="cta" data-ask-send="${esc(at)}"${answerText(qs, picked) ? '' : ' disabled'}>Send answers</button></div>` : '';
|
|
33
|
+
const foot = live ? '<p class="askfoot">Or write your own answer below.</p>' : '';
|
|
34
|
+
return `<p class="agtag">Claude asks</p>${body}${send}${foot}`;
|
|
35
|
+
}
|
|
@@ -10,6 +10,7 @@ import { lineItems, behindOf, whenRead } from './freshness-words.js';
|
|
|
10
10
|
import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches } from './goal-chat.js';
|
|
11
11
|
import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
|
|
12
12
|
import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
|
|
13
|
+
import { askCardHtml, answerText } from './chat-ask.js';
|
|
13
14
|
import { openReportTab } from './premium-report-tab.js';
|
|
14
15
|
import { openChartTab } from './premium-chart-tab.js';
|
|
15
16
|
/** A pmos-report block opens the Report tab, or the Chart tab for a chart or a dashboard (premium-reports-from-chat, slice C). */
|
|
@@ -423,7 +424,9 @@ export function threadHtml(th) {
|
|
|
423
424
|
export { toolLine }; // "Used Read ×2, slack_read_thread": chat-md.js shortens a connector tool's long name
|
|
424
425
|
/** The session's part of the panel: its turns, the permission question with its options, and Stop while Claude works. Pure, for Node. */
|
|
425
426
|
/** goal: the key's /goal record (GET /thread), so the newest grilling message can be pressed (slice 2, PRD G4, G5). */
|
|
426
|
-
|
|
427
|
+
/** answer: the panel can answer Claude's questions (a chat key's session; a session opened from the list answers in its terminal). */
|
|
428
|
+
const INTERRUPT = /^\[Request interrupted by user/;
|
|
429
|
+
export function sessionHtml(c, goal = null, { answer = false } = {}) {
|
|
427
430
|
if (!c) return '';
|
|
428
431
|
if (c.state === 'ended' && !(c.messages || []).length) return turnAgent('<p class="tt" role="status">This session has ended. Your next message starts a new one.</p>');
|
|
429
432
|
if (c.state !== 'conv' && c.state !== 'ended') return turnAgent(`<p class="tt" role="status">${esc(c.missing || 'Claude is starting.')}</p>`);
|
|
@@ -431,8 +434,14 @@ export function sessionHtml(c, goal = null) {
|
|
|
431
434
|
const waiting = !c.ask && c.turn !== 'agent' && c.turn !== 'tool';
|
|
432
435
|
const ctx = new Map(turnsOf(msgs, waiting || c.state === 'ended').filter((t) => t.done).map((t) => [t.at, t.items])); // premium-chat-viewer slice 2
|
|
433
436
|
const out = msgs.map((m, i) => {
|
|
434
|
-
if (m.role === 'user') return turnUser(shownUser(m.text));
|
|
435
|
-
if (m.role !== 'assistant')
|
|
437
|
+
if (m.role === 'user') return INTERRUPT.test(m.text || '') ? '<p class="toolline">Stopped</p>' : turnUser(shownUser(m.text));
|
|
438
|
+
if (m.role !== 'assistant') {
|
|
439
|
+
const line = `<p class="toolline" title="${esc((m.calls || []).map((x) => x.tool + (x.target ? ' ' + x.target : '')).join('\n'))}">${esc(toolLine(m.tools))}</p>`;
|
|
440
|
+
if (!m.ask) return line;
|
|
441
|
+
// chat-ask-card: Claude's question is a card; it can be answered until the PM writes again
|
|
442
|
+
const live = answer && c.state !== 'ended' && !msgs.slice(i + 1).some((x) => x.role === 'user');
|
|
443
|
+
return line + turnAgent(askCardHtml(m.ask, { live, picked: live ? (ASKS.picked[askId(m)] || {}) : {}, at: askId(m) }));
|
|
444
|
+
}
|
|
436
445
|
const g = splitGoal(m.text), rp = splitReport(g.text); // premium-reports-from-chat: a pmos-report block becomes a chip that opens the Report tab
|
|
437
446
|
const live = i === last && waiting && !!goal && goal.state === 'grilling';
|
|
438
447
|
return turnAgent(`<p class="agtag">Claude</p>${rp.text ? mdHtml(rp.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}${reportChipHtml(rp.block, i)}${chipsHtml(ctx.get(i))}`);
|
|
@@ -479,7 +488,8 @@ export function drawThread(th, key, conv) {
|
|
|
479
488
|
drawLead(box, th);
|
|
480
489
|
let t = $('#thr', box); if (!t) { box.insertAdjacentHTML('beforeend', '<div id="thr"></div>'); t = $('#thr', box); }
|
|
481
490
|
const b = $('#dBody'), atEnd = b.scrollHeight - b.scrollTop - b.clientHeight < 80;
|
|
482
|
-
|
|
491
|
+
S.conv = conv;
|
|
492
|
+
putHtml(t, threadHtml(th) + sessionHtml(conv, th.goal, { answer: true }));
|
|
483
493
|
ctxAuto(key, conv);
|
|
484
494
|
S.goal = th.goal || null; S.draft = readyDraft(conv); S.session = th.session || null;
|
|
485
495
|
goalView(key, conv);
|
|
@@ -640,6 +650,27 @@ async function sendText(key, text, files) {
|
|
|
640
650
|
loadThread(key);
|
|
641
651
|
return true;
|
|
642
652
|
}
|
|
653
|
+
/* chat-ask-card: the options of a card with several questions toggle, and Send answers sends them as one message */
|
|
654
|
+
const ASKS = { picked: {} };
|
|
655
|
+
const askId = (m) => String(m.at || '') + ':' + (m.ask || []).map((q) => q.question).join('|').slice(0, 80);
|
|
656
|
+
function askOf(id) { const m = ((S.conv && S.conv.messages) || []).find((x) => x.role === 'tool' && x.ask && askId(x) === id); return m ? m.ask : null; }
|
|
657
|
+
$('#dBody').addEventListener('click', async (e) => {
|
|
658
|
+
const pick = e.target.closest('[data-ask-pick]'), send = e.target.closest('[data-ask-send]');
|
|
659
|
+
if (!S.key || (!pick && !send)) return;
|
|
660
|
+
if (pick) {
|
|
661
|
+
const card = pick.closest('.tc'), btn = card && card.querySelector('[data-ask-send]');
|
|
662
|
+
const at = btn ? btn.dataset.askSend : null, ask = at != null && askOf(at); if (!ask) return;
|
|
663
|
+
const [q, k] = pick.dataset.askPick.split(':').map(Number);
|
|
664
|
+
const cur = (ASKS.picked[at] = ASKS.picked[at] || {}), had = cur[q] || [];
|
|
665
|
+
cur[q] = had.includes(k) ? had.filter((x) => x !== k) : ask[q].multi ? had.concat(k) : [k];
|
|
666
|
+
card.innerHTML = askCardHtml(ask, { live: true, picked: cur, at }); // the next poll draws the same picks
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const ask = askOf(send.dataset.askSend), text = ask && answerText(ask, ASKS.picked[send.dataset.askSend]);
|
|
670
|
+
if (!text) return;
|
|
671
|
+
send.disabled = true;
|
|
672
|
+
if (await sendText(S.key, text)) delete ASKS.picked[send.dataset.askSend];
|
|
673
|
+
});
|
|
643
674
|
async function onGoalPress(e) {
|
|
644
675
|
const say = e.target.closest('[data-chat-say]'), gb = e.target.closest('[data-goal]'), mi = e.target.closest('[data-slash]');
|
|
645
676
|
if (mi) { pickSlash(mi.dataset.slash); return; }
|
|
@@ -2675,3 +2675,9 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2675
2675
|
.plead p{margin:0 0 6px;font-size:var(--fs-3);line-height:1.5;overflow-wrap:anywhere}
|
|
2676
2676
|
.plead .fine2{color:var(--ink-3)}
|
|
2677
2677
|
.plead.none{display:flex;align-items:center;gap:10px;justify-content:space-between}.plead.none p{margin:0}
|
|
2678
|
+
|
|
2679
|
+
/* ── chat-ask-card (bug 2026-10-22): Claude's question in the chat panel, with its options as buttons. public/pm/chat-ask.js ── */
|
|
2680
|
+
.askq+.askq{margin-top:14px}
|
|
2681
|
+
.askh{margin:0 0 2px;font:600 var(--t-micro) var(--mono);color:var(--ink-3);text-transform:uppercase;letter-spacing:.04em}
|
|
2682
|
+
.chip.on{background:var(--solid);color:var(--on-solid);border-color:transparent}
|
|
2683
|
+
.askfoot{margin:8px 0 0;font-size:var(--t-small);color:var(--ink-3)}
|
package/workspace/server.js
CHANGED
|
@@ -663,6 +663,26 @@ function homeWorkspace() {
|
|
|
663
663
|
return HOME_ENABLED ? workspaces.get(wsId(SELF_ROOT)) : [...workspaces.values()][0];
|
|
664
664
|
}
|
|
665
665
|
function getWs(id) { return (id && workspaces.get(id)) || homeWorkspace(); }
|
|
666
|
+
// The folders an agent writes in that are not served workspaces: the git worktrees of a served repository and live session folders
|
|
667
|
+
// (lib/chat-file-locate.js extraRoots). A file there opens in the viewer read-only under the same root guard as a workspace. Memoised: it shells git.
|
|
668
|
+
const DOC_EXTRA_TTL_MS = 15000;
|
|
669
|
+
let docExtra = { at: 0, list: [] };
|
|
670
|
+
function docExtraRoots() {
|
|
671
|
+
if (Date.now() - docExtra.at < DOC_EXTRA_TTL_MS) return docExtra.list;
|
|
672
|
+
const list = chatFileLocate.extraRoots({
|
|
673
|
+
workspaces: [...workspaces.values()],
|
|
674
|
+
worktreesOf: (root) => gitInfo.worktrees(root).map((t) => t.dir),
|
|
675
|
+
sessionDirs: [...sessions.values()].map((s) => s && s.cwd),
|
|
676
|
+
home: os.homedir(),
|
|
677
|
+
});
|
|
678
|
+
docExtra = { at: Date.now(), list };
|
|
679
|
+
return list;
|
|
680
|
+
}
|
|
681
|
+
/** The root a document read uses: a served workspace, or a `wt-` id from docExtraRoots (an unknown `wt-` id is null, never the home workspace). */
|
|
682
|
+
function docRootOf(id) {
|
|
683
|
+
if (id && /^wt-[0-9a-f]{12}$/.test(id)) return docExtraRoots().find((r) => r.id === id) || null;
|
|
684
|
+
return getWs(id);
|
|
685
|
+
}
|
|
666
686
|
/** The registered workspace whose root is this path exactly, or null. Never the home workspace by default. */
|
|
667
687
|
function wsByRoot(root) {
|
|
668
688
|
const want = path.resolve(String(root));
|
|
@@ -7548,11 +7568,11 @@ async function handleRequest(req, res) {
|
|
|
7548
7568
|
}
|
|
7549
7569
|
if (p === '/api/doc/locate' && req.method === 'GET') {
|
|
7550
7570
|
// A file path Claude wrote in a premium chat panel: which served workspace holds it (lib/chat-file-locate.js). The panel then reads it read-only
|
|
7551
|
-
// through GET /api/doc. A path in no served workspace answers `outside`, and nothing is read.
|
|
7571
|
+
// through GET /api/doc. A path in no served workspace, no git worktree of one and no session folder answers `outside`, and nothing is read.
|
|
7552
7572
|
// a relative path is the session's own: it resolves against the folder the chat's session runs in, else the page's workspace
|
|
7553
7573
|
const sess = sessions.get(url.searchParams.get('session') || '');
|
|
7554
7574
|
const base = (sess && workspaces.get(sess.ws)) || getWs(url.searchParams.get('ws'));
|
|
7555
|
-
const r = chatFileLocate.locate({ path: url.searchParams.get('path') || '', roots: [...workspaces.values()].map((w) => ({ id: w.id, root: w.root })), base: base ? base.id : null, home: os.homedir() });
|
|
7575
|
+
const r = chatFileLocate.locate({ path: url.searchParams.get('path') || '', roots: [...[...workspaces.values()].map((w) => ({ id: w.id, root: w.root })), ...docExtraRoots()], base: base ? base.id : null, home: os.homedir() });
|
|
7556
7576
|
return json(res, r);
|
|
7557
7577
|
}
|
|
7558
7578
|
/* ── premium-viewer-share (D97): share links. Listing is a read; making and turning off a link is a page press, never an agent session. ── */
|
|
@@ -7575,7 +7595,7 @@ async function handleRequest(req, res) {
|
|
|
7575
7595
|
}
|
|
7576
7596
|
const host = shareHost();
|
|
7577
7597
|
if (!host) return json(res, { ok: false, error: 'Share links use your Online hostname. Set up Online in Settings first, or set PMOS_SHARE_HOST.' }, 409);
|
|
7578
|
-
const w =
|
|
7598
|
+
const w = docRootOf(body.ws);
|
|
7579
7599
|
const rel = String(body.path || '');
|
|
7580
7600
|
const got = w ? readTextDocWhy(w.root, rel) : { ok: false, reason: 'no such workspace' };
|
|
7581
7601
|
if (!got.ok) return json(res, { ok: false, error: got.reason }, 404);
|
|
@@ -7596,7 +7616,7 @@ async function handleRequest(req, res) {
|
|
|
7596
7616
|
// A markdown file from the viewer's download menu as Word (premium-viewer-share D4). The same guard as GET /api/doc
|
|
7597
7617
|
// (readTextDocWhy: inside the workspace, text only), built in memory by lib/report-export.js. It writes nothing and is never cached.
|
|
7598
7618
|
if (req.method !== 'GET') { res.writeHead(405, { 'Content-Type': 'text/plain; charset=utf-8' }); return res.end('GET only'); }
|
|
7599
|
-
const w =
|
|
7619
|
+
const w = docRootOf(url.searchParams.get('ws'));
|
|
7600
7620
|
const fmt = url.searchParams.get('fmt') || '';
|
|
7601
7621
|
if (fmt !== 'docx') { res.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' }); return res.end('fmt must be docx'); }
|
|
7602
7622
|
const rel = url.searchParams.get('path') || '';
|
|
@@ -7610,7 +7630,7 @@ async function handleRequest(req, res) {
|
|
|
7610
7630
|
return res.end(out.buffer);
|
|
7611
7631
|
}
|
|
7612
7632
|
if (p === '/api/doc') {
|
|
7613
|
-
const w =
|
|
7633
|
+
const w = docRootOf(url.searchParams.get('ws'));
|
|
7614
7634
|
// `ref` — a file that exists only on an initiative's own branch (status-clarity R5). Read through git, never the
|
|
7615
7635
|
// working tree, and only from an initiative branch; the reason for a refusal travels in the body.
|
|
7616
7636
|
const ref = url.searchParams.get('ref');
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"briefing-premium-writes.test.js",
|
|
40
40
|
"briefing-premium-agent.test.js",
|
|
41
41
|
"goal-chat.test.js",
|
|
42
|
+
"chat-ask.test.js",
|
|
42
43
|
"chat-md.test.js",
|
|
43
44
|
"md-table.test.js",
|
|
44
45
|
"chat-file-locate.test.js",
|
|
@@ -217,6 +218,7 @@
|
|
|
217
218
|
"briefing-premium-writes.test.js": 1,
|
|
218
219
|
"briefing-premium-agent.test.js": 1,
|
|
219
220
|
"goal-chat.test.js": 1,
|
|
221
|
+
"chat-ask.test.js": 1,
|
|
220
222
|
"chat-md.test.js": 1,
|
|
221
223
|
"md-table.test.js": 1,
|
|
222
224
|
"chat-file-locate.test.js": 1,
|