create-pmos 0.830.0 → 0.831.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 +66 -50
- 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 +65 -36
- package/workspace/guide/cli.md +8 -1
- package/workspace/guide/layout.md +2 -0
- package/workspace/lib/anchor-id.js +226 -0
- package/workspace/lib/artefacts-cli.js +25 -1
- package/workspace/lib/initiative-cli.js +67 -2
- package/workspace/lib/lessons-draft.js +242 -0
- package/workspace/lib/prefs-sync.js +1 -1
- package/workspace/lib/routes-c3-strategy.js +2 -1
- package/workspace/lib/routes-proposals.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/card-fold.js +123 -0
- package/workspace/public/pm/cozy-ev.css +7 -0
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/readonly.js +2 -0
- package/workspace/test-lists/anchor-id.json +9 -0
- package/workspace/test-lists/card-fold.json +9 -0
- package/workspace/test-lists/lessons-on-close.json +9 -0
|
@@ -49,7 +49,7 @@ const KEYS = Object.freeze({
|
|
|
49
49
|
'pmos.home.cardfold', 'pmos-report-orders-hidden', 'cz-live-side',
|
|
50
50
|
'pmos.pop.five', // the work popup's four toolbar actions, worked out weekly from use (idea A498, pm/pop-cap.js)
|
|
51
51
|
]),
|
|
52
|
-
prefix: Object.freeze(['pmos.board.', 'pmos.pv.tab:', 'pmos.dash.view:', 'cz-vw-fold:']),
|
|
52
|
+
prefix: Object.freeze(['pmos.board.', 'pmos.pv.tab:', 'pmos.dash.view:', 'cz-vw-fold:', 'pmos.fold:']),
|
|
53
53
|
});
|
|
54
54
|
const EXACT = new Set(KEYS.exact);
|
|
55
55
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* Sources: planning/records/{kr-metrics,bets,hypotheses}.jsonl through scripts/records, and <runtime>/signals/signals.jsonl. No facts
|
|
17
17
|
* reader is used, so the route never starts a cold repository read. A number that no record holds is null, never invented. */
|
|
18
|
+
const { anchorId } = require('./anchor-id.js');
|
|
18
19
|
const path = require('path');
|
|
19
20
|
const fs = require('fs');
|
|
20
21
|
const { repoScript } = require('./repo-script.js');
|
|
@@ -111,7 +112,7 @@ function signalsOf(outcomes, sig, readingsByMetric) {
|
|
|
111
112
|
function synergyOf(krs, bets) {
|
|
112
113
|
if (!bets.length) return null;
|
|
113
114
|
const cols = krs.map((k) => ({ id: k.rid, n: String(k.metric || k.rid), icon: 'target' }));
|
|
114
|
-
const hit = (b, c) =>
|
|
115
|
+
const hit = (b, c) => { const a = anchorId(b.parent_kr); return !!a && (a === c.id || a === c.n || String(b.parent_kr) === c.n); }; // the id, not its note (A547)
|
|
115
116
|
const rows = bets.slice().sort((a, b) => a.rank - b.rank).map((b) => ({ id: b.rid, title: String(b.title), parked: b.horizon === 'later', weights: cols.map((c) => (hit(b, c) ? 1 : 0)), initiative: b.initiative || null }));
|
|
116
117
|
const notes = [];
|
|
117
118
|
cols.forEach((c, j) => { if (!rows.some((r) => !r.parked && r.weights[j] > 0)) notes.push({ icon: 'alert', tone: 'bad', text: c.n + ' has no active bet.' }); });
|
|
@@ -399,7 +399,7 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
399
399
|
else {
|
|
400
400
|
const by = g.actor && g.actor.by && g.actor.by !== 'agent:auto' ? g.actor.by : 'agent:outcomes';
|
|
401
401
|
const r = O.recordCheck(p.w.root, { initiative: ini, disposition: d.disposition, evidence: d.evidence, by, via: 'pmos', sources: x.sources || [] });
|
|
402
|
-
if (r.ok) add({ op: 'verdict', at: r.line.at, disposition: d.disposition, horizon: d.horizon });
|
|
402
|
+
if (r.ok) { add({ op: 'verdict', at: r.line.at, disposition: d.disposition, horizon: d.horizon }); require('./lessons-draft.js').onClose(ctx, { root: p.w.root, id: ini }); } // lessons-on-close (A542)
|
|
403
403
|
else x.failed = r.error;
|
|
404
404
|
}
|
|
405
405
|
} else if (x.group === 'outcome' && x.type === 'test') {
|
|
@@ -428,7 +428,7 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
|
|
|
428
428
|
// a met kill line (lib/kill-check.js, its ref is the record's kill line) says so, not "the outcome check said"
|
|
429
429
|
const reason = (require('./kill-check.js').isKillRef(d.ref) ? `${String(d.evidence || '').replace(/[.\s]+$/, '')} (read ${d.check}).`
|
|
430
430
|
: `The outcome check on ${d.check} said it did not work: ${String(d.evidence || '').replace(/[.\s]+$/, '')}.`).slice(0, 440);
|
|
431
|
-
const stop = (why) => { const r = O.setLife(p.w.root, ini, 'cancelled', why, g.actor); if (r.ok) add({ op: 'life', from: r.from || 'active', to: 'cancelled' }); };
|
|
431
|
+
const stop = (why) => { const r = O.setLife(p.w.root, ini, 'cancelled', why, g.actor); if (r.ok) { add({ op: 'life', from: r.from || 'active', to: 'cancelled' }); require('./lessons-draft.js').onClose(ctx, { root: p.w.root, id: ini }); } }; // lessons-on-close (A542)
|
|
432
432
|
if (d.next === 'kill') stop(reason);
|
|
433
433
|
else if (d.next === 'iterate') {
|
|
434
434
|
const t = RB.taskAdd(ctx, { ws: p.w.id, board: p.board.id, initiative: ini, title: 'Change what the outcome check showed, then check again', notes: [reason, source ? 'From ' + source : ''].filter(Boolean).join('\n').slice(0, 1900) }, g);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.831.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.831.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* pm/card-fold.js — the big summary cards fold away (initiative card-fold).
|
|
2
|
+
*
|
|
3
|
+
* One shared fold for every big summary card: Strategy, Where it stands and North Star, on every page. An icon-only button at the
|
|
4
|
+
* right of the card's head folds the card to its head line; Where it stands keeps its first sentence on that line. A ✦ suggestion
|
|
5
|
+
* inside a folded card stays visible as a small "✦ 1" beside the head, which opens the card again. Zero suggestions: no mark.
|
|
6
|
+
* The fold is kept per page and per card in localStorage under 'pmos.fold:<page>:<card>'. That prefix is on the view-prefs allowlist
|
|
7
|
+
* (lib/prefs-sync.js), so the fold follows the person to their other browsers. No card's own markup or content changes: the module
|
|
8
|
+
* finds the cards by their aria-label and adds the button, so a card that redraws itself gets its button back on the next frame.
|
|
9
|
+
* A card that is being edited (it holds an input or a text box) never folds, so the PM can always see what they type.
|
|
10
|
+
*
|
|
11
|
+
* startCardFold(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing
|
|
12
|
+
* cardOf(label) PURE: the card's key for an aria-label, or '' when the card does not fold
|
|
13
|
+
* foldKey(page, card) PURE: the storage key · pageOf(path) PURE: '/premium-board.html' → 'premium-board'
|
|
14
|
+
* sugCount(section) the ✦ suggestions inside a card · enhance(section, doc) add the fold to one card · sweep(doc) every card
|
|
15
|
+
* btnHtml(card, folded, n, title) PURE: the head's fold controls */
|
|
16
|
+
|
|
17
|
+
export const CARDS = Object.freeze({ 'Strategy': 'strategy', 'Where it stands': 'stands', 'North Star': 'northstar' });
|
|
18
|
+
export const PREFIX = 'pmos.fold:';
|
|
19
|
+
const SEL = 'section.pm-block[aria-label]';
|
|
20
|
+
const SUG = '.pm-sug';
|
|
21
|
+
const EDITING = 'input, textarea, select, [contenteditable="true"], [contenteditable=""]';
|
|
22
|
+
const CHEV_UP = 'M7 14l5-5 5 5';
|
|
23
|
+
const CHEV_DOWN = 'M7 10l5 5 5-5';
|
|
24
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
25
|
+
const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
26
|
+
|
|
27
|
+
export const cardOf = (label) => CARDS[String(label || '').trim()] || '';
|
|
28
|
+
export const pageOf = (path) => (String(path || '').split('/').pop() || 'index').replace(/\.html?$/i, '') || 'index';
|
|
29
|
+
export const foldKey = (page, card) => PREFIX + page + ':' + card;
|
|
30
|
+
|
|
31
|
+
/** PURE: the fold button, and when folded with suggestions inside, the small ✦ count that opens the card. */
|
|
32
|
+
export function btnHtml(card, folded, n, title) {
|
|
33
|
+
const t = String(title || card);
|
|
34
|
+
const mark = folded && n > 0
|
|
35
|
+
? `<button type="button" class="pm-fold-sug" data-card-fold-sug="${esc(card)}" aria-label="${esc(n + (n === 1 ? ' suggestion' : ' suggestions') + ' from PMOS in ' + t + '. Open')}" title="${esc(n === 1 ? '1 suggestion waits inside' : n + ' suggestions wait inside')}">✦ ${n}</button>`
|
|
36
|
+
: '';
|
|
37
|
+
const label = (folded ? 'Open ' : 'Fold ') + t;
|
|
38
|
+
return mark + `<button type="button" class="pm-btn pm-fold-btn" data-card-fold="${esc(card)}" aria-expanded="${folded ? 'false' : 'true'}" aria-label="${esc(label)}" title="${esc(label)}">${SV(folded ? CHEV_DOWN : CHEV_UP)}</button>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The ✦ suggestions inside a card. */
|
|
42
|
+
export const sugCount = (sec) => (sec && sec.querySelectorAll ? sec.querySelectorAll(SUG).length : 0);
|
|
43
|
+
|
|
44
|
+
const store = (doc) => { try { return doc.defaultView.localStorage; } catch { return null; } };
|
|
45
|
+
const isFolded = (doc, key) => { const ls = store(doc); try { return !!ls && ls.getItem(key) === '1'; } catch { return false; } };
|
|
46
|
+
function setFolded(doc, key, on) {
|
|
47
|
+
const ls = store(doc); if (!ls) return;
|
|
48
|
+
try { if (on) ls.setItem(key, '1'); else ls.removeItem(key); } catch { /* storage blocked: the fold lasts for this page only */ }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The card's head: its .head row, else its first heading. */
|
|
52
|
+
function headOf(sec) {
|
|
53
|
+
for (const el of Array.from(sec.children || [])) {
|
|
54
|
+
if (el.classList && el.classList.contains('head')) return el;
|
|
55
|
+
if (/^H[1-6]$/.test(el.tagName || '')) return el;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Add the fold to one card, or bring its state up to date. Returns true when the card can fold. */
|
|
61
|
+
export function enhance(sec, doc) {
|
|
62
|
+
const card = cardOf(sec.getAttribute('aria-label'));
|
|
63
|
+
if (!card || sec.classList.contains('flat')) return false; // a one-line card (not written yet, drafting) has nothing to fold
|
|
64
|
+
const head = headOf(sec);
|
|
65
|
+
if (!head) return false;
|
|
66
|
+
const key = foldKey(pageOf(doc.defaultView && doc.defaultView.location ? doc.defaultView.location.pathname : ''), card);
|
|
67
|
+
const editing = !!sec.querySelector(EDITING);
|
|
68
|
+
const folded = !editing && isFolded(doc, key);
|
|
69
|
+
const n = folded ? sugCount(sec) : 0;
|
|
70
|
+
const sig = (folded ? 'f' : 'o') + n + (editing ? 'e' : '');
|
|
71
|
+
if (sec.dataset.cardFold === sig && head.querySelector('[data-card-fold]')) return true;
|
|
72
|
+
sec.dataset.cardFold = sig;
|
|
73
|
+
head.setAttribute('data-fold-head', '');
|
|
74
|
+
head.querySelectorAll('[data-card-fold], [data-card-fold-sug]').forEach((b) => b.remove());
|
|
75
|
+
if (!editing) {
|
|
76
|
+
const box = doc.createElement('span');
|
|
77
|
+
box.className = 'pm-fold-ctl';
|
|
78
|
+
box.innerHTML = btnHtml(card, folded, n, sec.getAttribute('aria-label'));
|
|
79
|
+
head.appendChild(box);
|
|
80
|
+
}
|
|
81
|
+
// Where it stands keeps its first sentence line on the folded head
|
|
82
|
+
const one = card === 'stands' ? Array.from(sec.children).find((el) => el !== head && el.tagName === 'P') : null;
|
|
83
|
+
sec.querySelectorAll(':scope > [data-fold-one]').forEach((el) => { if (el !== one) el.removeAttribute('data-fold-one'); });
|
|
84
|
+
if (one) one.setAttribute('data-fold-one', '');
|
|
85
|
+
sec.classList.toggle('pm-folded', folded);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Every card on the page. */
|
|
90
|
+
export function sweep(doc) {
|
|
91
|
+
let n = 0;
|
|
92
|
+
doc.querySelectorAll(SEL).forEach((sec) => { if (enhance(sec, doc)) n++; });
|
|
93
|
+
return n;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let started = false;
|
|
97
|
+
export function startCardFold(doc = typeof document !== 'undefined' ? document : null) {
|
|
98
|
+
if (started || !doc || !doc.body) return false;
|
|
99
|
+
started = true;
|
|
100
|
+
const win = doc.defaultView;
|
|
101
|
+
let queued = false;
|
|
102
|
+
const later = () => {
|
|
103
|
+
if (queued) return; queued = true;
|
|
104
|
+
const run = () => { queued = false; try { sweep(doc); } catch (e) { try { console.info('[card-fold] ' + e.message); } catch { /* no console */ } } };
|
|
105
|
+
if (win && win.requestAnimationFrame) win.requestAnimationFrame(run); else setTimeout(run, 16);
|
|
106
|
+
};
|
|
107
|
+
if (win) doc.defaultView.addEventListener('click', (e) => { // capture on the window, as focus mode does
|
|
108
|
+
const b = e.target && e.target.closest && e.target.closest('[data-card-fold], [data-card-fold-sug]');
|
|
109
|
+
if (!b) return;
|
|
110
|
+
const sec = b.closest(SEL);
|
|
111
|
+
if (!sec) return;
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
const card = cardOf(sec.getAttribute('aria-label'));
|
|
114
|
+
const key = foldKey(pageOf(win && win.location ? win.location.pathname : ''), card);
|
|
115
|
+
setFolded(doc, key, b.hasAttribute('data-card-fold') ? !sec.classList.contains('pm-folded') : false);
|
|
116
|
+
enhance(sec, doc);
|
|
117
|
+
const again = sec.querySelector('[data-card-fold]');
|
|
118
|
+
if (again && again.focus) again.focus();
|
|
119
|
+
}, true);
|
|
120
|
+
if (win && win.MutationObserver) new win.MutationObserver(later).observe(doc.body, { childList: true, subtree: true });
|
|
121
|
+
later();
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
@@ -570,3 +570,10 @@ body.pm-focus .cz-pop-card { inset: 0; border-radius: 0; }
|
|
|
570
570
|
::highlight(pm-term) { text-decoration: underline dotted; text-underline-offset: var(--space-4); } /* the text's own colour: --muted means another thing inside .c3 */
|
|
571
571
|
.gl-tip.pm-ds { position: fixed; z-index: 90; max-width: min(calc(var(--space-64) * 5), calc(100vw - var(--space-16))); background: var(--card); color: var(--ink); border-radius: var(--radius-md); box-shadow: var(--lift); padding: var(--space-8) var(--space-12); font-size: var(--fs-meta); line-height: var(--lh-meta); left: var(--fr-gl-x, 0); top: var(--fr-gl-y, 0); pointer-events: auto; }
|
|
572
572
|
.gl-tip.pm-ds .gl-m { margin: var(--space-4) 0 0; }
|
|
573
|
+
|
|
574
|
+
/* ── card fold (pm/card-fold.js, initiative card-fold): Strategy, Where it stands and North Star fold to their head line. The fold button
|
|
575
|
+
* sits at the right of the head; a folded card keeps a small ✦ count when a suggestion waits inside. Tokens only. ── */
|
|
576
|
+
.pm-fold-ctl { display: inline-flex; align-items: center; gap: var(--space-8); margin-left: auto; flex: none; }
|
|
577
|
+
.pm-folded > :not([data-fold-head]):not([data-fold-one]) { display: none !important; }
|
|
578
|
+
.pm-folded > [data-fold-one] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; color: var(--muted); }
|
|
579
|
+
.pm-fold-sug { border: 0; cursor: pointer; display: inline-flex; align-items: center; padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--blue-tint); color: var(--blue); font: inherit; font-size: var(--fs-badge); font-weight: var(--fw-strong); }
|
|
@@ -49,6 +49,7 @@ import { startUseLog } from './use-log.js'; // bet A466: every page mounts the
|
|
|
49
49
|
import { startActionKeys } from './action-keys.js'; // bet A477: y o s p z act on the item under the pointer, ? lists the keys
|
|
50
50
|
import { startGlossary } from './glossary.js'; // bet A386: a product's own words show their meaning on hover (a long press on a phone)
|
|
51
51
|
import { startFocusMode } from './focus-mode.js'; // bet A335: f shows only the item under the pointer and its chat; f again puts the page back
|
|
52
|
+
import { startCardFold } from './card-fold.js'; // card-fold: Strategy, Where it stands and North Star fold to one line, kept per person
|
|
52
53
|
|
|
53
54
|
/* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
|
|
54
55
|
* Today is today.html (slice 5; Home before it), Work is the Board and Goals is premium-goals.html (slice 9; Intelligence before it); the keys stay the pages' own (home, board, insights). */
|
|
@@ -209,6 +210,7 @@ export function mountNav(here, doc = document, opts = {}) {
|
|
|
209
210
|
askHere(doc, () => import('./ask-here.js')); // ask-anywhere: a right-click (a phone: a long-press) asks PMOS about what was pressed
|
|
210
211
|
startActionKeys(doc);
|
|
211
212
|
startFocusMode(doc);
|
|
213
|
+
startCardFold(doc);
|
|
212
214
|
startGlossary(doc);
|
|
213
215
|
const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
|
|
214
216
|
const draw = () => {
|
|
@@ -17,6 +17,8 @@ export const RO = !!PACK;
|
|
|
17
17
|
|
|
18
18
|
/** What a reader can do. Each is a selector; a press inside a match is let through. */
|
|
19
19
|
export const VIEW_CONTROLS = [
|
|
20
|
+
// the big cards' fold (pm/card-fold.js): Strategy, Where it stands and North Star fold to their head line, and the ✦ count opens one
|
|
21
|
+
'[data-card-fold]', '[data-card-fold-sug]',
|
|
20
22
|
// the Timeline: the span, the legend behind (i), a column's sort, back to today, the edge tab that scrolls to a bar off the view, the Deliveries lane, the folds, an initiative's name (opens its viewer)
|
|
21
23
|
'#bdLgdBtn', '.tg-chd', '.tg-tback', '.tg-edge', '.dl-fb', '.dl-dn', '.dl-e[aria-label*="press to open"]', '.bd-fold', '.bd-prdb', 'label.tg-n', 'button.tg-n.ini2',
|
|
22
24
|
// the stage track: the switch between it and the Timeline (the two views a publisher shares), an initiative's name, the Monitor and Evaluate fold
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Big cards fold away (initiative card-fold, done test planning/done-tests/card-fold.md F1-F4, N1-N2): the shared fold on Strategy, Where it stands and North Star, the kept fold per page and card, the ✦ count, and the menu's mount. No server, network or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"card-fold.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"card-fold.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Lessons drafted when an experiment closes (initiative lessons-on-close, done test L1-L5, N1, N2): the facts, the draft with an injected session and its plain fallback, the hook, the never-over-the-PM rule and pmos artefacts lessons on a scratch repository. No server, browser, model or network.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"lessons-draft.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"lessons-draft.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|