create-pmos 0.410.0 → 0.412.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 -30
- 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/briefing-premium-adddoc-test.js +2 -2
- package/workspace/briefing-premium-initiative-test.js +9 -15
- package/workspace/briefing-premium-insights-test.js +2 -2
- package/workspace/briefing-premium-test.js +3 -3
- package/workspace/changelog.json +24 -0
- package/workspace/chat-asks-test.js +146 -0
- package/workspace/guide/board.md +1 -1
- package/workspace/guide/breakdown.md +6 -13
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/home.md +24 -0
- package/workspace/guide/index.md +1 -1
- package/workspace/guide/initiative-driver.md +1 -1
- package/workspace/guide/initiatives-screen.md +1 -1
- package/workspace/guide/pm-only-acts.md +23 -24
- package/workspace/guide/today.md +1 -1
- package/workspace/home-rows-test.js +149 -56
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/briefing-premium-agent.js +8 -1
- package/workspace/lib/briefing-premium-writes.js +5 -4
- package/workspace/lib/coredoc-cli.js +1 -1
- package/workspace/lib/driver-cli.js +2 -1
- package/workspace/lib/driver-decide.js +3 -2
- package/workspace/lib/driver.js +2 -1
- package/workspace/lib/engine/boards.js +3 -1
- package/workspace/lib/goal-chat.js +94 -30
- package/workspace/lib/grant-mint.js +3 -2
- package/workspace/lib/initiative-cli.js +9 -9
- package/workspace/lib/issues.js +5 -4
- package/workspace/lib/mention-cli.js +70 -0
- package/workspace/lib/mention-store.js +307 -0
- package/workspace/lib/people-store.js +1 -1
- package/workspace/lib/people.js +3 -1
- package/workspace/lib/placements.js +13 -15
- package/workspace/lib/plan-items.js +17 -48
- package/workspace/lib/pm-guard.js +18 -5
- package/workspace/lib/pm-lines-needs.js +9 -5
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-cli.js +2 -2
- package/workspace/lib/routes-board-metric-targets.js +0 -1
- package/workspace/lib/routes-boards.js +12 -0
- package/workspace/lib/routes-briefing-premium.js +5 -7
- package/workspace/lib/routes-core-docs.js +0 -1
- package/workspace/lib/routes-custom-docs.js +0 -1
- package/workspace/lib/routes-driver.js +0 -1
- package/workspace/lib/routes-home-desk.js +1 -1
- package/workspace/lib/routes-home-review.js +1 -1
- package/workspace/lib/routes-initiative-layout.js +1 -1
- package/workspace/lib/routes-insights-records.js +0 -1
- package/workspace/lib/routes-meeting-material.js +0 -1
- package/workspace/lib/routes-mentions.js +62 -9
- package/workspace/lib/routes-onboarding.js +3 -1
- package/workspace/lib/routes-orchestrator.js +0 -1
- package/workspace/lib/routes-premium-charts.js +0 -1
- package/workspace/lib/routes-premium-dashboards.js +0 -1
- package/workspace/lib/routes-programs.js +1 -1
- package/workspace/lib/routes-records.js +1 -1
- package/workspace/lib/routes-report-design.js +7 -3
- package/workspace/lib/routes-report-setups.js +0 -1
- package/workspace/lib/routes-report-structure.js +0 -1
- package/workspace/lib/routes-runs.js +2 -5
- package/workspace/lib/routes-scan.js +0 -1
- package/workspace/lib/routes-sources.js +1 -1
- package/workspace/lib/run-answers.js +14 -5
- package/workspace/lib/scan-cli.js +2 -1
- package/workspace/lib/scan.js +2 -1
- package/workspace/lib/session-files.js +132 -0
- package/workspace/lib/session-name.js +103 -0
- package/workspace/lib/source-reads.js +4 -1
- package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +10 -8
- package/workspace/premium-chat-goal-setup-test.js +203 -0
- package/workspace/premium-chat-goal-view-test.js +28 -23
- package/workspace/premium-chat-line-test.js +189 -0
- package/workspace/premium-core-doc-issue-test.js +1 -1
- package/workspace/premium-viewer-share-test.js +5 -2
- package/workspace/premium-vw-backlog-test.js +1 -1
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +1 -1
- package/workspace/public/pm/chat-ask.js +17 -9
- package/workspace/public/pm/cozy-home-rows.css +39 -1
- package/workspace/public/pm/cozy-home.css +112 -12
- package/workspace/public/pm/cozy-search.js +2 -1
- package/workspace/public/pm/cozy-steps.css +69 -0
- package/workspace/public/pm/cozy-steps.js +90 -0
- package/workspace/public/pm/goal-chat.js +141 -23
- package/workspace/public/pm/home-app.js +68 -35
- package/workspace/public/pm/home-ask.js +121 -0
- package/workspace/public/pm/home-chat.js +120 -68
- package/workspace/public/pm/home-data.js +10 -2
- package/workspace/public/pm/home-goal.js +159 -0
- package/workspace/public/pm/home-ini.css +35 -0
- package/workspace/public/pm/home-ini.js +50 -19
- package/workspace/public/pm/home-line.css +59 -0
- package/workspace/public/pm/home-line.js +200 -0
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-mentions.js +303 -111
- package/workspace/public/pm/home-ses-name.js +65 -0
- package/workspace/public/pm/home-stage-card.js +94 -0
- package/workspace/public/pm/home-sweep.js +112 -0
- package/workspace/public/pm/home-today.js +7 -2
- package/workspace/public/pm/premium-initiative-head.js +8 -4
- package/workspace/public/pm/rename-press.js +24 -0
- package/workspace/public/pm/wf-page.css +3 -0
- package/workspace/public/pm/wf-page.js +2 -1
- package/workspace/public/premium-workflows.html +1 -0
- package/workspace/replaced-tests.json +101 -0
- package/workspace/server.js +133 -20
- package/workspace/session-names-test.js +144 -0
- package/workspace/skills/jira-push.skill +1 -0
- package/workspace/skills/morning-brief.skill +2 -1
- package/workspace/skills/report-daily.skill +1 -0
- package/workspace/skills/report-monthly.skill +1 -0
- package/workspace/skills/report-weekly.skill +1 -0
- package/workspace/skills/sources-read.skill +3 -2
- package/workspace/stage-card-test.js +203 -0
- package/workspace/test-lists/chat-asks.json +13 -0
- package/workspace/test-lists/chat-progress.json +13 -0
- package/workspace/test-lists/mentions-a-plus.json +9 -0
- package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
- package/workspace/test-lists/session-files.json +5 -0
- package/workspace/test-lists/session-names.json +13 -0
- package/workspace/test-lists/stage-card.json +6 -0
- package/workspace/tk-tasks-test.js +1 -1
- package/workspace/workflows-setup-test.js +17 -0
package/workspace/lib/scan.js
CHANGED
|
@@ -88,7 +88,8 @@ const REPORT_RE = /^r-[0-9a-f]{10}$/;
|
|
|
88
88
|
const PROPOSAL_RE = /^p-[0-9a-f]{10}$/;
|
|
89
89
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
90
90
|
const oneLine = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
91
|
-
|
|
91
|
+
// D98: a press line by the PM or an agent session takes effect; the line keeps who wrote it.
|
|
92
|
+
const pm = (by) => typeof by === 'string' && (by.startsWith('pm:') || by.startsWith('agent:'));
|
|
92
93
|
const newId = (prefix, bytes = 4) => `${prefix}-${crypto.randomBytes(bytes).toString('hex')}`;
|
|
93
94
|
const refuse = (status, error) => ({ ok: false, status, error });
|
|
94
95
|
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* session-files.js — a file outside every workspace that one session may still show in the viewer (PM, 2026-10-25: "Should be able to read any
|
|
3
|
+
* file, even outside workspace", on a session's scratchpad file that answered "Not in a workspace"). The phone reaches the workspace over the
|
|
4
|
+
* network, so this is NOT an arbitrary-path read. Two kinds of file only, both tied to the session the chat belongs to:
|
|
5
|
+
* - a file Claude itself named in that session (its words or its tool calls in the transcript; never a tool result, which can hold any text),
|
|
6
|
+
* - a file in that session's own scratchpad folder (<tmp>/claude-<uid>/<project slug>/<session id>/scratchpad).
|
|
7
|
+
* Read-only: the server sends the text and the viewer shows it sandboxed or offers it as a download. Nothing is run.
|
|
8
|
+
*
|
|
9
|
+
* allow({ path, transcript, sessionId, base, home, tmpRoots, uid }) -> { ok: true, real, name, size, mtime, via } | { ok: false, reason, why }
|
|
10
|
+
* path what Claude wrote: absolute, ~/… or relative to the session's folder (base).
|
|
11
|
+
* transcript the session's transcript file (.jsonl). Without one, nothing is allowed.
|
|
12
|
+
* via 'scratchpad' | 'named'.
|
|
13
|
+
* reason: 'outside' (not named and not in the scratchpad), 'missing', 'not-file', 'private', 'large', 'bad'.
|
|
14
|
+
* The path is resolved to its real path and the rules are checked again on that path, so a symlink cannot lead to a file nobody named. */
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const os = require('os');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { cleanPath } = require('./chat-file-locate.js');
|
|
19
|
+
|
|
20
|
+
const MAX_FILE_BYTES = 2 * 1024 * 1024; // the same cap as a workspace read of an unknown text file
|
|
21
|
+
const MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024; // only the newest part of a very long transcript is read
|
|
22
|
+
|
|
23
|
+
const inside = (root, p) => p === root || p.startsWith(root.endsWith(path.sep) ? root : root + path.sep);
|
|
24
|
+
const real = (p) => { try { return fs.realpathSync(p); } catch { return null; } };
|
|
25
|
+
|
|
26
|
+
// Files that hold keys or passwords stay closed even when a session named them.
|
|
27
|
+
const PRIVATE_DIRS = new Set(['.ssh', '.gnupg', '.aws', '.azure', '.kube', '.docker', '.password-store', 'Keychains', '.config/gcloud']);
|
|
28
|
+
const PRIVATE_NAME = /^(\.env(\..+)?|\.netrc|\.npmrc|\.pypirc|\.git-credentials|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|credentials(\.json)?)$/i;
|
|
29
|
+
const SYSTEM = ['/dev', '/proc', '/sys'];
|
|
30
|
+
function isPrivate(p) {
|
|
31
|
+
if (SYSTEM.some((s) => inside(s, p))) return true;
|
|
32
|
+
const parts = p.split(path.sep);
|
|
33
|
+
if (parts.some((s) => PRIVATE_DIRS.has(s))) return true;
|
|
34
|
+
if (/\/\.config\/gcloud(\/|$)/.test(p)) return true;
|
|
35
|
+
return PRIVATE_NAME.test(path.basename(p));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* What Claude itself wrote in the session: the text and tool-call inputs of assistant records, as one string. Memoised per file size and time. */
|
|
39
|
+
const said = new Map(); // file -> { stamp, text }
|
|
40
|
+
function claudeSaid(file) {
|
|
41
|
+
let st; try { st = fs.statSync(file); } catch { return ''; }
|
|
42
|
+
const stamp = st.size + ':' + st.mtimeMs;
|
|
43
|
+
const hit = said.get(file);
|
|
44
|
+
if (hit && hit.stamp === stamp) return hit.text;
|
|
45
|
+
let raw = '';
|
|
46
|
+
try {
|
|
47
|
+
const fd = fs.openSync(file, 'r');
|
|
48
|
+
try {
|
|
49
|
+
const len = Math.min(st.size, MAX_TRANSCRIPT_BYTES);
|
|
50
|
+
const buf = Buffer.alloc(len);
|
|
51
|
+
fs.readSync(fd, buf, 0, len, st.size - len);
|
|
52
|
+
raw = buf.toString('utf8');
|
|
53
|
+
} finally { fs.closeSync(fd); }
|
|
54
|
+
} catch { return ''; }
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const line of raw.split('\n')) {
|
|
57
|
+
if (!line.includes('"assistant"')) continue;
|
|
58
|
+
let r; try { r = JSON.parse(line); } catch { continue; }
|
|
59
|
+
if (!r || r.type !== 'assistant' || !r.message) continue;
|
|
60
|
+
const c = r.message.content;
|
|
61
|
+
if (typeof c === 'string') { out.push(c); continue; }
|
|
62
|
+
for (const b of Array.isArray(c) ? c : []) {
|
|
63
|
+
if (b && b.type === 'text' && typeof b.text === 'string') out.push(b.text);
|
|
64
|
+
else if (b && b.type === 'tool_use' && b.input) out.push(...Object.values(b.input).filter((v) => typeof v === 'string'));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const text = out.join('\n');
|
|
68
|
+
if (said.size > 50) said.clear();
|
|
69
|
+
said.set(file, { stamp, text });
|
|
70
|
+
return text;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** True when `p` stands in `text` as a whole path: not as the start of a longer one (`/a/b` in `/a/bc` or `/a/b/c`). Pure. */
|
|
74
|
+
function names(text, p) {
|
|
75
|
+
if (!p || !text) return false;
|
|
76
|
+
let i = text.indexOf(p);
|
|
77
|
+
while (i !== -1) {
|
|
78
|
+
const before = i === 0 ? '' : text[i - 1];
|
|
79
|
+
const after = text.slice(i + p.length, i + p.length + 2);
|
|
80
|
+
const okBefore = !before || !/[A-Za-z0-9_.\-/~]/.test(before);
|
|
81
|
+
const okAfter = !after || !/^([A-Za-z0-9_\-/]|\.[A-Za-z0-9_])/.test(after);
|
|
82
|
+
if (okBefore && okAfter) return true;
|
|
83
|
+
i = text.indexOf(p, i + 1);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The session's scratchpad folders that exist, as real paths. The slug is the transcript's own project folder name. */
|
|
89
|
+
function scratchpads({ transcript, sessionId, tmpRoots, uid }) {
|
|
90
|
+
if (!transcript || !sessionId || !/^[A-Za-z0-9-]+$/.test(sessionId)) return [];
|
|
91
|
+
const slug = path.basename(path.dirname(transcript));
|
|
92
|
+
if (!slug || slug === '.' || slug === '..') return [];
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const t of tmpRoots) {
|
|
95
|
+
const r = real(path.join(t, 'claude-' + uid, slug, sessionId, 'scratchpad'));
|
|
96
|
+
if (r && !out.includes(r)) out.push(r);
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function allow({ path: raw, transcript = null, sessionId = null, base = null, home = os.homedir(), tmpRoots = ['/tmp', '/private/tmp', os.tmpdir()], uid = typeof process.getuid === 'function' ? process.getuid() : 0 } = {}) {
|
|
102
|
+
const p = cleanPath(raw);
|
|
103
|
+
if (!p || p.length > 4096 || p.includes('\0')) return { ok: false, reason: 'bad', why: 'There is no file path to open.' };
|
|
104
|
+
const outside = { ok: false, reason: 'outside', why: 'This file is not in a workspace PMOS serves, and this session did not name it, so it is not shown here.' };
|
|
105
|
+
if (!transcript) return outside;
|
|
106
|
+
let abs;
|
|
107
|
+
if (p === '~' || p.startsWith('~/')) abs = home ? path.join(home, p.slice(2)) : null;
|
|
108
|
+
else if (path.isAbsolute(p)) abs = path.resolve(p);
|
|
109
|
+
else abs = base ? path.resolve(base, p) : null;
|
|
110
|
+
if (!abs) return outside;
|
|
111
|
+
const r = real(abs);
|
|
112
|
+
const pads = scratchpads({ transcript, sessionId, tmpRoots, uid });
|
|
113
|
+
const text = claudeSaid(transcript);
|
|
114
|
+
// named: the real path, or the path as written when only its folders are links (macOS /tmp is /private/tmp) and the file itself is not
|
|
115
|
+
const parent = real(path.dirname(abs));
|
|
116
|
+
const fileIsLink = !!(r && parent && path.join(parent, path.basename(abs)) !== r);
|
|
117
|
+
const named = !!r && (names(text, r) || (!fileIsLink && names(text, abs)));
|
|
118
|
+
const inPad = !!(r && pads.some((d) => inside(d, r) && r !== d));
|
|
119
|
+
if (!r) {
|
|
120
|
+
// a missing file says so only when the session could have opened it, so the answer never tells whether some other path exists
|
|
121
|
+
if (names(text, abs) || (parent && pads.some((d) => inside(d, parent)))) return { ok: false, reason: 'missing', why: 'There is no such file. It may have been moved or not written yet.' };
|
|
122
|
+
return outside;
|
|
123
|
+
}
|
|
124
|
+
if (!named && !inPad) return outside;
|
|
125
|
+
if (isPrivate(r) || isPrivate(abs)) return { ok: false, reason: 'private', why: 'This file can hold keys or passwords, so PMOS does not show it.' };
|
|
126
|
+
let st; try { st = fs.statSync(r); } catch { return { ok: false, reason: 'missing', why: 'The file could not be read.' }; }
|
|
127
|
+
if (!st.isFile()) return { ok: false, reason: 'not-file', why: 'This is not a file.' };
|
|
128
|
+
if (st.size > MAX_FILE_BYTES) return { ok: false, reason: 'large', why: 'The file is larger than 2 MB, so it is not shown here.' };
|
|
129
|
+
return { ok: true, real: r, name: path.basename(r), size: st.size, mtime: st.mtimeMs, via: inPad ? 'scratchpad' : 'named' };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = { allow, names, scratchpads, isPrivate, claudeSaid, MAX_FILE_BYTES };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* session-name.js — what a session is called, and Claude naming it by itself (testing feedback 2026-10-25, canvas XmsNames, agreed A).
|
|
3
|
+
*
|
|
4
|
+
* shownName(s) → the name every surface shows: the PM's own name when they gave one, else Claude's, else the
|
|
5
|
+
* CLI's opening title, else the name the session was started with
|
|
6
|
+
* due(s, { hx, automatic }) → 'first' | 'recheck' | null whether Claude should name the session now
|
|
7
|
+
* promptFor({ first, last, answer, current }) → the one prompt the namer reads
|
|
8
|
+
* parseName(text) → a clean name of at most NAME_MAX characters, 'KEEP', or null
|
|
9
|
+
* argv() → the argv after `claude` for the one-shot naming run
|
|
10
|
+
* apply(s, name, turns, at) → true when the record changed: Claude's name lands, or KEEP marks the check; never over the
|
|
11
|
+
* PM's own name
|
|
12
|
+
*
|
|
13
|
+
* The rules (Wawan, canvas comment 2026-10-25 01:53 "no need to ask, just rename"):
|
|
14
|
+
* - Claude names the session after its FIRST REAL ANSWER (the model finished a turn with words), not after the first prompt, and says
|
|
15
|
+
* nothing about it: no chip, no question.
|
|
16
|
+
* - It names it again only if the job changed. Every RECHECK_TURNS real turns it is asked once more, with the name it has, and keeps it
|
|
17
|
+
* (KEEP) unless the work has clearly moved on.
|
|
18
|
+
* - A name the PM typed always wins and locks it (s.nameBy === 'pm'): Claude never renames that session again.
|
|
19
|
+
*
|
|
20
|
+
* The naming run is `claude -p` with no tools and no saved session: it reads the PM's first message, the latest one and Claude's latest
|
|
21
|
+
* answer, and prints a name. It runs under the PM's own login, like every headless job (D75). Pure: no I/O, no process; server.js runs it.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const NAME_MAX = 60;
|
|
25
|
+
const RECHECK_TURNS = 12; // real model turns between two "does the name still fit?" checks
|
|
26
|
+
const MIN_ANSWER = 20; // an answer shorter than this ("OK.", "On it.") is not a real answer yet
|
|
27
|
+
const RETRY_MS = 10 * 60 * 1000; // a failed run is tried again after this long
|
|
28
|
+
|
|
29
|
+
const clip = (t, n) => { const s = String(t == null ? '' : t).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
|
|
30
|
+
|
|
31
|
+
/** The name every surface shows for a session row (the server's own record or the wire row). */
|
|
32
|
+
function shownName(s) {
|
|
33
|
+
if (!s) return '';
|
|
34
|
+
const by = s.nameBy || s.name_by;
|
|
35
|
+
const auto = s.autoName ? s.autoName.text : s.auto_name;
|
|
36
|
+
const cli = s.hx && s.hx.title;
|
|
37
|
+
if (by === 'pm') return s.name || auto || cli || '';
|
|
38
|
+
return auto || cli || s.name || '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether Claude should name this session now. `hx` is the harness read (lib/transcript-read.js): `turns` counts real model turns and
|
|
43
|
+
* `turn === 'user'` means the model finished speaking. `automatic` is true for a job the workspace started (a skill, a schedule): those
|
|
44
|
+
* are named by what started them.
|
|
45
|
+
*/
|
|
46
|
+
function due(s, { hx, automatic = false, now = Date.now() } = {}) {
|
|
47
|
+
if (!s || s.nameBy === 'pm') return null;
|
|
48
|
+
if (s.agent !== 'claude' || s.headless || automatic || s.state === 'exited') return null;
|
|
49
|
+
if (!hx || !hx.turns || hx.turn !== 'user') return null;
|
|
50
|
+
if (s.nameFail && now - s.nameFail.at < RETRY_MS && s.nameFail.turns === hx.turns) return null;
|
|
51
|
+
if (!s.autoName) return 'first';
|
|
52
|
+
const last = s.autoName.checked || s.autoName.turns || 0;
|
|
53
|
+
return hx.turns - last >= RECHECK_TURNS ? 'recheck' : null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function promptFor({ first, last, answer, current }) {
|
|
57
|
+
const lines = [
|
|
58
|
+
'Name this working session in 2 to 6 words, the way a person titles a to-do: sentence case, starting with a verb, naming the job (for example: Shortlist CIAM tender vendors).',
|
|
59
|
+
'No quotes, no ending period, no session or chat words. Reply with the name only, on one line.',
|
|
60
|
+
];
|
|
61
|
+
if (current) lines.push(`Its name now is: ${clip(current, NAME_MAX)}. If that still names the job, reply KEEP. Give a new name only when the job has clearly changed.`);
|
|
62
|
+
lines.push('', 'The PM first asked:', clip(first, 600));
|
|
63
|
+
if (last && last !== first) lines.push('', 'The PM most recently asked:', clip(last, 400));
|
|
64
|
+
lines.push('', 'Claude answered:', clip(answer, 800));
|
|
65
|
+
return lines.join('\n');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The first line of the run's text, cleaned: quotes, a leading "Name:" and an ending period are dropped. */
|
|
69
|
+
function parseName(text) {
|
|
70
|
+
let t = String(text == null ? '' : text).split('\n').map((l) => l.trim()).find(Boolean) || '';
|
|
71
|
+
t = t.replace(/^(?:session\s+)?(?:name|title)\s*:\s*/i, '').replace(/^["'“‘`*_]+|["'”’`*_]+$/g, '').replace(/[.。]+$/, '').replace(/[\u0000-\u001f\u007f]/g, '').trim();
|
|
72
|
+
if (!t) return null;
|
|
73
|
+
if (/^keep$/i.test(t)) return 'KEEP';
|
|
74
|
+
if (t.length > NAME_MAX) t = t.slice(0, NAME_MAX).replace(/\s+\S*$/, '') || t.slice(0, NAME_MAX);
|
|
75
|
+
return t;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The PM's first message, the latest one, and Claude's latest answer, from a conversation read; null until there is a real answer. */
|
|
79
|
+
function exchangeOf(messages) {
|
|
80
|
+
const ms = Array.isArray(messages) ? messages : [];
|
|
81
|
+
const users = ms.filter((m) => m && m.role === 'user' && m.text);
|
|
82
|
+
let answer = null;
|
|
83
|
+
for (let i = ms.length - 1; i >= 0; i--) if (ms[i] && ms[i].role === 'assistant' && ms[i].text) { answer = ms[i].text; break; }
|
|
84
|
+
if (!users.length || !answer || String(answer).trim().length < MIN_ANSWER) return null;
|
|
85
|
+
return { first: users[0].text, last: users[users.length - 1].text, answer };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** What the naming run's answer does to the session record. The PM's name always wins, even over a run that started before it. */
|
|
89
|
+
function apply(s, name, turns, at) {
|
|
90
|
+
if (!s || !name || s.nameBy === 'pm') return false;
|
|
91
|
+
if (name === 'KEEP' || (s.autoName && name === s.autoName.text)) {
|
|
92
|
+
if (!s.autoName) return false; // nothing to keep: the first run must give a name
|
|
93
|
+
s.autoName = { ...s.autoName, checked: turns };
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
s.autoName = { text: name, at, turns };
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** No tools, nothing saved, JSON out: the run can only print a name. */
|
|
101
|
+
const argv = () => ['-p', '--output-format', 'json', '--no-session-persistence', '--tools', ''];
|
|
102
|
+
|
|
103
|
+
module.exports = { shownName, due, promptFor, parseName, exchangeOf, argv, apply, NAME_MAX, RECHECK_TURNS, MIN_ANSWER, RETRY_MS };
|
|
@@ -71,7 +71,8 @@ function item(x, source, i) {
|
|
|
71
71
|
const at = `item ${i + 1} of ${source}`;
|
|
72
72
|
if (!isObj(x)) return { ok: false, error: `${at} must be an object` };
|
|
73
73
|
const r = fields(x, [['title', T(LIMITS.title)], ['link', (v) => link(v, at + ' link')], ['where', T(LIMITS.short)], ['who', T(LIMITS.short)],
|
|
74
|
-
['at', T(40)], ['about', T(LIMITS.about)], ['ask', T(LIMITS.ask)], ['due', T(40)], ['mention', B], ['reply_needed', B]
|
|
74
|
+
['at', T(40)], ['about', T(LIMITS.about)], ['ask', T(LIMITS.ask)], ['due', T(40)], ['mention', B], ['reply_needed', B],
|
|
75
|
+
['replied', B], ['broadcast', B]]);
|
|
75
76
|
if (!r.ok) return { ok: false, error: `${at}: ${r.error}` };
|
|
76
77
|
if (!r.v.title) return { ok: false, error: `${at} has no title` };
|
|
77
78
|
if (x.initiative_id !== undefined) {
|
|
@@ -166,6 +167,8 @@ function write(runtimeDir, r, now = new Date()) {
|
|
|
166
167
|
const tmp = `${f}.${process.pid}.tmp`;
|
|
167
168
|
fs.writeFileSync(tmp, JSON.stringify(rec) + '\n');
|
|
168
169
|
fs.renameSync(tmp, f);
|
|
170
|
+
// its mentions are kept apart, so the next read (which replaces this one) cannot lose one that still waits on the PM
|
|
171
|
+
try { require('./mention-store.js').ingestRead(runtimeDir, rec); } catch { /* the read is saved; Mentions reads it again on its next GET */ }
|
|
169
172
|
return rec;
|
|
170
173
|
}
|
|
171
174
|
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* proposed { id, kind:'proposed', proposal_id, scan_id, candidate, at, why } written by the scan process
|
|
9
9
|
* decided { id, kind:'decided', proposal_id, decision: approve|reject|revise, revision?, why, at } by (and via) from the call path
|
|
10
10
|
* fold(lines) gives each proposal its state: open | approved | rejected | revised. The latest decision wins; earlier ones stay in `history`.
|
|
11
|
-
* A decision is a PM press: decide() and approveBulk() take the actor as an argument and
|
|
11
|
+
* A decision is a PM press or an agent session's (D98): decide() and approveBulk() take the actor as an argument and
|
|
12
|
+
* refuse anything that is not 'human:' or 'agent:'.
|
|
12
13
|
*/
|
|
13
14
|
const fs = require('fs');
|
|
14
15
|
const path = require('path');
|
|
@@ -20,10 +21,13 @@ const SCAN_ACTOR = { by: 'process:onboarding-scan', via: 'cli' };
|
|
|
20
21
|
|
|
21
22
|
const inside = (child, parent) => { const r = path.relative(path.resolve(parent), path.resolve(child)); return r === '' || (!r.startsWith('..') && !path.isAbsolute(r)); };
|
|
22
23
|
|
|
23
|
-
/** The actor of a decision as ledger.append wants it ({by, via}). A bare string 'human:wawan' is a PM press;
|
|
24
|
+
/** The actor of a decision as ledger.append wants it ({by, via}). A bare string 'human:wawan' is a PM press; an
|
|
25
|
+
* `agent:…` actor is an agent session deciding (D98), and the line keeps its name. Anything else is refused. */
|
|
24
26
|
function humanActor(actor) {
|
|
25
27
|
const a = typeof actor === 'string' ? { by: actor, via: 'ui' } : actor;
|
|
26
|
-
|
|
28
|
+
// An agent is agent:<session> (the workspace) or claude-code/<skill> (scripts/trust/ledger.js actorFrom).
|
|
29
|
+
const ok = a && typeof a.by === 'string' && ((a.by.startsWith('human:') && a.by.length > 'human:'.length) || /^agent:(?:unknown|sess-\d+\.[0-9a-f]{8})$/.test(a.by) || /^claude-code\/[\w-]+$/.test(a.by));
|
|
30
|
+
if (!ok) throw new Error('a decision is made by the PM (human:<name>) or an agent session (agent:<session>) (got ' + (a && a.by ? a.by : 'none') + ')');
|
|
27
31
|
return { by: a.by, via: a.via || 'ui' };
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.412.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.412.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -188,7 +188,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
|
|
|
188
188
|
const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
|
|
189
189
|
const ip = I.page;
|
|
190
190
|
const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
|
|
191
|
-
const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('.hm-card
|
|
191
|
+
const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('.hm-card .cz-sl'); }), 60000);
|
|
192
192
|
ok('I0 the expand link lands on Home with the initiative selected, ws and board kept', !!landed, await ip.evaluate(() => location.href));
|
|
193
193
|
await ip.click('#czViewer .hi-pgh [data-hi-addtask]'); // the initiative's page (canvas HbC): its + drills into Tasks
|
|
194
194
|
await until(() => ip.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 60000);
|
|
@@ -206,21 +206,23 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
|
|
|
206
206
|
await ip.click('#czViewer [data-ov-life-no]');
|
|
207
207
|
ok('I3 Not now takes the question back', await until(() => ip.evaluate(() => !document.querySelector('#czViewer #ovWhy') && !!document.querySelector('#czViewer [data-ov-life="on-hold"]'))));
|
|
208
208
|
await ip.click('#czViewer [data-cz-vw="back"]'); // ← from Stage: the initiative's page again (canvas HbCDrill)
|
|
209
|
-
// the card:
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
// the card (stage card D): its last node, the next stage, opens the move popover with Move now and Back; Back always asks for a reason,
|
|
210
|
+
// and the move line carries it (InStage)
|
|
211
|
+
const openNext = async () => { await until(() => ip.evaluate(() => !!document.querySelector('.hm-card [data-hi-next]')), 30000); await ip.click('.hm-card [data-hi-next]'); return until(() => ip.evaluate(() => !!document.querySelector('.hi-pop [data-hi-goback]'))); };
|
|
212
|
+
const back = await openNext();
|
|
213
|
+
ok('I4 the card\'s next stage opens Move to the next stage now and Back', back && await ip.evaluate(() => /^Move to .+ now$/.test(((document.querySelector('.hi-pop [data-hi-go]') || {}).textContent || '').trim())));
|
|
212
214
|
if (back) {
|
|
213
215
|
const m0 = lines('boards.jsonl').filter((l) => l.kind === 'move').length;
|
|
214
|
-
await ip.click('.
|
|
216
|
+
await ip.click('.hi-pop [data-hi-goback]');
|
|
215
217
|
const asked = await until(() => ip.evaluate(() => { const d = document.querySelector('.hi-pop[role="dialog"]'); return d ? { go: d.querySelector('[data-hi-go]').disabled, chips: d.querySelectorAll('[data-hi-why]').length } : null; }));
|
|
216
218
|
ok('I4 Back asks why first: Move back waits for a reason and records nothing yet', !!asked && asked.go === true && asked.chips === 4 && lines('boards.jsonl').filter((l) => l.kind === 'move').length === m0, JSON.stringify(asked));
|
|
217
219
|
await ip.click('.hi-pop [data-hi-why="New research"]'); await ip.fill('.hi-pop #hiWhy', 'Interviews changed the scope');
|
|
218
220
|
await ip.click('.hi-pop [data-hi-go]');
|
|
219
221
|
ok('I4 Move back records one move line with the reason as its why', await until(() => { const L = lines('boards.jsonl').filter((l) => l.kind === 'move'); const x = L[L.length - 1]; return L.length === m0 + 1 && x.id === 'pa-one' && x.to === bar.cur && x.why === 'Back: New research. Interviews changed the scope'; }), JSON.stringify(lines('boards.jsonl').filter((l) => l.kind === 'move').slice(-1)));
|
|
220
222
|
ok('I4 the Undo toast shows after the move', await until(() => ip.evaluate(() => { const t = document.querySelector('#hiToast'); return !!t && !t.hidden && /moved to/.test(t.textContent) && !!t.querySelector('[data-hi-undo]'); })));
|
|
221
|
-
await
|
|
222
|
-
await ip.click('.
|
|
223
|
-
ok('I5 the Moves on by itself switch is a file-mode record of the initiative', await until(() => lines('initiative-layout.jsonl').some((l) => l.kind === 'auto' && l.initiative === 'pa-one' && l.on === false)) && await until(() => ip.evaluate(() => (document.querySelector('.
|
|
223
|
+
await openNext();
|
|
224
|
+
await ip.click('.hi-pop [data-hi-auto]');
|
|
225
|
+
ok('I5 the Moves on by itself switch is a file-mode record of the initiative', await until(() => lines('initiative-layout.jsonl').some((l) => l.kind === 'auto' && l.initiative === 'pa-one' && l.on === false)) && await until(() => ip.evaluate(() => (document.querySelector('.hi-pop [data-hi-auto]') || {}).getAttribute && document.querySelector('.hi-pop [data-hi-auto]').getAttribute('aria-checked') === 'false')));
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
/* S the PMOS-self board: the model says self, the page offers no move and no New initiative */
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-chat-goal-setup-test.js — the goal before Start in a Home chat (XcbOptions B, row 1; Ready for development 2026-10-25).
|
|
4
|
+
* A real server on a scratch repository (c3-scan-fixture.js); the thread, the conversation and the presses are routed, so each state is set here.
|
|
5
|
+
* M1 a question names its method in one line with Change, draws one dot per point (no S M A R T letters) and tap answers, one recommended
|
|
6
|
+
* M2 Change opens the other methods; a pick sends the method message, which reads as "Ask with …"
|
|
7
|
+
* P1 the ready plan is a card in the chat with Start (go arrow), Change and Cancel as icons; Start sends the plan
|
|
8
|
+
* E1 Change turns the card into an editor in place: type in a point, + adds one, × removes one, the arrow keys move one; ✓ sends the plan
|
|
9
|
+
* E2 a redraw while editing keeps what was typed; × discards the changes
|
|
10
|
+
* K1 a working goal's Goal view has × on a point that has not started, none on the point Claude is on; × sends the skip; Undo sends it back
|
|
11
|
+
* Q1 /goal while a goal works shows the choice instead of sending; Here, instead stops the goal (replace), then sends the new /goal
|
|
12
|
+
* Q2 In a new chat opens a new chat and sends the goal there; the old goal is not touched
|
|
13
|
+
* F1 no page error and no sideways scroll at 1280 and 390, light and dark
|
|
14
|
+
* Set GOAL_SETUP_SHOTS=<dir> to save the page. */
|
|
15
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
16
|
+
require('./test-run').configure({ name: 'premium-chat-goal-setup' });
|
|
17
|
+
const Fx = require('./c3-scan-fixture.js');
|
|
18
|
+
|
|
19
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
20
|
+
const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
21
|
+
const results = [];
|
|
22
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
|
|
23
|
+
let F = null, browser = null;
|
|
24
|
+
const finish = async (code) => {
|
|
25
|
+
if (browser) await browser.close().catch(() => {});
|
|
26
|
+
if (F) F.stop();
|
|
27
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
28
|
+
console.log(`\n${results.length - bad}/${results.length} premium-chat-goal-setup assertions passed`);
|
|
29
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
30
|
+
};
|
|
31
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
32
|
+
|
|
33
|
+
const fence = (o) => '\n\n```pmos-goal\n' + JSON.stringify(o) + '\n```';
|
|
34
|
+
const PTS = [{ name: 'What it delivers', agreed: true }, { name: 'The done points' }, { name: 'By when' }, { name: 'What it may do' }];
|
|
35
|
+
const QUESTION = 'I read the PRD folder.' + fence({ step: 'question', method: 'done-criteria', why: 'it ends in a document', points: PTS, question: 'What must be true for the draft to be review-ready?', options: [{ label: 'Parity table, open questions with owners, out-of-scope list', recommended: true }, { label: 'Only the parity table' }], draft: { goal: 'Bring the PRD to a review-ready draft' } });
|
|
36
|
+
const DRAFT = { goal: 'Bring the descope-feature-parity PRD to a review-ready draft', done: ['Parity table: every Descope feature against ours', 'Open questions, each with an owner', 'Out-of-scope list, with SSO on it', "Ready for Dita's review"], by: 'Friday', may: 'edit the PRD, ask Dita', limit: 12, assumed: ['may'] };
|
|
37
|
+
const READY = 'The plan reads like this.' + fence({ step: 'ready', method: 'done-criteria', points: PTS.map((p) => ({ ...p, agreed: true })), draft: DRAFT });
|
|
38
|
+
const grill = [{ role: 'user', text: '[PMOS /goal] The PM set a goal: Bring the descope-feature-parity PRD to a review-ready draft\n' }];
|
|
39
|
+
|
|
40
|
+
const look = () => {
|
|
41
|
+
const log = document.querySelector('#hmLog'), q = (s) => log.querySelector(s), ta = document.querySelector('#hmIn');
|
|
42
|
+
const vw = document.querySelector('#czViewer:not([hidden]) .obody.vw[data-vw="goal"]');
|
|
43
|
+
return {
|
|
44
|
+
meth: (q('.gmeth') || {}).textContent || null, methBtn: !!q('button.gmeth[data-goal-meth]'), menuOpen: !!q('.gmenu:not([hidden])'), menu: [...log.querySelectorAll('.gmenu:not([hidden]) [data-goal-method]')].map((b) => b.dataset.goalMethod),
|
|
45
|
+
dots: log.querySelectorAll('.gq .gdots i').length, dotsOn: log.querySelectorAll('.gq .gdots i.y').length, letters: !!q('.smart b'),
|
|
46
|
+
chips: [...log.querySelectorAll('.gchips [data-chat-say]')].map((b) => b.textContent), rec: (q('.gchip.rec') || {}).textContent || null,
|
|
47
|
+
plan: !!q('.gplan:not(.ed)'), planText: (q('.gplan') || {}).textContent || '', acts: [...log.querySelectorAll('.gplan .acts button')].map((b) => [b.getAttribute('aria-label'), b.textContent.trim()]),
|
|
48
|
+
go: !!q('.gplan [data-goal="start"] path[d="M5 12h14M13 6l6 6-6 6"]'),
|
|
49
|
+
ed: !!q('[data-goal-ed]'), fields: [...log.querySelectorAll('[data-goal-ed] [data-goal-fld="done"]')].map((f) => f.value),
|
|
50
|
+
choice: (q('.gchoice') || {}).textContent || null, goalq: document.querySelector('.hm-chat, #hmChat') ? !!document.querySelector('.hm-goalq') : false,
|
|
51
|
+
ph: ta ? ta.placeholder : null, box: ta ? ta.value : null,
|
|
52
|
+
view: vw ? vw.textContent.replace(/\s+/g, ' ').trim() : null, skips: vw ? [...vw.querySelectorAll('[data-goal-skip]')].map((b) => b.dataset.goalSkip) : [], unskip: vw ? [...vw.querySelectorAll('[data-goal-unskip]')].map((b) => b.dataset.goalUnskip) : [],
|
|
53
|
+
wide: document.documentElement.scrollWidth > innerWidth + 1,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
(async () => {
|
|
58
|
+
const exe = findBrowser();
|
|
59
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
60
|
+
let chromium;
|
|
61
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
62
|
+
F = await Fx.start({ name: 'premium-chat-goal-setup' });
|
|
63
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
64
|
+
const shots = process.env.GOAL_SETUP_SHOTS;
|
|
65
|
+
const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
|
|
66
|
+
const open = async (width, scheme, first) => {
|
|
67
|
+
const st = { goal: first.goal, messages: first.messages, posts: [], asks: [] };
|
|
68
|
+
const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
|
|
69
|
+
const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
|
|
70
|
+
await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-goal', goal: st.goal } }));
|
|
71
|
+
await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: st.turn || 'pm', messages: st.messages } }));
|
|
72
|
+
await p.route('**/api/briefing-premium/goal**', (r) => { st.posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true } }); });
|
|
73
|
+
await p.route('**/api/briefing-premium/ask**', (r) => { st.asks.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true, session: 's-goal' } }); });
|
|
74
|
+
await p.goto(chat + '&about=work:goal-setup');
|
|
75
|
+
await until(() => p.evaluate(() => !!document.querySelector('#hmLog .hm-a, #hmLog .hm-u')));
|
|
76
|
+
await sleep(400);
|
|
77
|
+
return { p, ctx, errs, st };
|
|
78
|
+
};
|
|
79
|
+
const poll = async (p, test, ms) => (await until(async () => { const v = await p.evaluate(look); return test(v) ? v : null; }, ms)) || p.evaluate(look);
|
|
80
|
+
|
|
81
|
+
for (const [width, scheme] of [[1280, 'light'], [390, 'dark']]) {
|
|
82
|
+
const tag = `(${width} ${scheme})`;
|
|
83
|
+
// M1, M2: the question and its method
|
|
84
|
+
{ const { p, ctx, errs, st } = await open(width, scheme, { goal: { id: 'g1', state: 'grilling' }, messages: grill.concat({ role: 'assistant', text: QUESTION }) });
|
|
85
|
+
const s0 = await p.evaluate(look);
|
|
86
|
+
ok(`M1 ${tag} the question names its method in one line with Change, and why it fits`, s0.methBtn && /Method: Done criteria/.test(s0.meth || '') && /it ends in a document/.test(s0.meth || ''), JSON.stringify(s0));
|
|
87
|
+
ok(`M1 ${tag} one dot per point the method needs, filled as agreed; no S M A R T letters`, s0.dots === 4 && s0.dotsOn === 1 && !s0.letters, JSON.stringify(s0));
|
|
88
|
+
ok(`M1 ${tag} tap answers, the recommended one marked; the box says so`, s0.chips.length === 2 && /recommended/.test(s0.rec || '') && s0.ph === 'Answer, or pick one above', JSON.stringify(s0));
|
|
89
|
+
if (shots) await p.screenshot({ path: `${shots}/question-${width}-${scheme}.png` });
|
|
90
|
+
await p.click('#hmLog [data-goal-meth]');
|
|
91
|
+
const s1 = await poll(p, (v) => v.menuOpen);
|
|
92
|
+
ok(`M2 ${tag} Change opens the other methods`, s1.menuOpen && s1.menu.length === 4 && s1.menu.includes('pre-mortem') && !s1.menu.includes('done-criteria'), JSON.stringify(s1));
|
|
93
|
+
if (shots) await p.screenshot({ path: `${shots}/method-menu-${width}-${scheme}.png` });
|
|
94
|
+
await p.keyboard.press('Escape');
|
|
95
|
+
const s1b = await poll(p, (v) => !v.menuOpen);
|
|
96
|
+
ok(`M2 ${tag} Esc closes the menu`, !s1b.menuOpen, JSON.stringify(s1b));
|
|
97
|
+
await p.click('#hmLog [data-goal-meth]'); await poll(p, (v) => v.menuOpen);
|
|
98
|
+
await p.click('#hmLog [data-goal-method="pre-mortem"]');
|
|
99
|
+
const asked = await until(() => st.asks.find((a) => /^\[PMOS \/goal method\] Use the Pre-mortem method/.test(a.text || '')));
|
|
100
|
+
ok(`M2 ${tag} a pick sends the method message to Claude`, !!asked && /Its points: What ships; How it could fail/.test(asked.text), JSON.stringify(st.asks));
|
|
101
|
+
ok(`F1 ${tag} question: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
|
|
102
|
+
await ctx.close(); }
|
|
103
|
+
|
|
104
|
+
// P1, E1, E2: the plan card and its editor
|
|
105
|
+
{ const { p, ctx, errs, st } = await open(width, scheme, { goal: { id: 'g1', state: 'grilling' }, messages: grill.concat({ role: 'assistant', text: READY }) });
|
|
106
|
+
const s0 = await p.evaluate(look);
|
|
107
|
+
ok(`P1 ${tag} the ready plan is a card in the chat: done when, by, it may (assumed)`, s0.plan && /Done when/.test(s0.planText) && /By Friday/.test(s0.planText) && /It may edit the PRD, ask Dita assumed/.test(s0.planText), JSON.stringify(s0));
|
|
108
|
+
ok(`P1 ${tag} Start (go arrow), Change and Cancel are icons with no words`, JSON.stringify(s0.acts.map((a) => a[0])) === '["Start","Change the plan","Cancel the goal"]' && s0.acts.every((a) => a[1] === '') && s0.go, JSON.stringify(s0.acts));
|
|
109
|
+
if (shots) await p.screenshot({ path: `${shots}/plan-${width}-${scheme}.png` });
|
|
110
|
+
await p.click('#hmLog .gplan [data-goal="change"]');
|
|
111
|
+
const s1 = await poll(p, (v) => v.ed);
|
|
112
|
+
ok(`E1 ${tag} Change turns the card into the editor in place, one field per point`, s1.ed && s1.fields.length === 4 && s1.fields[2] === DRAFT.done[2] && s1.ph === 'Or tell Claude what to change', JSON.stringify(s1));
|
|
113
|
+
const f3 = '#hmLog [data-goal-ed] .edl li:nth-child(3) textarea';
|
|
114
|
+
await p.fill(f3, 'Out-of-scope list, with SSO and Okta on it');
|
|
115
|
+
await p.click('#hmLog [data-goal-ed] [data-goal-add]');
|
|
116
|
+
await p.keyboard.type('Okta gap in the open questions');
|
|
117
|
+
await p.click('#hmLog [data-goal-ed] .edl li:nth-child(1) [data-goal-rm]');
|
|
118
|
+
await p.focus('#hmLog [data-goal-ed] .edl li:nth-child(4) [data-goal-grip]'); // the new point, last: up two with the arrow keys
|
|
119
|
+
await p.keyboard.press('ArrowUp'); await p.keyboard.press('ArrowUp');
|
|
120
|
+
// then drag the last point above the third by its handle
|
|
121
|
+
const gb = await p.locator('#hmLog [data-goal-ed] .edl li:nth-child(4) [data-goal-grip]').boundingBox(), tb = await p.locator('#hmLog [data-goal-ed] .edl li:nth-child(3)').boundingBox();
|
|
122
|
+
await p.mouse.move(gb.x + gb.width / 2, gb.y + gb.height / 2); await p.mouse.down();
|
|
123
|
+
await p.mouse.move(gb.x + gb.width / 2, tb.y + 4, { steps: 6 }); await p.mouse.up();
|
|
124
|
+
await p.fill('#hmLog [data-goal-ed] [data-goal-fld="by"]', 'Thursday');
|
|
125
|
+
const s2 = await p.evaluate(look);
|
|
126
|
+
ok(`E1 ${tag} a typed point, a new point, a removed point, the arrow keys and a drag show in place`, JSON.stringify(s2.fields) === JSON.stringify(['Open questions, each with an owner', 'Okta gap in the open questions', "Ready for Dita's review", 'Out-of-scope list, with SSO and Okta on it']), JSON.stringify(s2.fields));
|
|
127
|
+
// a redraw (a new poll with a changed conversation) must not lose what was typed
|
|
128
|
+
st.messages = st.messages.concat([]); st.turn = 'pm'; await p.evaluate(() => { const l = document.querySelector('#hmLog'); l.__h = null; });
|
|
129
|
+
await sleep(2600);
|
|
130
|
+
const s3 = await p.evaluate(look);
|
|
131
|
+
ok(`E2 ${tag} a redraw while editing keeps what was typed`, s3.ed && JSON.stringify(s3.fields) === JSON.stringify(s2.fields), JSON.stringify(s3.fields));
|
|
132
|
+
if (shots) await p.screenshot({ path: `${shots}/edit-${width}-${scheme}.png` });
|
|
133
|
+
await p.click('#hmLog [data-goal-ed] [data-goal-save]');
|
|
134
|
+
const saved = await until(() => st.posts.find((x) => x.act === 'plan'));
|
|
135
|
+
ok(`E1 ${tag} ✓ sends the edited plan for this goal`, saved && saved.id === 'g1' && JSON.stringify(saved.draft.done) === JSON.stringify(s2.fields) && saved.draft.by === 'Thursday' && saved.draft.goal === DRAFT.goal && !(saved.draft.assumed || []).includes('by'), JSON.stringify(st.posts));
|
|
136
|
+
const s4 = await poll(p, (v) => !v.ed);
|
|
137
|
+
ok(`E1 ${tag} after the save the card is shown again`, !s4.ed && s4.plan, JSON.stringify(s4));
|
|
138
|
+
await p.click('#hmLog .gplan [data-goal="change"]'); await poll(p, (v) => v.ed);
|
|
139
|
+
await p.fill('#hmLog [data-goal-ed] .edl li:nth-child(1) textarea', 'thrown away');
|
|
140
|
+
await p.click('#hmLog [data-goal-ed] [data-goal-discard]');
|
|
141
|
+
const s5 = await poll(p, (v) => !v.ed);
|
|
142
|
+
ok(`E2 ${tag} × discards the changes and sends nothing`, !s5.ed && !/thrown away/.test(s5.planText) && st.posts.filter((x) => x.act === 'plan').length === 1, JSON.stringify(st.posts));
|
|
143
|
+
await p.click('#hmLog .gplan [data-goal="start"]');
|
|
144
|
+
const go = await until(() => st.posts.find((x) => x.act === 'start'));
|
|
145
|
+
ok(`P1 ${tag} Start sends the plan`, go && go.id === 'g1' && go.draft && go.draft.goal === DRAFT.goal, JSON.stringify(st.posts));
|
|
146
|
+
ok(`F1 ${tag} plan: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
|
|
147
|
+
await ctx.close(); }
|
|
148
|
+
|
|
149
|
+
// K1, Q1, Q2: a working goal
|
|
150
|
+
const started = (extra = {}) => ({ id: 'g2', state: 'started', draft: DRAFT, met: [DRAFT.done[0]], rounds: 1, roundAt: '2026-10-25T01:00:00Z', ...extra });
|
|
151
|
+
const working = grill.concat([{ role: 'assistant', text: READY }, { role: 'user', text: '[PMOS /goal start] go' }, { role: 'assistant', text: 'On it.' }]);
|
|
152
|
+
{ const { p, ctx, errs, st } = await open(width, scheme, { goal: started(), messages: working });
|
|
153
|
+
await p.evaluate(() => import('/pm/premium-viewer.js').then(() => document.querySelector('#hmLog [data-goal-open]') && document.querySelector('#hmLog [data-goal-open]').click()));
|
|
154
|
+
let s0 = await poll(p, (v) => v.view, 3000);
|
|
155
|
+
if (!s0.view) { await p.evaluate(() => { const b = document.querySelector('.hm-pl [data-pl="toggle"], #hmLog [data-goal-open]'); if (b) b.click(); }); s0 = await poll(p, (v) => v.view, 3000); }
|
|
156
|
+
ok(`K1 ${tag} the Goal view has × on a point that has not started, none on the point Claude is on`, s0.skips.includes(DRAFT.done[2]) && s0.skips.includes(DRAFT.done[3]) && !s0.skips.includes(DRAFT.done[1]) && !s0.skips.includes(DRAFT.done[0]), JSON.stringify(s0));
|
|
157
|
+
await p.click(`#czViewer [data-goal-skip="${DRAFT.done[2]}"]`);
|
|
158
|
+
const sk = await until(() => st.posts.find((x) => x.act === 'skip'));
|
|
159
|
+
ok(`K1 ${tag} × sends the skip for that point`, sk && sk.point === DRAFT.done[2] && sk.id === 'g2', JSON.stringify(st.posts));
|
|
160
|
+
st.goal = started({ skipped: [DRAFT.done[2]], skipAt: { [DRAFT.done[2]]: '2026-10-25T02:00:00Z' } });
|
|
161
|
+
const s1 = await poll(p, (v) => v.unskip.length);
|
|
162
|
+
ok(`K1 ${tag} the skipped point is struck through with Undo, and the count leaves it out`, s1.unskip[0] === DRAFT.done[2] && /Skipped by you · Claude drops it after this step/.test(s1.view || '') && /1 of 3 (done )?points met/.test(s1.view || ''), JSON.stringify(s1));
|
|
163
|
+
await p.click(`#czViewer [data-goal-unskip="${DRAFT.done[2]}"]`);
|
|
164
|
+
const un = await until(() => st.posts.find((x) => x.act === 'unskip'));
|
|
165
|
+
ok(`K1 ${tag} Undo sends the point back`, un && un.point === DRAFT.done[2], JSON.stringify(st.posts));
|
|
166
|
+
if (shots) await p.screenshot({ path: `${shots}/skip-${width}-${scheme}.png` });
|
|
167
|
+
// during a run, the Viewer's pencil opens the same editor; ✓ sends the plan, which applies after the current step
|
|
168
|
+
await p.click('#czViewer [data-goal="change"]');
|
|
169
|
+
const e0 = await until(() => p.evaluate(() => document.querySelectorAll('#czViewer [data-goal-ed] [data-goal-fld="done"]').length));
|
|
170
|
+
ok(`K2 ${tag} the Viewer's pencil opens the plan editor for a working goal`, e0 === 4, String(e0));
|
|
171
|
+
await p.fill('#czViewer [data-goal-ed] .edl li:nth-child(4) textarea', "Ready for Dita's review by Thursday");
|
|
172
|
+
await p.click('#czViewer [data-goal-ed] [data-goal-save]');
|
|
173
|
+
const pe = await until(() => st.posts.find((x) => x.act === 'plan'));
|
|
174
|
+
ok(`K2 ${tag} ✓ sends the changed plan for the working goal`, pe && pe.id === 'g2' && pe.draft.done[3] === "Ready for Dita's review by Thursday", JSON.stringify(st.posts));
|
|
175
|
+
await p.evaluate(() => { const c = document.querySelector('#czViewer [data-cz-vw="close"], #czViewer [data-cz-vw="back"]'); if (c) c.click(); });
|
|
176
|
+
await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')), 3000);
|
|
177
|
+
st.goal = started();
|
|
178
|
+
const n0 = st.asks.length;
|
|
179
|
+
await p.fill('#hmIn', '/goal Draft the Q1 OKR review for the leads');
|
|
180
|
+
await p.keyboard.press('Enter');
|
|
181
|
+
const s2 = await poll(p, (v) => v.choice);
|
|
182
|
+
ok(`Q1 ${tag} /goal while a goal works shows the choice, and sends nothing yet`, /One goal runs in a chat at a time/.test(s2.choice || '') && /In a new chat/.test(s2.choice || '') && /recommended · this goal keeps going/.test(s2.choice || '') && /stops “Bring the descope-feature-parity PRD/.test(s2.choice || '') && st.asks.length === n0 && s2.goalq && s2.box === '', JSON.stringify(s2));
|
|
183
|
+
if (shots) await p.screenshot({ path: `${shots}/choice-${width}-${scheme}.png` });
|
|
184
|
+
await p.click('#hmLog [data-goal-where="here"]');
|
|
185
|
+
const rp = await until(() => st.posts.find((x) => x.act === 'replace'));
|
|
186
|
+
const sent = await until(() => st.asks.find((a) => a.text === '/goal Draft the Q1 OKR review for the leads'));
|
|
187
|
+
ok(`Q1 ${tag} Here, instead stops this goal (replace), then sends the new /goal here`, rp && rp.id === 'g2' && sent && sent.key === 'work:goal-setup' && !(await p.evaluate(look)).choice, JSON.stringify({ posts: st.posts, asks: st.asks }));
|
|
188
|
+
await p.fill('#hmIn', '/goal Another one'); await p.keyboard.press('Enter');
|
|
189
|
+
await poll(p, (v) => v.choice);
|
|
190
|
+
await p.keyboard.press('Escape');
|
|
191
|
+
const s3 = await poll(p, (v) => !v.choice);
|
|
192
|
+
ok(`Q1 ${tag} Esc closes the choice`, !s3.choice && !s3.goalq, JSON.stringify(s3));
|
|
193
|
+
await p.fill('#hmIn', '/goal Draft the Q1 OKR review'); await p.keyboard.press('Enter');
|
|
194
|
+
await poll(p, (v) => v.choice);
|
|
195
|
+
const reps = st.posts.filter((x) => x.act === 'replace').length;
|
|
196
|
+
await p.click('#hmLog [data-goal-where="new"]');
|
|
197
|
+
const nw = await until(() => st.asks.find((a) => a.text === '/goal Draft the Q1 OKR review'));
|
|
198
|
+
ok(`Q2 ${tag} In a new chat sends the goal to a new chat and leaves this goal running`, nw && nw.key !== 'work:goal-setup' && /^chat:loose-/.test(nw.key) && st.posts.filter((x) => x.act === 'replace').length === reps, JSON.stringify(st.asks));
|
|
199
|
+
ok(`F1 ${tag} working goal: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
|
|
200
|
+
await ctx.close(); }
|
|
201
|
+
}
|
|
202
|
+
return finish();
|
|
203
|
+
})();
|