create-pmos 0.763.0 → 0.765.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 +51 -45
- package/payload/AGENTS.md +1 -1
- 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 +50 -0
- package/workspace/chat-asks-test.js +1 -1
- package/workspace/guide/breakdown.md +1 -1
- package/workspace/guide/cli.md +8 -0
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/initiatives-and-next-steps.md +2 -2
- package/workspace/lib/briefing-premium-agent.js +4 -1
- package/workspace/lib/cos-chat.js +1 -1
- package/workspace/lib/engine/boards.js +9 -2
- package/workspace/lib/initiative-chat.js +1 -1
- package/workspace/lib/pmos-verbs.js +1 -1
- package/workspace/lib/program-chat.js +11 -6
- package/workspace/lib/program-cli.js +150 -2
- package/workspace/lib/programs.js +2 -1
- package/workspace/lib/question-batch.js +6 -2
- package/workspace/lib/routes-boards.js +62 -5
- package/workspace/lib/routes-proposals.js +15 -1
- package/workspace/lib/source-guard.js +10 -1
- package/workspace/lib/task-cli.js +45 -12
- package/workspace/lib/task-describe.js +228 -0
- package/workspace/lib/task-store.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-viewer-test.js +3 -0
- package/workspace/premium-vw-jira-test.js +1 -1
- package/workspace/public/pm/bd-prog-panel.js +2 -0
- package/workspace/public/pm/cozy-home.css +1 -0
- package/workspace/public/pm/cozy-popup.js +2 -2
- package/workspace/public/pm/cozy-task-pop.css +10 -0
- package/workspace/public/pm/cozy-task-pop.js +46 -2
- package/workspace/public/pm/home-app.js +1 -1
- package/workspace/public/pm/home-chat.js +16 -6
- package/workspace/public/pm/home-ini.js +2 -1
- package/workspace/public/pm/library-open.js +1 -0
- package/workspace/public/pm/page-chat.js +7 -2
- package/workspace/public/pm/premium-board.js +2 -1
- package/workspace/public/pm/task-card.js +2 -0
- package/workspace/public/pm/vw-ds.js +38 -0
- package/workspace/test-lists/chat-subtasks.json +9 -0
- package/workspace/test-lists/task-descriptions.json +9 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* task-describe.js — every task has a description PMOS writes (initiative task-descriptions; done test planning/done-tests/task-descriptions.md).
|
|
3
|
+
*
|
|
4
|
+
* Wawan (2026-11-24): a task page showed Where it stands, Linked and empty Notes, and nothing said what the task is, why it matters or when it
|
|
5
|
+
* is done. "Tasks miss a description. PMOS should work on the detailed description."
|
|
6
|
+
*
|
|
7
|
+
* docsOf(root, ini) → [{ path, title, lines }] READ-ONLY. The initiative's own files: its record, its PRD, its done test
|
|
8
|
+
* and the newest version of each of its core documents (<state>/core-docs/initiative-<id>/<key>/)
|
|
9
|
+
* sourcesOf({ root, ini, task }) → [{ n, path, line, title, text }] the lines of those files about the task: the most key words of its
|
|
10
|
+
* title, best 3 per file, at most 12; the record's first paragraph (the why) is always one
|
|
11
|
+
* promptOf(task, list) · parse(text, list) the session's prompt, and its answer read back ({ what, why, done: [], used: [passage] } | null) PURE
|
|
12
|
+
* textOf(d) → the description as the page and the ledger keep it: What, Why and Done when, plain text PURE
|
|
13
|
+
* fallbackOf(task, list) → { what, why, done, used } | null from the passages' own words, when no session answers PURE
|
|
14
|
+
* draft(ctx, { root, ini, task }) → { ok: true, text, sources } | { ok: true, text: null, why }
|
|
15
|
+
*
|
|
16
|
+
* The session is one normal PMOS session (`claude -p`, the existing read-only `briefing-ask:` ask kind, no tools: the same path as Search's
|
|
17
|
+
* answers, lib/search-ask.js). It writes from the passages only and names the ones it used: a description with no source is not kept. No
|
|
18
|
+
* passage about the task: no description (zero is silence). Nothing here writes: lib/routes-boards.js describe-draft writes the line.
|
|
19
|
+
* Tests inject ctx.askClaude(prompt, { job, key }) → Promise<string|null>. */
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const crypto = require('crypto');
|
|
23
|
+
const { wordsOf } = require('./library-find.js');
|
|
24
|
+
|
|
25
|
+
const MAX = 12, PER_FILE = 3, MIN_LEN = 20;
|
|
26
|
+
const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
|
|
27
|
+
const plain = (l) => String(l || '').replace(/^\s*\|\s*|\s*\|\s*$/g, '').replace(/\s*\|\s*/g, ' · ').replace(/^\s*(?:#+|[-*+>]|\d+[.)])\s*/, '').replace(/^\[[ xX]\]\s*/, '').replace(/\*\*|__|`|\[([^\]]*)\]\([^)]*\)/g, (m, a) => a || '').trim();
|
|
28
|
+
const reOf = (w) => new RegExp('(^|[^a-z0-9])' + w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
|
|
29
|
+
const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
|
|
30
|
+
const linesOf = (f) => { try { return fs.readFileSync(f, 'utf8').replace(/\r\n?/g, '\n').split('\n'); } catch { return null; } };
|
|
31
|
+
const inside = (root, f) => { const a = path.resolve(f); return a === root || a.startsWith(root + path.sep); };
|
|
32
|
+
|
|
33
|
+
function layoutOf(root) {
|
|
34
|
+
try { const l = require('./console-state').loadEngine(); if (l.ok) return l.engine.layout(root); } catch { /* fall through */ }
|
|
35
|
+
const kit = fs.existsSync(path.join(root, 'pmos', 'state'));
|
|
36
|
+
return { root, kit, initiatives: kit ? path.join(root, 'pmos', 'state', 'initiatives') : path.join(root, 'planning', 'initiatives') };
|
|
37
|
+
}
|
|
38
|
+
/** The frontmatter's end (0-based index of the first body line) and its keys. */
|
|
39
|
+
function front(L) {
|
|
40
|
+
const fm = {};
|
|
41
|
+
if (!/^---\s*$/.test(L[0] || '')) return { end: 0, fm };
|
|
42
|
+
let i = 1;
|
|
43
|
+
for (; i < L.length && !/^---\s*$/.test(L[i]); i++) { const m = /^([A-Za-z_][\w]*):\s*(.*)$/.exec(L[i]); if (m && !(m[1] in fm)) fm[m[1]] = m[2].replace(/^["']|["']$/g, '').trim(); }
|
|
44
|
+
return { end: i + 1, fm };
|
|
45
|
+
}
|
|
46
|
+
function titleOf(L, f) { const t = front(L).fm.title; if (t) return t; const h = L.find((l) => /^#\s/.test(l)); return h ? h.replace(/^#\s+/, '').trim() : path.basename(f, '.md'); }
|
|
47
|
+
|
|
48
|
+
/** The newest file of each core document of the initiative (the slots sort by day). */
|
|
49
|
+
function coreDocs(root, L, ini) {
|
|
50
|
+
let base;
|
|
51
|
+
try { base = path.join(root, require('./report-draft.js').stateRel(root)); } catch { base = L.kit ? path.join(root, 'pmos', 'state') : path.join(root, 'planning'); }
|
|
52
|
+
const dir = path.join(base, 'core-docs', 'initiative-' + ini);
|
|
53
|
+
const out = [];
|
|
54
|
+
let keys = [];
|
|
55
|
+
try { keys = fs.readdirSync(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort(); } catch { return out; }
|
|
56
|
+
for (const k of keys) {
|
|
57
|
+
let slots = [];
|
|
58
|
+
try { slots = fs.readdirSync(path.join(dir, k)).filter((f) => f.endsWith('.md')).sort(); } catch { continue; }
|
|
59
|
+
if (slots.length) out.push(path.join(dir, k, slots[slots.length - 1]));
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The initiative's own files, read once: [{ path, title, lines, end, record? }]. READ-ONLY. */
|
|
65
|
+
function docsOf(root, ini) {
|
|
66
|
+
root = path.resolve(String(root || ''));
|
|
67
|
+
if (!ini || !/^[a-z0-9][a-z0-9._-]{0,80}$/i.test(ini)) return [];
|
|
68
|
+
const L = layoutOf(root), files = [];
|
|
69
|
+
const rec = path.join(L.initiatives, ini + '.md');
|
|
70
|
+
const RL = linesOf(rec);
|
|
71
|
+
const fm = RL ? front(RL).fm : {};
|
|
72
|
+
if (RL) files.push(rec);
|
|
73
|
+
const cands = [];
|
|
74
|
+
for (const k of ['prd_path', 'prd', 'done_test_path']) if (fm[k]) cands.push(path.join(root, fm[k]), path.join(root, 'pmos', fm[k]));
|
|
75
|
+
cands.push(path.join(root, 'planning', 'prd', ini + '-prd.md'), path.join(root, 'pmos', 'planning', 'prd', ini + '-prd.md'));
|
|
76
|
+
for (const f of cands) { try { if (inside(root, f) && fs.statSync(f).isFile() && !files.includes(path.resolve(f))) files.push(path.resolve(f)); } catch { /* not there */ } }
|
|
77
|
+
for (const f of coreDocs(root, L, ini)) if (!files.includes(f)) files.push(f);
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const f of files.slice(0, 20)) {
|
|
80
|
+
const lines = linesOf(f); if (!lines) continue;
|
|
81
|
+
out.push({ path: rel(root, f), title: titleOf(lines, f), lines, end: front(lines).end, record: f === rec, fm: f === rec ? fm : null });
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The record's own first paragraph about the work (its why), or its `description:` line: { line, text } | null. */
|
|
87
|
+
function whyOf(doc) {
|
|
88
|
+
if (doc.fm && doc.fm.description && doc.fm.description.length >= MIN_LEN) {
|
|
89
|
+
const n = doc.lines.findIndex((l) => /^description:/.test(l));
|
|
90
|
+
return { line: n + 1, text: clip(doc.fm.description, 400) };
|
|
91
|
+
}
|
|
92
|
+
let head = '';
|
|
93
|
+
for (let i = doc.end; i < doc.lines.length; i++) {
|
|
94
|
+
const l = doc.lines[i];
|
|
95
|
+
if (/^#{1,6}\s/.test(l)) { head = l; continue; }
|
|
96
|
+
if (!l.trim() || /^\s*([-*+|>]|```|<!--)/.test(l)) continue;
|
|
97
|
+
if (head && !/^#{1,3}\s*(intent|goal|problem|why|background|context|summary|overview)\b/i.test(head) && !/^#\s/.test(head)) continue;
|
|
98
|
+
const t = plain(l);
|
|
99
|
+
if (t.length >= MIN_LEN) return { line: i + 1, text: clip(t, 400) };
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The passages about the task, best first. READ-ONLY. task: { title, notes? } */
|
|
105
|
+
function sourcesOf({ root, ini, task } = {}) {
|
|
106
|
+
const docs = docsOf(root, ini);
|
|
107
|
+
const words = wordsOf(String((task && task.title) || ''));
|
|
108
|
+
const out = [], seen = new Set();
|
|
109
|
+
const add = (d, line, text, why = false) => { const k = d.path + ':' + line; if (seen.has(k) || out.length >= MAX) return; seen.add(k); out.push({ n: out.length + 1, path: d.path, line, title: d.title, text: clip(text, 320), ...(why ? { why: true } : {}) }); };
|
|
110
|
+
const rec = docs.find((d) => d.record);
|
|
111
|
+
const why = rec ? whyOf(rec) : null;
|
|
112
|
+
if (why) add(rec, why.line, why.text, true);
|
|
113
|
+
if (!words.length) return [];
|
|
114
|
+
const need = Math.min(2, words.length);
|
|
115
|
+
const df = new Map(), hits = [];
|
|
116
|
+
for (const d of docs) {
|
|
117
|
+
for (let i = d.end; i < d.lines.length; i++) {
|
|
118
|
+
const t = plain(d.lines[i]);
|
|
119
|
+
if (t.length < MIN_LEN || /^---/.test(t)) continue;
|
|
120
|
+
const have = words.filter((w) => reOf(w).test(t));
|
|
121
|
+
if (have.length < need) continue;
|
|
122
|
+
// a line that only repeats the task's title adds nothing; the lines around it are the detail
|
|
123
|
+
hits.push({ d, line: i + 1, t, have });
|
|
124
|
+
for (const w of have) { let s = df.get(w); if (!s) { s = new Set(); df.set(w, s); } s.add(d.path); }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const nDocs = docs.length || 1;
|
|
128
|
+
const weight = (w) => 1 + Math.log((nDocs + 1) / ((df.get(w) || new Set()).size + 0.5));
|
|
129
|
+
for (const h of hits) h.score = h.have.reduce((a, w) => a + weight(w), 0) * 100 - Math.min(h.t.length, 400) / 10;
|
|
130
|
+
const per = new Map();
|
|
131
|
+
for (const h of hits.sort((a, b) => b.score - a.score || a.d.path.localeCompare(b.d.path) || a.line - b.line)) {
|
|
132
|
+
const c = per.get(h.d.path) || 0; if (c >= PER_FILE) continue;
|
|
133
|
+
per.set(h.d.path, c + 1);
|
|
134
|
+
add(h.d, h.line, h.t);
|
|
135
|
+
// the line under a matching heading or list item often holds the detail: take the next prose line of the same block
|
|
136
|
+
const nx = h.d.lines[h.line];
|
|
137
|
+
if (nx && plain(nx).length >= MIN_LEN && out.length < MAX && per.get(h.d.path) < PER_FILE) { per.set(h.d.path, per.get(h.d.path) + 1); add(h.d, h.line + 1, plain(nx)); }
|
|
138
|
+
}
|
|
139
|
+
// the task itself: no match beyond the why is no source about the task
|
|
140
|
+
return out.length > (why ? 1 : 0) ? out : [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function promptOf(task, list) {
|
|
144
|
+
return [
|
|
145
|
+
'You write the description of one task in a product manager\'s plan, from passages of their own files. Do not use any tool. Answer with JSON only.',
|
|
146
|
+
`The task: "${clip(task.title, 200)}"` + (task.iniTitle ? ` (part of the initiative "${clip(task.iniTitle, 120)}")` : ''),
|
|
147
|
+
'The passages, each with the file it comes from:',
|
|
148
|
+
list.map((p) => `${p.n}. [${clip(p.title, 100)}] ${p.text}`).join('\n'),
|
|
149
|
+
'Write, using ONLY what the passages say. Do not guess and do not add facts, names, numbers or dates the passages do not hold:',
|
|
150
|
+
'- what: one or two plain sentences on what this task does.',
|
|
151
|
+
'- why: one sentence on why it matters for the initiative.',
|
|
152
|
+
'- done: two to four short checks that show the task is done, each one testable.',
|
|
153
|
+
'Name the numbers of the passages you used. If the passages say nothing about this task, answer {"what":null}.',
|
|
154
|
+
'Answer: {"what":"…","why":"…","done":["…","…"],"used":[<passage numbers>]}',
|
|
155
|
+
].join('\n\n');
|
|
156
|
+
}
|
|
157
|
+
/** The session's answer read back, with only passages of the list, or null. Pure. */
|
|
158
|
+
function parse(text, list) {
|
|
159
|
+
const t = String(text || '');
|
|
160
|
+
const at = t.indexOf('{'), end = t.lastIndexOf('}');
|
|
161
|
+
if (at < 0 || end < at) return null;
|
|
162
|
+
let o; try { o = JSON.parse(t.slice(at, end + 1)); } catch { return null; }
|
|
163
|
+
const s = (v, n) => (typeof v === 'string' ? clip(v, n) : '');
|
|
164
|
+
const what = s(o && o.what, 400);
|
|
165
|
+
if (!what) return null;
|
|
166
|
+
const used = [];
|
|
167
|
+
for (const k of Array.isArray(o.used) ? o.used : []) { const p = list.find((x) => x.n === Number(k)); if (p && !used.includes(p)) used.push(p); }
|
|
168
|
+
if (!used.length) return null; // a description that names no passage has no source: it is not kept
|
|
169
|
+
const done = (Array.isArray(o.done) ? o.done : []).map((x) => s(x, 200)).filter(Boolean).slice(0, 5);
|
|
170
|
+
return { what, why: s(o.why, 300), done, used };
|
|
171
|
+
}
|
|
172
|
+
/** The description as plain text: What, Why, Done when. Pure. */
|
|
173
|
+
function textOf(d) {
|
|
174
|
+
const out = ['What: ' + d.what];
|
|
175
|
+
if (d.why) out.push('Why: ' + d.why);
|
|
176
|
+
if (d.done && d.done.length) out.push('Done when:\n' + d.done.map((x) => '- ' + x).join('\n'));
|
|
177
|
+
return out.join('\n\n');
|
|
178
|
+
}
|
|
179
|
+
const CHECK = /\b(done when|acceptance|must|should|passes|verified|criteria|test|check)\b|^\s*-\s*\[[ xX]\]/i;
|
|
180
|
+
/** From the passages' own words, when no session answers. Pure. */
|
|
181
|
+
function fallbackOf(task, list) {
|
|
182
|
+
const whyP = list.find((p) => p.why) || null;
|
|
183
|
+
const about = list.filter((p) => !p.why);
|
|
184
|
+
if (!about.length) return null;
|
|
185
|
+
const whatP = about.find((p) => !CHECK.test(p.text)) || about[0];
|
|
186
|
+
const done = about.filter((p) => p !== whatP && CHECK.test(p.text)).slice(0, 3);
|
|
187
|
+
const used = [whatP, whyP, ...done].filter(Boolean);
|
|
188
|
+
return { what: whatP.text, why: whyP ? whyP.text : '', done: done.map((p) => p.text), used };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ── the session ── */
|
|
192
|
+
const MODEL = 'claude-sonnet-5-5';
|
|
193
|
+
const LEAN = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
|
|
194
|
+
const TIMEOUT_MS = 90000;
|
|
195
|
+
|
|
196
|
+
function viaSession(ctx, prompt, key) {
|
|
197
|
+
if (typeof ctx.askClaude === 'function') return Promise.resolve(ctx.askClaude(prompt, { job: 'task-describe', key })).catch(() => null);
|
|
198
|
+
const headless = require('./headless.js');
|
|
199
|
+
const origin = 'briefing-ask:task-describe:' + key;
|
|
200
|
+
if (typeof ctx.spawnSession !== 'function' || headless.kindFor({ agent: 'claude', origin }) !== 'ask') return Promise.resolve(null);
|
|
201
|
+
return new Promise((resolve) => {
|
|
202
|
+
let settled = false; const done = (v) => { if (settled) return; settled = true; clearTimeout(t); resolve(v); };
|
|
203
|
+
const t = setTimeout(() => done(null), TIMEOUT_MS);
|
|
204
|
+
let s = null;
|
|
205
|
+
try {
|
|
206
|
+
s = ctx.spawnSession({ name: 'task: write its description', agent: 'claude', origin, initialInput: prompt,
|
|
207
|
+
modelAsk: { explicit: { model: MODEL, effort: 'low' } }, launchFlags: LEAN.map((f) => ({ ...f })),
|
|
208
|
+
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null); } });
|
|
209
|
+
} catch { s = null; }
|
|
210
|
+
if (!s || s.state === 'exited') done(null);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const srcOf = (p) => ({ path: p.path, line: p.line, title: p.title });
|
|
214
|
+
const dedupe = (used) => { const seen = new Set(); return used.filter((p) => { const k = p.path + ':' + p.line; return !seen.has(k) && seen.add(k); }).slice(0, 6).map(srcOf); };
|
|
215
|
+
|
|
216
|
+
/** The description of one task, written from its sources, or none with why. */
|
|
217
|
+
async function draft(ctx, { root, ini, task } = {}) {
|
|
218
|
+
const t = { title: String((task && task.title) || '').slice(0, 200), iniTitle: (task && task.iniTitle) || '' };
|
|
219
|
+
const list = sourcesOf({ root, ini, task: t });
|
|
220
|
+
if (!list.length) return { ok: true, text: null, why: 'nothing in the initiative\'s files is about this task' };
|
|
221
|
+
const key = crypto.createHash('sha1').update(String(root) + '\n' + ini + '\n' + t.title + '\n' + list.map((p) => p.path + p.text).join('\n')).digest('hex').slice(0, 12);
|
|
222
|
+
const said = await viaSession(ctx || {}, promptOf(t, list), key);
|
|
223
|
+
const d = (said != null && parse(said, list)) || fallbackOf(t, list);
|
|
224
|
+
if (!d) return { ok: true, text: null, why: 'the sources say nothing about this task' };
|
|
225
|
+
return { ok: true, text: textOf(d).slice(0, 4000), sources: dedupe(d.used), made: said != null && !!parse(said, list) };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
module.exports = { docsOf, sourcesOf, promptOf, parse, textOf, fallbackOf, draft };
|
|
@@ -28,7 +28,7 @@ const path = require('path');
|
|
|
28
28
|
const ledgers = require('./plan-ledgers.js');
|
|
29
29
|
|
|
30
30
|
const LEDGER = 'initiative-tasks.jsonl';
|
|
31
|
-
const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority']);
|
|
31
|
+
const TASK_KINDS = Object.freeze(['task', 'task-update', 'task-remove', 'task-restore', 'task-section', 'task-milestone', 'task-pin', 'task-order', 'task-parent', 'task-priority', 'task-description']);
|
|
32
32
|
const KINDS = new Set(TASK_KINDS);
|
|
33
33
|
const isTaskKind = (k) => KINDS.has(k);
|
|
34
34
|
const isTaskLine = (r) => !!r && typeof r === 'object' && !Array.isArray(r) && isTaskKind(r.kind);
|
|
@@ -118,7 +118,7 @@ function view(boardLines, storeLines) {
|
|
|
118
118
|
/** The task part of a boards fold, as JSON text: equal text = the Board shows the same tasks, dates, places, milestones, pins and orders. */
|
|
119
119
|
function snapshot(f) {
|
|
120
120
|
const m = (x) => (x instanceof Map ? [...x.entries()].sort((a, b) => (String(a[0]) < String(b[0]) ? -1 : String(a[0]) > String(b[0]) ? 1 : 0)) : []);
|
|
121
|
-
return JSON.stringify({ tasks: m(f.tasks), removed: m(f.removed), sections: m(f.sections), parents: m(f.parents), milestones: m(f.milestones), pins: m(f.pins), orders: m(f.orders),
|
|
121
|
+
return JSON.stringify({ tasks: m(f.tasks), removed: m(f.removed), sections: m(f.sections), parents: m(f.parents), milestones: m(f.milestones), pins: m(f.pins), orders: m(f.orders), descriptions: m(f.descriptions),
|
|
122
122
|
// the last task-remove of a task is what its Undo reads (routes-boards tasks/restore)
|
|
123
123
|
removes: (f.events || []).filter((e) => e.kind === 'task-remove').map((e) => [e.task, e.at || null, e.why || null]) });
|
|
124
124
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.765.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.765.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -71,6 +71,9 @@ const look = () => {
|
|
|
71
71
|
// at 1280 the chat is the popup's (home-page-retire): its work side shows what opens; ✕ closes the popup, so V1's close and V3's
|
|
72
72
|
// "Open the Viewer" button are phone checks now (Home's desk page with its list is gone)
|
|
73
73
|
{ const { p, ctx, errs } = await open(1280);
|
|
74
|
+
// the popup with the chat comes after Today's log on a slow machine (CI under load): wait for it rather than read too early
|
|
75
|
+
await until(() => p.evaluate(() => !!document.querySelector('.cz-pop:not([hidden]) #hmChat')), 12000);
|
|
76
|
+
await sleep(300);
|
|
74
77
|
const s0 = await p.evaluate(look);
|
|
75
78
|
const popChat = await p.evaluate(() => !!document.querySelector('.cz-pop:not([hidden]) #hmChat'));
|
|
76
79
|
ok('V1 at 1280 /premium-chat.html opens Today with the conversation in the popup, no file open yet', popChat && s0.conv >= 360 && !/\.md$/.test(s0.title || ''), JSON.stringify(s0));
|
|
@@ -191,7 +191,7 @@ const TICKETS = {
|
|
|
191
191
|
await I.page.click('#czViewer [data-iv-ticket="PMOS-142"]');
|
|
192
192
|
ok('I2 a Jira ticket in the page\'s Tasks opens its ticket in the Viewer', !!(await until(async () => /^jira:PMOS-142$/.test(String(await curId(I.page))))), JSON.stringify(await curId(I.page)));
|
|
193
193
|
await I.page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1');
|
|
194
|
-
ok('I1 the initiative loads the Jira view module without a page error', !!(await until(() => I.page.evaluate(() => !!window.__premiumVwJira))) && I.errors.length === 0, I.errors.join(' | '));
|
|
194
|
+
ok('I1 the initiative loads the Jira view module without a page error', !!(await until(() => I.page.evaluate(() => !!window.__premiumVwJira), 20000)) && I.errors.length === 0, I.errors.join(' | '));
|
|
195
195
|
await I.ctx.close();
|
|
196
196
|
}
|
|
197
197
|
|
|
@@ -620,6 +620,8 @@ async function popPress(e) {
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
+
/** Draw the open program panel again from the programs the page has now (after a chat turn re-read them). Nothing open: nothing. */
|
|
624
|
+
export function refresh() { if (O && cur && shownHere()) draw(); }
|
|
623
625
|
export function mount(o) {
|
|
624
626
|
if (O) return;
|
|
625
627
|
O = o;
|
|
@@ -196,6 +196,7 @@ body.cz-home { min-height: 100vh; overflow: hidden; }
|
|
|
196
196
|
.hm-ren .sv { width: 32px; height: 32px; border-radius: var(--radius-pill, 999px); border: 0; background: var(--cz-solid); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
|
|
197
197
|
.hm-ren .sv:disabled { opacity: .6; cursor: default; }
|
|
198
198
|
.hm-renerr { margin: var(--space-4) 0 0 10px; font-size: var(--fs-meta); color: var(--cz-red); line-height: var(--lh-meta); }
|
|
199
|
+
.hm-senderr { flex-basis: 100%; order: 10; margin: var(--space-4) 0 0; padding: 0 var(--space-8); font-size: var(--fs-meta); color: var(--cz-red); line-height: var(--lh-meta); } /* a send that failed says why (home-chat.js errRow) */
|
|
199
200
|
.hm-chs { flex: 0 1 auto; min-width: 0; height: 28px; padding: 0 10px; border-radius: var(--radius-pill, 999px); background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-label); font-weight: var(--fw-strong); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: var(--lh-label); }
|
|
200
201
|
.hm-chs > span { overflow: hidden; text-overflow: ellipsis; }
|
|
201
202
|
.hm-chs .hv-mt { margin-left: 0; }
|
|
@@ -172,7 +172,7 @@ function show(pop) {
|
|
|
172
172
|
S.el.hidden = false; document.body.classList.add('cz-pop-on');
|
|
173
173
|
S.all.hidden = true; closeMenu();
|
|
174
174
|
const p = pop && typeof pop === 'object' ? pop : {};
|
|
175
|
-
S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws } : null;
|
|
175
|
+
S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws, ...(p.path ? { path: p.path } : {}) } : null;
|
|
176
176
|
width(parseInt(store.get('cz-pop-chat') || '', 10) || DEF_CHAT);
|
|
177
177
|
// the chat shows when it was asked for (the rail's chat icon, a session row, search's Ask PMOS), else when it was recently open on this item
|
|
178
178
|
S.userSet = false;
|
|
@@ -188,7 +188,7 @@ function show(pop) {
|
|
|
188
188
|
function retarget(pop) {
|
|
189
189
|
const p = pop && typeof pop === 'object' ? pop : null;
|
|
190
190
|
if (!p || !p.id || p.keep || (S.about && S.about.id === p.id)) return;
|
|
191
|
-
S.about = { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws };
|
|
191
|
+
S.about = { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws, ...(p.path ? { path: p.path } : {}) };
|
|
192
192
|
S.userSet = false;
|
|
193
193
|
chatOn(!!(p.target || p.chat || recentOn(S.about)));
|
|
194
194
|
attach(p.target || aboutTarget(S.about), null);
|
|
@@ -64,6 +64,16 @@ button.ctp-cr:hover { text-decoration: underline; }
|
|
|
64
64
|
.ctp-main .ctp-hx { margin: 0; }
|
|
65
65
|
.ctp-say { margin: 0; }
|
|
66
66
|
.ctp-side { position: sticky; top: 0; min-width: 0; }
|
|
67
|
+
/* the Description block (initiative task-descriptions): the text, Done when as a short list, PMOS's sources; edited in place like the notes */
|
|
68
|
+
.ctp-desc { display: flex; flex-direction: column; gap: var(--space-8); }
|
|
69
|
+
.ctp-desc .head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
|
|
70
|
+
.ctp-dh { margin: var(--space-4) 0 0; }
|
|
71
|
+
.ctp-done { margin: 0; padding-left: var(--space-16); display: flex; flex-direction: column; gap: var(--space-4); }
|
|
72
|
+
.ctp-dsrc { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
|
|
73
|
+
.ctp-dt { border: 0; outline: 0; resize: none; field-sizing: content; min-height: 72px; border-radius: 12px; padding: 6px var(--space-8); margin: 0 calc(-1 * var(--space-8)); font: inherit; font-size: var(--fs-body); line-height: 1.55; color: var(--cz-ink); background: transparent; }
|
|
74
|
+
.ctp-dt::placeholder { color: var(--cz-ink3); }
|
|
75
|
+
.ctp-dt:hover { background: var(--cz-well); }
|
|
76
|
+
.ctp-dt:focus { background: var(--cz-card); box-shadow: 0 0 0 1.5px var(--cz-blue), 0 0 0 5px var(--cz-bluebg); }
|
|
67
77
|
.ctp-ad { flex: none; width: 52px; }
|
|
68
78
|
.ctp-main .pm-li { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
|
|
69
79
|
.ctp-main .pm-li:hover { background: var(--well); }
|
|
@@ -102,6 +102,7 @@ export async function openTask(uid, ctx = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
document.addEventListener('keydown', onKey, true);
|
|
104
104
|
el.addEventListener('click', press);
|
|
105
|
+
el.addEventListener('focusout', descOut); // the description saves when the PM leaves its box (task-descriptions)
|
|
105
106
|
// the status pick waits for the day (point 18): the card's own press is held here, the line opens under the card
|
|
106
107
|
el.addEventListener('click', holdStatus, true);
|
|
107
108
|
}
|
|
@@ -138,7 +139,7 @@ async function show(uid) {
|
|
|
138
139
|
S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}${t.jira ? '<span class="pm-chip">Jira</span>' : ''}</nav>`
|
|
139
140
|
+ `<span class="ctp-tools">${step}${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${more}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
|
|
140
141
|
+ `<div class="ctp-th">${kind}${title}</div><p class="pm-meta ctp-meta">${esc(VD.metaOf(t))}</p>`
|
|
141
|
-
+ `<div class="ctp-g"><div class="ctp-main">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`
|
|
142
|
+
+ `<div class="ctp-g"><div class="ctp-main">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-descw"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`
|
|
142
143
|
+ '<aside class="ctp-side"><section class="pm-block" aria-label="Fields and notes"><div class="ctp-b"></div><div class="ctp-when" hidden></div></section></aside></div>';
|
|
143
144
|
} else {
|
|
144
145
|
S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
|
|
@@ -166,7 +167,7 @@ async function show(uid) {
|
|
|
166
167
|
// the full popup says PMOS's changes once, in its Activity block; the small popup keeps the card's History fold
|
|
167
168
|
history: ctx.full ? null : S.hist,
|
|
168
169
|
});
|
|
169
|
-
if (ctx.full) { drawMain(); loadActivity(); }
|
|
170
|
+
if (ctx.full) { drawMain(); loadActivity(); describe(); }
|
|
170
171
|
const f = S.el.querySelector('.ctp-t') || S.el.querySelector('button'); if (f) f.focus();
|
|
171
172
|
}
|
|
172
173
|
/* the full popup's main column (viewer-ds-task, pm/vw-ds.js): Where it stands and Linked from the task, Activity from PMOS's kept changes */
|
|
@@ -174,9 +175,50 @@ function drawMain() {
|
|
|
174
175
|
if (!S || !S.ctx.full || !S.t) return;
|
|
175
176
|
const put = (sel, html) => { const x = S.el.querySelector(sel); if (x) x.innerHTML = html; };
|
|
176
177
|
put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '' }));
|
|
178
|
+
// the description (initiative task-descriptions): never redrawn under the PM's typing
|
|
179
|
+
const dw = S.el.querySelector('.ctp-descw');
|
|
180
|
+
if (dw && !(document.activeElement && dw.contains(document.activeElement) && document.activeElement.matches('[data-ctp-desc]'))) dw.innerHTML = VD.descriptionHtml(S.t, { busy: !!S.dbusy, edit: !!S.dedit, undo: !!S.dundo });
|
|
177
181
|
put('.ctp-linked', VD.linkedHtml(S.t));
|
|
178
182
|
put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen }));
|
|
179
183
|
}
|
|
184
|
+
/* PMOS writes a task's description by itself when it has none (POST /api/boards/tasks/describe-draft): once per task, from the initiative's
|
|
185
|
+
* own files, with its sources and Undo. The server never writes it twice, so opening the task again costs nothing. */
|
|
186
|
+
async function describe() {
|
|
187
|
+
const s = S; if (!s || s.t.jira || s.t.description || !s.ctx.pmPost) return;
|
|
188
|
+
s.dbusy = true; drawMain();
|
|
189
|
+
const r = await s.ctx.pmPost('/api/boards/tasks/describe-draft', { ws: s.ctx.ws, board: s.raw.board || s.ctx.board, task: s.t.uid }).catch(() => null);
|
|
190
|
+
s.dbusy = false;
|
|
191
|
+
if (S !== s) return;
|
|
192
|
+
if (r && r.ok && r.wrote && !s.t.description) {
|
|
193
|
+
Object.assign(s.t, { description: r.description, descBy: 'pmos', descSources: r.sources || [] });
|
|
194
|
+
s.raw.description = r.description; s.raw.descBy = 'pmos'; s.raw.descSources = r.sources || [];
|
|
195
|
+
s.dundo = true;
|
|
196
|
+
if (s.ctx.onChange) s.ctx.onChange();
|
|
197
|
+
}
|
|
198
|
+
drawMain();
|
|
199
|
+
}
|
|
200
|
+
/** Save the description (the PM's words, or '' for PMOS's Undo) through tasks/edit, with Undo in the toast. */
|
|
201
|
+
async function saveDesc(text, { word = 'Description saved' } = {}) {
|
|
202
|
+
const s = S; if (!s) return;
|
|
203
|
+
const before = { description: s.t.description, descBy: s.t.descBy, descSources: s.t.descSources };
|
|
204
|
+
const post = (v) => s.ctx.pmPost('/api/boards/tasks/edit', { ws: s.ctx.ws, board: s.raw.board || s.ctx.board, task: s.t.uid, description: v });
|
|
205
|
+
const set = (o) => { Object.assign(s.t, o); s.raw.description = o.description; s.raw.descBy = o.descBy; s.raw.descSources = o.descSources; };
|
|
206
|
+
set({ description: text, descBy: text ? 'you' : '', descSources: [] }); s.dedit = false; s.dundo = false; drawMain();
|
|
207
|
+
const r = await post(text).catch(() => null);
|
|
208
|
+
if (!r || r.ok === false) { set(before); if (S === s) drawMain(); if (s.ctx.toast) s.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
|
|
209
|
+
if (s.ctx.onChange) s.ctx.onChange();
|
|
210
|
+
if (s.ctx.toast) s.ctx.toast(word, async () => {
|
|
211
|
+
const u = await post(before.description || '').catch(() => null);
|
|
212
|
+
if (u && u.ok !== false) { set(before); if (S === s) drawMain(); if (s.ctx.onChange) s.ctx.onChange(); }
|
|
213
|
+
return u || { ok: false };
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function descOut(e) {
|
|
217
|
+
const a = e.target; if (!S || !a.matches || !a.matches('[data-ctp-desc]')) return;
|
|
218
|
+
const v = a.value.replace(/\s+$/, '');
|
|
219
|
+
if (v === (S.t.description || '')) { if (S.dedit) { S.dedit = false; setTimeout(drawMain, 0); } return; }
|
|
220
|
+
saveDesc(v, { word: v ? 'Description saved' : 'Description cleared' });
|
|
221
|
+
}
|
|
180
222
|
function loadActivity() {
|
|
181
223
|
const s = S; if (!s || !s.hist) return;
|
|
182
224
|
Promise.resolve(s.hist.load()).catch(() => []).then((L) => { if (S !== s) return; s.histL = Array.isArray(L) ? L : []; drawMain(); });
|
|
@@ -219,6 +261,8 @@ async function press(e) {
|
|
|
219
261
|
return;
|
|
220
262
|
}
|
|
221
263
|
if ('ctpAfold' in d) { S.aopen = true; drawMain(); return; }
|
|
264
|
+
if ('ctpDedit' in d) { S.dedit = true; drawMain(); const a = S.el.querySelector('[data-ctp-desc]'); if (a) { a.focus(); a.setSelectionRange(a.value.length, a.value.length); } return; }
|
|
265
|
+
if ('ctpDundo' in d) { saveDesc('', { word: 'PMOS\'s description taken back' }); return; }
|
|
222
266
|
if (b.closest('.ctp-hx')) { if (ctx.headPress) { const s0 = S; await ctx.headPress(b, { refresh: () => { if (S === s0) show(s0.uid); }, close: closeTask }); } return; }
|
|
223
267
|
if ('ctpClose' in d) { closeTask(); return; }
|
|
224
268
|
if ('ctpChat' in d) { if (ctx.chat) ctx.chat(); return; }
|
|
@@ -1057,7 +1057,7 @@ const chat = mountChat($('#hmChat'), {
|
|
|
1057
1057
|
let turnT = null;
|
|
1058
1058
|
function turnEnded() {
|
|
1059
1059
|
clearTimeout(turnT);
|
|
1060
|
-
turnT = setTimeout(async () => { await load(); iniFresh(); }, 400); // two chats that finish together read once
|
|
1060
|
+
turnT = setTimeout(async () => { await load(); iniFresh(); if (progPanel) progPanel.then((PP) => PP.refresh()); }, 400); // two chats that finish together read once
|
|
1061
1061
|
// the popup's own reads (the case card, the Library's rows) are read again too, as on every other page (initiative chat-saves-to-cards)
|
|
1062
1062
|
document.dispatchEvent(new CustomEvent('cz:chat-turn'));
|
|
1063
1063
|
}
|
|
@@ -500,7 +500,7 @@ export function mountChat(el, host) {
|
|
|
500
500
|
+ `<div class="hm-tb">${add}`
|
|
501
501
|
+ to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
|
|
502
502
|
+ `${NPU.undoHtml()}${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
|
|
503
|
-
+ marksRow() + filesRow()
|
|
503
|
+
+ marksRow() + filesRow() + errRow()
|
|
504
504
|
+ '</form>';
|
|
505
505
|
if (foot.__h !== html) {
|
|
506
506
|
const focused = document.activeElement && document.activeElement.id === 'hmIn';
|
|
@@ -509,6 +509,9 @@ export function mountChat(el, host) {
|
|
|
509
509
|
if (focused) { ta.focus(); ta.setSelectionRange(ta.value.length, ta.value.length); }
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
+
/* a send that failed says why under the box, and stays until the PM writes again or sends (bug 2026-11-24: a toast behind the popup
|
|
513
|
+
* showed nothing, so the send looked dead) */
|
|
514
|
+
const errRow = () => (C.err ? `<p class="hm-senderr" role="alert">Not sent: ${esc(C.err)}</p>` : '');
|
|
512
515
|
/* the files on the next message: a photo shows its picture, a saved file its size; × takes it off and deletes the copy nothing will name */
|
|
513
516
|
const filesRow = () => (C.files.length ? `<div class="hm-files" id="hmFiles">${C.files.map((f, i) => `<span class="hm-att${f.state === 'saving' ? ' saving' : ''}">`
|
|
514
517
|
+ (f.url ? `<img class="hm-ath" src="${esc(f.url)}" alt="">` : '') + `<b>${esc(f.name)}</b><em>${f.state === 'saving' ? 'Saving…' : f.note ? 'Note' : esc(sizeText(f.size || 0))}</em>`
|
|
@@ -530,7 +533,7 @@ export function mountChat(el, host) {
|
|
|
530
533
|
const mk = C.mark || {};
|
|
531
534
|
if (text && (mk.point || mk.from)) text = (mk.from ? `[From version ${mk.from}] ` : '') + (mk.point ? `[On: ${String(mk.point.label || mk.point.el).replace(/[\]·]/g, ' ').trim()}${mk.point.el ? ' · ' + mk.point.el : ''}] ` : '') + text;
|
|
532
535
|
if (text) C.mark = null;
|
|
533
|
-
C.sending = true;
|
|
536
|
+
C.sending = true; C.err = '';
|
|
534
537
|
let r;
|
|
535
538
|
const was = running();
|
|
536
539
|
// the bubble first, then the server (batch 24 item 2): the files leave the box with the words, and come back if the send fails
|
|
@@ -548,8 +551,9 @@ export function mountChat(el, host) {
|
|
|
548
551
|
if (!r || r.ok !== true) {
|
|
549
552
|
C.pend = C.pend.filter((x) => x !== p);
|
|
550
553
|
if (C.t === t && !C.files.length) C.files = sentFiles;
|
|
551
|
-
|
|
552
|
-
|
|
554
|
+
const why = notSentWhy(r);
|
|
555
|
+
if (C.t === t) { C.err = why; draw(); }
|
|
556
|
+
host.toast('Not sent: ' + why); return false;
|
|
553
557
|
}
|
|
554
558
|
const s = sid() || r.session;
|
|
555
559
|
if (host.touch) host.touch(s);
|
|
@@ -561,6 +565,12 @@ export function mountChat(el, host) {
|
|
|
561
565
|
read();
|
|
562
566
|
return true;
|
|
563
567
|
}
|
|
568
|
+
/** Why a send failed, in the PM's words: the server's own reason, else that the workspace did not answer. */
|
|
569
|
+
function notSentWhy(r) {
|
|
570
|
+
const e = String((r && r.error) || '').trim();
|
|
571
|
+
if (!r) return 'the workspace server did not answer. Your words and files are still here; send again.';
|
|
572
|
+
return (e ? e.charAt(0).toUpperCase() + e.slice(1) : 'PMOS did not take the message') + (/[.!?]$/.test(e) ? '' : '.');
|
|
573
|
+
}
|
|
564
574
|
async function press(k) {
|
|
565
575
|
const t = C.t; if (!t) return;
|
|
566
576
|
const r = t.key && !t.sid ? await host.pmPost('/api/briefing-premium/press' + (t.ws ? '?ws=' + encodeURIComponent(t.ws) : ''), { key: t.key, press: k }).catch(() => null)
|
|
@@ -683,7 +693,7 @@ export function mountChat(el, host) {
|
|
|
683
693
|
el.addEventListener('input', (e) => {
|
|
684
694
|
const card = C.t && C.t.intro && C.t.intro.card;
|
|
685
695
|
if (card && card.input && e.target.closest('.hm-icard')) { card.input(e.target, e.target.closest('.hm-icard')); return; }
|
|
686
|
-
if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; drawSlash(); NPU.input(e.target.value); }
|
|
696
|
+
if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; drawSlash(); NPU.input(e.target.value); if (C.err) { C.err = ''; const er = foot.querySelector('.hm-senderr'); if (er) er.remove(); foot.__h = null; } }
|
|
687
697
|
});
|
|
688
698
|
/* ── the mic ── dictation into the box only (HmMic). A desk shows the blue dot in the box; a phone shows the Speak to Claude sheet. */
|
|
689
699
|
const box = () => foot.querySelector('textarea');
|
|
@@ -790,7 +800,7 @@ export function mountChat(el, host) {
|
|
|
790
800
|
if (notesM) notesM.then((M) => setTimeout(() => M.syncNotes(), 0)); // the Notes open in the Viewer belonged to the conversation before
|
|
791
801
|
const same = C.t && t && C.t.key === t.key && C.t.sid === t.sid;
|
|
792
802
|
C.t = t;
|
|
793
|
-
if (!same) { C.mark = null; NPU.open(); C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.marked = null; C.touched = null; C.picked = {}; C.pend = []; C.plOpen = false; C.plAll = false; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); put(pl, ''); pl.hidden = true; C.jump = true; peek(null); }
|
|
803
|
+
if (!same) { C.mark = null; NPU.open(); C.addOpen = false; C.th = null; C.conv = null; C.show = 12; C.open = new Set(); C.files = []; C.err = ''; C.marked = null; C.touched = null; C.picked = {}; C.pend = []; C.plOpen = false; C.plAll = false; C.seenAt = t.key ? host.seen(t.key) : null; put(log, introHtml(t.intro)); put(pl, ''); pl.hidden = true; C.jump = true; peek(null); }
|
|
794
804
|
draw(); read();
|
|
795
805
|
},
|
|
796
806
|
refresh() { if (C.t) draw(); },
|
|
@@ -500,7 +500,8 @@ export function iniPage(o = {}) {
|
|
|
500
500
|
let rename = X.ctx.renameIni ? X.ctx.renameIni(id, '') : null;
|
|
501
501
|
if (rename) rename = { ...rename, value: X.ctx.iniTitle(id) };
|
|
502
502
|
const dh = dashFor(id);
|
|
503
|
-
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => (PW.on(BODY) ? PW.moreItems(null, popExtra(id), BODY) : []).concat(pageMore(id), PW.on(BODY) && !PW.inPop(BODY) ? moreOf(id, 'page').filter((x) => x.sep || /full record|Sprint/.test(x.label)) : []), rename, // a phone's page (Ph2_init) keeps the record and the sprint
|
|
503
|
+
BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => (PW.on(BODY) ? PW.moreItems(null, popExtra(id), BODY) : []).concat(pageMore(id), PW.on(BODY) && !PW.inPop(BODY) ? moreOf(id, 'page').filter((x) => x.sep || /full record|Sprint/.test(x.label)) : []), rename, // a phone's page (Ph2_init) keeps the record and the sprint
|
|
504
|
+
pop: o.pop || undefined, // on a desk: the one popup (goIni passes it); never inside the comment above, or work opens beside the page
|
|
504
505
|
discuss: () => X.ctx.newIn(id), discussHome: true, // the one view (OvViewers): Discuss starts a new session about it, where + New session was
|
|
505
506
|
// the kind of work (batch 29 item 11, KdV1-3): its glyph stands before Discuss; a tap opens the three kinds
|
|
506
507
|
presses: [WK.pressOf(kindNow(id))].concat(dh ? dh.presses() : []), onPress: (a, btn) => {
|
|
@@ -14,6 +14,7 @@ import * as POP from './cozy-popup.js';
|
|
|
14
14
|
const KIND = { doc: 'document', link: 'link', meeting: 'meeting', proto: 'prototype' };
|
|
15
15
|
const CHIP = { link: 'Link', meeting: 'Meeting notes', proto: 'Prototype' };
|
|
16
16
|
export const aboutOf = (x, from) => ({ id: String(x.id || '').replace(/[^A-Za-z0-9._:-]+/g, '-').slice(0, 100), kind: KIND[x.kind] || 'document', title: x.name || '', ws: (x.about && x.about.ws) || undefined,
|
|
17
|
+
...(x.open && x.open.doc && x.open.doc.path ? { path: String(x.open.doc.path) } : {}),
|
|
17
18
|
...(from ? { from } : {}), kindChip: CHIP[x.kind] || x.kindText || 'Document' });
|
|
18
19
|
|
|
19
20
|
export function openItem(x, { from } = {}) {
|
|
@@ -46,12 +46,17 @@ export function targetOf(it, ws) {
|
|
|
46
46
|
return { key: keyOf(it), ws: ws || undefined, title, about: title, scope: { text: title, icon: FLAG }, role: CLAUDE, rich: false, context: contextOf(it, ws),
|
|
47
47
|
placeholder: 'Message PMOS about ' + title, empty: 'Ask about ' + title + '. PMOS reads its records and works on it in a real session.' };
|
|
48
48
|
}
|
|
49
|
-
/** What the chat is about, in the page's words, for a chat whose key the server's model has no row for (a program, a whole product):
|
|
49
|
+
/** What the chat is about, in the page's words, for a chat whose key the server's model has no row for (a program, a whole product, a document):
|
|
50
50
|
* lib/briefing-premium-agent.js starts it from these words (bug 2026-11-23). An initiative's chat reads its own record and needs none. */
|
|
51
51
|
export function contextOf(it, ws) {
|
|
52
52
|
const kind = String((it && (it.scopeKind || it.kind)) || '').toLowerCase(), title = String((it && it.title) || '').replace(/\s+/g, ' ').trim().slice(0, 80);
|
|
53
|
-
if (!title || !/^(program|product)$/.test(kind)) return undefined;
|
|
53
|
+
if (!title || !/^(program|product|document|doc)$/.test(kind)) return undefined;
|
|
54
54
|
const where = ws ? ' (workspace ' + String(ws).slice(0, 60) + ')' : '';
|
|
55
|
+
// a document (Library, an initiative's artefacts; bug 2026-11-24): its title and file, so the chat reads the document the PM has open
|
|
56
|
+
if (kind !== 'program' && kind !== 'product') {
|
|
57
|
+
const file = String((it && it.path) || '').replace(/\s+/g, ' ').trim().slice(0, 300);
|
|
58
|
+
return 'The document ' + title + where + (file ? ', file ' + file : '') + '. Read it before you answer.';
|
|
59
|
+
}
|
|
55
60
|
return kind === 'product'
|
|
56
61
|
? 'The product ' + title + where + ': its programs and initiatives on the Work page. Read them with pmos before you answer.'
|
|
57
62
|
: 'The program ' + title + where + ': its initiatives and milestones. Read it with pmos before you answer.';
|
|
@@ -117,7 +117,8 @@ mountPanels({ page: document.getElementById('stage'), key: 'board', sources: BP2
|
|
|
117
117
|
/* Discuss in chat on an initiative's or a program's panel opens Home's chat about it in a panel of its own, beside the panel or sliding over
|
|
118
118
|
* it (batch 26 item 4, page-chat.js); the Board stays. A finished turn reads the board again. A phone goes to Home as before. */
|
|
119
119
|
VW.chatHere((it) => { const r = M && (M.rows || []).find((x) => x.id === it.id); import('./page-chat.js').then((C) => C.openChat(it, { ws: (r && r.ws) || (M && M.board.ws) || undefined })); return true; });
|
|
120
|
-
|
|
120
|
+
// the programs too, and an open program panel draws again: a chat that saved a program's goal shows it at once (initiative chat-saves-to-cards)
|
|
121
|
+
document.addEventListener('cz:chat-turn', () => { clearTimeout(chatT); chatT = setTimeout(async () => { await loadPrograms(); PP.refresh(); load(); }, 400); });
|
|
121
122
|
let chatT = null;
|
|
122
123
|
// the popup's sessions name the work they are about, and the chat icon opens a session's initiative here, in the popup
|
|
123
124
|
POP.setTitles((id) => { const r = M && ((M.rows || []).find((x) => x.id === id) || goneRows().find((x) => x.id === id)); return r ? r.title : ''; });
|
|
@@ -64,6 +64,8 @@ export function taskOf(row, extra = {}) {
|
|
|
64
64
|
iniTitle: extra.iniTitle || '', group: extra.group != null ? extra.group : '', board: r.board || extra.board || '',
|
|
65
65
|
section: typeof r.section === 'string' ? r.section : '', milestone: !!r.milestone, wbs: r.wbs && (r.wbs.title || r.wbs.id) ? { id: r.wbs.id || '', title: r.wbs.title || r.wbs.id } : null,
|
|
66
66
|
jira: jira ? { key: r.ref || r.key || r.uid || '', readAt: r.readAt || extra.readAt || '' } : null,
|
|
67
|
+
// the task's description (initiative task-descriptions): its words, who wrote the last one ('pmos' | 'you') and PMOS's sources
|
|
68
|
+
description: typeof r.description === 'string' ? r.description : '', descBy: r.descBy || '', descSources: Array.isArray(r.descSources) ? r.descSources : [],
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
|