create-pmos 0.492.0 → 0.494.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 +75 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/mods/pmos-cockpit/README.md +1 -1
- package/payload/mods/pmos-cockpit/hooks/lib/guard.mjs +2 -2
- 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-initiative-test.js +2 -1
- package/workspace/changelog.json +74 -0
- package/workspace/fixtures/initiatives-api/list.json +0 -4
- package/workspace/fixtures/initiatives-api/roadmap.json +255 -275
- package/workspace/fixtures/initiatives-api/sheet.json +2 -3
- package/workspace/fixtures/report-api/draft.json +4 -4
- package/workspace/fixtures/reports-page/draft-biweekly-2026-10-16.md +4 -4
- package/workspace/guide/board.md +2 -2
- package/workspace/guide/briefing-premium.md +2 -0
- package/workspace/guide/claude-proposes.md +2 -2
- package/workspace/guide/data-freshness.md +3 -1
- package/workspace/guide/index.md +2 -2
- package/workspace/guide/initiative-boards.md +2 -2
- package/workspace/guide/initiatives-roadmap.md +38 -39
- package/workspace/guide/initiatives-screen.md +22 -20
- package/workspace/guide/initiatives-timeline.md +7 -9
- package/workspace/guide/integrated-work.md +7 -8
- package/workspace/guide/layout.md +2 -2
- package/workspace/guide/lifecycle.md +2 -2
- package/workspace/guide/notes.md +1 -1
- package/workspace/guide/pm-only-acts.md +5 -5
- package/workspace/guide/pm-only-lines.md +3 -3
- package/workspace/guide/report-slides.md +14 -1
- package/workspace/guide/reports.md +4 -2
- package/workspace/guide/today.md +2 -2
- package/workspace/guide/your-impact.md +6 -7
- package/workspace/lib/board-cli.js +1 -1
- package/workspace/lib/board-fold.js +6 -6
- package/workspace/lib/board-premium.js +3 -3
- package/workspace/lib/board-trail.js +30 -3
- package/workspace/lib/calendar-tidy.js +1 -1
- package/workspace/lib/core-docs.js +2 -2
- package/workspace/lib/engine/boards.js +11 -11
- package/workspace/lib/engine/signals/detectors.js +13 -13
- package/workspace/lib/engine/signals/facts.js +5 -3
- package/workspace/lib/git-shape.js +21 -0
- package/workspace/lib/grill-runs.js +21 -6
- package/workspace/lib/grill.js +1 -1
- package/workspace/lib/health-rules-factory.js +13 -14
- package/workspace/lib/health-rules-plan.js +8 -7
- package/workspace/lib/impact.js +29 -16
- package/workspace/lib/initiative-cli.js +59 -63
- package/workspace/lib/initiative-needs.js +6 -6
- package/workspace/lib/initiative-premium.js +2 -2
- package/workspace/lib/initiative-writer.js +2 -2
- package/workspace/lib/lifecycle-stage.js +39 -0
- package/workspace/lib/page-warm.js +68 -0
- package/workspace/lib/placements.js +117 -95
- package/workspace/lib/plan-rules.js +7 -5
- package/workspace/lib/pm-guard.js +1 -3
- package/workspace/lib/pm-lines-needs.js +1 -1
- package/workspace/lib/report-design.js +6 -1
- package/workspace/lib/report-draft.js +17 -16
- package/workspace/lib/report-export.js +148 -9
- package/workspace/lib/report-pyramid.js +434 -0
- package/workspace/lib/report-slides-data.js +11 -7
- package/workspace/lib/report-structure.js +5 -1
- package/workspace/lib/report-templates.js +81 -20
- package/workspace/lib/routes-boards.js +9 -8
- package/workspace/lib/routes-brief-page.js +20 -3
- package/workspace/lib/routes-grill.js +10 -4
- package/workspace/lib/routes-impact.js +12 -4
- package/workspace/lib/routes-initiatives.js +29 -43
- package/workspace/lib/routes-notes.js +24 -15
- package/workspace/lib/routes-programs.js +6 -4
- package/workspace/lib/routes-report-design.js +15 -0
- package/workspace/lib/routes-report-flow.js +106 -17
- package/workspace/lib/routes-report-setups.js +2 -1
- package/workspace/lib/routes-report-structure.js +3 -0
- package/workspace/lib/split-merge.js +2 -3
- package/workspace/lib/wf-bridge.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-report-tab-test.js +5 -1
- package/workspace/public/pm/cozy-vw-rp.css +12 -0
- package/workspace/public/pm/fetch-share.js +38 -0
- package/workspace/public/pm/home-app.js +21 -3
- package/workspace/public/pm/home-chat.js +5 -4
- package/workspace/public/pm/home-impact.css +23 -13
- package/workspace/public/pm/home-impact.js +49 -32
- package/workspace/public/pm/home-ini.css +2 -0
- package/workspace/public/pm/http.js +1 -1
- package/workspace/public/pm/ini-view.css +55 -0
- package/workspace/public/pm/ini-view.js +5 -2
- package/workspace/public/pm/premium-board.js +1 -0
- package/workspace/public/pm/premium-insights.js +1 -0
- package/workspace/public/pm/premium-report-read.js +25 -6
- package/workspace/public/pm/premium-report-tab.js +69 -14
- package/workspace/public/pm/report-flow.js +93 -10
- package/workspace/public/pm/view-notes.js +8 -8
- package/workspace/replaced-tests.json +14 -0
- package/workspace/server.js +24 -3
- package/workspace/skills/report-template.skill +8 -0
- package/workspace/test-lists/page-open-speed.json +5 -0
- package/workspace/test-lists/report-pyramid.json +9 -0
|
@@ -33,6 +33,7 @@ const guard = require('./pm-guard.js');
|
|
|
33
33
|
const pmItems = require('./pm-items.js');
|
|
34
34
|
const P = require('./programs.js');
|
|
35
35
|
const MS = require('./milestone-suggest.js');
|
|
36
|
+
const gitShape = require('./git-shape.js');
|
|
36
37
|
const gitInfo = require('./git-info.js');
|
|
37
38
|
const deletedIds = require('./ini-deleted.js');
|
|
38
39
|
|
|
@@ -54,17 +55,18 @@ const read = (f) => { try { return f ? pmItems.readLines(f).filter(Boolean) : []
|
|
|
54
55
|
* such, a charter saved from the worktree puts the program under the worktree product while its members sit under the main one, and a
|
|
55
56
|
* member line that both hold shows twice. So the ledgers of a repo's trees are read as ONE product, the main tree's. Null when the
|
|
56
57
|
* workspace is not a linked worktree, or its main tree is not registered (nothing to fold into). Memoised: all() runs on every poll. */
|
|
57
|
-
|
|
58
|
-
const mainCache = new Map(); // root -> {
|
|
58
|
+
// Kept while the folder's git shape stamp is unchanged (page-open-speed): a 15 s clock re-ran `git` on every Board open after a break.
|
|
59
|
+
const mainCache = new Map(); // root -> { stamp, main: root of the repo's main tree | null }
|
|
59
60
|
function mainTreeRoot(w) {
|
|
60
61
|
const hit = mainCache.get(w.root);
|
|
61
|
-
|
|
62
|
+
const stamp = gitShape.shapeStamp(w.root);
|
|
63
|
+
if (hit && hit.stamp === stamp) return hit.main;
|
|
62
64
|
let main = null;
|
|
63
65
|
try {
|
|
64
66
|
const top = gitInfo.repoRoot(w.root), trees = top ? gitInfo.worktrees(w.root) : [];
|
|
65
67
|
if (top && trees.length && trees[0].dir && path.resolve(trees[0].dir) !== path.resolve(top)) main = path.join(path.resolve(trees[0].dir), path.relative(path.resolve(top), path.resolve(w.root)));
|
|
66
68
|
} catch { main = null; }
|
|
67
|
-
mainCache.set(w.root, {
|
|
69
|
+
mainCache.set(w.root, { stamp, main });
|
|
68
70
|
return main;
|
|
69
71
|
}
|
|
70
72
|
function foldedInto(list, w) {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* POST /api/report-design/revert { ws, id, n } → { ok, design }
|
|
15
15
|
* GET /api/report-design/cycle?ws&path → { ok, designed, design_version, format, outline, differences, decisions, matches, rendering, previous }
|
|
16
16
|
* GET /api/report-design/cycle-html?ws&path → text/html, the sanitized cycle render
|
|
17
|
+
* GET /api/report-design/pyramid?ws&path → text/html, the finished slides of a cadence draft (lib/report-pyramid.js; 404 for another document)
|
|
17
18
|
* POST /api/report-design/cycle-decision { ws, path, diff, choice: keep | adopt | match } → { ok, cycle }
|
|
18
19
|
* GET /api/report-notes?ws&path → { ok, speaker, suggestions, pins }
|
|
19
20
|
* POST /api/report-notes/speaker { ws, path, slide, text } | { ws, path, slide, keep: true }
|
|
@@ -43,9 +44,11 @@ const path = require('path');
|
|
|
43
44
|
const crypto = require('crypto');
|
|
44
45
|
const guard = require('./pm-guard.js');
|
|
45
46
|
const D = require('./report-design.js');
|
|
47
|
+
const RT = require('./report-templates.js');
|
|
46
48
|
const RS = require('./report-setups.js');
|
|
47
49
|
const RC = require('./report-checks.js');
|
|
48
50
|
const RDraft = require('./report-draft.js');
|
|
51
|
+
const RP = require('./report-pyramid.js');
|
|
49
52
|
const headless = require('./headless.js');
|
|
50
53
|
|
|
51
54
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
@@ -475,6 +478,14 @@ async function handle(req, res, url, ctx) {
|
|
|
475
478
|
const setup = e ? setupOf(w.root, e.id) : null;
|
|
476
479
|
return send({ status: 200, body: { ok: true, id: setup ? e.id : null, name: setup ? setup.name : null, at: setup ? e.at : null } });
|
|
477
480
|
}
|
|
481
|
+
if (sub === 'pyramid') {
|
|
482
|
+
// The finished slides of a cadence draft (canvas RsA): the Pyramid deck in the report's saved look, else the standard PMOS look.
|
|
483
|
+
const d = reportDoc(w, text(url.searchParams.get('path'))); if (d.error) return send(d.error);
|
|
484
|
+
let md; try { md = fs.readFileSync(d.c.md, 'utf8'); } catch { return send(bad(404, 'no such report document')); }
|
|
485
|
+
const deck = RP.deckOf(md, RP.lookOf(w.root, d.c.cadence));
|
|
486
|
+
if (!deck) return send(bad(404, 'this document is not a cadence draft, so it has no Pyramid deck'));
|
|
487
|
+
return sendHtml(res, D.sanitize(RP.deckHtml(deck)));
|
|
488
|
+
}
|
|
478
489
|
if (sub === 'cycle' || sub === 'cycle-html') {
|
|
479
490
|
const d = reportDoc(w, text(url.searchParams.get('path'))); if (d.error) return send(d.error);
|
|
480
491
|
if (sub === 'cycle') return send({ status: 200, body: cycleAnswer(w, d.c) });
|
|
@@ -532,7 +543,9 @@ async function handle(req, res, url, ctx) {
|
|
|
532
543
|
rules: D.rulesFor(root, c.cadence, st.saved.version), from: 'adopt', actor: g.actor });
|
|
533
544
|
if (!v.ok) return fail(v);
|
|
534
545
|
newVersion = v.n;
|
|
546
|
+
const tw = RT.followBefore(root, c.cadence, setupOf(root, c.cadence));
|
|
535
547
|
D.append(root, c.cadence, { ev: 'accept', n: v.n, rules: D.rulesFor(root, c.cadence, v.n) }, { actor: g.actor });
|
|
548
|
+
RT.followAfter(root, c.cadence, { design: v.n }, tw); // the template follows the saved look as T<n+1> (canvas TplA)
|
|
536
549
|
D.writeBrief(root, c.cadence, setupOf(root, c.cadence));
|
|
537
550
|
}
|
|
538
551
|
const r = D.decideCycle(root, c.rel, { diff: diff.id, choice, newVersion });
|
|
@@ -597,7 +610,9 @@ async function handle(req, res, url, ctx) {
|
|
|
597
610
|
const n = body.n;
|
|
598
611
|
if (!Number.isInteger(n) || !D.stateOf(root, id).versions.has(n)) return send(bad(404, 'no such version'));
|
|
599
612
|
if (sub === 'revert') { D.append(root, id, { ev: 'revert', n }, { actor: g.actor }); return answer(); }
|
|
613
|
+
const tw = RT.followBefore(root, id, setup);
|
|
600
614
|
D.append(root, id, { ev: 'accept', n, rules: D.rulesFor(root, id, n) }, { actor: g.actor });
|
|
615
|
+
RT.followAfter(root, id, { design: n }, tw); // the template follows the saved look as T<n+1> (canvas TplA)
|
|
601
616
|
const b = D.writeBrief(root, id, setup);
|
|
602
617
|
if (!b.ok) return fail(b);
|
|
603
618
|
// the current cycle is redrawn in the saved design at once (Wawan, 2026-10-13); older cycles, and a cycle already sent, keep their look
|
|
@@ -3,12 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* GET /api/report-flow?ws&id → { ok, id, name, audience, output, schedule, status, template: { current, versions: [{ n, settings, words,
|
|
5
5
|
* why, at, current, cycles }] }, cycles: [{ path, slot, state }] (newest first), latest, drafting, session,
|
|
6
|
-
* review } the report's current state: what the chat chip opens
|
|
6
|
+
* review, sections, look } the report's current state: what the chat chip opens.
|
|
7
|
+
* sections: { saved: S<n> | null, titles } the sections the next cycle follows
|
|
8
|
+
* look: { saved: D<n> | null, words, follows: [sample], newer: { n, words } | null } the look, and a newer
|
|
9
|
+
* design version not saved yet (made in Design): the template panel offers it as a change
|
|
7
10
|
* GET /api/report-flow/review?ws&path → { ok, review: { fix: [{ id, title, why }], passed: [label] } } Claude's review of one draft
|
|
8
11
|
* POST /api/report-flow/start { ws, id, chat? } → { ok, n } T1 of a report just set up, and the conversation it came from
|
|
9
|
-
* POST /api/report-flow/template { ws, id, settings }
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* POST /api/report-flow/template { ws, id, settings?, sections?, design? } → { ok, n } the PM's ✓ on a changed template (canvas TplA): applied,
|
|
13
|
+
* and ONE T<n+1> holding all of it. sections: the titles in order (a new S version, saved); design: a D
|
|
14
|
+
* version made in Design (saved), or null for the standard look. The open draft is not written again.
|
|
15
|
+
* POST /api/report-flow/restore { ws, id, n } → { ok, n, restored } Go back to T<n>: its format, readers and schedule,
|
|
16
|
+
* and its sections and look when it recorded them, are applied; nothing is deleted. Cycles keep
|
|
17
|
+
* the look they were made with; the open draft stays as it is
|
|
18
|
+
* POST /api/report-flow/ask { ws, id, text, path? } → { ok, session, path, passed | started } a change for the report's own session
|
|
19
|
+
* Without a path the change goes to the report's latest draft; an issued latest cycle (or path) is refused
|
|
20
|
+
* 409, as an issued report is frozen. The session always gets the file and its slot, and "do not draft a new
|
|
21
|
+
* slot", so a change edits the draft that exists (report-building brief 1).
|
|
12
22
|
*
|
|
13
23
|
* THE REPORT'S OWN SESSION. Each template drafts in a session of its own, never in the PM's chat (the agreed note). A report with a saved
|
|
14
24
|
* structure drafts in the session its schedule starts (lib/routes-report-structure.js draftNow, origin schedule:<id>). A change the PM asks for
|
|
@@ -25,6 +35,8 @@ const guard = require('./pm-guard.js');
|
|
|
25
35
|
const RT = require('./report-templates.js');
|
|
26
36
|
const RS = require('./report-setups.js');
|
|
27
37
|
const RN = require('./report-needs.js');
|
|
38
|
+
const RSt = require('./report-structure.js');
|
|
39
|
+
const RD = require('./report-design.js');
|
|
28
40
|
const issues = require('./issues.js');
|
|
29
41
|
|
|
30
42
|
const prefixes = ['/api/report-flow'];
|
|
@@ -52,6 +64,7 @@ function stateOf(ctx, w, id, now = Date.now()) {
|
|
|
52
64
|
const cycles = cyclesOf(root, id);
|
|
53
65
|
const f = RT.fold(RT.readLines(root, id));
|
|
54
66
|
const counts = RT.cyclesOf(f, cycles.filter((c) => c.issued_at).map((c) => ({ at: c.issued_at })));
|
|
67
|
+
const names = RT.namesOf(root, id), live = RT.liveRefs(root, id);
|
|
55
68
|
const sess = readSession(root, id);
|
|
56
69
|
const drafting = draftingOf(ctx, w, id);
|
|
57
70
|
const latest = cycles[0] || null;
|
|
@@ -59,12 +72,59 @@ function stateOf(ctx, w, id, now = Date.now()) {
|
|
|
59
72
|
if (latest && latest.state === 'draft') { const t = readText(root, latest.path); if (t != null) review = RT.review(t, { slot: latest.slot, now, listed: s && Array.isArray(s.sections) ? s.sections : [] }); }
|
|
60
73
|
return {
|
|
61
74
|
ok: true, id, name: s ? s.name : id, audience: s ? s.audience : '', output: s ? s.output : '', schedule: s ? s.schedule : null, status: s ? s.status : 'removed',
|
|
62
|
-
template: { current: f.current, versions: f.versions.map((v) => ({ ...v, words: RT.settingsWords(v.settings), cycles: counts.get(v.n) || 0 })) },
|
|
75
|
+
template: { current: f.current, versions: f.versions.map((v) => ({ ...v, words: RT.settingsWords(v.settings, names), cycles: counts.get(v.n) || 0 })) },
|
|
63
76
|
cycles, latest, drafting,
|
|
64
77
|
session: sess ? { id: sess.session, alive: alive(ctx, sess.session), since: sess.since || null } : null,
|
|
65
78
|
review,
|
|
79
|
+
sections: { saved: live.structure, titles: names.sections(live.structure) || (s && Array.isArray(s.sections) ? s.sections.slice() : []) },
|
|
80
|
+
look: lookOf(root, id, live.design, names),
|
|
66
81
|
};
|
|
67
82
|
}
|
|
83
|
+
/** The look the next cycle follows, the samples it follows, and the newest design version made after it and not saved yet. */
|
|
84
|
+
function lookOf(root, id, saved, names) {
|
|
85
|
+
let st = null; try { st = RD.stateOf(root, id); } catch { st = null; }
|
|
86
|
+
const follows = st ? [...st.samples.values()].map((x) => x.name).filter(Boolean).slice(0, 3) : [];
|
|
87
|
+
const top = st && st.versions.size ? Math.max(...st.versions.keys()) : null;
|
|
88
|
+
const newer = top != null && top !== saved && (saved == null || top > saved) ? { n: top, words: names.look(top) } : null;
|
|
89
|
+
return { saved, words: names.look(saved), follows, newer };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Save a template's sections and look in their own stores, as the studios' accept does, when they differ from what is saved now. A ref that is
|
|
93
|
+
* undefined (a T line from before TplA) is left as it is. */
|
|
94
|
+
function applyRefs(root, id, setup, want, actor) {
|
|
95
|
+
const live = RT.liveRefs(root, id), done = {};
|
|
96
|
+
if (want.structure !== undefined && want.structure !== live.structure) {
|
|
97
|
+
if (want.structure == null) { RSt.append(root, id, { ev: 'unsave' }, { actor }); try { fs.unlinkSync(RSt.paths(root, id).brief); } catch { /* none written */ } }
|
|
98
|
+
else {
|
|
99
|
+
if (!RSt.stateOf(root, id).versions.has(want.structure) || !RSt.readVersion(root, id, want.structure)) return { ok: false, status: 409, error: `S${want.structure} is not on disk, so its sections cannot come back` };
|
|
100
|
+
RSt.append(root, id, { ev: 'accept', n: want.structure, charts: [] }, { actor });
|
|
101
|
+
RSt.writeBrief(root, id, setup);
|
|
102
|
+
}
|
|
103
|
+
done.structure = true;
|
|
104
|
+
}
|
|
105
|
+
if (want.design !== undefined && want.design !== live.design) {
|
|
106
|
+
if (want.design == null) { RD.append(root, id, { ev: 'unsave' }, { actor }); try { fs.unlinkSync(RD.paths(root, id).brief); } catch { /* none written */ } }
|
|
107
|
+
else {
|
|
108
|
+
if (!RD.stateOf(root, id).versions.has(want.design)) return { ok: false, status: 409, error: `D${want.design} is not on disk, so its look cannot come back` };
|
|
109
|
+
RD.append(root, id, { ev: 'accept', n: want.design, rules: RD.rulesFor(root, id, want.design) }, { actor });
|
|
110
|
+
RD.writeBrief(root, id, setup);
|
|
111
|
+
}
|
|
112
|
+
done.design = true;
|
|
113
|
+
}
|
|
114
|
+
return { ok: true, done };
|
|
115
|
+
}
|
|
116
|
+
/** The sections the PM named, as a new S version (planFromSections keeps the saved plan's purpose, sources and charts). → { ok, n } | refusal.
|
|
117
|
+
* The same titles as saved write nothing (n is the saved one). */
|
|
118
|
+
function sectionsVersion(root, id, setup, titles, actor) {
|
|
119
|
+
const live = RT.liveRefs(root, id);
|
|
120
|
+
const was = live.structure != null ? RSt.readVersion(root, id, live.structure) : null;
|
|
121
|
+
const shaped = RSt.planFromSections(titles, { readers: (setup && setup.audience) || '', decision: (setup && setup.purpose) || '', base: was });
|
|
122
|
+
if (!shaped.ok) return shaped;
|
|
123
|
+
const same = was && Array.isArray(was.outline) && was.outline.map((o) => o.title).join('\n') === shaped.plan.outline.map((o) => o.title).join('\n');
|
|
124
|
+
if (same) return { ok: true, n: live.structure, same: true };
|
|
125
|
+
const v = RSt.landVersion(root, id, shaped.plan, { turn: 'The sections named in the chat.', answer: `Made the sections you named, for the next template.`, from: 'template', actor });
|
|
126
|
+
return v.ok ? { ok: true, n: v.n } : v;
|
|
127
|
+
}
|
|
68
128
|
|
|
69
129
|
/** Apply a template's settings to the setup line (report-setups change and reschedule): the live values follow the current version. */
|
|
70
130
|
function apply(root, id, settings, opts) {
|
|
@@ -79,10 +139,16 @@ function apply(root, id, settings, opts) {
|
|
|
79
139
|
return { ok: true };
|
|
80
140
|
}
|
|
81
141
|
|
|
142
|
+
const slotOfRel = (rel) => { const m = /(\d{4}-\d{2}-\d{2})\.md$/.exec(String(rel || '')); return m ? m[1] : null; };
|
|
143
|
+
/** The line that names the draft a change is for: its file, its slot, and the rule that no new slot is drafted. */
|
|
144
|
+
function draftWords(id, rel) {
|
|
145
|
+
const slot = slotOfRel(rel);
|
|
146
|
+
return rel && slot ? `The draft: ${rel} (slot ${slot}). Change that file in place. Do not draft a new slot: run \`pmos report draft ${id} ${slot} --redraft\` only, never \`pmos report draft ${id}\` without the slot.` : '';
|
|
147
|
+
}
|
|
82
148
|
/** The words the report's session gets for one change. */
|
|
83
149
|
function askPrompt(skill, id, rel, change) {
|
|
84
150
|
return `${skill}\n\nThe PM's request for this run, given when it was scheduled (do not ask again): ${id}\n\n`
|
|
85
|
-
+ `This is the report's own drafting session (the PMOS report flow), not the PM's chat. ${rel ?
|
|
151
|
+
+ `This is the report's own drafting session (the PMOS report flow), not the PM's chat. ${rel ? draftWords(id, rel) + ' ' : ''}`
|
|
86
152
|
+ `The change the PM asked for: ${change}\nChange only the draft. Never issue, send or share it: the PM issues it on the page.`;
|
|
87
153
|
}
|
|
88
154
|
function ask(ctx, w, id, change, rel) {
|
|
@@ -90,10 +156,10 @@ function ask(ctx, w, id, change, rel) {
|
|
|
90
156
|
const d = draftingOf(ctx, w, id);
|
|
91
157
|
const sess = readSession(root, id);
|
|
92
158
|
const target = d && d.state === 'drafting' && alive(ctx, d.session) ? d.session : sess && alive(ctx, sess.session) ? sess.session : null;
|
|
93
|
-
const msg = `[PMOS report change] ${rel ?
|
|
159
|
+
const msg = `[PMOS report change] ${rel ? draftWords(id, rel) + ' ' : ''}The change: ${change}. Change only the draft; never issue, send or share it.`;
|
|
94
160
|
if (target) {
|
|
95
161
|
const sent = typeof ctx.sendToSession === 'function' && ctx.sendToSession(target, msg);
|
|
96
|
-
if (sent) return { ok: true, session: target, passed: true };
|
|
162
|
+
if (sent) return { ok: true, session: target, path: rel, passed: true };
|
|
97
163
|
}
|
|
98
164
|
if (typeof ctx.spawnSession !== 'function') return { ok: false, status: 409, error: 'This workspace cannot start a session for the report.' };
|
|
99
165
|
const skill = typeof ctx.skillPrompt === 'function' ? ctx.skillPrompt('report-template', w) : null;
|
|
@@ -104,7 +170,7 @@ function ask(ctx, w, id, change, rel) {
|
|
|
104
170
|
const sp = ctx.spawnSession({ name: 'Report · ' + ((s && s.name) || id), agent: 'claude', ws: w.id, origin, initialInput: askPrompt(skill, id, rel, change) + '\r' });
|
|
105
171
|
if (!sp || sp.state === 'exited' || !sp.id) return { ok: false, status: 409, error: 'The report\'s session did not start: ' + ((sp && sp.note) || 'no session') };
|
|
106
172
|
try { fs.mkdirSync(path.dirname(sessionFile(root, id)), { recursive: true }); fs.writeFileSync(sessionFile(root, id), JSON.stringify({ session: sp.id, since: new Date().toISOString() }) + '\n'); } catch { /* shown as no session */ }
|
|
107
|
-
return { ok: true, session: sp.id, started: true };
|
|
173
|
+
return { ok: true, session: sp.id, path: rel, started: true };
|
|
108
174
|
}
|
|
109
175
|
|
|
110
176
|
async function handle(req, res, url, ctx) {
|
|
@@ -152,15 +218,31 @@ async function handle(req, res, url, ctx) {
|
|
|
152
218
|
return r.ok ? send({ status: 200, body: { ok: true, n: r.n } }) : fail(r);
|
|
153
219
|
}
|
|
154
220
|
if (sub === 'template') {
|
|
155
|
-
const want = RT.cleanSettings(body.settings);
|
|
156
|
-
|
|
221
|
+
const want = { ...(RT.cleanSettings(body.settings) || {}) };
|
|
222
|
+
delete want.structure; delete want.design; // these come only as sections (titles) and design (a D version), checked below
|
|
223
|
+
const titles = Array.isArray(body.sections) ? body.sections : null;
|
|
224
|
+
const hasDesign = body.design === null || Number.isInteger(body.design);
|
|
225
|
+
if (!Object.keys(want).length && !titles && !hasDesign) return send(bad(400, 'say what changes: the format, who reads it, when it goes out, its sections or its look'));
|
|
226
|
+
if (Number.isInteger(body.design) && !RD.stateOf(w.root, id).versions.has(body.design)) return send(bad(404, 'no such design version'));
|
|
157
227
|
RT.ensureFirst(w.root, id, s);
|
|
228
|
+
const live = RT.liveRefs(w.root, id);
|
|
158
229
|
const f = RT.fold(RT.readLines(w.root, id)), cur = f.versions.find((v) => v.current);
|
|
159
|
-
|
|
160
|
-
|
|
230
|
+
// a T line from before TplA did not record its sections or look: it is compared as the ones saved now
|
|
231
|
+
const was = { ...live, ...(cur ? cur.settings : RT.settingsOf(s)) };
|
|
232
|
+
if (titles) {
|
|
233
|
+
const sv = sectionsVersion(w.root, id, s, titles, g.actor);
|
|
234
|
+
if (!sv.ok) return fail(sv);
|
|
235
|
+
want.structure = sv.n;
|
|
236
|
+
}
|
|
237
|
+
if (hasDesign) want.design = body.design;
|
|
238
|
+
const next = { ...was, ...want };
|
|
239
|
+
if (cur && RT.sameSettings(was, next)) return send({ status: 200, body: { ok: true, n: cur.n, unchanged: true } });
|
|
161
240
|
const a = apply(w.root, id, next, opts);
|
|
162
241
|
if (!a.ok) return fail(a);
|
|
163
|
-
const
|
|
242
|
+
const ar = applyRefs(w.root, id, s, next, g.actor);
|
|
243
|
+
if (!ar.ok) return fail(ar);
|
|
244
|
+
const names = RT.namesOf(w.root, id);
|
|
245
|
+
const v = RT.addVersion(w.root, id, next, { names, why: RT.diffWords(was, next, names).join('; ').slice(0, 200) });
|
|
164
246
|
return v.ok ? send({ status: 200, body: { ok: true, n: v.n, state: stateOf(ctx, w, id) } }) : fail(v);
|
|
165
247
|
}
|
|
166
248
|
if (sub === 'restore') {
|
|
@@ -168,17 +250,24 @@ async function handle(req, res, url, ctx) {
|
|
|
168
250
|
if (!v) return send(bad(404, 'no such template version'));
|
|
169
251
|
const a = apply(w.root, id, v.settings, opts);
|
|
170
252
|
if (!a.ok) return fail(a);
|
|
253
|
+
const ar = applyRefs(w.root, id, s, v.settings, g.actor);
|
|
254
|
+
if (!ar.ok) return fail(ar);
|
|
171
255
|
const r = RT.restore(w.root, id, v.n);
|
|
172
|
-
return r.ok ? send({ status: 200, body: { ok: true, n: r.n, state: stateOf(ctx, w, id) } }) : fail(r);
|
|
256
|
+
return r.ok ? send({ status: 200, body: { ok: true, n: r.n, restored: RT.settingsWords(v.settings, RT.namesOf(w.root, id)), state: stateOf(ctx, w, id) } }) : fail(r);
|
|
173
257
|
}
|
|
174
258
|
// ask
|
|
175
259
|
const change = text(body.text).replace(/\s+/g, ' ').trim();
|
|
176
260
|
if (!change) return send(bad(400, 'say the change'));
|
|
177
261
|
if (change.length > MAX_ASK) return send(bad(413, 'a change is at most ' + MAX_ASK + ' characters'));
|
|
178
|
-
|
|
262
|
+
let rel = text(body.path);
|
|
179
263
|
if (rel && !(new RegExp('(?:^|/)reports/' + id + '/\\d{4}-\\d{2}-\\d{2}\\.md$').test(rel) && !rel.split('/').includes('..'))) return send(bad(400, 'path must be a draft of this report'));
|
|
264
|
+
// The change goes to a draft that exists: the one named, else the latest cycle. An issued cycle is frozen, so its change is refused.
|
|
265
|
+
const cycles = cyclesOf(w.root, id);
|
|
266
|
+
const named = rel ? cycles.find((c) => c.slot === slotOfRel(rel)) : cycles[0];
|
|
267
|
+
if (named && named.state === 'issued') return send(bad(409, `the ${named.slot} report is issued, so it is frozen. Change the template for the next cycle instead`));
|
|
268
|
+
if (!rel && named) rel = named.path;
|
|
180
269
|
const r = ask(ctx, w, id, change, rel || null);
|
|
181
270
|
return r.ok ? send({ status: 200, body: r }) : fail(r);
|
|
182
271
|
}
|
|
183
272
|
|
|
184
|
-
module.exports = { prefixes, handle, stateOf, askPrompt };
|
|
273
|
+
module.exports = { prefixes, handle, stateOf, askPrompt, draftWords };
|
|
@@ -288,7 +288,8 @@ function exportAnswer(ctx, res, w, url) {
|
|
|
288
288
|
if (!real.startsWith(fs.realpathSync(abs) + path.sep)) return bad(404, 'outside workspace');
|
|
289
289
|
md = fs.readFileSync(real, 'utf8');
|
|
290
290
|
} catch { return bad(404, 'no such document'); }
|
|
291
|
-
const
|
|
291
|
+
const cyc = /(?:^|\/)reports\/([a-z][a-z0-9-]{0,39})\/\d{4}-\d{2}-\d{2}\.md$/.exec(rel);
|
|
292
|
+
const out = RX.exportOf(md, fmt, { look: fmt === 'pptx' && cyc ? require('./report-pyramid.js').lookOf(abs, cyc[1]) : null });
|
|
292
293
|
if (!out.ok) return bad(500, out.error);
|
|
293
294
|
return { status: 200, file: out };
|
|
294
295
|
}
|
|
@@ -42,6 +42,7 @@ const path = require('path');
|
|
|
42
42
|
const os = require('os');
|
|
43
43
|
const guard = require('./pm-guard.js');
|
|
44
44
|
const S = require('./report-structure.js');
|
|
45
|
+
const RT = require('./report-templates.js');
|
|
45
46
|
const CS = require('./charts-store.js');
|
|
46
47
|
const RS = require('./report-setups.js');
|
|
47
48
|
const RDraft = require('./report-draft.js');
|
|
@@ -775,7 +776,9 @@ async function handle(req, res, url, ctx) {
|
|
|
775
776
|
c.chart = r.chart.id; written.push(r.chart.id);
|
|
776
777
|
}
|
|
777
778
|
if (written.length) S.rewriteVersion(root, id, n, next);
|
|
779
|
+
const tw = RT.followBefore(root, id, setup);
|
|
778
780
|
S.append(root, id, { ev: 'accept', n, charts: written }, { actor: g.actor });
|
|
781
|
+
RT.followAfter(root, id, { structure: n }, tw); // the template follows the saved sections as T<n+1> (canvas TplA)
|
|
779
782
|
const b = S.writeBrief(root, id, setup);
|
|
780
783
|
if (!b.ok) return fail(b);
|
|
781
784
|
return send({ status: 200, body: { ok: true, structure: answerOf(root, id), brief: b.path, charts: written } });
|
|
@@ -193,9 +193,8 @@ function split(ctx, w, body, actor) {
|
|
|
193
193
|
}
|
|
194
194
|
if (!made) return refuse(409, 'an initiative with this name exists already; give it another name');
|
|
195
195
|
const id = made.id, sha = writer.recordSha(w.root, id);
|
|
196
|
-
// the new one sits right after the old one on the Roadmap
|
|
197
|
-
|
|
198
|
-
try { Placements.appendFromUi(w.root, [{ ev: 'placed', initiative: id, horizon: ['now', 'next', 'later'].includes(b0.horizon) ? b0.horizon : 'later', after: from }], { actor }); } catch { /* it stays in Later */ }
|
|
196
|
+
// the new one sits right after the old one on the Roadmap (D105: a `ranked` line). A refused line only leaves it at the end.
|
|
197
|
+
try { Placements.appendFromUi(w.root, [{ ev: 'ranked', initiative: id, after: from }], { actor }); } catch { /* it stays at the end */ }
|
|
199
198
|
const R = F.R, file = F.file, why = 'split from ' + from;
|
|
200
199
|
const op = opId();
|
|
201
200
|
const undo = { tasks: [], items: [], tickets: [], docs: [], program: null, sha };
|
|
@@ -69,12 +69,14 @@ function proposals(ctx) {
|
|
|
69
69
|
const dir = home && ctx.stateDirFor ? ctx.stateDirFor(home) : null;
|
|
70
70
|
if (!dir) return [];
|
|
71
71
|
const lib = WS.library(dir);
|
|
72
|
+
// Most libraries replace nothing: then no workspace's initiatives are read at all (page-open-speed: New for you read every workspace's
|
|
73
|
+
// board frame on each Home open, ~100 ms on the thread every answer waits for, to find there was no ✦ to show).
|
|
74
|
+
const pairs = [...lib.byId.values()].map((wf) => [wf, replacesOf(lib, wf)]).filter(([, from]) => from);
|
|
75
|
+
if (!pairs.length) return [];
|
|
72
76
|
const all = [];
|
|
73
77
|
for (const w of workspaces(ctx)) { const st = standing(ctx, w); if (st) all.push(...st); }
|
|
74
78
|
const out = [];
|
|
75
|
-
for (const wf of
|
|
76
|
-
const from = replacesOf(lib, wf);
|
|
77
|
-
if (!from) continue;
|
|
79
|
+
for (const [wf, from] of pairs) {
|
|
78
80
|
const mine = all.filter((x) => movable(x, from.id));
|
|
79
81
|
if (!mine.length) continue;
|
|
80
82
|
const map = WF.mapOf(from, wf);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.494.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.494.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -46,7 +46,7 @@ const ANSWER = { role: 'assistant', text: 'Signups from the lightbox rose to 1,2
|
|
|
46
46
|
const look = () => {
|
|
47
47
|
const vw = document.querySelector('#czViewer:not([hidden])'), pane = vw ? vw.querySelector('.vz[data-vw^="report:"]') : null;
|
|
48
48
|
return { shut: !pane, title: vw ? ((vw.querySelector('.cz-vw-title') || {}).textContent || '') : '', reader: !!(vw && vw.querySelector('.vz-rp0')), review: vw && vw.querySelector('.rf-rv') ? vw.querySelector('.rf-rv').textContent : null,
|
|
49
|
-
tpl: !!(vw && vw.querySelector('[data-cz-vw-p="template"]')), layer: false, chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null,
|
|
49
|
+
tpl: !!(vw && vw.querySelector('[data-cz-vw-p="template"]')) && !!(vw && vw.querySelector('[data-cz-vw-p="chat"]')), layer: false, chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null,
|
|
50
50
|
json: /pmos-report|"kind"/.test((document.querySelector('#hmLog') || {}).textContent || ''), user: [...document.querySelectorAll('#hmLog .hm-u .hm-bub')].map((u) => u.textContent.trim()),
|
|
51
51
|
tabs: pane ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
|
|
52
52
|
secs: pane ? (pane.querySelector('.vz-dkt') ? pane.querySelectorAll('.vz-dkt button').length - 1 : pane.querySelectorAll('.vz-secs li').length) : 0,
|
|
@@ -100,6 +100,10 @@ const look = () => {
|
|
|
100
100
|
ok('R4 Draft it records the report, pauses it (Once) and records T1', !!setup && setup.output === 'google-slides' && setup.audience === 'Growth leads' && L.some((l) => l.ev === 'pause' && l.id === setup.id) && T1 && T1.current === 1, JSON.stringify([L.map((l) => l.ev), T1]));
|
|
101
101
|
ok('R4 the report\'s current state opens: its first draft in the reader, Claude\'s review under it (RfH2), the template icon in the header', s3.reader && /I read it as your readers would/.test(s3.review || '') && s3.tpl, JSON.stringify(s3).slice(0, 600));
|
|
102
102
|
if (shots) await p.screenshot({ path: `${shots}/draft-1280-light.png` });
|
|
103
|
+
// the chat icon (Wawan, 2026-11-02): the report's own conversation opens in Home's chat, the report stays beside it
|
|
104
|
+
await p.click('#czViewer [data-cz-vw-p="chat"]');
|
|
105
|
+
const ch = await until(() => p.evaluate(() => { const i = document.getElementById('hmIn'); return i && i.placeholder === 'Change the report' ? { ph: i.placeholder, log: (document.getElementById('hmLog') || {}).textContent || '', reader: !!document.querySelector('#czViewer .vz-slide, #czViewer .vz-rp0') } : null; }), 8000);
|
|
106
|
+
ok('R4 the chat icon opens the report\'s own conversation beside it: Claude asks what to change, the report stays open', !!ch && /Tell me what to change in/.test(ch.log) && ch.reader, JSON.stringify(ch));
|
|
103
107
|
await p.click('#czViewer [data-cz-vw-p="template"]');
|
|
104
108
|
await until(() => p.evaluate(() => !!document.querySelector('#czViewer .vz[data-panel="template"] [data-rt="fmt|google-doc"]')));
|
|
105
109
|
await p.click('#czViewer [data-rt="fmt|google-doc"]');
|
|
@@ -298,3 +298,15 @@ button.rp-cc { cursor: pointer; }
|
|
|
298
298
|
.rp-rfh .rp-bar { justify-content: flex-end; }
|
|
299
299
|
.rp-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 4px; }
|
|
300
300
|
.rp-foot .rp-pri { width: 40px; height: 40px; margin: 0; }
|
|
301
|
+
|
|
302
|
+
/* a template's sections and look (canvas TplA, brief 3; public/pm/report-flow.js): chips in order, a small title slide and one line */
|
|
303
|
+
.rf-cps { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
304
|
+
.rf-cp { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); font-size: var(--fs-2); }
|
|
305
|
+
.rf-cp[data-k="new"] { border-color: color-mix(in oklab, var(--cz-blue) 55%, transparent); background: var(--cz-bluebg); color: var(--cz-blueink); }
|
|
306
|
+
.rf-cp[data-k="gone"] { border-style: dashed; color: var(--cz-ink3); }
|
|
307
|
+
.rf-lk { display: flex; align-items: center; gap: 12px; }
|
|
308
|
+
.rf-mini { width: 96px; height: 54px; flex: none; border-radius: 7px; display: flex; align-items: flex-end; padding: 6px 7px; box-sizing: border-box; background: linear-gradient(135deg, var(--cz-c-2546b8), var(--cz-c-1b3a9e)); color: var(--cz-c-ffffff); font-size: var(--fs-1); line-height: 1.2; overflow: hidden; }
|
|
309
|
+
.rf-mini[data-k="own"] { background: var(--cz-well2); color: var(--cz-ink); border: 1px solid var(--cz-hair); }
|
|
310
|
+
.rf-lk .rf-fix small { color: var(--cz-ink3); font-size: var(--fs-2); }
|
|
311
|
+
.rf-tplx { padding: 10px 12px; border: 1px solid var(--cz-hair); border-radius: 14px; background: var(--cz-bluebg); }
|
|
312
|
+
.rf-hv em.rf-rest { color: var(--cz-ink2); }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* pm/fetch-share.js — one request for the same answer while it is on its way (page-open-speed).
|
|
2
|
+
*
|
|
3
|
+
* Imported FIRST by the page entries (home-app.js, premium-board.js, premium-insights.js). Parts of a page ask for the same GET on their
|
|
4
|
+
* own, so Home asked for /api/notes three times and /api/settings twice in its opening burst, and the Board asked for /api/board-premium,
|
|
5
|
+
* /api/board-publish, /api/sources and /api/settings twice each (bench 2026-11-02). Every one of them waits on the server's one thread.
|
|
6
|
+
*
|
|
7
|
+
* The rule: a GET to /api/ with the same address as one that is still on its way gets a copy of that one's answer instead of a second
|
|
8
|
+
* request. Nothing is kept once the answer is in, so a later read always asks the server again. Any other method (a press) first drops
|
|
9
|
+
* what is on its way, so a read made after a write never gets an answer that was asked for before it. Only plain same-origin GETs with no
|
|
10
|
+
* body, signal or cache option are shared; everything else goes to fetch as before. */
|
|
11
|
+
const KEY = '__pmosFetchShare';
|
|
12
|
+
if (typeof window !== 'undefined' && typeof window.fetch === 'function' && !window[KEY]) {
|
|
13
|
+
const real = window.fetch.bind(window);
|
|
14
|
+
const flying = new Map(); // url → Promise<Response>
|
|
15
|
+
window[KEY] = { flying };
|
|
16
|
+
window.fetch = function shared(input, init) {
|
|
17
|
+
let url = null, method = 'GET';
|
|
18
|
+
try {
|
|
19
|
+
url = typeof input === 'string' ? input : (typeof URL !== 'undefined' && input instanceof URL ? input.href : null);
|
|
20
|
+
method = String((init && init.method) || (input && typeof input === 'object' && input.method) || 'GET').toUpperCase();
|
|
21
|
+
} catch { url = null; }
|
|
22
|
+
if (method !== 'GET' && method !== 'HEAD') { flying.clear(); return real(input, init); }
|
|
23
|
+
if (!url || method !== 'GET') return real(input, init); // a Request object or a HEAD goes to fetch as before
|
|
24
|
+
if (init && (init.body != null || init.signal || init.cache || init.keepalive)) return real(input, init);
|
|
25
|
+
let abs;
|
|
26
|
+
try { abs = new URL(url, location.href); } catch { return real(input, init); }
|
|
27
|
+
if (abs.origin !== location.origin || !abs.pathname.startsWith('/api/')) return real(input, init);
|
|
28
|
+
const key = abs.href;
|
|
29
|
+
const hit = flying.get(key);
|
|
30
|
+
if (hit) return hit.then((r) => r.clone());
|
|
31
|
+
const p = real(input, init);
|
|
32
|
+
flying.set(key, p);
|
|
33
|
+
const done = () => { if (flying.get(key) === p) flying.delete(key); };
|
|
34
|
+
p.then(done, done);
|
|
35
|
+
return p.then((r) => r.clone());
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* The models are in home-data.js and home-list.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's
|
|
16
16
|
* press (pmPost). Nothing here opens the old dialog or links to the console. */
|
|
17
|
+
import './fetch-share.js'; // first: identical GETs in flight are asked once (page-open-speed)
|
|
17
18
|
import { mountNav } from './cozy-nav.js';
|
|
18
19
|
import { mountSetupChecklist } from './setup-checklist.js';
|
|
19
20
|
import { mountOnboard } from './cozy-onboard.js';
|
|
@@ -222,7 +223,8 @@ async function load() {
|
|
|
222
223
|
// an initiative of another product opened before its board was read (a link, a quick press): read it again from its own board
|
|
223
224
|
if (S.ini && !S.IM && otherIni(S.ini)) goIni(S.ini, { page: VW.isOpen() });
|
|
224
225
|
}
|
|
225
|
-
/* ── Home's one line (canvas FcPhone, Home: "only when something changed"): the newest grill this week that left findings, from GET /api/grill
|
|
226
|
+
/* ── Home's one line (canvas FcPhone, Home: "only when something changed"): the newest grill this week that left findings, from GET /api/grill,
|
|
227
|
+
* and how many other initiatives were grilled with it ("I grilled Inline login and 5 more this week: 21 findings.").
|
|
226
228
|
* "Checkout v2 will miss its date. I grilled it overnight: 3 findings." ✦ opens them on the initiative. Nothing to say is silence. ── */
|
|
227
229
|
async function loadGrillNews() {
|
|
228
230
|
const b0 = (S.D.board && S.D.board.board) || {};
|
|
@@ -236,6 +238,7 @@ function grillNews() {
|
|
|
236
238
|
const row = H.boardRows(S.D).find((r) => r.id === n.ini), title = (row && row.title) || n.ini;
|
|
237
239
|
const t = n.turn && GW.turnWord(n.turn.to), when = GW.whenWord(n.at), f = n.n + (n.n === 1 ? ' finding' : ' findings');
|
|
238
240
|
const text = t ? (n.turn.scope === 'goal' ? 'A goal ' + title + ' moves ' + t + '. I grilled it ' + when + ': ' + f + '.' : title + ' ' + t + (t === 'will miss' ? ' its date' : '') + '. I grilled it ' + when + ': ' + f + '.')
|
|
241
|
+
: n.more > 0 ? 'I grilled ' + title + ' and ' + n.more + ' more this week: ' + n.total + ' findings.'
|
|
239
242
|
: 'I grilled ' + title + ' ' + when + (GW.whyWord(n) ? ', ' + GW.whyWord(n) : '') + ': ' + f + '.';
|
|
240
243
|
return { id: n.ini, title, text, n: n.n };
|
|
241
244
|
}
|
|
@@ -1052,12 +1055,12 @@ function homeTarget() {
|
|
|
1052
1055
|
empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null),
|
|
1053
1056
|
intro: S.impact ? S.impact.intro : undefined };
|
|
1054
1057
|
}
|
|
1055
|
-
/* Your impact (batch 16 item 7):
|
|
1058
|
+
/* Your impact (batch 16 item 7; batch 23 item 4, IcA): while last week's check is open, Home's own chat opens on Claude's thank-you card.
|
|
1056
1059
|
* Off in Settings, or nothing to check: no card. Read after the list is drawn, so it never holds Home up. */
|
|
1057
1060
|
async function loadImpact() {
|
|
1058
1061
|
const c = await IMP.readCheck(pmGet).catch(() => null);
|
|
1059
1062
|
const was = !!S.impact;
|
|
1060
|
-
S.impact = c ? { c, intro: IMP.checkIntro(c, { esc, pmPost
|
|
1063
|
+
S.impact = c ? { c, intro: IMP.checkIntro(c, { esc, pmPost }) } : null;
|
|
1061
1064
|
const cur = chat.current && chat.current();
|
|
1062
1065
|
if ((was || S.impact) && cur && cur.key === 'chat:main') { chat.open(homeTarget()); }
|
|
1063
1066
|
if (was || S.impact) drawList();
|
|
@@ -1583,6 +1586,19 @@ function menCtx() {
|
|
|
1583
1586
|
drawList(); chat.focus();
|
|
1584
1587
|
} };
|
|
1585
1588
|
}
|
|
1589
|
+
/* A conversation about one item that names its own context (a report's chat icon, report-flow.js chatOf): Home's chat opens on it, the Viewer
|
|
1590
|
+
* stays beside it (on a phone the chat takes the page). Another page hands it over through sessionStorage with ?about=<its key>. */
|
|
1591
|
+
function chatAbout(t) {
|
|
1592
|
+
S.phoneChat = isPhone(); if (isPhone()) VW.close();
|
|
1593
|
+
openTarget({ ...homeTarget(), key: t.key, title: t.title, scope: { text: 'Report · ' + t.title, icon: I.chat }, intro: t.intro ? { role: CLAUDE, text: t.intro } : undefined,
|
|
1594
|
+
placeholder: t.placeholder || 'Message Claude', context: t.context });
|
|
1595
|
+
drawList(); chat.focus();
|
|
1596
|
+
}
|
|
1597
|
+
addEventListener('pmos-chat-about', (e) => { const t = e.detail; if (!t || !/^pop:[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/.test(String(t.key)) || !t.context) return; e.preventDefault(); chatAbout(t); });
|
|
1598
|
+
function aboutHanded(key) {
|
|
1599
|
+
let t = null; try { t = JSON.parse(sessionStorage.getItem('pmos-chat-about') || 'null'); sessionStorage.removeItem('pmos-chat-about'); } catch { return null; }
|
|
1600
|
+
return t && t.key === key && t.context ? t : null;
|
|
1601
|
+
}
|
|
1586
1602
|
function recLive() {
|
|
1587
1603
|
if (!REC) return null;
|
|
1588
1604
|
const h = REC.holding && REC.holding();
|
|
@@ -1949,6 +1965,7 @@ load().then(() => {
|
|
|
1949
1965
|
const say = (P.get('say') || P.get('q') || '').slice(0, 500);
|
|
1950
1966
|
const asked = !ask ? '' : /^board:/.test(ask) ? ask : /^(insights|verdict)$/.test(ask) ? 'ins:' + ask : 'init:' + ask;
|
|
1951
1967
|
const about = KEY.test(P.get('about') || '') ? P.get('about') : KEY.test(asked) ? asked : null;
|
|
1968
|
+
const handed = about && /^pop:/.test(about) ? aboutHanded(about) : null;
|
|
1952
1969
|
if (isPhone() && ((open && !blockOpen) || sid || about)) { S.phoneChat = true; drawList(); } // the conversation the address names, not the list
|
|
1953
1970
|
if (open && !blockOpen) {
|
|
1954
1971
|
// ?item=pt:<program>:<key> (the program panel's link to a program task) names the row by its id; Home lists no task, so the chat opens
|
|
@@ -1960,6 +1977,7 @@ load().then(() => {
|
|
|
1960
1977
|
else if (about && /^init:/.test(about) && iniRowOf(P.get('vid') || about.slice(5))) { const id = iniRowOf(P.get('vid')) ? P.get('vid') : about.slice(5); goIni(id).then(() => { if (P.get('vk') && S.ini === id && !isPhone()) iniOverview(); }); }
|
|
1961
1978
|
// the Board's program panel Discuss in chat names board:program:<id>: the program's own conversation, the one its tasks open (bug 2026-10-24)
|
|
1962
1979
|
else if (about && /^board:program:[A-Za-z0-9][A-Za-z0-9._-]{0,100}$/.test(about)) openTarget(programTarget(about.slice(14)));
|
|
1980
|
+
else if (handed) chatAbout(handed); // a report's chat icon on another page
|
|
1963
1981
|
else if (about) { openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about }); discussed(about, P.get('vid'), P.get('label')); }
|
|
1964
1982
|
else if (P.get('view') === 'metrics') openMetrics(P.get('ws') || ''); // ?view=metrics: an old link lands on Intelligence › Delivery trends
|
|
1965
1983
|
else if (S.ini) goIni(S.ini);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* started, POST /ask and /press) or a session with no chat key (GET /api/sessions/conversation?id=, POST /api/session/say and /keys).
|
|
16
16
|
* A loose session the host can place (host.suggestLink(target, firstText) → { id, title }) shows one chip: Link it (host.linkTo) or × (host.dismissLink).
|
|
17
17
|
* Every write is the PM's press. mountChat(el, host) returns { open(target), refresh(), focus(), send(text) }.
|
|
18
|
-
* target: { key?, sid?, title, scope: { text, icon, loose }, role: { name, initial }, intro?: { role, text, at, pills: [{ label, primary, go }] },
|
|
18
|
+
* target: { key?, sid?, title, scope: { text, icon, loose }, role: { name, initial }, intro?: { role, text, at, mood? (Adler as the avatar while the log is empty), pills: [{ label, primary, go }] },
|
|
19
19
|
* ini?, rich, also?: { text, go } }
|
|
20
20
|
* host: { esc, toast, pmGet, pmPost, roles(), seen(key), markSeen(key), onScope(btn), onLink(btn), onTo(btn), workItem(text, target),
|
|
21
21
|
* viewerClosed(), reopenViewer(), head(target), touch(sid) (the PM opened, typed in or answered that session: the Live pill) } */
|
|
@@ -138,11 +138,12 @@ export function mountChat(el, host) {
|
|
|
138
138
|
if (a.kind === 'reach' && R.stop && R.stop.reach && it.mi === R.lastMsg) return '';
|
|
139
139
|
return kindCardHtml(a, { live, role: R.role.name });
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
/** alone: nothing else in the log yet, so an intro with a mood shows Adler as Claude's avatar (one Adler: a reply takes him over). */
|
|
142
|
+
function introHtml(o, alone = true) {
|
|
142
143
|
if (!o) return '';
|
|
143
144
|
const r = o.role || { name: 'Claude', initial: 'C' };
|
|
144
145
|
const card = o.card && typeof o.card.html === 'function' ? o.card.html() : '';
|
|
145
|
-
return `<div class="hm-a">${avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p>${card ? `<div class="hm-icard">${card}</div>` : ''}</div></div>`
|
|
146
|
+
return `<div class="hm-a">${o.mood && alone && isClaude(r) ? adlerAvHtml(o.mood) : avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p>${card ? `<div class="hm-icard">${card}</div>` : ''}</div></div>`
|
|
146
147
|
+ (o.pills && o.pills.length ? `<div class="hm-pills">${o.pills.map((p, i) => `<button type="button" class="${p.primary ? 'pri' : ''}" data-hm-pill="${i}"${p.disabled ? ' disabled' : ''}>${esc(p.label)}</button>`).join('')}</div>` : '');
|
|
147
148
|
}
|
|
148
149
|
/** Claude's question card (AskUserQuestion), answerable until the PM writes again. */
|
|
@@ -204,7 +205,7 @@ export function mountChat(el, host) {
|
|
|
204
205
|
const goal = C.th && C.th.goal;
|
|
205
206
|
const parts = items.map((it, i) => msgHtml(it, i, R));
|
|
206
207
|
placeDivider(parts, items, goal);
|
|
207
|
-
let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + queuedHtml();
|
|
208
|
+
let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + queuedHtml();
|
|
208
209
|
html += GU.choiceHtml(); // /goal while a goal works here: In a new chat, or Here instead
|
|
209
210
|
if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
|
|
210
211
|
if (C.conv && C.conv.state === 'ended') html += '<p class="hm-note">This session has ended. Your conversation is kept here, and your next message picks it up.</p>';
|