create-pmos 0.710.0 → 0.712.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.
@@ -27,7 +27,7 @@ export const ICON = {
27
27
  };
28
28
  const svg = (d, w = 2) => `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"></path></svg>`;
29
29
  /** One answer as an icon button. a = { icon, label, attr, pri }. */
30
- export const iconBtn = (a) => `<button type="button" class="hm-icb${a.pri ? ' pri' : ''}" ${a.attr} aria-label="${esc(a.label)}" title="${esc(a.label)}"${a.off ? ' disabled' : ''}>${svg(ICON[a.icon] || a.icon, a.icon === 'yes' ? 2.4 : 2)}</button>`;
30
+ export const iconBtn = (a) => `<button type="button" class="hm-icb${a.pri ? ' pri' : ''}" ${a.attr} aria-label="${esc(a.label)}" title="${esc(a.label)}"${a.sw ? ` data-sw-${a.sw}` : ''}${a.off ? ' disabled' : ''}>${svg(ICON[a.icon] || a.icon, a.icon === 'yes' ? 2.4 : 2)}</button>`;
31
31
 
32
32
  // systems where a write leaves PMOS; a read from them still asks as a plain Allow
33
33
  const OUTSIDE = /jira|confluence|atlassian|slack|gmail|mail|calendar|google|drive|notion|linear|asana|teams|figma|wispr/i;
@@ -57,7 +57,11 @@ export function permissionAsk(conv) {
57
57
  const more = opts.filter((o) => o !== allow && o !== deny);
58
58
  const send = !!ch && OUTSIDE.test(ch.system || '') && WRITE.test(ch.tool || '');
59
59
  const verb = ch && ch.tool && !/^mcp__/.test(ch.tool) ? ch.tool + ' ' : '';
60
+ // tap for why (PhoneTodayDS, job 1540): PMOS's own words just before it asked, so the PM need not scroll up to see the reason
61
+ const said = (Array.isArray(c.messages) ? c.messages : []).filter((m) => m.role === 'assistant').pop();
62
+ const why = said ? clip(splitAsk(said.text).text, 300) : '';
60
63
  return {
64
+ why,
61
65
  kind: send ? 'send' : 'file',
62
66
  label: send ? 'Asks before it sends to ' + ch.system : 'Asks before it goes on',
63
67
  title: ch ? (send ? ch.what : verb + ch.what) : c.ask.question,
@@ -113,8 +117,14 @@ export function askCardHtml(a, { live = true, role = 'PMOS' } = {}) {
113
117
  const ft = a.from || a.to ? `<p class="ft">${a.from ? `<s>${esc(a.from)}</s> → ` : ''}<b>${esc(a.to)}</b></p>` : '';
114
118
  const more = live && a.more && a.more.length
115
119
  ? `<span class="hm-mw"><button type="button" class="hm-icb hm-dots" data-hm-pmore aria-haspopup="menu" aria-label="More choices: ${esc(a.more.map((o) => o.label).join(', '))}" title="${esc(a.more.map((o) => o.label).join(' · '))}">${svg(ICON.dots, 2.6)}</button><span class="hm-pmenu" role="menu" hidden>${a.more.map((o) => `<button type="button" role="menuitem" ${o.attr}>${esc(o.label)}</button>`).join('')}</span></span>` : '';
116
- return `<div class="hm-askw" role="group" aria-label="${esc(role)} asks before it goes on"><div class="hm-askk" data-ask-kind="${a.kind}"><p class="k">${esc(a.label)}</p><b class="q">${esc(a.title)}</b>${ft}`
117
- + `<div class="acts">${a.answers.map((x) => iconBtn({ ...x, off: !live })).join('')}${more}</div></div></div>`;
120
+ // a phone (PhoneTodayDS, job #1540): a live Allow · No card is a blue-lined line that swipes, right allows, left denies; its icon
121
+ // answers stay for the keyboard and a screen reader (cozy-home.css hides them from sight on a phone only)
122
+ const yes = a.answers.find((x) => x.icon === 'yes'), no = a.answers.find((x) => x.icon === 'no');
123
+ const sw = live && yes && no ? ` data-sw-right="yes" data-sw-left="no"` : '';
124
+ const hint = sw ? `<p class="hm-swh">${esc('Swipe right: ' + yes.label + ' · left: ' + no.label)}</p>` : '';
125
+ const why = live && a.why && a.why !== a.title ? `<details class="hm-why"><summary>Why</summary><p>${esc(a.why)}</p></details>` : '';
126
+ return `<div class="hm-askw" role="group" aria-label="${esc(role)} asks before it goes on"><div class="hm-askk" data-ask-kind="${a.kind}"${sw}><p class="k">${esc(a.label)}</p><b class="q">${esc(a.title)}</b>${ft}${hint}${why}`
127
+ + `<div class="acts">${a.answers.map((x) => iconBtn({ ...x, off: !live, sw: x === yes ? 'yes' : x === no ? 'no' : '' })).join('')}${more}</div></div></div>`;
118
128
  }
119
129
 
120
130
  /** True while something in the chat waits on the PM's answer: the permission prompt, a live question card or a live pmos-ask block.
@@ -132,3 +142,16 @@ export function openAsk(conv) {
132
142
  }
133
143
  return false;
134
144
  }
145
+
146
+ /** What a change PMOS was allowed to make says after it, with one Undo (PhoneTodayDS, job 1540: "Done: COM-412 is due 27 Nov. Undo").
147
+ * a = the card the PM answered (permissionAsk). Undo asks PMOS in words to put it back; a send to another system cannot be taken back
148
+ * by PMOS alone, so its Undo asks PMOS to undo it there and say what it could not. null when the card held no change. */
149
+ export function doneLine(a) {
150
+ if (!a || !a.title || (a.kind !== 'file' && a.kind !== 'send')) return null;
151
+ const what = clip(a.title, 160);
152
+ const undo = a.from || a.to
153
+ ? `Undo that change: put back "${clip(a.from, 200)}" in place of "${clip(a.to, 200)}" (${what}).`
154
+ : `Undo that change: ${what}.`;
155
+ return { text: what, undo };
156
+ }
157
+ export const doneLineHtml = (d) => d ? `<p class="hm-done" role="status">Done: ${esc(d.text)}. <button type="button" class="hm-undo" data-chat-say="${esc(d.undo)}">Undo</button></p>` : '';
@@ -30,7 +30,8 @@ import { goalUi } from './home-goal.js';
30
30
  import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
31
31
  import { turnsOf } from './chat-context.js';
32
32
  import { askCardHtml, answerText } from './chat-ask.js';
33
- import { permissionAsk, splitAsk, blockAsk, iconBtn, openAsk, askCardHtml as kindCardHtml } from './home-ask.js';
33
+ import { wireSwipe } from './cozy-phone-swipe.js'; // a phone: the ask card swipes (PhoneTodayDS, job #1540)
34
+ import { permissionAsk, splitAsk, blockAsk, iconBtn, openAsk, askCardHtml as kindCardHtml, doneLine, doneLineHtml } from './home-ask.js';
34
35
  import { splitChase, runStop, sweepLine, stopText } from './home-sweep.js';
35
36
  import { splitSrc, srcHtml } from './chat-src.js'; // chief-of-staff C1: where each answer came from
36
37
  import { splitFiles, filesHtml, sizeText, MAX_BYTES, MAX_FILES, setAttachSink } from './premium-attach.js';
@@ -85,6 +86,9 @@ export function mountChat(el, host) {
85
86
  el.innerHTML = `<button type="button" class="hm-reopen" id="hmReopen" aria-label="Open the Viewer" title="Open the Viewer" hidden>${PANE}</button>`
86
87
  + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-sug" id="hmSug" hidden></div><div class="hm-plw" id="hmPl" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
87
88
  const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh'), sug = el.querySelector('#hmSug'), pl = el.querySelector('#hmPl');
89
+ // a phone: a live ask swiped right allows (or sends), left denies; it presses the card's own icon answer (home-ask.js askCardHtml)
90
+ if (log) wireSwipe(log, { on: () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches,
91
+ act: (row, way) => { const b = row.querySelector(way === 'right' ? '[data-sw-yes]' : '[data-sw-no]'); if (b && !b.disabled) b.click(); } });
88
92
  const GU = goalUi({ C, host, el, draw: () => draw(), send: (t) => send(t), read: () => read(), openGoal: () => openGoal(), live: () => goalLive(), viewBody: () => document.querySelector('.obody.vw[data-vw="goal"]') });
89
93
  GU.wire(el);
90
94
  loadSlash(host.pmGet).then(() => { if (el.querySelector('#hmSlash:not([hidden])')) drawSlash(); });
@@ -211,6 +215,15 @@ export function mountChat(el, host) {
211
215
  const a = permissionAsk(C.conv);
212
216
  return a ? kindCardHtml(a, { role: R.role.name }) : '';
213
217
  }
218
+ /** The last allowed change: "Done: … Undo", kept until the PM writes again (a new PM turn, or the next ask, takes its place). */
219
+ function doneHtml() {
220
+ if (!C.done) return '';
221
+ const users = ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').length;
222
+ const ask = C.conv && C.conv.ask;
223
+ if (users > C.done.n || (ask && ask.question !== C.done.q)) { C.done = null; return ''; }
224
+ if (ask) return ''; // the answered prompt is still on screen until the next read
225
+ return doneLineHtml(C.done);
226
+ }
214
227
  function queuedHtml() {
215
228
  const q = host.queued ? host.queued(sid()) : [];
216
229
  // as typed: PMOS wraps a report ask or a /goal in its rule, adds the files line, and a live session joins the lines (batch 22 item 10:
@@ -286,7 +299,7 @@ export function mountChat(el, host) {
286
299
  const goal = C.th && C.th.goal;
287
300
  const parts = items.map((it, i) => msgHtml(it, i, R));
288
301
  placeDivider(parts, items, goal);
289
- let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + pendHtml() + queuedHtml();
302
+ let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro, !items.length) : '') + parts.join('') + askHtml(R) + doneHtml() + (R.stop && R.lastAgent < 0 ? dividerHtml(R.stop) : '') + pendHtml() + queuedHtml();
290
303
  html += GU.choiceHtml(); // /goal while a goal works here: In a new chat, or Here instead
291
304
  for (const n of C.notes || []) if (t.ini && n.ini === t.ini) html += `<p class="hm-note hm-you">${esc(n.text)}</p>`;
292
305
  if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
@@ -623,7 +636,11 @@ export function mountChat(el, host) {
623
636
  if ('hmRetry' in d) { const u = ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').pop(); if (u) send(u.text); return; }
624
637
  if (d.hmWi) { const it = C.items[+d.hmWi]; if (it) host.workItem(it.text, C.t); return; }
625
638
  if (d.hmPill) { const p = C.t.intro.pills[+d.hmPill]; if (p && p.go) { b.disabled = true; await p.go(b); b.disabled = false; } return; }
626
- if (d.hmPress) { b.disabled = true; press(d.hmPress); return; }
639
+ if (d.hmPress) {
640
+ // an allowed change says Done with one Undo under the chat until the PM writes again (PhoneTodayDS, job 1540)
641
+ if ('swYes' in d) { const dl = doneLine(permissionAsk(C.conv)); C.done = dl ? { ...dl, q: C.conv && C.conv.ask ? C.conv.ask.question : '', n: ((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').length } : null; }
642
+ b.disabled = true; press(d.hmPress); return;
643
+ }
627
644
  if ('hmPmore' in d) { const m = b.nextElementSibling; m.hidden = !m.hidden; return; }
628
645
  if ('hmTerm' in d) { host.openTerminal(sid()); return; }
629
646
  if ('hmCopyterm' in d) { const cmd = C.th && C.th.resume; try { await navigator.clipboard.writeText(cmd); host.toast('Copied. Paste it in Terminal on the computer PMOS runs on.'); } catch { host.toast('Copy did not work here. The command: ' + cmd); } return; }
@@ -1,6 +1,7 @@
1
1
  /* pm/phone-ask.js — Ask PMOS on a phone (phone design, board Ph2_asklist on Exploring 2; build brief nav-structure/phone/build-brief-v2.md).
2
2
  *
3
- * On a phone, Home's page (premium.html) is Ask PMOS: the chats, grouped by the work each is about, "Not in a work yet" last. The header is
3
+ * On a phone, Today's page with ?chats=1 is Ask PMOS (PhoneTodayDS, job #1540: a group heads with its work and product, the blue dot
4
+ * sits after the time): the chats, grouped by the work each is about, "Not in a work yet" last. The header is
4
5
  * the title only (the ⋯ of the menu at its right); no search and no new-chat icon: a new chat starts from the composer at the foot. A chat
5
6
  * that waits for you carries a blue dot. A row: the chat's name and when it was last used, then its last words ("PMOS: …").
6
7
  *
@@ -13,8 +14,7 @@
13
14
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
15
  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>`;
15
16
  const IC = {
16
- ini: 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6',
17
- loose: 'M4 5h16v11H9l-5 4z', plus: 'M12 5v14M5 12h14', mic: 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', up: 'M12 19V5M6 11l6-6 6 6',
17
+ plus: 'M12 5v14M5 12h14', mic: 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', up: 'M12 19V5M6 11l6-6 6 6',
18
18
  };
19
19
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
20
20
  /** The chat's last words: "PMOS: …" from the session's last output, '' when there is none (zero is silence). */
@@ -24,12 +24,12 @@ export function lastLine(s) {
24
24
  return t ? 'PMOS: ' + clip(t, 120) : '';
25
25
  }
26
26
  export function askGroups(rows, raw = [], o = {}) {
27
- const titleOf = o.titleOf || (() => '');
27
+ const titleOf = o.titleOf || (() => ''), productOf = o.productOf || (() => '');
28
28
  const byId = new Map((raw || []).filter(Boolean).map((s) => [s.id, s]));
29
29
  const G = new Map();
30
30
  for (const r of rows || []) {
31
31
  const k = r.ini || '';
32
- if (!G.has(k)) G.set(k, { ini: r.ini || null, title: r.ini ? titleOf(r.ini) || r.work || r.ini : 'Not in a work yet', rows: [] });
32
+ if (!G.has(k)) G.set(k, { ini: r.ini || null, title: r.ini ? titleOf(r.ini) || r.work || r.ini : 'Not in a work yet', product: r.ini ? productOf(r.ini) || '' : '', rows: [] });
33
33
  G.get(k).rows.push({ id: r.id, name: r.name, word: r.state === 'wait' || r.state === 'work' ? r.at ? timeOnly(r.at, o.now) : '' : r.word, last: lastLine(byId.get(r.id)), wait: r.state === 'wait', work: r.state === 'work' });
34
34
  }
35
35
  const out = [...G.values()].map((g) => ({ ...g, n: g.rows.length }));
@@ -49,9 +49,9 @@ export function askHtml(groups, o = {}) {
49
49
  const head = '<header class="pa-top"><h1>Ask PMOS</h1></header>';
50
50
  const body = !o.ready ? '<p class="pa-none">Reading your chats.</p>'
51
51
  : !groups.length ? '<p class="pa-none">No chats yet. Write to PMOS below to start one.</p>'
52
- : groups.map((g) => `<section class="pa-g" aria-label="${esc(g.title)}"><h2><span class="pa-gi${g.ini ? '' : ' loose'}">${svg(g.ini ? IC.ini : IC.loose, 14)}</span><span class="pa-gt">${esc(g.title)}</span><em>${esc(g.n)}</em></h2>`
52
+ : groups.map((g) => `<section class="pa-g" aria-label="${esc(g.title + (g.product ? ', ' + g.product : ''))}"><h2><span class="pa-gt">${esc(g.title)}</span>${g.product ? `<em>· ${esc(g.product)}</em>` : ''}</h2>`
53
53
  + `<ul>${g.rows.map((r) => `<li><button type="button" class="pa-r${r.wait ? ' wait' : ''}" data-ask-sid="${esc(r.id)}" aria-label="${esc(r.name + (r.wait ? '. Waits for you' : r.work ? '. PMOS is working' : '') + (r.last ? '. ' + r.last : ''))}">`
54
- + `${r.wait ? '<i class="pa-d" aria-hidden="true"></i>' : ''}<span class="pa-x"><b>${esc(r.name)}</b>${r.last ? `<small>${esc(r.last)}</small>` : ''}</span>${r.word ? `<time>${esc(r.word)}</time>` : ''}</button></li>`).join('')}</ul></section>`).join('');
54
+ + `<span class="pa-x"><b>${esc(r.name)}</b>${r.last ? `<small>${esc(r.last)}</small>` : ''}</span>${r.word ? `<time>${esc(r.word)}</time>` : ''}${r.wait ? '<i class="pa-d" aria-hidden="true"></i>' : ''}</button></li>`).join('')}</ul></section>`).join('');
55
55
  const foot = `<div class="pa-foot"><button type="button" class="pa-new" data-ask-new aria-label="Message PMOS: start a new chat"><span class="pa-pl">${svg(IC.plus, 18)}</span><span class="pa-ph">Message PMOS</span><span class="pa-mic">${svg(IC.mic, 18)}</span><span class="pa-go">${svg(IC.up, 18, 2)}</span></button></div>`;
56
56
  return `<div class="pa">${head}${body}</div>${foot}`;
57
57
  }
@@ -862,7 +862,7 @@ function drawInit() {
862
862
  const body = $('#ibBody');
863
863
  body.dataset.view = v; body.dataset.span = v === 'time' ? span : '';
864
864
  document.body.classList.toggle('wk-on', v === 'work');
865
- const html = v === 'work' ? drawWork(L) : v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
865
+ const html = v === 'work' ? drawWork(L) : v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? ST.standsHtml(L, { sug: false, max: 2 }) + V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
866
866
  // a phone has no ⋯ menu: Metrics and Cancelled and archived stay one press away in every view, not only the track
867
867
  const phx = phone && v !== 'track' ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : '';
868
868
  if (v === 'time') TL.hold(); else TL.forget();
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The phone Today, Ask PMOS and Work (job #1540, done test planning/done-tests/phone-today-work.md C1-C7, C10): the pure parts of Today's phone page, the menu, Ask PMOS, the Work list row and the initiative on a phone. No browser.",
3
+ "modules": [
4
+ "phone-today-work.test.js"
5
+ ],
6
+ "seconds": {
7
+ "phone-today-work.test.js": 1
8
+ }
9
+ }