create-pmos 0.779.0 → 0.781.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 +36 -44
- 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 +35 -0
- package/workspace/guide/agent-capabilities.md +2 -1
- package/workspace/guide/claude-proposes.md +11 -1
- package/workspace/guide/cli.md +2 -2
- package/workspace/guide/initiatives-and-next-steps.md +1 -1
- package/workspace/guide/positioning.md +4 -2
- package/workspace/lib/card-catalog.js +67 -0
- package/workspace/lib/card-catalog.json +2032 -0
- package/workspace/lib/routes-card-catalog.js +19 -0
- package/workspace/lib/routes-slash.js +7 -1
- package/workspace/lib/routes-star-drafts.js +36 -0
- package/workspace/lib/star-draft.js +99 -0
- package/workspace/lib/strategy-card.js +6 -3
- package/workspace/lib/strategy-cli.js +7 -3
- package/workspace/lib/strategy-sources.js +46 -10
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-run.js +120 -0
- package/workspace/public/pm/bd-pop-ds.js +2 -2
- package/workspace/public/pm/bd-positioning.js +19 -7
- package/workspace/public/pm/bd-strategy.js +9 -2
- package/workspace/public/pm/card-run.js +25 -0
- package/workspace/public/pm/cozy-pop-work.js +91 -10
- package/workspace/public/pm/goals-open.js +14 -2
- package/workspace/public/pm/star-draft.js +63 -0
- package/workspace/public/pm/state-blocks.js +18 -1
- package/workspace/skills/strategy-draft.skill +6 -3
- package/workspace/test-lists/star-buttons-act-directly.json +13 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* pm/card-run.js — a catalog button's "run" read as a pmos command, for the page (star-buttons-act-directly; the same reading as
|
|
2
|
+
* lib/card-catalog.js parseRun, which card-catalog.test.js holds equal on every button of the catalog).
|
|
3
|
+
*
|
|
4
|
+
* words(s) → the words of a command: "a quoted part", <a placeholder> and plain words PURE
|
|
5
|
+
* parseRun(s) → { verb, sub, pos: [word], flags: { name: word | true } } | null (null when it is not "pmos …") PURE */
|
|
6
|
+
export function words(s) {
|
|
7
|
+
const out = []; const re = /"[^"]*"|<[^>]*>|\S+/g; let m;
|
|
8
|
+
while ((m = re.exec(s))) out.push(m[0]);
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
export function parseRun(run) {
|
|
12
|
+
const w = words(String(run || '').trim());
|
|
13
|
+
if (w[0] !== 'pmos' || !w[1]) return null;
|
|
14
|
+
const verb = w[1];
|
|
15
|
+
const sub = w[2] && !w[2].startsWith('-') && !w[2].startsWith('<') && !w[2].startsWith('"') ? w[2] : '';
|
|
16
|
+
const pos = [], flags = {};
|
|
17
|
+
for (let i = sub ? 3 : 2; i < w.length; i++) {
|
|
18
|
+
const x = w[i];
|
|
19
|
+
if (x.startsWith('--')) {
|
|
20
|
+
const nx = w[i + 1];
|
|
21
|
+
if (nx !== undefined && !nx.startsWith('--')) { flags[x.slice(2)] = nx; i++; } else flags[x.slice(2)] = true;
|
|
22
|
+
} else pos.push(x);
|
|
23
|
+
}
|
|
24
|
+
return { verb, sub, pos, flags };
|
|
25
|
+
}
|
|
@@ -33,6 +33,7 @@ import * as AK from './artefact-kind.js';
|
|
|
33
33
|
import * as WT from './work-tree.js'; // subtasks, the epic check and its fix (initiative work-subtasks)
|
|
34
34
|
import * as SEL from './work-select.js'; // select several rows and move them together (WorkBulkDS)
|
|
35
35
|
import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
|
|
36
|
+
import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
|
|
36
37
|
import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
|
|
37
38
|
|
|
38
39
|
const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
|
|
@@ -181,7 +182,7 @@ function ovLines(ov, oid, edit = true) {
|
|
|
181
182
|
const dr = dropped();
|
|
182
183
|
return `<div class="pw-ols">${ov.lines.map((L) => {
|
|
183
184
|
const ed = edit && L.edit;
|
|
184
|
-
const words = L.text ? esc(L.text) : 'Not written yet.'; // the label already names it: said once (round 3 design check)
|
|
185
|
+
const words = L.text ? esc(L.text) : L.drafting ? 'PMOS is drafting it. It shows here.' : 'Not written yet.'; // the label already names it: said once (round 3 design check)
|
|
185
186
|
const tx = ed ? `<span class="pw-otx${L.text ? '' : ' grey'}" data-pw-line="${esc(L.id)}" tabindex="0" role="button" aria-label="${esc((L.text ? 'Change the ' : 'Write the ') + L.k.toLowerCase())}">${words}</span>` : `<span class="${L.text ? '' : 'grey'}">${words}</span>`;
|
|
186
187
|
const src = !RO && L.text && L.src ? (L.path ? ` <button type="button" class="pw-osrc" data-pw-src="${esc(L.path)}">from ${esc(L.src)}</button>` : ` <span class="pw-osrc">from ${esc(L.src)}</span>`) : '';
|
|
187
188
|
const sid = 'ov:' + oid + ':' + L.id;
|
|
@@ -401,6 +402,7 @@ function model(r, v0, o) {
|
|
|
401
402
|
const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
|
|
402
403
|
const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
|
|
403
404
|
if (pd && W.overview) for (const L of W.overview.lines || []) if (pd.lines[L.id] != null) { L.text = pd.lines[L.id]; delete L.ask; delete L.miss; }
|
|
405
|
+
if (W.overview) for (const L of W.overview.lines || []) if (!L.text && DRAFTING.has(id0 + ':' + L.id)) { L.drafting = true; delete L.ask; delete L.miss; }
|
|
404
406
|
const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
|
|
405
407
|
W.epics = (r.epics || []).filter(Boolean); RSEL = S.sel; // the epic check and the picked rows, for the Gantt rows (initiative work-subtasks)
|
|
406
408
|
// the Gantt's Jira column (work-subtasks-followups): on unless Choose columns hides it, and only when the work has a Jira row
|
|
@@ -600,12 +602,89 @@ function sendToChat(text) {
|
|
|
600
602
|
const f = ta.closest('form'); if (f && f.requestSubmit) f.requestSubmit(); else ta.focus();
|
|
601
603
|
return true;
|
|
602
604
|
}
|
|
605
|
+
/* the words go to Ask PMOS (star-buttons-act-directly A5): the popup's chat when it is open, else the chat over the page (page-chat.js ask),
|
|
606
|
+
* written in and not sent. No press ends at a toast that only says to open the chat. */
|
|
607
|
+
function toAsk(text, h) {
|
|
608
|
+
if (!text || sendToChat(text)) return;
|
|
609
|
+
const w = h && h.where ? h.where() : {};
|
|
610
|
+
import('./page-chat.js').then((PC) => PC.ask(text, { ws: w.ws || (ASK_AT && ASK_AT.ws) || undefined, here: 'Work' })).catch(() => { if (h && h.toast) h.toast('Ask PMOS did not open. Try again.'); });
|
|
611
|
+
}
|
|
612
|
+
/* a ✦ draft (star-buttons-act-directly A7; Wawan chose "Yes, run drafts in background" on 2026-11-24): the words run as a PMOS background
|
|
613
|
+
* job (pm/star-draft.js, POST /api/star-drafts) with no chat and no session of the PM's. The line says PMOS is drafting it; the draft then
|
|
614
|
+
* lands on the line itself through the line's own save, with Undo. A job that fails says why, with Try again. */
|
|
615
|
+
const DRAFTING = new Set(); // '<popup key>:<line id>' while its job runs
|
|
616
|
+
async function draftLine(L, x, h) {
|
|
617
|
+
const w = h.where ? h.where() : {}, kid = keyOf(x.v(), x.o()), k = kid + ':' + L.id;
|
|
618
|
+
if (DRAFTING.has(k)) return;
|
|
619
|
+
DRAFTING.add(k); if (h.redraw) h.redraw();
|
|
620
|
+
const r = await SD.run(L.ask, { ws: w.ws || x.o().ws, pmPost, pmGet });
|
|
621
|
+
DRAFTING.delete(k);
|
|
622
|
+
if (!r.ok) { if (h.redraw) h.redraw(); undoToast(r.why, () => draftLine(L, x, h), 12000, 'Try again'); return; }
|
|
623
|
+
await saveLine(L, r.text.replace(/\s+/g, ' ').trim().slice(0, 600), x, h);
|
|
624
|
+
}
|
|
625
|
+
/* a program's line (its charter's why or goal): the same job, saved with POST /api/programs/save, and Undo saves the line as it was */
|
|
626
|
+
const LV_FIELD = { for: 'why', goal: 'goal' };
|
|
627
|
+
async function draftLevelLine(Lv, line, h) {
|
|
628
|
+
const f = LV_FIELD[line.id], k = 'level:' + Lv.id + ':' + line.id;
|
|
629
|
+
if (!f || !Lv.id || Lv.kind !== 'program') { toAsk(line.ask, h); return; }
|
|
630
|
+
if (DRAFTING.has(k)) return;
|
|
631
|
+
DRAFTING.add(k); if (h.redraw) h.redraw();
|
|
632
|
+
const r = await SD.run(line.ask, { ws: Lv.home || Lv.ws, pmPost, pmGet });
|
|
633
|
+
DRAFTING.delete(k);
|
|
634
|
+
if (!r.ok) { if (h.redraw) h.redraw(); undoToast(r.why, () => draftLevelLine(Lv, line, h), 12000, 'Try again'); return; }
|
|
635
|
+
const text = r.text.replace(/\s+/g, ' ').trim().slice(0, 600);
|
|
636
|
+
const all = await pmGet('/api/programs').catch(() => null), p = all && all.ok ? (all.programs || []).find((q) => q.id === Lv.id) : null;
|
|
637
|
+
if (!p) { if (h.redraw) h.redraw(); undoToast('The program was not found, so the draft was not saved.', () => draftLevelLine(Lv, line, h), 12000, 'Try again'); return; }
|
|
638
|
+
const was = p[f] || '';
|
|
639
|
+
const res = await pmPost('/api/programs/save', { ws: p.home, program: { ...p, [f]: text } }).catch(() => null);
|
|
640
|
+
if (!res || res.ok === false) { if (h.redraw) h.redraw(); undoToast(LE.notSaved(res), () => draftLevelLine(Lv, line, h), 12000, 'Try again'); return; }
|
|
641
|
+
if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
|
|
642
|
+
undoToast(line.k + ' saved.', async () => {
|
|
643
|
+
const u = await pmPost('/api/programs/save', { ws: p.home, program: { ...((res && res.program) || p), [f]: was } }).catch(() => null);
|
|
644
|
+
if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
|
|
645
|
+
if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/* the documents a gate needs (d:draft): each is a PMOS background job with no chat. A core document runs its own draft run (POST
|
|
649
|
+
* /api/core-docs/draft) and lands in Artefacts as a draft for the PM to read; the done test is drafted by the ✦ job and lands as its checks
|
|
650
|
+
* (POST /api/artefacts/set, with Undo); a document PMOS has no writer for here (a PRD or rubric with no core-document entry) is drafted the
|
|
651
|
+
* same way and its draft is written into Ask PMOS with where to save it, so the PM reads it before anything is kept. */
|
|
652
|
+
async function draftDocs(s, x, h) {
|
|
653
|
+
const w = h.where ? h.where() : {}, o = x.o(), id = o.id, ws = w.ws || o.ws, kid = keyOf(x.v(), o), k = kid + ':d:draft';
|
|
654
|
+
if (DRAFTING.has(k)) return;
|
|
655
|
+
const W = model(x.r(), x.v(), o).W, miss = (W.artefacts || []).filter((a) => a.missing);
|
|
656
|
+
if (!miss.length) { toAsk(s.ask, h); return; }
|
|
657
|
+
DRAFTING.add(k);
|
|
658
|
+
if (h.toast) h.toast('PMOS is drafting ' + miss.map((a) => 'the ' + a.title).join(', ').replace(/, (?=[^,]*$)/, ' and ') + '. Each lands in Artefacts.');
|
|
659
|
+
let started = 0;
|
|
660
|
+
for (const a of miss) {
|
|
661
|
+
if (a.key) { const r = await pmPost('/api/core-docs/draft', { ws, scope: 'initiative:' + id, key: a.key }).catch(() => null); if (r && r.ok !== false) { started++; continue; } }
|
|
662
|
+
const done = /^done test$/i.test(a.title);
|
|
663
|
+
const ask = done ? 'Draft the done test for ' + (x.v().title || id) + ': two to four checks, one per line, each one testable. Do not invent anything the records do not say.'
|
|
664
|
+
: 'Draft the ' + a.title + ' for ' + (x.v().title || id) + ' from its documents. Do not invent anything the records do not say.';
|
|
665
|
+
const r = await SD.run(ask, { ws, pmPost, pmGet });
|
|
666
|
+
if (!r.ok) { undoToast(a.title + ': ' + r.why, () => draftDocs(s, x, h), 12000, 'Try again'); continue; }
|
|
667
|
+
started++;
|
|
668
|
+
if (done) {
|
|
669
|
+
const refs = [];
|
|
670
|
+
for (const line of r.text.split(/\n+/).map((t) => t.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, '').trim()).filter(Boolean).slice(0, 6)) {
|
|
671
|
+
const res = await pmPost('/api/artefacts/set', { ws, scope: 'experiment:' + id, artefact: 'done-test', field: 'check', text: line }).catch(() => null);
|
|
672
|
+
if (res && res.ok !== false && res.line) refs.push(res.line.id);
|
|
673
|
+
}
|
|
674
|
+
ART.delete(id);
|
|
675
|
+
if (refs.length) undoToast('Done test drafted: ' + refs.length + (refs.length === 1 ? ' check.' : ' checks.'), async () => { for (const ref of refs) await pmPost('/api/artefacts/undo', { ws, ref }).catch(() => null); ART.delete(id); if (h.redraw) h.redraw(); });
|
|
676
|
+
} else toAsk('Here is a draft of the ' + a.title + ' for ' + (x.v().title || id) + '. Read it with me, then save it where the Artefacts list reads it.\n\n' + r.text, h);
|
|
677
|
+
}
|
|
678
|
+
DRAFTING.delete(k);
|
|
679
|
+
if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
|
|
680
|
+
return started;
|
|
681
|
+
}
|
|
603
682
|
/* a direct ✓ (bet 1f): the plan end, closing the open tasks, reopening. One press writes through POST /api/boards/ini-<act> with Undo; no chat
|
|
604
683
|
* message, no session. Only when the route answers ask: true (the plain reading does not hold) do the words go to Ask PMOS, as before. */
|
|
605
684
|
async function direct(d, ask, x, h) {
|
|
606
685
|
const w = h.where ? h.where() : {}, id = x.o().id;
|
|
607
686
|
const res = await pmPost('/api/boards/ini-' + d.act, { ws: w.ws, board: w.board, id, ...(d.to ? { to: d.to } : {}) }).catch(() => null);
|
|
608
|
-
if (!res || res.ask) {
|
|
687
|
+
if (!res || res.ask) { toAsk(ask, h); return; }
|
|
609
688
|
if (res.ok === false) { if (h.toast) h.toast(res.error || 'Nothing was changed.'); return; }
|
|
610
689
|
if (h.reload) await h.reload();
|
|
611
690
|
if (res.same) { if (h.toast) h.toast(res.said || 'Nothing to change.'); return; }
|
|
@@ -624,7 +703,8 @@ async function keepSug(s, x, h) {
|
|
|
624
703
|
if (s.move && h.move) { await h.move(s.move.uid, { to: s.move.to, from: '', name: s.move.name }); return; }
|
|
625
704
|
if (s.moveAll) { await moveAll(s.moveAll, h); return; }
|
|
626
705
|
if (s.direct) { await direct(s.direct, s.ask, x, h); return; }
|
|
627
|
-
if (s.ask &&
|
|
706
|
+
if (s.ask && s.id === 'd:draft') { draftDocs(s, x, h); return; }
|
|
707
|
+
if (s.ask) toAsk(s.ask, h);
|
|
628
708
|
return;
|
|
629
709
|
}
|
|
630
710
|
if (s.sm) { if (h.sm) h.sm('yes'); return; }
|
|
@@ -728,20 +808,20 @@ export function wire(body, h0, x0) {
|
|
|
728
808
|
if ('pwSpan' in d) { spanMenu(b, redraw); return; }
|
|
729
809
|
if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
|
|
730
810
|
if ('pwBig' in d) { big(c, x, h); return; }
|
|
731
|
-
if (d.pwKeep && /^merge:/.test(d.pwKeep)) { const m = mergeOf(W.artefacts); if (m
|
|
811
|
+
if (d.pwKeep && /^merge:/.test(d.pwKeep)) { const m = mergeOf(W.artefacts); if (m) toAsk(m.ask, h); return; }
|
|
732
812
|
if (d.pwDrop && /^merge:/.test(d.pwDrop)) { const dd = dropped(); dd.add(d.pwDrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
|
|
733
|
-
if (d.pwSug && /^merge:/.test(d.pwSug)) { const m = mergeOf(W.artefacts); if (m
|
|
813
|
+
if (d.pwSug && /^merge:/.test(d.pwSug)) { const m = mergeOf(W.artefacts); if (m) toAsk(m.ask, h); return; }
|
|
734
814
|
if (d.pwKeep) { const s = findSug(W, d.pwKeep); if (s) { b.disabled = true; await keepSug(s, x, h); if (VW.current() && /^sug:/.test(VW.current().id)) VW.back(); } return; }
|
|
735
815
|
if (d.pwDrop) { const s = findSug(W, d.pwDrop); if (s) { b.disabled = true; await dropSug(s, x, h); if (VW.current() && /^sug:/.test(VW.current().id)) VW.back(); } return; }
|
|
736
816
|
if (d.pwSug) { const s = findSug(W, d.pwSug); if (s) openSug(s, c, x, h); return; }
|
|
737
817
|
if ('pwProps' in d) { if (h.props) h.props(); return; }
|
|
738
818
|
if (d.pwLine) { const L = W.overview.lines.find((q) => q.id === d.pwLine); if (L && L.edit) editLine(b, L, c, x, h); return; }
|
|
739
819
|
// a phone asks for several lines in one proposal: "problem,done"
|
|
740
|
-
if (d.pwLkeep) { const
|
|
820
|
+
if (d.pwLkeep) { const ls = d.pwLkeep.split(',').map((k) => W.overview.lines.find((q) => q.id === k)).filter((L) => L && L.ask); for (const L of ls) { if (L.edit) draftLine(L, x, h); else toAsk(L.ask, h); } return; }
|
|
741
821
|
if (d.pwLdrop) { const dd = dropped(); for (const k of d.pwLdrop.split(',')) dd.add(k); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
|
|
742
822
|
if ('pwPdocs' in d) { if (PH_ARTS.has(c.id)) PH_ARTS.delete(c.id); else PH_ARTS.add(c.id); redraw(); return; }
|
|
743
823
|
if (d.pwSrc) { if (h.doc) h.doc(d.pwSrc); return; }
|
|
744
|
-
if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && ch.direct) { b.disabled = true; await direct(ch.direct, ch.ask, x, h); return; } if (ch
|
|
824
|
+
if (d.pwChoice) { const [sid, k] = d.pwChoice.split('|'), s = findSug(W, sid), ch = s && s.choices && s.choices[+k]; if (ch && ch.direct) { b.disabled = true; await direct(ch.direct, ch.ask, x, h); return; } if (ch) toAsk(ch.ask, h); return; }
|
|
745
825
|
if (d.pwMore != null) { S.moreOpen.add(d.pwMore); redraw(); return; }
|
|
746
826
|
if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
|
|
747
827
|
if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h, body); return; }
|
|
@@ -1469,12 +1549,13 @@ function artItems(body) {
|
|
|
1469
1549
|
const W = model(r, v, x.o()).W, mg = mergeOf(W.artefacts);
|
|
1470
1550
|
return PD.artMenu(W.artefacts, { ro: RO, merge: mg }).map((it) => ({ ...it, top: true })).map((it) => (it.art != null ? { ...it, on: () => openArt(W.artefacts[it.art], h, x) }
|
|
1471
1551
|
: it.add ? { ...it, on: () => addArt(x, h) }
|
|
1472
|
-
: it.merge ? { ...it, on: () =>
|
|
1552
|
+
: it.merge ? { ...it, on: () => toAsk(mg.ask, h) } : it));
|
|
1473
1553
|
}
|
|
1474
1554
|
|
|
1475
1555
|
/* ── one level up: a program or a product (boards 26, 27) ── */
|
|
1476
1556
|
export function levelHtml(L, o = {}) {
|
|
1477
1557
|
const W = M.levelOf(L, { today: o.today, mode: store.get(SPAN, 'full') }), C = cols(), mode = store.get(SPAN, 'full');
|
|
1558
|
+
for (const q of (W.overview && W.overview.lines) || []) if (!q.text && DRAFTING.has('level:' + L.id + ':' + q.id)) { q.drafting = true; delete q.ask; delete q.miss; }
|
|
1478
1559
|
const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
|
|
1479
1560
|
const sug = !RO && W.suggests.length ? `<div class="pw-sugs" role="list" aria-label="PMOS suggests"><p class="pw-sugh">PMOS suggests</p>${W.suggests.map((s) => sugLine(s)).join('')}</div>` : '';
|
|
1480
1561
|
// the same Overview shape as an initiative (round 3 point 10): what it is for, its goal, done when; then the status line and Details ›
|
|
@@ -1510,9 +1591,9 @@ export function wireLevel(body, h0, L0) {
|
|
|
1510
1591
|
if (d.pwTune) { tuneMenu(b, d.pwTune, redraw); return; }
|
|
1511
1592
|
if (d.pwDetails) { const S = stOf(d.pwDetails); S.details = !S.details; redraw(); return; }
|
|
1512
1593
|
if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
|
|
1513
|
-
if ((d.pwKeep || d.pwSug) && /^merge:/.test(d.pwKeep || d.pwSug)) { const m = mergeOf(M.levelOf(L()).artefacts); if (m
|
|
1594
|
+
if ((d.pwKeep || d.pwSug) && /^merge:/.test(d.pwKeep || d.pwSug)) { const m = mergeOf(M.levelOf(L()).artefacts); if (m) toAsk(m.ask, h); return; }
|
|
1514
1595
|
if (d.pwDrop && /^merge:/.test(d.pwDrop)) { const dd = dropped(); dd.add(d.pwDrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
|
|
1515
|
-
if (d.pwLkeep) { const x = M.levelOf(
|
|
1596
|
+
if (d.pwLkeep) { const Lv = L(), x = M.levelOf(Lv).overview.lines.find((q) => q.id === d.pwLkeep); if (x && x.ask) draftLevelLine(Lv, x, h); return; }
|
|
1516
1597
|
if (d.pwLdrop) { const dd = dropped(); dd.add(d.pwLdrop); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
|
|
1517
1598
|
if (d.pwGo) { const i = d.pwGo.indexOf(':'); if (h.go) h.go(d.pwGo.slice(0, i), d.pwGo.slice(i + 1), b); return; }
|
|
1518
1599
|
if (d.pwArt != null) { const a = M.levelOf(L()).artefacts[+d.pwArt]; if (a && h.art && h.art(a, b)) return; if (a && a.url) window.open(a.url, '_blank', 'noopener'); else if (a && a.path && h.doc) h.doc(a.path); return; }
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
import * as POP from './cozy-popup.js';
|
|
15
15
|
import * as VW from './cozy-viewer.js';
|
|
16
16
|
import * as GM from './goals-model.js';
|
|
17
|
+
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands under its row (star-buttons-act-directly A7)
|
|
17
19
|
|
|
18
20
|
const CSS = ['./cozy-pop-work.css', './cozy-goals.css'].map((p) => new URL(p, import.meta.url).href);
|
|
19
21
|
if (typeof document !== 'undefined' && document.head) for (const h of CSS) if (!document.querySelector(`link[href="${h}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = h; document.head.appendChild(l); }
|
|
@@ -25,6 +27,16 @@ const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cl
|
|
|
25
27
|
const row = (attr, label, val, cls = '') => `<button type="button" class="pw-src gl-src" ${attr}><span>${esc(label)}</span><span class="gl-srcv"><small class="${cls}">${esc(val || '')}</small>${SVG(P.right, 14)}</span></button>`;
|
|
26
28
|
const ask = '<button type="button" class="pw-ask" data-gl-ask>' + SVG(P.chat, 15) + 'Ask PMOS about this</button>';
|
|
27
29
|
|
|
30
|
+
/** A ✦ draft (star-buttons-act-directly A7): the words run as a PMOS background job with no chat, and the draft lands under the row that
|
|
31
|
+
* was pressed, for the PM to read. ✓ writes the read draft into the chat with `keep` (what to keep), so nothing is kept without the PM. */
|
|
32
|
+
function draftHere(t, ctx, ask, what, keep) {
|
|
33
|
+
const host = (t.closest && t.closest('.pw-card, .pw-spc')) || t.parentElement;
|
|
34
|
+
if (!host || !host.after) { toChat(ask); return; }
|
|
35
|
+
let el = host.nextElementSibling;
|
|
36
|
+
if (!el || !el.hasAttribute || !el.hasAttribute('data-gl-draft')) { el = document.createElement('div'); el.setAttribute('data-gl-draft', ''); host.after(el); }
|
|
37
|
+
SD.mount(el, { ask, ws: ctx.ws || undefined, pmPost, pmGet, what, keep: async (text) => { toChat(keep + '\n\n' + text); return true; } });
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
/** The words go in the chat on the right, as a draft the PM sends. The chat shows first when it was hidden. */
|
|
29
41
|
export function toChat(text) {
|
|
30
42
|
const a = document.querySelector('.cz-pop [data-pop="ask"]'); if (a && !a.closest('[hidden]')) a.click();
|
|
@@ -88,7 +100,7 @@ export function openSetup(ctx) {
|
|
|
88
100
|
if ('glNsdrop' in d) { t.disabled = true; await ctx.dropNs(ns.row); return; }
|
|
89
101
|
// the draft run files the draft this page waits for; the chat could not (initiative chat-saves-to-cards)
|
|
90
102
|
if ('glNsdraft' in d) { t.disabled = true; if (ctx.startNs) { const ok = await ctx.startNs(); if (ok) b.innerHTML = '<div class="pw gl-pg"><p class="grey">PMOS is drafting the North Star. It shows here for your tick.</p></div>'; else t.disabled = false; } else toChat('Draft a North Star for this product from its key results. I approve it with a tick.'); return; }
|
|
91
|
-
if (d.glName) { const n = S.names.find((x) => x.id === d.glName); if (n)
|
|
103
|
+
if (d.glName) { const n = S.names.find((x) => x.id === d.glName); if (n) draftHere(t, ctx, (n.named ? 'Check the name of ' : 'Name ') + n.label + ' (' + n.krs + '). Draft it from its key results; I approve it with a tick.', 'a name for ' + n.label, 'Keep this name for ' + n.label + '.'); return; }
|
|
92
104
|
if (d.glSrc) { const s = S.sources.find((x) => x.need === d.glSrc); if (s) toChat('Connect ' + s.need + '. ' + s.frees + '. Test a read before you keep it, and tell me what you need from me.'); return; }
|
|
93
105
|
if ('glAsk' in d) toChat('About setting up Goals: what should I confirm or connect first?');
|
|
94
106
|
});
|
|
@@ -107,7 +119,7 @@ export function openVerdict(ctx, id, back = false) {
|
|
|
107
119
|
+ ask + '</div>';
|
|
108
120
|
show(ctx, { id: 'outcome:' + id, kind: 'Outcome', title: V.title, back }, html, (t) => {
|
|
109
121
|
const d = t.dataset;
|
|
110
|
-
if ('glJudge' in d) {
|
|
122
|
+
if ('glJudge' in d) { draftHere(t, ctx, 'Judge the outcome of ' + V.title + ': read the result, set it beside the promise and give me a verdict with the reason. Change nothing in the plan until I approve the lesson.', 'a verdict on ' + V.title, 'Keep this verdict on the outcome of ' + V.title + '. Change nothing in the plan until I approve the lesson.'); return; }
|
|
111
123
|
if (d.glKr) { openKr(ctx, d.glKr, true); return; }
|
|
112
124
|
if (d.glIni) { openIni(ctx, d.glIni); return; }
|
|
113
125
|
if ('glAsk' in d) toChat('About the outcome of ' + V.title + ': did it do what it promised?');
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* pm/star-draft.js — a ✦ "Draft …" answer runs as a PMOS background job, and the draft lands on the row it came from (initiative
|
|
2
|
+
* star-buttons-act-directly, done test A7; the job is lib/star-draft.js behind POST/GET /api/star-drafts).
|
|
3
|
+
*
|
|
4
|
+
* run(ask, { ws, pmPost, pmGet, again, every, upto }) → { ok: true, text } | { ok: false, why }
|
|
5
|
+
* starts the job (or reads the kept draft) and reads it every `every` ms until it lands or `upto` ms pass. No chat, no session of
|
|
6
|
+
* the PM's: the job reads the records and writes nothing.
|
|
7
|
+
* mount(el, { ask, ws, pmPost, pmGet, what, keep, done })
|
|
8
|
+
* draws the job in `el`, the row's own place: "PMOS is drafting …" (the State part, loading), then the draft with ✓ Keep and ✕,
|
|
9
|
+
* or the reason with Try again. keep(text) → true | false saves it the row's own way (with its Undo); done() after ✓ or ✕.
|
|
10
|
+
* pendingHtml(what) · readyHtml(text, what) · failedHtml(why) the three looks PURE
|
|
11
|
+
*
|
|
12
|
+
* Nothing is kept until ✓: the draft is for the PM to read (the words of every draft ask say so). */
|
|
13
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
14
|
+
const SVG = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
15
|
+
const OK = 'M5 12.5l4.5 4.5L19 7.5', NO = 'M6 6l12 12M18 6L6 18', AGAIN = 'M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8M3 3v5h5';
|
|
16
|
+
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
|
|
18
|
+
export async function run(ask, { ws, pmPost, pmGet, again = false, every = 2500, upto = 200000 } = {}) {
|
|
19
|
+
if (!pmPost || !pmGet) return { ok: false, why: 'No way to reach PMOS from here.' };
|
|
20
|
+
let r = await pmPost('/api/star-drafts', { ws, ask, again }).catch(() => null);
|
|
21
|
+
if (!r || r.ok === false) return { ok: false, why: (r && r.error) || 'PMOS could not start the draft.' };
|
|
22
|
+
const t0 = Date.now();
|
|
23
|
+
while (r.state === 'pending' && Date.now() - t0 < upto) {
|
|
24
|
+
await wait(every);
|
|
25
|
+
r = (await pmGet('/api/star-drafts?key=' + encodeURIComponent(r.key)).catch(() => null)) || { state: 'pending', key: r.key };
|
|
26
|
+
}
|
|
27
|
+
if (r.state === 'ready' && r.text) return { ok: true, text: r.text, key: r.key };
|
|
28
|
+
if (r.state === 'pending') return { ok: false, why: 'The draft is taking longer than it should.' };
|
|
29
|
+
return { ok: false, why: r.why || 'PMOS could not draft it.' };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const pendingHtml = (what) => `<div class="pm-sug pm-draft" role="status"><span class="pm-star" aria-hidden="true">✦</span><span class="say">PMOS is drafting ${esc(what || 'it')}. It shows here.</span></div>`;
|
|
33
|
+
export const readyHtml = (text, what) => `<div class="pm-sug pm-draft" role="group" aria-label="${esc('Draft of ' + (what || 'it'))}"><span class="pm-star" aria-hidden="true">✦</span>`
|
|
34
|
+
+ `<div class="say">${String(text).split(/\n{2,}/).map((p) => `<p>${esc(p).replace(/\n/g, '<br>')}</p>`).join('')}</div>`
|
|
35
|
+
+ `<span class="ans"><button type="button" class="pm-btn primary" data-sd-keep aria-label="Keep this draft" title="Keep this draft">${SVG(OK)}</button>`
|
|
36
|
+
+ `<button type="button" class="pm-btn" data-sd-drop aria-label="Not this one" title="Not this one">${SVG(NO)}</button></span></div>`;
|
|
37
|
+
export const failedHtml = (why) => `<p class="pm-state error" role="alert"><span>${esc(why)}</span><button type="button" class="pm-btn" data-sd-again aria-label="Try again" title="Try again">${SVG(AGAIN)}</button></p>`;
|
|
38
|
+
|
|
39
|
+
export function mount(el, o = {}) {
|
|
40
|
+
if (!el) return null;
|
|
41
|
+
let text = '';
|
|
42
|
+
const go = async (again) => {
|
|
43
|
+
el.innerHTML = pendingHtml(o.what);
|
|
44
|
+
const r = await run(o.ask, { ws: o.ws, pmPost: o.pmPost, pmGet: o.pmGet, again, every: o.every, upto: o.upto });
|
|
45
|
+
if (!el.isConnected && el.isConnected !== undefined) return;
|
|
46
|
+
if (r.ok) { text = r.text; el.innerHTML = readyHtml(text, o.what); } else el.innerHTML = failedHtml(r.why);
|
|
47
|
+
};
|
|
48
|
+
// one press handler on the document, for the buttons inside el (the design system's rule: no click listener on an element)
|
|
49
|
+
const on = async (e) => {
|
|
50
|
+
if (!el.isConnected) { document.removeEventListener('click', on); return; }
|
|
51
|
+
const b = e.target && e.target.closest ? e.target.closest('[data-sd-keep],[data-sd-drop],[data-sd-again]') : null;
|
|
52
|
+
if (!b || !el.contains(b)) return;
|
|
53
|
+
e.preventDefault(); e.stopPropagation();
|
|
54
|
+
if ('sdAgain' in b.dataset) { go(true); return; }
|
|
55
|
+
if ('sdDrop' in b.dataset) { el.innerHTML = ''; if (o.done) o.done(false); return; }
|
|
56
|
+
b.disabled = true;
|
|
57
|
+
const ok = o.keep ? await o.keep(text) : false;
|
|
58
|
+
if (ok) { el.innerHTML = ''; if (o.done) o.done(true); } else b.disabled = false;
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener('click', on);
|
|
61
|
+
go(false);
|
|
62
|
+
return { again: () => go(true) };
|
|
63
|
+
}
|
|
@@ -49,6 +49,21 @@ export function next(step) {
|
|
|
49
49
|
+ `<button type="button" data-sb-next="${esc(step.ask)}" class="pm-btn primary" aria-label="${name}" title="${name}">${SEND}</button></div>`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/** A draft step runs as a PMOS background job (star-buttons-act-directly A7): the draft lands under the step for the person to read, and ✓
|
|
53
|
+
* writes it into the chat with what to keep, so nothing is kept without their yes. A step that needs the person's own words (a list to
|
|
54
|
+
* paste, what they want to reach: its words end in an empty line) still goes to the chat for them to write. */
|
|
55
|
+
export const isDraft = (ask) => /^(Draft|Make draft)\b/.test(String(ask || '')) && !/\n\n$/.test(String(ask || ''));
|
|
56
|
+
async function draftHere(b, ask) {
|
|
57
|
+
const host = b.closest('.pm-state-next') || b.parentElement;
|
|
58
|
+
if (!host || !host.after) { askInChat(ask).catch(() => null); return; }
|
|
59
|
+
let el = host.nextElementSibling;
|
|
60
|
+
if (!el || !el.hasAttribute || !el.hasAttribute('data-sb-draft')) { el = document.createElement('div'); el.setAttribute('data-sb-draft', ''); host.after(el); }
|
|
61
|
+
let ws; try { ws = new URLSearchParams(location.search).get('ws') || undefined; } catch { ws = undefined; }
|
|
62
|
+
const [SD, H] = await Promise.all([import('./star-draft.js'), import('./http.js')]);
|
|
63
|
+
SD.mount(el, { ask, ws, pmPost: H.pmPost, pmGet: H.pmGet, what: 'it',
|
|
64
|
+
keep: async (text) => { await askInChat('Keep these drafts. Make each one as you show it here.\n\n' + text); return true; } });
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
/** The step's words go in the one chat, not sent: Home's own box on Home, else the chat over this page. */
|
|
53
68
|
async function askInChat(text) {
|
|
54
69
|
const box = document.getElementById('hmIn');
|
|
@@ -62,6 +77,8 @@ if (typeof document !== 'undefined' && document.addEventListener) {
|
|
|
62
77
|
const b = e.target && e.target.closest ? e.target.closest('[data-sb-next]') : null;
|
|
63
78
|
if (!b) return;
|
|
64
79
|
e.preventDefault();
|
|
65
|
-
|
|
80
|
+
const ask = b.getAttribute('data-sb-next') || '';
|
|
81
|
+
if (isDraft(ask)) { draftHere(b, ask); return; }
|
|
82
|
+
askInChat(ask).catch(() => null);
|
|
66
83
|
});
|
|
67
84
|
}
|
|
@@ -8,7 +8,7 @@ output:
|
|
|
8
8
|
- Strategy
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
/strategy-draft — draft the FIVE-LINE STRATEGY of THIS product from its own files. Each line is short, plain and true to what the product's files already say. The PM edits or undoes each line on the Strategy card. Work only from what you can read here.
|
|
11
|
+
/strategy-draft — draft the FIVE-LINE STRATEGY of THIS product from its own files. The strategy is about the WHOLE PRODUCT: who the product serves, the problem it exists to fix, its bet and its edge. It is not the scope of any one initiative, feature or release. Each line is short, plain and true to what the product's files already say. The PM edits or undoes each line on the Strategy card. Work only from what you can read here.
|
|
12
12
|
|
|
13
13
|
The five lines and their keys:
|
|
14
14
|
- `for` — Who it is for: the people the product serves, as its files name them.
|
|
@@ -17,15 +17,18 @@ The five lines and their keys:
|
|
|
17
17
|
- `win` — How we win: why this product wins over the other ways people solve the problem.
|
|
18
18
|
- `wont` — What we won't do: what the product leaves out on purpose, as its files show (out-of-scope lists, non-goals, parked or killed work).
|
|
19
19
|
|
|
20
|
+
Product, not feature. A line that names one feature, one release, one screen, one technical mechanism (a paywall rule, a flag, a URL) or a number from one initiative is feature scope: lift it to what it says about the product, or leave the line out. Test each line: would it still be true after this quarter's initiatives are done? If not, it is not strategy.
|
|
21
|
+
|
|
20
22
|
Rules that always hold:
|
|
21
23
|
1. ONE KIND OF WRITE. Your only write is `pmos strategy draft` (step 3), once per line. Write no file. Send, post or share nothing.
|
|
22
24
|
2. CITED. Every line cites 1 to 5 sources it came from: file paths that `pmos strategy sources` lists (or another file of this product), or a tracker key (ABC-123). Cite the files that say it, not the files near it.
|
|
23
25
|
3. NOTHING INVENTED. Never invent customers, numbers, dates, competitors or features the files do not name. If the files do not show a line, leave that line blank: four true lines are correct, five guessed ones are not.
|
|
24
26
|
4. SHORT. One line each, at most 160 characters, in the product's own words. No marketing tone.
|
|
25
|
-
5.
|
|
27
|
+
5. WIDE SOURCES. A line cites a product-level file (README or product doc, goals, brief, out-of-scope, research, decisions), or work from 2 or more different initiatives. `pmos strategy draft` refuses a line whose sources are all one initiative's files.
|
|
28
|
+
6. NEVER OVER THE PM. `pmos strategy draft` refuses a line that is already written. Leave it.
|
|
26
29
|
|
|
27
30
|
Procedure:
|
|
28
31
|
1. Run `pmos strategy show` for the lines already written, and `pmos strategy sources` for the product's files you may cite.
|
|
29
|
-
2. Read the files
|
|
32
|
+
2. Read the whole-product files first (`pmos strategy sources` lists them first): the README or product doc, the goals, briefs, the out-of-scope list, research and decisions. Then skim the initiatives as EVIDENCE: what do several of them have in common about who the product serves and what it bets on? One initiative's details are never a strategy line on their own.
|
|
30
33
|
3. For each blank line you can support, run once: `pmos strategy draft --line <key> --text "<the line>" --source <ref> [--source <ref>]`. A refused draft says why: fix it or leave the line out.
|
|
31
34
|
4. End with one line: which lines you drafted, and which you left blank and why.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "✦ buttons act directly, from one action catalog (initiative star-buttons-act-directly, done test A1-A7): the card catalog loader and route, the action runner with a stub pmPost, a read of the page code and the ✦ draft job with a stubbed session answer. No server, browser or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"card-catalog.test.js",
|
|
5
|
+
"action-run.test.js",
|
|
6
|
+
"star-direct.test.js"
|
|
7
|
+
],
|
|
8
|
+
"seconds": {
|
|
9
|
+
"card-catalog.test.js": 1,
|
|
10
|
+
"action-run.test.js": 1,
|
|
11
|
+
"star-direct.test.js": 1
|
|
12
|
+
}
|
|
13
|
+
}
|