create-pmos 0.547.0 → 0.549.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 +27 -57
- package/payload/KIT-VERSION +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/payload/state/log.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/home.md +9 -4
- package/workspace/guide/programs.md +2 -0
- package/workspace/guide/settings-and-switches.md +15 -1
- package/workspace/lib/artefacts.js +49 -0
- package/workspace/lib/autonomy.js +107 -9
- package/workspace/lib/board-pack-route.js +5 -0
- package/workspace/lib/board-pack.js +7 -1
- package/workspace/lib/driver-decide.js +6 -1
- package/workspace/lib/routes-artefacts.js +40 -1
- package/workspace/lib/routes-autonomy.js +65 -8
- package/workspace/lib/routes-proposals.js +1 -1
- package/workspace/lib/settings-store.js +5 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-board.css +6 -0
- package/workspace/public/pm/cozy-ev.css +5 -0
- package/workspace/public/pm/cozy-settings.js +47 -4
- package/workspace/public/pm/cozy-today.css +7 -0
- package/workspace/public/pm/good-morning.js +73 -14
- package/workspace/public/pm/home-app.js +24 -10
- package/workspace/public/pm/home-day.js +11 -6
- package/workspace/public/pm/ini-agent.js +164 -0
- package/workspace/public/pm/ini-view.css +32 -3
- package/workspace/public/pm/ini-view.js +25 -2
- package/workspace/public/pm/move-rank.js +6 -3
- package/workspace/public/pm/readonly.js +18 -0
- package/workspace/public/pm/story.css +8 -0
- package/workspace/public/pm/story.js +39 -0
- package/workspace/skills/report-weekly.skill +2 -1
- package/workspace/stage-card-tasks-test.js +3 -0
- package/workspace/test-lists/agent-run-workspace.json +9 -0
|
@@ -25,6 +25,7 @@ import { ownTab, bring, tabUrl } from './rec-tab-core.js';
|
|
|
25
25
|
import * as VW from './cozy-viewer.js';
|
|
26
26
|
import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
|
|
27
27
|
import { pmGet, pmPost, pmHeaders } from './http.js';
|
|
28
|
+
import * as ST from './story.js';
|
|
28
29
|
import * as H from './home-data.js';
|
|
29
30
|
import { mountChat, avHtml } from './home-chat.js';
|
|
30
31
|
import * as MORE from './home-more.js';
|
|
@@ -398,9 +399,10 @@ async function readMove() {
|
|
|
398
399
|
return pmGet('/api/lab' + (q ? '?' + q : '')).then((r) => (r && r.ok && r.lab && (r.lab.loose || []).length ? { ws: L[i], board: b, n: r.lab.loose.length, say: r.lab.say || '' } : null)).catch(() => null); }));
|
|
399
400
|
L.forEach((ws, i) => {
|
|
400
401
|
const r = got[i], A = auto[i] && auto[i].ok ? auto[i] : null; if (!r || !r.ok) return;
|
|
401
|
-
const done = A ? (A.done || []).map((d) => ({ ref: d.ref, ini: d.ini || '', said: d.title || 'done', at: d.at, via: 'autonomy' }))
|
|
402
|
+
const done = A ? (A.done || []).map((d) => ({ ref: d.ref, ini: d.ini || '', said: d.title || 'done', at: d.at, via: 'autonomy', reason: d.reason || '', way: d.way || '' }))
|
|
402
403
|
: (r.done || []).map((d) => ({ ref: d.batch, ini: d.ini, board: d.board, said: d.said, at: d.at, via: 'proposals' }));
|
|
403
|
-
|
|
404
|
+
// agent-run (AwA, R4): the runs that stopped, one amber line in Claude did
|
|
405
|
+
next[ws] = { verdicts: r.verdicts || [], kr: r.kr || null, expired: r.expired || [], done, notices: A ? A.notices || [] : [], failed: A ? A.failed || [] : [] };
|
|
404
406
|
});
|
|
405
407
|
const ob = await pmGet('/api/outbox').catch(() => null);
|
|
406
408
|
const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
|
|
@@ -498,7 +500,7 @@ function dayParts() {
|
|
|
498
500
|
// Good morning (GM2): the goal data (the quarter, the PM's line, the morning snapshot, a goal tag per row) is GM1's, in S.gmGoals once it reads
|
|
499
501
|
const G = GM.gmModel(Y, S.D, NOW(), { quarter: S.gmGoals && S.gmGoals.quarter, tags: S.gmGoals && S.gmGoals.tags, notes: noteRows(), picks: S.notePicks || {}, today: H.todayOf(S.D) });
|
|
500
502
|
S.G = G;
|
|
501
|
-
return { Y, P: YD.gmParts(Y, G, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first, html: GM.gmHtml }) };
|
|
503
|
+
return { Y, P: YD.gmParts(Y, G, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first, html: GM.gmHtml, didRow: GM.didRowHtml }) };
|
|
502
504
|
}
|
|
503
505
|
/** The quarter under Good morning (GET /api/morning-goals, GM1): goal states, the PM's line or Claude's ✦ line, the move since the
|
|
504
506
|
* morning, and a goal tag per initiative. Read when Your day opens (never on Home's first draw: page speed). No answer, no strip. */
|
|
@@ -525,6 +527,7 @@ async function readNotePicks() {
|
|
|
525
527
|
async function gmPress(b) {
|
|
526
528
|
const act = b.dataset.yd, body = b.closest('.yd');
|
|
527
529
|
if (act === 'gm-intel') { location.href = insightsHref(deskWs()); return; }
|
|
530
|
+
if (act === 'gm-claude') { import('./cozy-settings.js').then((M) => M.openSettings('claude')); return; } // AwG: how Claude decides, per kind
|
|
528
531
|
if (act === 'gm-cal') { openCalendar(); return; }
|
|
529
532
|
if (act === 'gm-fold') {
|
|
530
533
|
const sec = body && body.querySelector('.czs-sec[data-czs-id="' + b.dataset.fold + '"]'); if (!sec) return;
|
|
@@ -1235,8 +1238,11 @@ function productPageHtml(x, ws, vid, name, g) {
|
|
|
1235
1238
|
{ id: 'reports', label: 'Reports', n: reps.length, sig: reps.some((r) => r.state === 'drafted') ? 'ready' : '', html: () => `<div class="db" data-level="product">${d ? DB.trustHtml(d) : ''}${R}</div><section class="pv-card" aria-label="More reports">${extra}</section>` },
|
|
1236
1239
|
{ id: 'documents', label: 'Documents', html: () => '<p class="pv-none">Each initiative keeps its PRD, rubric and release notes on its own page. Open one from Initiatives.</p>' },
|
|
1237
1240
|
];
|
|
1238
|
-
|
|
1239
|
-
|
|
1241
|
+
// "The story so far" (board AwE): the product's Narrative under the top line, a source on every line; the top line says it is the weekly update
|
|
1242
|
+
const story = x.story ? ST.storyHtml(x.story, { sources: true }) : '';
|
|
1243
|
+
const lead = story ? 'Your weekly update is this story.' : d && d.handled ? d.handled.lead : '';
|
|
1244
|
+
const rest = story ? 'I keep it current from the records, and every line says where it came from.' : d && d.handled ? d.handled.rest : '';
|
|
1245
|
+
return PV.pageHtml({ page: 'product:' + (ws || 'own'), line: { lead, rest, warn: !story && !!(d && d.handled && d.handled.tone === 'warn') }, goal: story + goal, cards: progs + budgets, props, tabs,
|
|
1240
1246
|
tail: isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '' });
|
|
1241
1247
|
}
|
|
1242
1248
|
function productDash(b, ws, vid, name, g) {
|
|
@@ -1259,7 +1265,11 @@ function productDash(b, ws, vid, name, g) {
|
|
|
1259
1265
|
paint();
|
|
1260
1266
|
DB.readDash(ws, 'product', 'read').then((d) => { if (d) { x.d = d; paint(); } });
|
|
1261
1267
|
DB.readKr(ws).then((k) => { x.kr = k; if (DB.krOf(k).length) paint(); });
|
|
1268
|
+
ST.readStory(ws).then((st) => { STORY.set(ws || '', st); if (JSON.stringify(st) !== JSON.stringify(x.story || null)) { x.story = st; paint(); } });
|
|
1262
1269
|
}
|
|
1270
|
+
/** The product's story (pm/story.js) by workspace, as last read: the weekly update Claude drafts leads with it. */
|
|
1271
|
+
const STORY = new Map();
|
|
1272
|
+
const deskStory = () => STORY.get(deskWs() || '') || STORY.get('') || null;
|
|
1263
1273
|
/** A phone: the page's "Message Claude about …" closes the sheet and opens the chat full screen; its ← goes back to the list (HbCPhone). */
|
|
1264
1274
|
function talk() { S.phoneChat = true; VW.close(); drawList(); chat.focus(); }
|
|
1265
1275
|
/** "Overview with Claude" on the initiative's card: the ask is typed into the chat box, for the PM to send or change. */
|
|
@@ -1710,9 +1720,10 @@ function openUpdateViewer(o = {}) {
|
|
|
1710
1720
|
const sent = (U.sent || []).find((x) => x.week === U.week.iso);
|
|
1711
1721
|
// workspace grill W2: the words come from the sections (H.updateWords); a week with nothing moved and no open risk has no update to send
|
|
1712
1722
|
const flag = U.sections.flatMap((x) => x[2]).find((x) => x.flag);
|
|
1713
|
-
const
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1723
|
+
const story = deskStory(); // board AwE: the weekly update is the story; the sections below stay what PMOS read
|
|
1724
|
+
const text = story ? ST.storyText(story) : (U.draft || sent ? H.updateWords(U) : 'Nothing moved and no risk is open this week, so there is no update to send.') + (flag ? ' ' + flag.title + ': ' + flag.flag.toLowerCase() + '.' : '');
|
|
1725
|
+
const sum = VW.czSummary({ line: sent ? 'Sent ' + new Date(sent.at).toDateString().slice(0, 10) : U.draft || story ? 'Ready to send' : 'Nothing new this week', tone: sent || !(U.draft || story) ? '' : 'you', text,
|
|
1726
|
+
meta: 'Communicator · ' + (U.to.length ? 'to ' + U.to.join(', ') : 'say who gets it under More'), primary: U.draft || sent || story ? { label: sent ? 'Send again' : 'Send now', act: 'send' } : null });
|
|
1716
1727
|
const it = (x) => x.key ? `<div class="czs-it"><span class="w">${esc(x.title)}<span>${esc([x.meta, x.text].filter(Boolean).join(' · '))}</span></span></div>` : `<button type="button" class="czs-it" data-hv-ini="${esc(x.id)}"><span class="w">${esc(x.title)}<span>${esc([x.meta, x.text].filter(Boolean).join(' · '))}</span>${x.flag ? `<span class="flag">${esc(x.flag)}</span>` : ''}</span></button>`;
|
|
1717
1728
|
// "Before you send": Claude's risks the PM has not confirmed, with one press that confirms them all (each a ✓ Keep on its program's charter)
|
|
1718
1729
|
const confirmAll = (L) => { const say = L.length === 1 ? 'Confirm this risk' : 'Confirm all ' + L.length + ' risks'; return `<p><button type="button" class="hv-chip" data-hv-confirm aria-label="${say}" title="${say}">${SVG(I.check, 15, 2.4)}</button></p>`; };
|
|
@@ -1724,13 +1735,14 @@ function openUpdateViewer(o = {}) {
|
|
|
1724
1735
|
if (edit) { const i = b.querySelector('#hvTo'); if (i) i.focus(); }
|
|
1725
1736
|
};
|
|
1726
1737
|
const U0 = H.weeklyUpdate(S.D, S.D.now);
|
|
1727
|
-
const copy = async () => { try { await navigator.clipboard.writeText(
|
|
1738
|
+
const copy = async () => { try { await navigator.clipboard.writeText(updateBody(H.weeklyUpdate(S.D, S.D.now), H.productName(S.D))); toast('The update is copied as text.'); } catch { toast('The text could not be copied.'); } };
|
|
1728
1739
|
const more = () => [
|
|
1729
1740
|
{ label: 'Change who gets it', note: U0.to.length ? U0.to.length + (U0.to.length === 1 ? ' person' : ' people') : '', on: () => { edit = !edit; draw(body); } },
|
|
1730
1741
|
{ label: 'Copy as text', on: copy },
|
|
1731
1742
|
{ label: 'Past updates', note: (U0.sent || []).length ? U0.sent.length + ((U0.sent.length === 1) ? ' week' : ' weeks') : '', on: () => { past = !past; draw(body); } },
|
|
1732
1743
|
];
|
|
1733
1744
|
const body = VW.open({ id: 'update', kind: 'Weekly update', title: H.productName(S.D) + ' · week of ' + U0.week.label, icon: 'doc', url: selfUrl({ ini: 'product' }), more: more(), render: draw });
|
|
1745
|
+
if (!STORY.has(deskWs() || '')) ST.readStory(deskWs()).then((st) => { STORY.set(deskWs() || '', st); if (st && body && body.isConnected) draw(body); });
|
|
1734
1746
|
const saveTo = async (to) => { const r = await pmPost('/api/home-desk/recipients', { ws: deskWs(), to }); if (r && r.ok) { S.D.desk.product = { ...(S.D.desk.product || {}), recipients: r.recipients }; draw(body); drawList(); } else toast((r && r.error) || 'The recipients were not saved.'); };
|
|
1735
1747
|
body.onkeydown = (e) => { if (e.target.id === 'hvTo' && (e.key === 'Enter' || e.key === ',')) { e.preventDefault(); const v = e.target.value.trim(); if (v) saveTo(H.weeklyUpdate(S.D).to.concat(v)); } };
|
|
1736
1748
|
body.onclick = async (e) => {
|
|
@@ -1752,12 +1764,14 @@ async function confirmRisks(L, after) {
|
|
|
1752
1764
|
/** This page's address for one view (the Viewer's Open in a new tab): the workspace and board of this page, and the view's own keys. */
|
|
1753
1765
|
const selfUrl = (o) => { const q = new URLSearchParams(); if (WS) q.set('ws', WS); if (BOARD) q.set('board', BOARD); for (const [k, v] of Object.entries(o)) q.set(k, v); return location.pathname + '?' + q.toString(); };
|
|
1754
1766
|
const deskWs = () => (S.D.desk && S.D.desk.ws) || ((S.D.board && S.D.board.board) || {}).ws || WS || undefined;
|
|
1767
|
+
/** The words of the weekly update: the story first when Claude keeps one (board AwE; no sources, it goes to people), then what PMOS read. */
|
|
1768
|
+
const updateBody = (U, name) => { const st = deskStory(); const t = H.updateText(U, name); if (!st) return t; const L = t.split('\n'); return [L[0], '', ST.storyText(st), '', ...L.slice(2)].join('\n'); };
|
|
1755
1769
|
async function sendUpdate() {
|
|
1756
1770
|
const U = H.weeklyUpdate(S.D, S.D.now);
|
|
1757
1771
|
if (!U.to.length) { openUpdateViewer({ edit: true }); toast('Say who the update goes to first.'); setTimeout(() => { const i = $('#hvTo'); if (i) i.focus(); }, 0); return; }
|
|
1758
1772
|
const name = H.productName(S.D), subject = name + ' · week of ' + U.week.label;
|
|
1759
1773
|
const mails = U.to.filter((x) => /@/.test(x));
|
|
1760
|
-
location.href = 'mailto:' + mails.map(encodeURIComponent).join(',') + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(
|
|
1774
|
+
location.href = 'mailto:' + mails.map(encodeURIComponent).join(',') + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(updateBody(U, name) + (U.to.length > mails.length ? '\n\nAlso for: ' + U.to.filter((x) => !/@/.test(x)).join(', ') : ''));
|
|
1761
1775
|
const r = await pmPost('/api/home-desk/update-sent', { ws: deskWs(), week: U.week.iso, to: U.to, subject });
|
|
1762
1776
|
if (r && r.ok) { toast('The draft is open in your mail. Recorded as sent this week.'); await load(); if (S.ini === 'product') openTarget(updateTarget()); }
|
|
1763
1777
|
else toast((r && r.error) || 'The send was not recorded.');
|
|
@@ -352,14 +352,19 @@ export function dayParts(Y, o = {}) {
|
|
|
352
352
|
* Drafted for you, Can wait, Now (a phone's moment card) and This week. Nothing is dropped. → { gm, sections, night } */
|
|
353
353
|
export function gmParts(Y, G, o = {}) {
|
|
354
354
|
const now = o.now || Date.now(), sections = [];
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
// agent-run (AwA): the fold under Your move holds only the rest of the PM's calls (Can wait is gone: Claude acts on the rest), and the
|
|
356
|
+
// fold under Claude did the rest of what Claude did, each with its reason and Undo (o.didRow: good-morning.js didRowHtml)
|
|
357
|
+
const calls = G.rest || [];
|
|
358
|
+
if (calls.length || (Y.rank && (Y.rank.expired || []).length)) {
|
|
359
|
+
const mv = moveSection({ rows: calls, expired: Y.rank && Y.rank.expired });
|
|
360
|
+
if (mv) sections.push({ ...mv, id: 'more', title: 'More of your calls', open: false });
|
|
359
361
|
}
|
|
360
362
|
if (Y.drafts.length) sections.push({ id: 'drafts', title: 'Drafted for you', count: Y.drafts.length, html: `<div class="hv-card">${Y.drafts.map((d, i) => draftRow(d, i)).join('')}</div>` });
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
const dr = (G.did || []).slice(5);
|
|
364
|
+
if ((dr.length && o.didRow) || ((Y.rank && Y.rank.notices) || []).length) {
|
|
365
|
+
const nt = ((Y.rank && Y.rank.notices) || []).map((n) => `<p class="yd-exp">${esc(n.text || ((n.job || 'A job') + ' asks again before it changes anything, until ' + String(n.until || '').slice(0, 10) + '.'))}</p>`).join('');
|
|
366
|
+
sections.push({ id: 'done', title: 'More Claude did', count: dr.length, open: !!nt, html: nt + (o.didRow ? `<div class="gm-didl">${dr.map(o.didRow).join('')}</div>` : '') });
|
|
367
|
+
}
|
|
363
368
|
if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' });
|
|
364
369
|
sections.push(weekSection(Y));
|
|
365
370
|
// one Adler per screen: the morning scene on the day's first open before noon, else his face on the lead
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* pm/ini-agent.js — the agent's part of the initiative Viewer (agent-run workspace, board AwB on the main canvas, In development; agreed by
|
|
2
|
+
* Wawan 2026-11-10; requirements R4, R5, R7, R12, R17, R18 and decision D107). Pure parts first: Node imports them (ini-agent.test.js).
|
|
3
|
+
*
|
|
4
|
+
* agentModel(art, auto, id, o) → M | null what the Viewer shows, from GET /api/artefacts?scope=experiment:<id> and GET /api/autonomy
|
|
5
|
+
* expHtml(M) · workHtml(M) · sectionsHtml(M) the Experiment section and Claude's work (with its amber line and Coming up), or ''
|
|
6
|
+
* comingUp(v) → { date, text } | null the next dated thing of the initiative, from the Viewer's own model (ini-view-model.js)
|
|
7
|
+
* gateOf(M) → { label, parts } | null D107: the gate to Build reads the done test and the kill condition, not PRD and rubric
|
|
8
|
+
* want(ws, id, done) · cached(id) · edit(body, btn) · save(body, form) · undo(btn) the reads and presses (the page only)
|
|
9
|
+
*
|
|
10
|
+
* THE EXPERIMENT (R12, R18): we bet (hypothesis), stop if (kill), budget, who builds (executor, R17), specimens (the kept one, or how many
|
|
11
|
+
* attempts) and done when (the done test's checks). Claude writes it from the record; a field nobody wrote is left out, and with nothing
|
|
12
|
+
* written there is no section (zero is silence). The PM edits a one-line field in place (POST /api/artefacts/set); Claude then asks before
|
|
13
|
+
* it changes that line again (lib/artefacts.js pmEdited).
|
|
14
|
+
* CLAUDE'S WORK (R7): the changes Claude made here by itself in the last 14 days (GET /api/autonomy done, by initiative), each with its
|
|
15
|
+
* one-line reason, its day and Undo; a run that stopped is one amber line (R4); one Coming up line names the next dated thing (R5).
|
|
16
|
+
* Icon-only presses carry their words in aria-label and title. */
|
|
17
|
+
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
|
|
19
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
20
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
21
|
+
const P = { undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', check: 'M5 12l5 5 9-10', warn: 'M12 8v5M12 16.5v.01M10.3 3.9L2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z',
|
|
22
|
+
clock: 'M12 7.5V12l3 2M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17', x: 'M6 6l12 12M18 6L6 18', right: 'M10 7l5 5-5 5' };
|
|
23
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
24
|
+
const dm = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
25
|
+
const DAY = 864e5, SHOW = 3;
|
|
26
|
+
export const WHO = { factory: 'Claude builds it (the factory).', team: 'The team builds it. Claude writes the done test.', 'team-agents': 'The team’s agents build it. Claude writes the done test.' };
|
|
27
|
+
|
|
28
|
+
const art = (A, key) => ((A && A.artefacts) || []).find((a) => a.key === key) || null;
|
|
29
|
+
const one = (a, f) => { const v = a && a.fields && a.fields[f]; return v && !Array.isArray(v) && v.text ? v : null; };
|
|
30
|
+
const list = (a, f) => { const v = a && a.fields && a.fields[f]; return Array.isArray(v) ? v.filter((x) => x && x.text) : []; };
|
|
31
|
+
const carried = (a, f) => ((a && a.carried) || []).filter((c) => c.field === f && c.text);
|
|
32
|
+
|
|
33
|
+
/** The Viewer's model. art: GET /api/artefacts answer for scope experiment:<id>; auto: GET /api/autonomy answer; o: { now }. */
|
|
34
|
+
export function agentModel(A, U, id, o = {}) {
|
|
35
|
+
const now = o.now || Date.now();
|
|
36
|
+
const X = art(A, 'experiment'), S = art(A, 'specimens'), T = art(A, 'done-test');
|
|
37
|
+
const row = (key, label, v, edit) => (v ? { key, label, text: v.text, by: v.by || '', at: v.at || '', edit: edit || null } : null);
|
|
38
|
+
const hyp = one(X, 'hypothesis') || (carried(X, 'hypothesis')[0] ? { text: carried(X, 'hypothesis')[0].text } : null);
|
|
39
|
+
const kill = one(X, 'kill'), budget = one(X, 'budget'), ex = one(X, 'executor');
|
|
40
|
+
const kept = one(S, 'kept'), tries = list(S, 'specimen'), checks = list(T, 'check'), result = one(T, 'result');
|
|
41
|
+
const rows = [
|
|
42
|
+
row('hypothesis', 'We bet', hyp, { artefact: 'experiment', field: 'hypothesis' }),
|
|
43
|
+
row('kill', 'Stop if', kill, { artefact: 'experiment', field: 'kill' }),
|
|
44
|
+
row('budget', 'Budget', budget, { artefact: 'experiment', field: 'budget' }),
|
|
45
|
+
ex ? { key: 'executor', label: 'Who builds', text: WHO[ex.text] || ex.text, value: ex.text, by: ex.by || '', at: ex.at || '', edit: { artefact: 'experiment', field: 'executor', pick: Object.keys(WHO) } } : null,
|
|
46
|
+
kept ? row('specimens', 'Specimens', { ...kept, text: 'Kept: ' + kept.text + (tries.length > 1 ? ' (of ' + tries.length + ' attempts)' : '') })
|
|
47
|
+
: tries.length ? row('specimens', 'Specimens', { text: tries.length + (tries.length === 1 ? ' attempt' : ' attempts') + ', none kept yet: ' + tries[tries.length - 1].text, at: tries[tries.length - 1].at }) : null,
|
|
48
|
+
checks.length ? { key: 'done', label: 'Done when', text: checks.map((c) => c.text).join(' · '), sub: result ? 'Result: ' + result.text : '', at: checks[checks.length - 1].at || '', edit: null } : null,
|
|
49
|
+
].filter(Boolean);
|
|
50
|
+
// the newest line Claude wrote dates the section: "Claude keeps it · 3 Nov"
|
|
51
|
+
const dates = rows.map((r) => r.at).filter(Boolean).sort();
|
|
52
|
+
const exp = rows.length ? { rows, at: dates.length ? dates[dates.length - 1] : '' } : null;
|
|
53
|
+
const gate = rows.length ? { kill: !!kill, done: checks.length > 0 } : null;
|
|
54
|
+
// Claude's work: this initiative's changes, newest first, and its runs that stopped
|
|
55
|
+
const mine = ((U && U.done) || []).filter((d) => d && d.ini === id);
|
|
56
|
+
const work = mine.map((d) => ({ ref: d.ref, title: d.title || 'A change', reason: d.reason || '', at: d.at || '', ws: (U && U.ws) || '' }));
|
|
57
|
+
const fl = ((U && U.failed) || []).filter((f) => f && f.ini === id && now - Date.parse(f.at || '') <= 7 * DAY);
|
|
58
|
+
const failed = fl.length ? { n: fl.length, at: fl[0].at, why: fl[0].why || '' } : null;
|
|
59
|
+
const week = work.filter((w) => now - Date.parse(w.at) <= 7 * DAY).length;
|
|
60
|
+
return { id, ws: (U && U.ws) || (A && A.ws) || '', exp, gate, work, week, failed };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** D107: with an experiment on record, the gate to Build is its done test and its kill condition (not the PRD and the rubric). */
|
|
64
|
+
export function gateOf(M) {
|
|
65
|
+
if (!M || !M.gate) return null;
|
|
66
|
+
return { label: 'Gate to Build', parts: [{ text: 'done test', ok: M.gate.done, ...(M.gate.done ? {} : { note: 'No done test is written yet' }) }, { text: 'kill condition', ok: M.gate.kill, ...(M.gate.kill ? {} : { note: 'No kill condition is written yet' }) }] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The next dated thing of the initiative (R5), from the Viewer's model: the nearest open milestone ahead, else the plan's end. */
|
|
70
|
+
export function comingUp(v) {
|
|
71
|
+
const st = v && v.stage;
|
|
72
|
+
if (!st) return null;
|
|
73
|
+
const g = ((st.gates && st.gates.open) || []).find((x) => !x.late && x.date);
|
|
74
|
+
if (g) return { date: g.date, text: g.name + (g.left === 0 ? ' is due today.' : g.left === 1 ? ' is due tomorrow.' : ' is due.') };
|
|
75
|
+
const D = st.dates;
|
|
76
|
+
if (D && D.end && !D.over && D.left) return { date: D.end, text: 'The plan ends (' + D.left + ').' };
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const failLine = (F) => `<div class="ia-fl" role="status">${SVG(P.warn, 14, 2)}<span>${esc((F.n === 1 ? 'The ' + dm(F.at) + ' run' : F.n + ' runs') + ' ended with an error.' + (F.why ? ' ' + String(F.why).replace(/\.?$/, '.') : '') + ' Claude runs ' + (F.n === 1 ? 'it' : 'them') + ' again on the next wake. Nothing ' + (F.n === 1 ? 'it' : 'they') + ' made was kept.')}</span></div>`;
|
|
81
|
+
|
|
82
|
+
export function expHtml(M) {
|
|
83
|
+
if (!M || !M.exp) return '';
|
|
84
|
+
const rowHtml = (r) => {
|
|
85
|
+
const val = `<span class="ia-v">${esc(r.text)}${r.sub ? `<small>${esc(r.sub)}</small>` : ''}</span>`;
|
|
86
|
+
return r.edit ? `<button type="button" class="ia-xr" data-ia-edit="${esc(r.key)}" aria-label="${esc(r.label + ': ' + r.text + '. Edit')}" title="Edit"><b>${esc(r.label)}</b>${val}</button>`
|
|
87
|
+
: `<div class="ia-xr"><b>${esc(r.label)}</b>${val}</div>`;
|
|
88
|
+
};
|
|
89
|
+
return `<section class="ia-sec" aria-label="Experiment" data-ia-exp><div class="ia-th"><b>Experiment</b><span class="n">${esc('Claude keeps it' + (M.exp.at ? ' · ' + dm(M.exp.at) : ''))}</span></div>`
|
|
90
|
+
+ `<div class="iv-folds">${M.exp.rows.map(rowHtml).join('')}<p class="ia-note">Press a line to edit it. Claude asks before it changes one you edited.</p></div></section>`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function workHtml(M, up, o = {}) {
|
|
94
|
+
if (!M || (!M.work.length && !M.failed && !up)) return '';
|
|
95
|
+
const all = !!o.all, shown = all ? M.work : M.work.slice(0, SHOW), more = M.work.length - shown.length;
|
|
96
|
+
const row = (w) => `<div class="ia-dr" data-ref="${esc(w.ref)}"><span class="ck" aria-hidden="true">${SVG(P.check, 12, 2.6)}</span><span><b>${esc(w.title)}</b><em>${esc([w.reason, dm(w.at)].filter(Boolean).join(' · '))}</em></span>`
|
|
97
|
+
+ `<button type="button" class="yd-alt sm" data-ia-undo="${esc(w.ref)}" data-ws="${esc(w.ws)}" aria-label="${esc('Undo: ' + w.title)}" title="Undo">${SVG(P.undo, 16, 2)}</button></div>`;
|
|
98
|
+
const list = M.work.length || M.failed ? `<div class="iv-folds">${M.failed ? failLine(M.failed) : ''}${shown.map(row).join('')}`
|
|
99
|
+
+ (more > 0 ? `<button type="button" class="iv-fr" data-ia-more aria-expanded="false"><b>${more} more</b><span class="iv-cv" aria-hidden="true">${SVG(P.right, 14, 2)}</span></button>` : '') + '</div>' : '';
|
|
100
|
+
const cu = up ? `<p class="ia-cu">${SVG(P.clock, 14, 2)}<span><b>${esc('Coming up · ' + up.date + '.')}</b> ${esc(up.text)}</span></p>` : '';
|
|
101
|
+
const n = M.week ? M.week + ' this week' : M.work.length ? M.work.length + ' in 14 days' : '';
|
|
102
|
+
return `<section class="ia-sec" aria-label="Claude’s work" data-ia-work><div class="ia-th"><b>Claude’s work</b>${n ? `<span class="n">${esc(n)}</span>` : ''}</div>${list}${cu}</section>`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Both sections in one holder the page can swap when the reads arrive. */
|
|
106
|
+
export function sectionsHtml(M, v, id, o = {}) {
|
|
107
|
+
return `<div class="ia" data-ia="${esc(id)}">${expHtml(M)}${workHtml(M, comingUp(v), o)}</div>`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ── the reads and the presses (the page only) ── */
|
|
111
|
+
const CACHE = new Map(), WANT = new Map(), OPEN = new Set();
|
|
112
|
+
const FRESH_MS = 30e3;
|
|
113
|
+
export const cached = (id) => (CACHE.get(id) || {}).M || null;
|
|
114
|
+
export const allOpen = (id) => OPEN.has(id);
|
|
115
|
+
/** Read the experiment and Claude's work for one initiative, at most every 30 s; done() runs when the answer changed what shows. */
|
|
116
|
+
export function want(ws, id, done) {
|
|
117
|
+
if (!id) return;
|
|
118
|
+
const c = CACHE.get(id), k = ws + '|' + id;
|
|
119
|
+
if (c && Date.now() - c.at < FRESH_MS) return;
|
|
120
|
+
if (WANT.has(k)) return;
|
|
121
|
+
const q = ws ? 'ws=' + encodeURIComponent(ws) + '&' : '';
|
|
122
|
+
const p = Promise.all([pmGet('/api/artefacts?' + q + 'scope=' + encodeURIComponent('experiment:' + id)).catch(() => null), pmGet('/api/autonomy' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)])
|
|
123
|
+
.then(([a, u]) => {
|
|
124
|
+
const M = agentModel(a && a.ok ? a : null, u && u.ok ? u : null, id);
|
|
125
|
+
const was = JSON.stringify(cached(id));
|
|
126
|
+
CACHE.set(id, { M, at: Date.now() });
|
|
127
|
+
if (JSON.stringify(M) !== was && done) done();
|
|
128
|
+
}).finally(() => WANT.delete(k));
|
|
129
|
+
WANT.set(k, p);
|
|
130
|
+
}
|
|
131
|
+
const forget = (id) => { const c = CACHE.get(id); if (c) c.at = 0; };
|
|
132
|
+
export function toggleMore(id) { if (OPEN.has(id)) OPEN.delete(id); else OPEN.add(id); }
|
|
133
|
+
|
|
134
|
+
/** A press on a field: the line turns into its editor (a text field, or the three builders for Who builds). */
|
|
135
|
+
export function edit(btn) {
|
|
136
|
+
const sec = btn.closest('[data-ia]'), id = sec && sec.dataset.ia, M = cached(id);
|
|
137
|
+
const r = M && M.exp && M.exp.rows.find((x) => x.key === btn.dataset.iaEdit);
|
|
138
|
+
if (!r || !r.edit) return;
|
|
139
|
+
const field = r.edit.pick ? `<select name="v" aria-label="${esc(r.label)}">${r.edit.pick.map((p) => `<option value="${esc(p)}"${p === r.value ? ' selected' : ''}>${esc(WHO[p])}</option>`).join('')}</select>`
|
|
140
|
+
: `<textarea name="v" rows="2" aria-label="${esc(r.label)}">${esc(r.text)}</textarea>`;
|
|
141
|
+
const f = document.createElement('form');
|
|
142
|
+
f.className = 'ia-xr ia-ed'; f.dataset.iaKey = r.key;
|
|
143
|
+
f.innerHTML = `<b>${esc(r.label)}</b><span class="ia-v">${field}<span class="ia-eb"><button type="submit" class="yd-ok sm" aria-label="Save" title="Save">${SVG(P.check, 16, 2.6)}</button><button type="button" class="yd-alt sm" data-ia-cancel aria-label="Cancel" title="Cancel">${SVG(P.x, 16, 2)}</button></span></span>`;
|
|
144
|
+
btn.replaceWith(f);
|
|
145
|
+
const el = f.querySelector('[name="v"]'); if (el) el.focus();
|
|
146
|
+
}
|
|
147
|
+
/** Save the PM's edit of one line; then read again and draw. */
|
|
148
|
+
export async function save(form, ws, redraw, toast) {
|
|
149
|
+
const id = form.closest('[data-ia]').dataset.ia, M = cached(id), r = M && M.exp && M.exp.rows.find((x) => x.key === form.dataset.iaKey);
|
|
150
|
+
const v = String(form.querySelector('[name="v"]').value || '').trim();
|
|
151
|
+
if (!r || !v) { redraw(); return; }
|
|
152
|
+
const res = await pmPost('/api/artefacts/set', { ws: ws || undefined, scope: 'experiment:' + id, artefact: r.edit.artefact, field: r.edit.field, text: v }).catch(() => null);
|
|
153
|
+
if (!res || !res.ok) { if (toast) toast((res && res.error) || 'It could not be saved. Nothing changed.'); redraw(); return; }
|
|
154
|
+
forget(id); want(ws, id, redraw);
|
|
155
|
+
}
|
|
156
|
+
/** Undo one change Claude made here (POST /api/autonomy/undo); then read again and draw. */
|
|
157
|
+
export async function undo(btn, ws, redraw, toast) {
|
|
158
|
+
if (btn.disabled) return; btn.disabled = true;
|
|
159
|
+
const id = btn.closest('[data-ia]').dataset.ia;
|
|
160
|
+
const res = await pmPost('/api/autonomy/undo', { ws: btn.dataset.ws || ws || undefined, ref: btn.dataset.iaUndo }).catch(() => null);
|
|
161
|
+
if (!res || !res.ok) { btn.disabled = false; if (toast) toast((res && res.error) || 'It could not be undone. Nothing changed.'); return; }
|
|
162
|
+
if (toast) toast('Undone.');
|
|
163
|
+
forget(id); want(ws, id, redraw);
|
|
164
|
+
}
|
|
@@ -169,9 +169,9 @@ button.iv-wf:hover, .iv-prog:hover { background: var(--cz-well2) !important; col
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/* Tasks: the WBS, one section per stage */
|
|
172
|
-
.iv-th { display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
|
|
173
|
-
.iv-th b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
174
|
-
.iv-th .n { font-size: var(--fs-label); color: var(--cz-ink3); font-weight: var(--fw-strong); line-height: var(--lh-label); }
|
|
172
|
+
.iv-th, .ia-th { display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
|
|
173
|
+
.iv-th b, .ia-th b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
174
|
+
.iv-th .n, .ia-th .n { font-size: var(--fs-label); color: var(--cz-ink3); font-weight: var(--fw-strong); line-height: var(--lh-label); }
|
|
175
175
|
.iv-th .iv-ib { margin-left: auto; }
|
|
176
176
|
.iv-wbs { display: flex; flex-direction: column; border-radius: 18px; border: 1px solid var(--cz-hair); overflow: hidden; }
|
|
177
177
|
.iv-ws { display: flex !important; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 4px 12px 4px 14px !important; position: relative; }
|
|
@@ -1324,3 +1324,32 @@ body.iv-dragging { user-select: none; -webkit-user-select: none; cursor: grabbin
|
|
|
1324
1324
|
.bp-say { flex: 1 1 100%; min-height: 40px; border-radius: 12px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); padding: 0 12px; font: inherit; }
|
|
1325
1325
|
.bp-full { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 12px; border: 0; background: none; color: var(--cz-ink3); font: inherit; font-size: var(--fs-meta); cursor: pointer; }
|
|
1326
1326
|
.bp-full:hover { color: var(--cz-blueink); }
|
|
1327
|
+
|
|
1328
|
+
/* agent-run (board AwB, agreed 2026-11-10): the Experiment, Claude's work with its reasons and Undo, one Coming up line (pm/ini-agent.js) */
|
|
1329
|
+
.ia { display: contents; }
|
|
1330
|
+
.ia-sec { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
|
|
1331
|
+
.ia-xr, .iv button.ia-xr { display: flex; gap: 12px; width: 100%; padding: 11px 14px; position: relative; border: 0; background: none; text-align: left; font: inherit; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink); }
|
|
1332
|
+
button.ia-xr { cursor: pointer; }
|
|
1333
|
+
button.ia-xr:hover { background: var(--cz-well); }
|
|
1334
|
+
.ia-xr + .ia-xr::before { content: ""; position: absolute; left: 14px; right: 12px; top: 0; height: 1px; background: var(--cz-hair); }
|
|
1335
|
+
.ia-xr > b { flex: none; width: 112px; font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
1336
|
+
.ia-v { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
1337
|
+
.ia-v small { display: block; font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
1338
|
+
.ia-ed textarea, .ia-ed select { width: 100%; box-sizing: border-box; font: inherit; color: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--cz-hair); background: var(--cz-card); }
|
|
1339
|
+
.ia-eb { display: flex; gap: 6px; }
|
|
1340
|
+
.ia-note { margin: 0; padding: 4px 14px 11px; font-size: var(--fs-label); color: var(--cz-ink3); line-height: 1.45; }
|
|
1341
|
+
.ia-dr { display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 14px; position: relative; font-size: var(--fs-meta); line-height: 1.45; }
|
|
1342
|
+
.ia-dr + .ia-dr::before, .ia-fl + .ia-dr::before { content: ""; position: absolute; left: 14px; right: 12px; top: 0; height: 1px; background: var(--cz-hair); }
|
|
1343
|
+
.ia-dr .ck { flex: none; width: 20px; height: 20px; border-radius: 10px; margin-top: 1px; background: var(--cz-blueink); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; }
|
|
1344
|
+
.ia-dr > span:not(.ck) { flex: 1; min-width: 0; }
|
|
1345
|
+
.ia-dr b { font-weight: var(--fw-strong); }
|
|
1346
|
+
.ia-dr em { display: block; font-style: normal; font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
1347
|
+
.ia-dr .yd-alt.sm { flex: none; width: 36px; height: 36px; }
|
|
1348
|
+
.ia-fl { display: flex; gap: 8px; align-items: flex-start; margin: 8px 8px 4px; padding: 9px 12px; border-radius: 12px; background: var(--cz-latebg); color: var(--cz-late); font-size: var(--fs-label); line-height: 1.45; }
|
|
1349
|
+
.ia-fl svg, .ia-cu svg { flex: none; margin-top: 2px; }
|
|
1350
|
+
.ia-cu { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 14px; font-size: var(--fs-label); color: var(--cz-blueink); line-height: 1.45; }
|
|
1351
|
+
@media (max-width: 760px) { .ia-xr { flex-direction: column; gap: 2px; } .ia-xr > b { width: auto; } }
|
|
1352
|
+
.ia .yd-ok, .ia .yd-alt { flex: none; border: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font: inherit; width: 36px; height: 36px; border-radius: 18px; }
|
|
1353
|
+
.ia .yd-ok { background: var(--cz-blue); color: var(--cz-onsolid); }
|
|
1354
|
+
.ia .yd-alt { background: var(--cz-well); color: var(--cz-ink2); }
|
|
1355
|
+
.ia .yd-alt:disabled { opacity: .5; cursor: default; }
|
|
@@ -47,6 +47,7 @@ import * as AB from './ini-about.js'; // About: the description and the succes
|
|
|
47
47
|
import { headerFlags } from './grill-words.js'; // the grill findings on the header (workspace grill W3)
|
|
48
48
|
import * as ED from './ini-edit.js'; // a task changed where it sits in the List: open in place, ⋯, + per stage, drag (batch 18 item 16)
|
|
49
49
|
import { ticks } from './ini-view-model.js'; // W1: a task group ticks only when every task in it is done
|
|
50
|
+
import * as IA from './ini-agent.js'; // agent-run (board AwB): the Experiment, Claude's work with Undo, Coming up; the D107 gate
|
|
50
51
|
|
|
51
52
|
const CSS = new URL('./ini-view.css', import.meta.url).href;
|
|
52
53
|
if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
|
|
@@ -409,12 +410,15 @@ function foldsHtml(v, o) {
|
|
|
409
410
|
const VIEWED = new Map(); // initiative id → the view drawn last (the ✦ in the Viewer's header reads it)
|
|
410
411
|
const OPTS = new Map(); // initiative id → the options it was drawn with, so About can draw alone when its description arrives
|
|
411
412
|
export function viewHtml(v, o = {}) {
|
|
413
|
+
// agent-run (AwB): with an experiment on record the gate to Build reads its done test and kill condition (D107), not PRD and rubric
|
|
414
|
+
const AM = v && v.id ? IA.cached(v.id) : null, ag = IA.gateOf(AM);
|
|
415
|
+
if (ag && v.stage) v = { ...v, stage: { ...v.stage, gate: ag } };
|
|
412
416
|
if (v && v.id) { VIEWED.set(v.id, v); OPTS.set(v.id, o); }
|
|
413
417
|
// a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
|
|
414
418
|
if (v.merged) return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${smMerged(v.merged)}</div><div class="iv-cr">${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
|
|
415
419
|
// One reading column: summary, milestones and proposals, then content-sized Tasks and document folds.
|
|
416
420
|
return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${ctrlHtml(v, o)}${o.sm !== false ? smCard(v.suggest, v.title) : ''}</div>`
|
|
417
|
-
+ `<div class="iv-cr"
|
|
421
|
+
+ `<div class="iv-cr">${v.id ? IA.sectionsHtml(AM, v, v.id, { all: IA.allOpen(v.id) }) : ''}<section class="iv-tasks" aria-label="Tasks">${tasksHtml(v, o)}</section>${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
|
|
418
422
|
}
|
|
419
423
|
|
|
420
424
|
/* ── the presses ── */
|
|
@@ -423,7 +427,19 @@ export function wireView(body, h) {
|
|
|
423
427
|
const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
|
|
424
428
|
body.__iv = LK.wrap(VS.wrap(ED.writes({ ...h, __id: idOf }), body, (id) => SHOWN.get(id)), idOf);
|
|
425
429
|
// the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
|
|
426
|
-
const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); fitMission(body); };
|
|
430
|
+
const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); agent(id); fitMission(body); };
|
|
431
|
+
// agent-run (AwB): the experiment and Claude's work, read every 30 s at most; they draw alone (and the gate with them) when they change
|
|
432
|
+
const wsOf = () => { const H = body.__iv || {}; return ((H.where && H.where()) || {}).ws || ''; };
|
|
433
|
+
const agent = (id) => { if (id && VIEWED.has(id)) IA.want(wsOf(), id, () => paintAgent(id)); };
|
|
434
|
+
const paintAgent = (id) => {
|
|
435
|
+
if (idOf() !== id || !VIEWED.has(id)) return;
|
|
436
|
+
const v0 = VIEWED.get(id), M = IA.cached(id), g = IA.gateOf(M), v = g ? { ...v0, stage: { ...v0.stage, gate: g } } : v0;
|
|
437
|
+
VIEWED.set(id, v);
|
|
438
|
+
// replace only what changed: a node another press holds (a task card's day picker) is never swapped for an identical copy
|
|
439
|
+
const swap = (n, html) => { const t = document.createElement('template'); t.innerHTML = html; const x = t.content.firstElementChild; if (!x || !x.isEqualNode(n)) n.outerHTML = html; };
|
|
440
|
+
const at = body.querySelector('[data-ia]'); if (at) swap(at, IA.sectionsHtml(M, v, id, { all: IA.allOpen(id) }));
|
|
441
|
+
if (g) for (const n of body.querySelectorAll('.iv-gate')) swap(n, srcGateHtml({ gate: g }));
|
|
442
|
+
};
|
|
427
443
|
// the success measure Claude drafted: read once per page load, the view draws again when it arrives
|
|
428
444
|
const drafts = (id) => { const H = body.__iv || {}; if (id && VIEWED.has(id)) MD.want(((H.where && H.where()) || {}).ws || '', 'initiative', id, () => { if (idOf() === id && H.redraw) H.redraw(); }); };
|
|
429
445
|
// the description: the PRD, read once per path through /api/doc; the view draws again when it arrives
|
|
@@ -465,6 +481,11 @@ export function wireView(body, h) {
|
|
|
465
481
|
const root = b.closest('[data-iv]'); if (!root) return;
|
|
466
482
|
const id = root.dataset.iv;
|
|
467
483
|
const d = b.dataset;
|
|
484
|
+
// agent-run (AwB): edit a line of the experiment, Undo a change of Claude's, the rest of Claude's work
|
|
485
|
+
if (d.iaEdit) { e.preventDefault(); IA.edit(b); return; }
|
|
486
|
+
if ('iaCancel' in d) { e.preventDefault(); paintAgent(id); return; }
|
|
487
|
+
if (d.iaUndo) { e.preventDefault(); IA.undo(b, wsOf(), () => paintAgent(id), H.toast); return; }
|
|
488
|
+
if ('iaMore' in d) { e.preventDefault(); IA.toggleMore(id); paintAgent(id); return; }
|
|
468
489
|
if (d.ivMc) { e.preventDefault(); const M = MD.measuresOf(id); mcToggle(id, d.ivMc, { proposal: !!(M && M.mode === 'open') }); if (H.redraw) H.redraw(); later(b, (r) => r.querySelector(`[data-iv-mc="${d.ivMc}"]`), true); return; }
|
|
469
490
|
if (d.abMore && AB.pressMore(b, H.redraw)) { e.preventDefault(); return; }
|
|
470
491
|
if (d.md && MD.press(b, { redraw: H.redraw, toast: H.toast })) { e.preventDefault(); return; }
|
|
@@ -497,6 +518,8 @@ export function wireView(body, h) {
|
|
|
497
518
|
});
|
|
498
519
|
// the inline add (the Tasks + icon): Enter adds, Esc puts the + back
|
|
499
520
|
body.addEventListener('submit', (e) => {
|
|
521
|
+
const ed = e.target.closest('form.ia-ed');
|
|
522
|
+
if (ed) { e.preventDefault(); const r = ed.closest('[data-iv]'); IA.save(ed, wsOf(), () => paintAgent(r && r.dataset.iv), (body.__iv || {}).toast); return; }
|
|
500
523
|
const f = e.target.closest('[data-iv-addform]'); if (!f) return;
|
|
501
524
|
e.preventDefault(); const H = body.__iv || {}, inp = f.querySelector('input'), t = inp ? inp.value.trim() : '';
|
|
502
525
|
if (t && H.addTask) H.addTask(t, inp);
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
* rows, mentions: GET /api/mentions waiting, outbox: GET /api/outbox entries, now }
|
|
37
37
|
* → { rows (at most CAP), wait (Can wait, ranked), older: [] (kept for old callers), expired: [{ ini, title, why, at, name }],
|
|
38
38
|
* done: [{ ref, via: 'autonomy' | 'proposals', ini, board, ws, at, said, name }] (C2: what Claude finished by itself, with Undo),
|
|
39
|
-
* notices: [{ job, product, until, text?, ws }] (a job demoted to propose, said once),
|
|
39
|
+
* notices: [{ job, product, until, text?, ws }] (a job demoted to propose, said once), failed: [{ run, ini, at, why, ws, name }] (agent-run
|
|
40
|
+
* R4: the runs that stopped, GET /api/autonomy failed), n }
|
|
40
41
|
* A row: { key, rank, kind, title, sub, tag, at, age, older, ws, board, ini, program, props: [{ ws, board, ini, ids, sigs }], ms: { program,
|
|
41
42
|
* keys } | null, verdict: { ini, board, verdict, text } | null, yes: label | '', alt: label | '', call } */
|
|
42
43
|
import { findingOf } from './grill-words.js';
|
|
@@ -201,13 +202,15 @@ export function rankMove(o = {}) {
|
|
|
201
202
|
rows.sort((a, b) => a.rank - b.rank || (a.at == null) - (b.at == null) || (a.at || 0) - (b.at || 0) || a.key.localeCompare(b.key));
|
|
202
203
|
// C3: at most CAP show; the rest can wait, in the same order. The expired ✦ of the last 7 days, said once.
|
|
203
204
|
// C2: what Claude finished by itself (lib/done-feed.js), one line per batch with its initiative's name and one Undo
|
|
204
|
-
const expired = [], done = [], notices = [];
|
|
205
|
+
const expired = [], done = [], notices = [], failed = [];
|
|
205
206
|
for (const P of o.products || []) {
|
|
206
207
|
const M = (o.move && o.move[P.ws || '']) || {}, nameOf = (ini) => { const r = (P.rows || []).find((x) => x && x.id === ini); return (r && (r.title || r.id)) || ini || ''; };
|
|
207
208
|
for (const x of M.expired || []) expired.push({ ...x, ws: P.ws || '', name: nameOf(x.ini) });
|
|
208
209
|
for (const x of M.done || []) done.push({ ...x, ws: P.ws || '', board: x.board || P.board || '', name: x.ini ? nameOf(x.ini) : '' });
|
|
209
210
|
for (const x of M.notices || []) notices.push({ ...x, ws: P.ws || '' });
|
|
211
|
+
for (const x of M.failed || []) failed.push({ ...x, ws: P.ws || '', name: P.name || '', iniName: x.ini ? nameOf(x.ini) : '' }); // agent-run R4: a run that stopped
|
|
210
212
|
}
|
|
211
213
|
done.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
212
|
-
|
|
214
|
+
failed.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
215
|
+
return { rows: rows.slice(0, CAP), wait: rows.slice(CAP), older: [], expired, done, notices, failed, n: rows.length };
|
|
213
216
|
}
|
|
@@ -128,6 +128,24 @@ function banner() {
|
|
|
128
128
|
main.insertBefore(d, main.firstChild);
|
|
129
129
|
const tabs = tabsHtml(PACK, location);
|
|
130
130
|
if (tabs) d.insertAdjacentHTML('afterend', tabs);
|
|
131
|
+
// "The story so far" (board AwF): the product's story above the timeline, as its page has it, without sources or Claude's activity
|
|
132
|
+
const st = storyOf(PACK, location);
|
|
133
|
+
if (st) (main.querySelector('.ro-tabs') || d).insertAdjacentHTML('afterend', st);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The story of the board on screen, from the pack (lib/board-pack.js carries it as text lines). '' when the pack holds none. A program's tab
|
|
137
|
+
* (?program=) has no product story. */
|
|
138
|
+
export function storyOf(pack, loc) {
|
|
139
|
+
const q = new URLSearchParams(loc.search); if (q.get('program')) return '';
|
|
140
|
+
const R = (pack && pack.responses) || {};
|
|
141
|
+
const ws = q.get('ws') || (pack && pack.scope && pack.scope.kind === 'product' ? pack.scope.id : '');
|
|
142
|
+
const a = R['/api/artefacts/story?' + new URLSearchParams({ ws }).toString()];
|
|
143
|
+
const S = a && a.ok && a.story; const L = S && Array.isArray(S.lines) ? S.lines.filter((l) => l && l.text) : [];
|
|
144
|
+
if (!L.length) return '';
|
|
145
|
+
const day = (() => { const t = Date.parse(S.at || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' }) : ''; })();
|
|
146
|
+
const sub = [pack.scope && pack.scope.kind === 'product' ? pack.scope.label : '', day ? 'as of ' + day : ''].filter(Boolean).join(' · ');
|
|
147
|
+
return '<section class="ro-story" aria-label="The story so far"><div class="ro-sth"><b>The story so far</b>' + (sub ? '<small>' + esc(sub) + '</small>' : '') + '</div>'
|
|
148
|
+
+ L.map((l) => '<p>' + esc(l.text).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>') + '</p>').join('') + '</section>';
|
|
131
149
|
}
|
|
132
150
|
|
|
133
151
|
function start() {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* pm/story.css — "The story so far" (pm/story.js; boards AwE and AwF). Tokens only. */
|
|
2
|
+
.st-story { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; }
|
|
3
|
+
.st-story p { margin: 0; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--cz-ink); }
|
|
4
|
+
.st-story p b { font-weight: var(--fw-strong); }
|
|
5
|
+
.st-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 0 0 2px; }
|
|
6
|
+
.st-h h4 { margin: 0; font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
7
|
+
.st-h small { font-size: var(--fs-label); color: var(--cz-ink3); line-height: var(--lh-label); }
|
|
8
|
+
.st-src { display: inline-flex; align-items: center; height: 22px; margin-left: 6px; padding: 0 8px; border-radius: 6px; background: var(--cz-well); color: var(--cz-ink3); font-size: var(--fs-label); font-weight: var(--fw-strong); vertical-align: 1px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* pm/story.js — "The story so far" (agent-run workspace boards AwE and AwF, agreed by the PM 2026-11-10).
|
|
2
|
+
* The standing Narrative of a product (D107), written by Claude from the records, read with GET /api/artefacts/story?ws.
|
|
3
|
+
*
|
|
4
|
+
* storyHtml(story, { sources, label, sub }) the card. story: { at, lines: [{ text, sources? }] }; sources true draws each line's source
|
|
5
|
+
* chips (the product page); a shared Board draws none (its pack holds none). '' when empty.
|
|
6
|
+
* storyText(story) the story as plain text: the body of the weekly update Claude drafts
|
|
7
|
+
* readStory(ws) the GET; null when there is no story or the server does not answer
|
|
8
|
+
*
|
|
9
|
+
* A line's **words** are bold. Zero is silence: no story, no card. */
|
|
10
|
+
import { pmGet } from './http.js';
|
|
11
|
+
|
|
12
|
+
const CSS = new URL('./story.css', import.meta.url).href;
|
|
13
|
+
if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
|
|
14
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
|
|
15
|
+
}
|
|
16
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
17
|
+
const bold = (t) => esc(t).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
|
|
18
|
+
const plain = (t) => String(t || '').replace(/\*\*([^*]+)\*\*/g, '$1');
|
|
19
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
20
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
21
|
+
/** "3 Nov 16:05" in this browser's time. */
|
|
22
|
+
export function when(iso) {
|
|
23
|
+
const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return '';
|
|
24
|
+
const d = new Date(t); return `${d.getDate()} ${MON[d.getMonth()]} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
25
|
+
}
|
|
26
|
+
const lines = (s) => (s && Array.isArray(s.lines) ? s.lines.filter((l) => l && String(l.text || '').trim()) : []);
|
|
27
|
+
|
|
28
|
+
export function storyHtml(story, o = {}) {
|
|
29
|
+
const L = lines(story); if (!L.length) return '';
|
|
30
|
+
const chip = (x) => `<span class="st-src" title="${esc(x.ref || x.label)}">${esc(x.label)}</span>`;
|
|
31
|
+
const p = L.map((l) => `<p>${bold(l.text)}${o.sources && Array.isArray(l.sources) ? l.sources.filter((x) => x && x.label).map(chip).join('') : ''}</p>`).join('');
|
|
32
|
+
const sub = o.sub != null ? o.sub : ['Claude keeps it current', when(story.at)].filter(Boolean).join(' · ');
|
|
33
|
+
return `<section class="${o.cls || 'pv-card'} st-story" aria-label="The story so far"><div class="st-h"><h4>${esc(o.label || 'The story so far')}</h4>${sub ? `<small>${esc(sub)}</small>` : ''}</div>${p}</section>`;
|
|
34
|
+
}
|
|
35
|
+
export function storyText(story) { return lines(story).map((l) => plain(l.text)).join('\n\n'); }
|
|
36
|
+
export async function readStory(ws) {
|
|
37
|
+
const r = await pmGet('/api/artefacts/story' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null);
|
|
38
|
+
return r && r.ok && r.story && lines(r.story).length ? r.story : null;
|
|
39
|
+
}
|
|
@@ -50,7 +50,8 @@ Procedure:
|
|
|
50
50
|
`definition` says whether the definition used is confirmed (`stable`) or only proposed (`draft`). Do not add a `timestamp` or `verified`.
|
|
51
51
|
5. Under the frontmatter: a Headline (one or two sentences: what the reader most needs to know), then the sections the definition names in its order, then "Needs your call" (decisions or answers only the PM can give), then "Sources reached and not reached" (each source kind: reached or not reached and why; private items skipped).
|
|
52
52
|
6. If the definition was a draft, say so in the first line of the Headline so the PM sees it.
|
|
53
|
-
7.
|
|
53
|
+
7. Keep the product's story current (D107 Narrative; the product page shows it as "The story so far", and the weekly update leads with it). Write 3 to 6 short sentences, one per line, on where the product stands now: what was settled, what waits, what is late, what has no verdict yet. Give one `--source` per line, in the same order, each pointing at the record that holds that sentence: `pmos artefacts set portfolio narrative now --text "<line 1>"$'\n'"<line 2>"… --source "<label>=<ref>" --source …`. A label is short ("Jira IDPF-3326 · 30 Oct"). Bold a few words with **two stars** when they are the point. A sentence with no record is left out. The story goes to people only when the PM sends it.
|
|
54
|
+
8. Finish by saying in one line where the draft is. Do not commit; the PM's Sync carries the file.
|
|
54
55
|
|
|
55
56
|
Default shape, used ONLY when proposing a definition: a weekly report: progress against initiatives, decisions made, risks, what is next. Use the report frame of D78: a Headline, then What moved, Risks and Metrics, then Needs your call and Sources reached and not reached.
|
|
56
57
|
|
|
@@ -237,6 +237,9 @@ const TICKETS = [{ key: 'IDPF-3387', title: 'Refactor the AppAuthService', statu
|
|
|
237
237
|
ok('S7 ⋯ Milestone makes it a milestone and clears its start (one date), keeping the due day', ms && ms.body.task === 'task-b3' && ms.body.start === '' && ms.body.due == null, JSON.stringify(ms));
|
|
238
238
|
const one7 = await until(() => p.evaluate(() => { const r = document.querySelector('#czViewer .iv-ed[data-iv-open="task-b3"]'); if (!r) return null; const d = [...r.querySelectorAll('.iv-edd')]; return d.length === 1 && d[0].dataset.one === '1' ? d[0].getAttribute('aria-label') : null; }));
|
|
239
239
|
ok('S7 the open row then shows one ◇ date chip, no Start and Due', one7 === 'Milestone date: Nov 12. Change', one7);
|
|
240
|
+
// the Viewer's Experiment and Claude's work sit above Tasks, so the row may sit below the fold: bring it in first and let that scroll
|
|
241
|
+
// settle, or its late scroll event closes the picker the click just opened (a scroll outside the picker closes it)
|
|
242
|
+
await p.$eval('#czViewer .iv-ed .iv-edd', (n) => n.scrollIntoView({ block: 'center' })); await p.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
|
240
243
|
await p.click('#czViewer .iv-ed .iv-edd');
|
|
241
244
|
const op7 = await until(() => p.evaluate(() => { const q = document.querySelector('.tkc.ivq .tkc-dp'); return q ? { tabs: q.querySelectorAll('[data-tkc-field]').length, head: (q.querySelector('.ivd-h b') || {}).textContent, sub: (q.querySelector('.ivd-s') || {}).textContent } : null; }));
|
|
242
245
|
ok('S7 its picker is one date: "◇ Date", no Start and Due tabs', op7 && op7.tabs === 0 && op7.head === 'Date' && /one date: the milestone/.test(op7.sub || ''), JSON.stringify(op7));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Agent-run workspace (boards AwA, AwB): the initiative Viewer's Experiment, Claude's work with Undo, Coming up and the D107 gate (pure, node): pm/ini-agent.js.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"ini-agent.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"ini-agent.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|