create-pmos 0.286.0 → 0.287.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.
@@ -4,6 +4,7 @@
4
4
  * My work depth (initiative premium-work-depth): the dialog's tool row (Edit, Who does each step, Not before, Someday), the Focus bar and its jobs, the agent on an item
5
5
  * (draft, stop, edit, post after a confirm, send back, try again), and keys and swipe on the rows. */
6
6
  import { pmPost } from './http.js';
7
+ import { mdRender } from './markdown.js';
7
8
  import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, turnU, ptx, CHECK, RM, S } from './premium-shell.js';
8
9
 
9
10
  let M = null; // the model
@@ -15,6 +16,9 @@ const GLYPH = {
15
16
  Board: '<path d="M12 3 3 8l9 5 9-5z"/><path d="m3 13 9 5 9-5"/>',
16
17
  Yours: '<path d="M4 20l4-1 11-11-3-3L5 16z"/>',
17
18
  };
19
+ const mdHtml = (t) => { try { const d = document.createElement('div'); d.append(...mdRender(String(t)).blocks.map((b) => b.node || b)); return d.innerHTML; } catch { return '<p class="tt">' + esc(t) + '</p>'; } }; // mdRender builds nodes, never a string, so nothing in a draft runs
20
+ const KIND = { ask: 'You asked', draft: 'Agent drafted', edit: 'You edited it', note: 'You sent it back', sent: 'Posted', post: 'Posted' };
21
+ const turnsHtml = (a) => (a.turns && a.turns.length ? `<h3 class="h2">Conversation with the agent</h3><ol class="agturns">${a.turns.map((t) => `<li class="${t.who}"><b>${esc(t.who === 'agent' ? 'Agent' : 'You')}</b> ${esc(KIND[t.kind] || t.kind || 'said')}${t.at ? ' · ' + esc(String(t.at).slice(0, 10)) : ''}${t.text ? `<span>${esc(t.text)}</span>` : ''}</li>`).join('')}</ol>` : '');
18
22
  const glyph = (src) => GLYPH[src] || '<circle cx="12" cy="12" r="4"/>';
19
23
  wireRail('work');
20
24
  const WS = new URLSearchParams(location.search).get('ws') || '';
@@ -47,7 +51,9 @@ function rowHtml(r, o = {}) {
47
51
  else lead = `<button class="wck" data-ck="${esc(r.id)}" aria-pressed="false" aria-label="Mark done: ${esc(r.title)}">${CHECK}</button>`;
48
52
  const meta = r.chip ? `<span class="wm"><span class="due${r.overdue ? ' od' : ''}">${esc(r.chip)}</span></span>` : '';
49
53
  const state = sm === 'ag' ? ' · ' + ({ ready: 'draft ready to review', failed: 'the run failed', queued: 'queued', working: 'working', sending: 'sending' }[r.agent] || '') : '';
50
- return `<div class="wrw"><div class="wrow${sm ? ' sm' : ''}${inbox ? ' inb' : ''}${o.first ? ' first' : ''}" data-key="${esc(r.key)}">${lead}<button class="wrh" aria-haspopup="dialog"${desc}><span class="wtx"><span class="wtit">${esc(r.title)}${o.first ? '<em class="tgf">Do this first</em>' : ''}${r.focus ? '<em class="xfc">Focus</em>' : ''}</span><span class="ws">${esc(r.sub)}${esc(state)}</span></span>${meta}</button></div></div>`;
54
+ const sug = !sm && r.sug ? `<span class="wsg">${ICO('<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>')}<span><b>${esc(r.sug.b)}</b> ${esc(r.sug.t)}</span></span>` : '';
55
+ const cta = !sm && r.cta ? `<button type="button" class="wcta" data-key="${esc(r.key)}" data-act="${r.cta.act}" aria-label="${esc(r.cta.label + ': ' + r.title)}">${esc(r.cta.label)}</button>` : '';
56
+ return `<div class="wrw"><div class="wrow${sm ? ' sm' : ''}${cta ? ' hc' : ''}${inbox ? ' inb' : ''}${o.first ? ' first' : ''}" data-key="${esc(r.key)}">${lead}<button class="wrh" aria-haspopup="dialog"${desc}><span class="wtx"><span class="wtit">${esc(r.title)}${o.first ? '<em class="tgf">Do this first</em>' : ''}${r.focus ? '<em class="xfc">Focus</em>' : ''}</span><span class="ws">${esc(r.sub)}${esc(state)}</span>${sug}</span>${meta}</button>${cta}</div></div>`;
51
57
  }
52
58
  function drawPlate() {
53
59
  const P = M.plate;
@@ -89,7 +95,17 @@ function drawReview() {
89
95
  $('#revCap').textContent = R.n + ' ' + (R.n === 1 ? 'item' : 'items');
90
96
  $('#revTxt').innerHTML = `<b>${R.n}</b> ${R.n === 1 ? 'item has' : 'items have'} sat untouched for ${R.days} days. Open one to keep it or let it go.`;
91
97
  }
92
- function draw() { drawHero(); drawFocus(); drawPlate(); drawTray(); drawAgents(); drawWaiting(); drawReview(); drawDock(); onScroll(); backFocus(); }
98
+ function drawWeek() {
99
+ const W = M.week; if (!W) return;
100
+ $('#weekCap').textContent = W.cap;
101
+ const top = Math.max(60, ...W.days.map((d) => d.meet_min));
102
+ $('#weekBody').innerHTML = `<div class="wkd" role="list">${W.days.map((d) => {
103
+ const h = d.meet_min ? Math.max(8, Math.round(d.meet_min / top * 100)) : 0;
104
+ const hrs = d.meet_min ? (Math.round(d.meet_min / 6) / 10) + ' h' : '';
105
+ return `<div class="wkc${d.today ? ' now' : ''}${d.past ? ' past' : ''}" role="listitem" aria-label="${esc(d.dow + ' ' + d.n + ': ' + (W.calendar ? (d.meet_min ? hrs + ' of meetings, ' : 'no meetings, ') : '') + d.done + ' done, ' + d.due + ' due')}"><span class="wkl">${d.dow}</span><b>${d.n}</b><span class="wkb">${h ? `<i style="height:${h}%"></i>` : ''}</span><span class="wkt">${W.calendar ? (hrs || 'free') : '·'}</span><span class="wkn">${d.done} done${d.due ? ' · ' + d.due + ' due' : ''}</span></div>`;
106
+ }).join('')}</div><p class="note" style="margin-top:12px">${esc(W.note)}</p>`;
107
+ }
108
+ function draw() { drawHero(); drawWeek(); drawFocus(); drawPlate(); drawTray(); drawAgents(); drawWaiting(); drawReview(); drawDock(); onScroll(); backFocus(); }
93
109
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || null;
94
110
 
95
111
  /* ── the dialog: detail first, the presses of the Work page, the tool row, the agent, the read-only agent beside it ─────────────────── */
@@ -107,7 +123,7 @@ function agentHtml(r) {
107
123
  const a = r.dialog.agent;
108
124
  if (!a) return '';
109
125
  const w = a.where || 'anyone', dr = a.draft;
110
- const draftBox = dr && dr.body ? `<div class="agdraft"><p class="agtag">Agent draft · not checked</p>${paras(dr.body)}</div>` : dr && dr.summary ? `<div class="agdraft"><p class="agtag">Agent draft · not checked</p><p>${esc(dr.summary)}</p></div>` : '';
126
+ const draftBox = dr && dr.body ? `<div class="agdraft"><p class="agtag">Agent draft · not checked</p><div class="mdr">${mdHtml(dr.body)}</div></div>${turnsHtml(a)}` : dr && dr.summary ? `<div class="agdraft"><p class="agtag">Agent draft · not checked</p><p>${esc(dr.summary)}</p></div>` : '';
111
127
  let h = '';
112
128
  if (a.state === 'suggest') {
113
129
  h = `<p class="nodef">${a.mine ? 'The agent can draft a first version of this for you. You read it here. Nothing leaves PMOS.' : `The agent can draft this for you. You read it here first. Nothing goes to ${esc(w)} until you post it.`}</p>`
@@ -428,6 +444,14 @@ $('#agl').addEventListener('click', (e) => { listClick(e); });
428
444
  $('#waitBody').addEventListener('click', (e) => { listClick(e); });
429
445
  $('#trayBody').addEventListener('click', (e) => { listClick(e); });
430
446
  async function listClick(e) {
447
+ const cta = e.target.closest('.wcta');
448
+ if (cta) {
449
+ const r = rowOf(cta.dataset.key); if (!r) return;
450
+ const o = { list: true };
451
+ refocus = null;
452
+ if (cta.dataset.act === 'open') openRow(r); else if (cta.dataset.act === 'tomorrow') deferP(r, addIso(M.today, 1), o); else todayP(r, o);
453
+ return;
454
+ }
431
455
  const ck = e.target.closest('.wck');
432
456
  if (ck && ck.dataset.open) { openRow(rowOf(ck.dataset.open)); return; }
433
457
  if (ck) {
@@ -1784,6 +1784,19 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1784
1784
  .phstats span{font-size:var(--t-small);color:var(--ink-3)}
1785
1785
  }
1786
1786
 
1787
+ /* My work: per-row suggestion and press, and the This week card */
1788
+ .wrow.hc .wcta{grid-column:2;justify-self:start;margin-bottom:10px}
1789
+ .wcta{min-height:44px;padding:0 16px;border-radius:999px;background:var(--solid);color:var(--on-solid);font-size:13px;font-weight:650;white-space:nowrap}
1790
+ .wkd{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
1791
+ .wkc{display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 4px 8px;border-radius:18px;border:1.5px solid transparent;font-size:12px;color:var(--ink-3)}
1792
+ .wkc.now{border-color:var(--ink)}.wkc.past{opacity:.75}
1793
+ .wkl{font:500 11px var(--mono);letter-spacing:.06em}.wkc b{font-size:20px;color:var(--ink);font-weight:650}
1794
+ .wkb{display:flex;align-items:flex-end;width:26px;height:84px;border-radius:10px;background:var(--well);overflow:hidden}.wkb i{display:block;width:100%;background:var(--ink-3);border-radius:10px 10px 0 0}
1795
+ .wkt{font-weight:650;color:var(--ink-2)}.wkn{font-size:11.5px;text-align:center}
1796
+ @media (max-width:520px){.wkd{gap:4px}.wkn{font-size:11px}}
1797
+
1798
+ .agdraft .mdr{font-size:14px;line-height:1.55;overflow-x:auto}.agdraft .mdr table{border-collapse:collapse;margin:8px 0}.agdraft .mdr th,.agdraft .mdr td{border:1px solid var(--hair);padding:5px 9px;text-align:left}
1799
+ .agturns{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:13px;color:var(--ink-3)}.agturns li b{color:var(--ink)}.agturns span{display:block;color:var(--ink-2)}
1787
1800
  /* the meeting dialog, as the mockup draws it (briefing-artifact.html, meetCanvas): header chips, Focus and Record, Prepared for you, Material, Previous meetings, Topics */
1788
1801
  .mtg .mh2{display:flex;justify-content:space-between;align-items:flex-start;gap:14px;flex-wrap:wrap}
1789
1802
  .mtg .mh2 .d1{font-size:28px;line-height:1.2;margin:0 0 2px;font-weight:700;letter-spacing:-.02em}
@@ -1835,3 +1848,33 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1835
1848
  .mtg .tp i{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;font:600 12.5px var(--mono);font-style:normal;box-shadow:inset 0 0 0 1.8px var(--ink-3);color:var(--ink-3)}
1836
1849
  .mtg .tp small{color:var(--ink-3);font-size:12.5px}
1837
1850
  .mtg .mtg-link{margin:8px 0 6px}
1851
+
1852
+ /* the document sheet as the mockup and the console reader draw it: one status line, the file's path and front matter behind a toggle, an outline with Find, a full-width body */
1853
+ .dsm2{display:flex;flex-wrap:wrap;gap:6px 8px;align-items:center;margin:0 0 12px}
1854
+ .dsm2 .chp{padding:4px 10px;font-size:12px;gap:6px;font-weight:600}
1855
+ .dsm2 .chp b{font-weight:700;color:var(--ink)}
1856
+ .dsm2 .chp.mono{font-family:var(--mono)}
1857
+ .dsm2 .chp.lk{cursor:pointer;min-height:32px}
1858
+ .dsm2 .chp.lk:hover{background:var(--b3)}
1859
+ .dsm2 .chp.lk[aria-expanded="true"]{background:var(--solid);color:var(--on-solid)}
1860
+ .dsmeta{margin:0 0 14px;padding:12px 14px;border-radius:14px;background:var(--well)}
1861
+ .dsmeta .dpath{margin:0 0 8px}
1862
+ .dsmeta .kv2{margin:0}
1863
+ .dsrd.no{grid-template-columns:minmax(0,1fr)}
1864
+ .dsvb.ol{margin-left:auto;font-weight:600}
1865
+ .dsfind{width:100%;min-height:36px;margin:0 0 8px;padding:0 10px;border-radius:10px;border:1px solid var(--hair);background:var(--well);font:inherit;font-size:12.5px;color:inherit}
1866
+ .dso{max-height:62vh;overflow:auto}
1867
+ .dso .l2{padding-left:20px}
1868
+ .dso .l3{padding-left:30px;color:var(--ink-3)}
1869
+ .dsbody .mdt{overflow-x:auto;margin:0 0 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--hair)}
1870
+ .dsbody table{border-collapse:collapse;width:100%;font-size:13.5px}
1871
+ .dsbody th{font:600 11px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);text-align:left;padding:8px 12px;background:var(--well)}
1872
+ .dsbody td{padding:8px 12px;border-top:1px solid var(--hair);vertical-align:top;line-height:1.5}
1873
+ .dsbody code{font:12.5px var(--mono);padding:1px 5px;border-radius:6px;background:var(--well)}
1874
+ .dsbody a{color:var(--ember-ink);text-decoration:underline;text-underline-offset:2px}
1875
+ .dsbody ol{margin:0 0 10px;padding-left:22px;font-size:15px;line-height:1.6}
1876
+ #dsOlItems{display:grid;gap:2px}
1877
+ .dso button{display:block;width:100%}
1878
+ @media (max-width:700px){#dsOlItems{display:flex;flex-wrap:wrap;gap:6px}.dso button{display:inline-flex;width:auto}.dso .l2,.dso .l3{padding-left:10px}.dso{max-height:none}}
1879
+ .dsbody .dsat{display:flex;align-items:center;gap:6px;margin:-2px 0 8px;font-size:12px;color:var(--ink-3)}
1880
+ .dsbody .dsat i{width:18px;height:18px;border-radius:50%;background:var(--well);display:grid;place-items:center;font:600 10px var(--mono);font-style:normal;color:var(--ink-2)}
@@ -145,6 +145,7 @@ function cardHtml(r) {
145
145
  return `${head}${opts}${err}${ask ? `<p class="nodef">Start this agent session? It drafts “${esc(w.what)}” for you to read and sends nothing outside PMOS.</p><div class="cact" id="cardAct"><button class="cta" id="startGo" data-start="go">${CHECK}<span>Start the session</span></button><button class="cta alt" data-start="no">Not now</button></div>` : `<div class="cact" id="cardAct"><button class="cta" id="startBtn" data-start="ask">${CHECK}<span>${esc(d.prim[d.sel])}</span></button></div>${d.hold ? holdNote(d.hold) : ''}`}</div>`;
146
146
  }
147
147
  if (d.opts.length) return `${head}${opts}${d.nodef ? `<p class="nodef">${esc(d.nodef)}</p>` : ''}<div class="cact" id="cardAct"><button class="cta" disabled title="${esc(d.hold || 'Nothing here can be recorded yet.')}">${o ? esc(d.prim[o.k]) : 'Your call: choose one'}</button></div>${d.hold ? holdNote(d.hold) : ''}</div>`;
148
+ if (d.proposals) return `${head}<div class="cact"><button class="cta" id="openProps" type="button">Review the drafts</button></div><p class="nodef">Keep, send back and Drop are under Around you, Agent proposals. Nothing here changes a record.</p></div>`;
148
149
  if (d.link) return `${head}<div class="cact"><a class="cta" id="srcLink" href="${esc(d.link)}" target="_blank" rel="noopener noreferrer">${esc(d.linkLabel || 'Open the source')}</a></div></div>`;
149
150
  return `${head}${d.nodef ? `<p class="nodef">${esc(d.nodef)}</p>` : ''}${d.action ? `<div class="cact"><button class="cta" disabled title="${esc(d.hold || 'Nothing here can be recorded.')}">${CHECK}${esc(d.action)}</button></div>${d.hold ? holdNote(d.hold) : ''}` : ''}</div>`;
150
151
  }
@@ -189,6 +190,7 @@ $('#dBody').addEventListener('click', (e) => {
189
190
  const lt = e.target.closest('#logT');
190
191
  if (lt) { const c = $('#alog').classList.toggle('col'); lt.setAttribute('aria-expanded', !c); return; }
191
192
  if (!openR) return;
193
+ if (e.target.closest('#openProps')) { closeDlg(); openPropsDlg(); return; }
192
194
  const op = e.target.closest('[data-op]');
193
195
  if (op) { WHY[openR.key] = ($('#why') || {}).value || ''; SEL[openR.key] = op.dataset.op; $('#card').outerHTML = cardHtml(openR); $('#oMain').innerHTML = paneHtml(openR); ctaState(openR); return; }
194
196
  const st = e.target.closest('[data-start]');
@@ -58,6 +58,10 @@
58
58
  </section>
59
59
  </div>
60
60
  <div>
61
+ <section class="card rise" style="--d:6" id="weekCard" aria-labelledby="hWeek">
62
+ <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><h2 id="hWeek">This week</h2><small id="weekCap"></small></div>
63
+ <div id="weekBody"></div>
64
+ </section>
61
65
  <section class="card rise" style="--d:7" id="agCard" aria-labelledby="hAg">
62
66
  <div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/></svg></span><h2 id="hAg">With agents</h2><small id="agCap"></small></div>
63
67
  <div class="pipe" id="pipe"></div>
@@ -50,6 +50,7 @@
50
50
  "briefing-premium-calendar-3.test.js",
51
51
  "briefing-premium-products.test.js",
52
52
  "briefing-premium-sources.test.js",
53
+ "briefing-premium-drafts.test.js",
53
54
  "briefing-premium-metrics.test.js",
54
55
  "premium-welcome.test.js",
55
56
  "calendar-events.test.js",
@@ -220,6 +221,7 @@
220
221
  "briefing-premium-calendar-3.test.js": 1,
221
222
  "briefing-premium-products.test.js": 1,
222
223
  "briefing-premium-sources.test.js": 1,
224
+ "briefing-premium-drafts.test.js": 1,
223
225
  "briefing-premium-metrics.test.js": 1,
224
226
  "premium-welcome.test.js": 1,
225
227
  "calendar-events.test.js": 1,