create-pmos 0.741.0 → 0.742.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.
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* try-it.js — try what shipped (initiative try-what-shipped). After an update, the user tries each change and says if it works.
4
+ * THE ONE WRITER and THE ONE FOLD of <state>/try/answers.jsonl, the list of changes to try, and the `pmos try` command.
5
+ *
6
+ * WHERE THE STEPS COME FROM. Each PR's changelog entry (workspace/changelog.json, written by scripts/kit-changelog.js) may carry
7
+ * try: { steps: [1 to 3], see?, open? }, copied from the PR's Story (Try:, Expect:, Open:). The Builder writes them (factory BUILDER.md).
8
+ * BETA ONLY (Wawan 2026-11-23: "That should only lands on Beta."). A computer on the GA line gets an empty list and no Home row.
9
+ * LOCAL ONLY. The answers stay in the state folder on this computer. Nothing here sends anything. The factory reads the file from the
10
+ * test-bed computer (factory/checker/try-feedback.js; Wawan's card 2026-11-23: "Factory reads it from your computer").
11
+ *
12
+ * THE LEDGER. One line per press, { at, key, v, n, verdict, note?, until? }:
13
+ * key '<version>#<PR number>' (the change) verdict works | broken | note | undo (undo takes the key's answer back)
14
+ * key '*' verdict later, until: 'YYYY-MM-DD' Later hides Today's row until that local day
15
+ *
16
+ * changesOf(appDir) → the installed changelog, raw installedOf(appDir) → the app version
17
+ * listOf({ changes, installed, answers, now, beta }) → { beta, items: [card], total, shown } PURE
18
+ * fold(lines) → { answers: Map key → line, later: 'YYYY-MM-DD' | '' } PURE
19
+ * answer(dir, { key, verdict, note }, list) → { ok, line } | { ok: false, error } refuses a key the list does not hold
20
+ * count(lines, changes, now) → { tried, answered, pct } PURE, the health number
21
+ * rowOf(list, { later, today }) → the Home row or null PURE (public/pm/try-view.js has the same rule for the page)
22
+ * CLI: pmos try [list|works|broken|note|undo|later|count] … (run), and node lib/try-it.js count (the health number on its last line) */
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+
26
+ const TAG = '[try-it]';
27
+ const DAYS = 14;
28
+ const SHOW = 5;
29
+ const VERDICTS = new Set(['works', 'broken', 'note', 'undo']);
30
+ const APP_DIR = path.resolve(__dirname, '..');
31
+
32
+ const ledgerFile = (dir) => path.join(String(dir || ''), 'try', 'answers.jsonl');
33
+ const localDay = (t = Date.now()) => { const d = new Date(t); return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 10); };
34
+ const vnum = (v) => String(v || '').split('-')[0].split('.').map((x) => Number(x) || 0);
35
+ const vcmp = (a, b) => { const A = vnum(a), B = vnum(b); for (let i = 0; i < 3; i++) if ((A[i] || 0) !== (B[i] || 0)) return (A[i] || 0) - (B[i] || 0); return 0; };
36
+ const str = (x, max) => (typeof x === 'string' ? x.replace(/\s+/g, ' ').trim().slice(0, max) : '');
37
+ const OPEN_RE = /^\/(?!\/)[A-Za-z0-9._~!$&'()*+,;=:@%/?#-]{0,300}$/;
38
+
39
+ function changesOf(appDir = APP_DIR) {
40
+ try { const j = JSON.parse(fs.readFileSync(path.join(appDir, 'changelog.json'), 'utf8')); return Array.isArray(j) ? j : []; } catch { return []; }
41
+ }
42
+ function installedOf(appDir = APP_DIR) {
43
+ try { return JSON.parse(fs.readFileSync(path.join(appDir, 'package.json'), 'utf8')).version || null; } catch { return null; }
44
+ }
45
+ function readLines(dir) {
46
+ try { return fs.readFileSync(ledgerFile(dir), 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); }
47
+ catch { return []; }
48
+ }
49
+
50
+ /** The answers by key (the last press wins; undo removes it) and the Later day. */
51
+ function fold(lines) {
52
+ const answers = new Map(); let later = '';
53
+ for (const l of lines || []) {
54
+ if (!l || typeof l.key !== 'string') continue;
55
+ if (l.key === '*') { if (l.verdict === 'later' && /^\d{4}-\d{2}-\d{2}$/.test(l.until || '')) later = l.until; continue; }
56
+ if (l.verdict === 'undo') answers.delete(l.key); else if (VERDICTS.has(l.verdict)) answers.set(l.key, l);
57
+ }
58
+ return { answers, later };
59
+ }
60
+
61
+ /** One card per change: from versions up to the installed one, in the last DAYS days, with try steps, not a chore, not answered. */
62
+ function cardsOf(changes, installed, now) {
63
+ const out = [];
64
+ for (const e of changes || []) {
65
+ if (!e || typeof e.v !== 'string' || !Array.isArray(e.prs)) continue;
66
+ if (installed && vcmp(e.v, installed) > 0) continue;
67
+ const at = Date.parse(e.at || '');
68
+ if (!Number.isFinite(at) || now - at > DAYS * 864e5) continue;
69
+ for (const p of e.prs) {
70
+ const y = p && p.try;
71
+ if (!y || !Array.isArray(y.steps) || !y.steps.length || p.k === 'x') continue;
72
+ const steps = y.steps.map((s) => str(s, 140)).filter(Boolean).slice(0, 3);
73
+ if (!steps.length) continue;
74
+ const open = typeof y.open === 'string' && OPEN_RE.test(y.open) ? y.open : null;
75
+ out.push({ key: `${e.v}#${p.n == null ? str(p.h || p.t, 40) : p.n}`, v: e.v, n: p.n == null ? null : p.n, at: e.at,
76
+ title: str(p.h || p.t || p.s, 120), kind: p.k || null, steps, see: str(y.see, 200) || null, open });
77
+ }
78
+ }
79
+ return out.sort((a, b) => vcmp(b.v, a.v) || (b.n || 0) - (a.n || 0));
80
+ }
81
+
82
+ function listOf({ changes, installed, answers = new Map(), now = Date.now(), beta = true } = {}) {
83
+ if (!beta) return { beta: false, items: [], total: 0, shown: 0 };
84
+ const open = cardsOf(changes, installed, now).filter((c) => !answers.has(c.key));
85
+ const items = open.slice(0, SHOW);
86
+ return { beta: true, items, total: open.length, shown: items.length };
87
+ }
88
+
89
+ /** Home's one row, or null (zero is silence; Later hides it until its day). */
90
+ function rowOf(list, { later = '', today = localDay() } = {}) {
91
+ if (!list || !list.beta || !list.total) return null;
92
+ if (later && later > today) return null;
93
+ return { key: 'try', go: 'try', title: list.total + (list.total === 1 ? ' new thing to try' : ' new things to try'), sub: 'From your recent updates. Each takes under a minute.' };
94
+ }
95
+
96
+ function append(dir, line) {
97
+ const f = ledgerFile(dir);
98
+ fs.mkdirSync(path.dirname(f), { recursive: true });
99
+ fs.appendFileSync(f, JSON.stringify(line) + '\n');
100
+ }
101
+
102
+ /** A press: works, broken, note (with text), or undo; the key must be a change the list knows (answered ones count for undo). */
103
+ function answer(dir, { key, verdict, note } = {}, { changes = [], installed = null, now = Date.now() } = {}) {
104
+ if (!VERDICTS.has(verdict)) return { ok: false, error: 'verdict is works, broken, note or undo' };
105
+ const known = cardsOf(changes, installed, now).find((c) => c.key === key);
106
+ if (!known) return { ok: false, error: 'no change to try has that key' };
107
+ const text = str(note, 1000);
108
+ if (verdict === 'note' && !text) return { ok: false, error: 'a note needs its text' };
109
+ const line = { at: new Date(now).toISOString(), key, v: known.v, n: known.n, title: known.title, verdict, ...(text ? { note: text } : {}) };
110
+ append(dir, line);
111
+ console.log(`${TAG} ${verdict} ${key}`);
112
+ return { ok: true, line };
113
+ }
114
+ function later(dir, { now = Date.now() } = {}) {
115
+ const until = localDay(now + 864e5);
116
+ const line = { at: new Date(now).toISOString(), key: '*', verdict: 'later', until };
117
+ append(dir, line);
118
+ return { ok: true, line };
119
+ }
120
+
121
+ /** The health number: of the changes with try steps in the last DAYS days, how many got an answer. */
122
+ function count(lines, changes, now = Date.now()) {
123
+ const cards = cardsOf(changes, null, now), { answers } = fold(lines);
124
+ const answered = cards.filter((c) => answers.has(c.key)).length;
125
+ return { tried: cards.length, answered, pct: cards.length ? Math.round((answered / cards.length) * 100) : 0 };
126
+ }
127
+
128
+ /* ── pmos try ─────────────────────────────────────────────────────────────────────────────────────────────── */
129
+ const USAGE = [
130
+ 'usage: pmos try [list|works|broken|note|undo|later|count] — try what shipped in your recent updates (beta only)',
131
+ ' pmos try the changes to try, newest first, each with its steps, what you should see and where to open',
132
+ ' pmos try works <n> it works (n is the number pmos try shows, or the change key 0.738.0#1639)',
133
+ ' pmos try broken <n> [--note "…"] it did not work; the factory takes it first',
134
+ ' pmos try note <n> --note "…" a note on the change',
135
+ ' pmos try undo <n> take your answer back',
136
+ ' pmos try later hide the Today row until tomorrow',
137
+ ' pmos try count answered percent of the last 14 days; the number is on the last line',
138
+ 'Answers stay on this computer. Nothing is sent.',
139
+ ];
140
+ /** The beta line: PMOS_CHANNEL beta/early, else the setting upd.channel=early (the rule lib/kit-update.js channel() states; read here
141
+ * without requiring kit-update, which no other library module may load). */
142
+ function betaOf(env, stateDir) {
143
+ const e = String((env && env.PMOS_CHANNEL) || '').trim().toLowerCase();
144
+ if (e === 'beta' || e === 'early') return true;
145
+ if (e === 'latest' || e === 'ga' || e === 'stable' || !stateDir) return false;
146
+ try { return require('./settings-store.js').get(stateDir, 'upd.channel') === 'early'; } catch { return false; }
147
+ }
148
+
149
+ function ctxOf(o) {
150
+ const stateDir = o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env });
151
+ const appDir = o.appDir || APP_DIR;
152
+ const beta = o.beta != null ? o.beta : betaOf(o.env || process.env, stateDir);
153
+ return { stateDir, changes: changesOf(appDir), installed: installedOf(appDir), beta, now: o.now || Date.now() };
154
+ }
155
+ function run(argv, o = {}) {
156
+ const say = o.say || console.log;
157
+ const args = argv[0] === 'try' ? argv.slice(1) : argv.slice();
158
+ const flag = (k) => { const i = args.indexOf('--' + k); if (i < 0) return null; const v = args[i + 1]; args.splice(i, 2); return v; };
159
+ const note = flag('note');
160
+ const [cmd = 'list', ref] = args;
161
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
162
+ const C = ctxOf(o), lines = readLines(C.stateDir), F = fold(lines);
163
+ if (cmd === 'count') { const c = count(lines, C.changes, C.now); say(`${TAG} ${c.answered} of ${c.tried} changes answered`); say(String(c.pct)); return 0; }
164
+ if (!C.beta) { say('This computer follows the GA line, so PMOS does not ask you to try changes. Beta computers do.'); return cmd === 'list' ? 0 : 1; }
165
+ const L = listOf({ changes: C.changes, installed: C.installed, answers: F.answers, now: C.now, beta: true });
166
+ if (cmd === 'list') {
167
+ if (!L.total) { say('Nothing new to try.'); return 0; }
168
+ L.items.forEach((c, i) => {
169
+ say(`${i + 1}. ${c.title} (${c.v}) · ${c.key}`);
170
+ c.steps.forEach((s, j) => say(` ${j + 1}) ${s}`));
171
+ if (c.see) say(` You should see: ${c.see}`);
172
+ if (c.open) say(` Open: ${c.open}`);
173
+ });
174
+ if (L.total > L.shown) say(`${L.total - L.shown} more after these.`);
175
+ return 0;
176
+ }
177
+ if (cmd === 'later') { later(C.stateDir, { now: C.now }); say('Hidden from Today until tomorrow.'); return 0; }
178
+ if (!VERDICTS.has(cmd)) { say(`✗ ${cmd} is not a command of pmos try`); USAGE.forEach((l) => say(l)); return 2; }
179
+ if (!ref) { say(`✗ pmos try ${cmd} needs the change: its number in pmos try, or its key`); return 2; }
180
+ const all = cardsOf(C.changes, C.installed, C.now);
181
+ const key = /^\d+$/.test(ref) && Number(ref) <= L.items.length ? L.items[Number(ref) - 1].key : ref;
182
+ const r = answer(C.stateDir, { key: all.some((c) => c.key === key) ? key : ref, verdict: cmd, note }, C);
183
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
184
+ say(cmd === 'works' ? 'Marked as working.' : cmd === 'broken' ? 'Marked as not working. The factory takes it first.' : cmd === 'undo' ? 'Your answer is taken back.' : 'Note kept.');
185
+ return 0;
186
+ }
187
+
188
+ if (require.main === module) {
189
+ const a = process.argv.slice(2);
190
+ if (a[0] === 'count') { const sd = require('./state-root.js').defaultRoot({ env: process.env }); const c = count(readLines(sd), changesOf()); console.log(`${TAG} ${c.answered} of ${c.tried} changes answered`); console.log(String(c.pct)); }
191
+ else process.exitCode = run(a);
192
+ }
193
+
194
+ module.exports = { TAG, DAYS, SHOW, ledgerFile, localDay, vcmp, changesOf, installedOf, readLines, fold, cardsOf, listOf, rowOf, answer, later, count, run, ctxOf, USAGE, COMMANDS: { try: ['list', 'works', 'broken', 'note', 'undo', 'later', 'count'] } };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.741.0",
3
+ "version": "0.742.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.741.0",
9
+ "version": "0.742.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.741.0",
3
+ "version": "0.742.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -542,6 +542,14 @@
542
542
  .ev-st.pm-ds svg.ev-gbar .bg { fill: var(--well); }
543
543
  .ev-st.pm-ds svg.ev-gbar .fg { fill: var(--leaf); }
544
544
 
545
+ /* try-what-shipped (pm/try-view.js): the changes to try, one card each, in Settings › Updates and in the Viewer from Home. Tokens only. */
546
+ .try-list { display: flex; flex-direction: column; gap: var(--space-12); }
547
+ .try-list .try-card { display: flex; flex-direction: column; gap: var(--space-8); }
548
+ .try-list .try-steps { margin: 0; padding-left: var(--space-24); }
549
+ .try-list .try-acts { display: flex; flex-wrap: wrap; gap: var(--space-8); align-items: center; }
550
+ .try-list .try-note { display: block; width: 100%; box-sizing: border-box; margin-top: var(--space-4); font: inherit; }
551
+ @media (max-width: 640px) { .try-list .try-acts .ev-btn { min-height: 44px; flex: 1 1 40%; } }
552
+
545
553
  /* ── the ? list of action keys (pm/action-keys.js, bet A477): a Komorebi sheet over the page; its parts are pm-h-sm, pm-row, pm-kbd, pm-meta, pm-btn.
546
554
  * It takes the width of its rows, never wider than the window less space-16 a side, and its head and list are reached through those parts. ── */
547
555
  .ev-keys.pm-ds { border: 0; border-radius: var(--radius-card); background: var(--card); color: var(--ink); box-shadow: var(--lift); padding: var(--space-24); width: fit-content; max-width: calc(100% - var(--space-32)); }
@@ -397,7 +397,7 @@ function updates() {
397
397
  const acts = T.phase === 'busy' ? '' : `<button type="button" class="ev-btn sm" data-ev-upd="check"${T.busy ? ' disabled' : ''}>Check now</button>${ready() ? `<button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button>` : ''}`;
398
398
  const kits = (T.ws || []).filter((w) => !w.linked).map((w) => { const k = T.st[w.id], kit = k && k.kit; return trow(w.label || w.name || w.id, kit && kit.present ? 'kit ' + (kit.version || 'vendored by hand') : 'no kit in this workspace', k && k.kitBehind && L ? `<span class="pm-badge blue">${esc(L)} ready</span>` : kit && kit.present && (k.lastCheck || k.latest) ? '<span class="pm-badge">Up to date</span>' : ''); }).join('');
399
399
  const last = s.lastCheck ? 'Last checked ' + new Date(s.lastCheck.at).toLocaleString() + '. ' : '';
400
- return `<div class="ev-card ev-upd first">${mood ? adFace(mood) : ''}<div class="ev-tx ev-grow">${head}</div>${acts}</div>${kits}<p class="pm-meta">${esc(last)}${s.checkDaily ? 'PMOS checks when you open Updates and once a day while a page is open; Check now asks again.' : 'PMOS checks only when you press Check now.'}</p>${weeks()}`;
400
+ return `<div class="ev-card ev-upd first">${mood ? adFace(mood) : ''}<div class="ev-tx ev-grow">${head}</div>${acts}</div>${kits}<p class="pm-meta">${esc(last)}${s.checkDaily ? 'PMOS checks when you open Updates and once a day while a page is open; Check now asks again.' : 'PMOS checks only when you press Check now.'}</p><div data-try-host></div>${weeks()}`;
401
401
  }
402
402
  /** Design E (UpE). A story line: a blue dot for New, an amber dot for Fixed, no dot for Improved; Claude's plain title, then the sentence. */
403
403
  const SPARK = 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z';
@@ -582,6 +582,7 @@ function draw() {
582
582
  cardRows(el.querySelector('.ev-st-main')); el.querySelectorAll('.ev-st-main .sc-w').forEach(cardRows);
583
583
  if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
584
584
  wfPanel(el);
585
+ tryPanel(el);
585
586
  const setup = el.querySelector('[data-claude-setup]');
586
587
  if (setup) disposeClaudeSetup = mountClaudeSetup(setup, { ws: wsParam() || (T.ws && T.ws[0] && T.ws[0].id) || '', onReady: () => {} });
587
588
  const cur = el.querySelector('.ev-st-nav [aria-current="page"]'); if (cur && cur.scrollIntoView) cur.scrollIntoView({ block: 'nearest', inline: 'nearest' }); // on a phone the section row scrolls: keep the open one in view
@@ -595,6 +596,15 @@ function cardRows(root) {
595
596
  [...root.children].forEach((k) => { if (k.classList.contains('ev-trow')) run.push(k); else flush(); });
596
597
  flush();
597
598
  }
599
+ /** Updates › To try (try-what-shipped): pm/try-view.js draws the changes to try into one node kept across redraws, so an answer in
600
+ * progress is not lost when the status line redraws. Beta only; nothing to try draws nothing. */
601
+ let TRY = null;
602
+ function tryPanel(el) {
603
+ const spot = el.querySelector('[data-try-host]');
604
+ if (!spot) return;
605
+ if (!TRY) { TRY = document.createElement('div'); TRY.className = 'try-host'; import('./try-view.js').then((TV) => TV.mountTry(TRY, { toast, head: true })).catch(() => {}); }
606
+ spot.replaceWith(TRY);
607
+ }
598
608
  /** Workspaces › Workflows (UI grill U1): pm/wf-page.js draws into its host, the same node across redraws; leaving it lets it go. */
599
609
  let WF = null, wfOpts = {};
600
610
  function wfPanel(el) {
@@ -841,7 +851,7 @@ async function load() {
841
851
  T.prods = pk ? pk.products : b && b.ok && b.model && b.model.products ? b.model.products.available || [] : [];
842
852
  if (!w || !Array.isArray(w.workspaces)) T.msg = 'The repositories could not be read.'; else if (!p || !p.ok) T.msg = 'The connectors could not be read.';
843
853
  draw();
844
- await Promise.all(T.ws.map(async (x) => { const r = await pmGet('/api/kit/status?ws=' + encodeURIComponent(x.id)); if (r && r.ok) T.st[x.id] = r; }));
854
+ await Promise.all((T.ws || []).map(async (x) => { const r = await pmGet('/api/kit/status?ws=' + encodeURIComponent(x.id)); if (r && r.ok) T.st[x.id] = r; }));
845
855
  draw();
846
856
  openCheck();
847
857
  }
@@ -447,6 +447,8 @@ function rankIn() {
447
447
  for (const l of S.lab || []) extra.push({ key: 'lab:' + l.ws, go: 'lab', ws: l.ws, board: l.board, title: l.n + (l.n === 1 ? ' Lab finding' : ' Lab findings') + ' to keep or drop', sub: l.say || 'Keep one to start an initiative, or let it go.' });
448
448
  // weekly-what-moved (A441): last week's date and scope moves of every product, one row until the PM opens the list (pm/moves-view.js)
449
449
  if (S.movesRow) extra.push(S.movesRow);
450
+ // try-what-shipped: one row while the updates brought changes to try (beta only; GET /api/try says the row, pm/try-view.js opens the list)
451
+ if (S.tryRow) extra.push(S.tryRow);
450
452
  return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], gaps: (S.wait && S.wait.gaps) || [], extra };
451
453
  }
452
454
  /** Each product's GET /api/your-move, read when Your day opens (never on Home's first draw: page speed). */
@@ -473,10 +475,12 @@ async function readMove() {
473
475
  S.moves = mv.filter((r) => r && r.ok);
474
476
  const prevMoves = JSON.stringify(S.movesRow || null);
475
477
  try { const MV = await import('./moves-view.js'); S.movesRow = MV.rowOf(S.moves, { looked: MV.lookedWeek() }); } catch { S.movesRow = null; }
478
+ const prevTry = JSON.stringify(S.tryRow || null);
479
+ try { const TV = await import('./try-view.js'); S.tryRow = TV.rowOf(await pmGet('/api/try').catch(() => null)); } catch { S.tryRow = null; }
476
480
  const ob = await pmGet('/api/outbox').catch(() => null);
477
481
  const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
478
482
  const lab = labs.filter(Boolean);
479
- const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null);
483
+ const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevTry === JSON.stringify(S.tryRow || null);
480
484
  S.move = next; S.outbox = outbox; S.lab = lab;
481
485
  if (!same) { redrawLater(); drawList(); }
482
486
  // a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
@@ -514,6 +518,7 @@ async function movePress(b) {
514
518
  if (r.go === 'impact') { S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; }
515
519
  if (r.go === 'loose') { VW.drill(); LPV.open(lpHost); return; }
516
520
  if (r.go === 'moves') { VW.drill(); import('./moves-view.js').then((MV) => { MV.openMoves(S.moves || [], { toast }); S.movesRow = null; drawList(); }); return; }
521
+ if (r.go === 'try') { VW.drill(); import('./try-view.js').then((TV) => TV.openTry({ toast, toastUndo, onChange: (l) => { S.tryRow = TV.rowOf({ ...l, ok: true, row: l.total ? { ...S.tryRow, title: l.total + (l.total === 1 ? ' new thing to try' : ' new things to try') } : null }); drawList(); } })); return; }
517
522
  if (r.go === 'lab') { VW.drill(); import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: r.ws, board: r.board }), iniHref: (id) => '/premium-initiative.html?' + (r.ws ? 'ws=' + encodeURIComponent(r.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })); return; }
518
523
  return;
519
524
  }
@@ -259,7 +259,7 @@ export function install(g = globalThis) {
259
259
  const url = typeof input === 'string' ? input : input && input.url;
260
260
  const method = String((init && init.method) || (input && typeof input === 'object' && input.method) || 'GET').toUpperCase();
261
261
  if (method === 'POST' && url && init && typeof init.body === 'string') {
262
- const p = new URL(url, 'http://x').pathname;
262
+ const p = new URL(url, 'http://127.0.0.1/').pathname;
263
263
  if (TASK_WRITE.test(p) || JIRA_MOVE.test(p)) le = begin(p, JSON.parse(init.body));
264
264
  }
265
265
  } catch { le = null; }
@@ -0,0 +1,99 @@
1
+ /* pm/try-view.js — try what shipped (initiative try-what-shipped; lib/try-it.js is the store and the list, lib/routes-try.js the HTTP).
2
+ * Pure apart from mountTry and openTry: Node imports it (try-it.test.js Y5).
3
+ *
4
+ * rowOf(list) → Home's Your move row ({ key, go, title, sub }) or null; the server's GET /api/try already says row
5
+ * listHtml(list, { esc }) → one card per change: its title, 1 to 3 steps, what you should see, Show me, Works, Didn't work, a note
6
+ * mountTry(host, H) reads GET /api/try and draws the list in host, with its presses. H: { toast, onChange, phone }
7
+ * openTry(H) the list in the Viewer (Home's row opens it)
8
+ * Beta only: a computer on the GA line gets an empty list, and the list draws nothing (zero is silence).
9
+ * Every answer is the PM's press (pmPost carries the launch nonce) and has Undo. Nothing is sent: the answers stay on this computer. */
10
+ import { pmGet, pmPost } from './http.js';
11
+
12
+ const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
13
+ const ICON = 'M9 11l3 3L22 4M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11';
14
+ const svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
15
+ const YES = svg('M20 6 9 17l-5-5'), NO = svg('M18 6 6 18M6 6l12 12');
16
+ const OPEN_RE = /^\/(?!\/)[A-Za-z0-9._~!$&'()*+,;=:@%/?#-]{0,300}$/;
17
+
18
+ export function rowOf(list) {
19
+ if (!list || !list.ok || !list.beta) return null;
20
+ return list.row || null;
21
+ }
22
+
23
+ function cardHtml(c, esc, i) {
24
+ const steps = c.steps.map((s) => `<li>${esc(s)}</li>`).join('');
25
+ const open = c.open && OPEN_RE.test(c.open) ? `<a class="ev-btn sm" href="${esc(c.open)}" data-try-open="${esc(c.key)}">Show me</a>` : '';
26
+ return `<section class="pm-block try-card" data-try-key="${esc(c.key)}" aria-label="${esc(c.title)}">`
27
+ + `<div class="head"><h3 class="pm-h-sm">${esc(c.title)}</h3><span class="pm-meta">${esc(c.v)}</span></div>`
28
+ + `<ol class="try-steps">${steps}</ol>`
29
+ + (c.see ? `<p class="pm-meta">You should see: ${esc(c.see)}</p>` : '')
30
+ + `<div class="try-acts">${open}`
31
+ + `<button type="button" class="ev-btn sm" data-try-act="works" data-try-i="${i}" aria-label="It works" title="It works">${YES} Works</button>`
32
+ + `<button type="button" class="ev-btn sm" data-try-act="broken" data-try-i="${i}" aria-label="It did not work" title="It did not work">${NO} Didn't work</button>`
33
+ + `<button type="button" class="ev-btn sm" data-try-act="note" data-try-i="${i}" aria-label="Add a note" title="Add a note">Note</button>`
34
+ + `</div></section>`;
35
+ }
36
+
37
+ /** The list, or '' when there is nothing to try (zero is silence). */
38
+ export function listHtml(list, { esc = escDefault, head = false } = {}) {
39
+ if (!list || !list.beta || !list.items || !list.items.length) return '';
40
+ const more = list.total > list.shown ? `<p class="pm-meta">${list.total - list.shown} more after these.</p>` : '';
41
+ return `<div class="try-list">${head ? `<div class="head"><h3 class="pm-h">To try</h3><span class="pm-meta">${list.total}</span></div>` : ''}<p class="pm-meta">Your recent updates brought these. Each takes under a minute. Didn't work goes to the front of the fix queue.</p>`
42
+ + list.items.map((c, i) => cardHtml(c, esc, i)).join('') + more + '</div>';
43
+ }
44
+
45
+ const SAID = { works: 'Thanks. Marked as working.', broken: 'Marked as not working. It goes to the front of the fix queue.', note: 'Note kept.' };
46
+
47
+ /** Draw the list in host and handle its presses. Returns { list } once read. */
48
+ export async function mountTry(host, H = {}) {
49
+ const toast = H.toast || (() => {});
50
+ const r = await pmGet('/api/try').catch(() => null);
51
+ let list = r && r.ok ? r : { ok: false, beta: false, items: [] };
52
+ const draw = () => { host.innerHTML = listHtml(list, { head: !!H.head }) || (H.empty || ''); };
53
+ draw();
54
+ const send = async (c, verdict, note) => {
55
+ const a = await pmPost('/api/try/answer', { key: c.key, verdict, ...(note ? { note } : {}) }).catch((e) => ({ ok: false, error: String(e && e.message || e) }));
56
+ if (!a || !a.ok) { toast('Not saved: ' + ((a && a.error) || 'the workspace did not answer') + '.'); return false; }
57
+ return true;
58
+ };
59
+ // the presses are real <button>s in host; one listener on the document reads them (a remounted host drops its old one)
60
+ if (host._tryOff) host._tryOff();
61
+ const onPress = async (ev) => {
62
+ const b = ev.target && ev.target.closest && ev.target.closest('[data-try-act]'); if (!b || !host.contains(b)) return;
63
+ const c = list.items[Number(b.dataset.tryI)]; if (!c) return;
64
+ const verdict = b.dataset.tryAct;
65
+ let note = '';
66
+ if (verdict === 'note' || verdict === 'broken') {
67
+ const card = b.closest('.try-card');
68
+ const box = card && card.querySelector('textarea.try-note');
69
+ if (!box) { // the first press opens a note box under the card; broken may be sent without text
70
+ card.insertAdjacentHTML('beforeend', `<label class="pm-meta">${verdict === 'broken' ? 'What happened? (optional)' : 'Your note'}<textarea class="try-note" rows="2"></textarea></label>`
71
+ + `<div class="try-acts"><button type="button" class="ev-btn sm pri" data-try-act="${verdict}" data-try-i="${b.dataset.tryI}" data-try-send="1">Send</button></div>`);
72
+ card.querySelector('textarea.try-note').focus();
73
+ return;
74
+ }
75
+ note = box.value.trim();
76
+ if (verdict === 'note' && !note) { box.focus(); return; }
77
+ }
78
+ b.disabled = true;
79
+ if (!(await send(c, verdict, note))) { b.disabled = false; return; }
80
+ list = { ...list, items: list.items.filter((x) => x.key !== c.key), total: Math.max(0, list.total - 1), shown: Math.max(0, list.shown - 1) };
81
+ draw();
82
+ if (H.onChange) H.onChange(list);
83
+ if (H.toastUndo) H.toastUndo(SAID[verdict], async () => { if (await send(c, 'undo')) { list = await pmGet('/api/try').catch(() => list) || list; draw(); if (H.onChange) H.onChange(list); } });
84
+ else toast(SAID[verdict]);
85
+ };
86
+ host.ownerDocument.addEventListener('click', onPress);
87
+ host._tryOff = () => host.ownerDocument.removeEventListener('click', onPress);
88
+ return { list };
89
+ }
90
+
91
+ /** The list in the Viewer: Home's row opens it. */
92
+ export function openTry(H = {}) {
93
+ const VW = window.czViewer;
94
+ if (!VW) { if (H.toast) H.toast('The list could not open here.'); return; }
95
+ VW.open({ id: 'try', kind: 'To try', title: 'New things to try', icon: ICON, presses: [],
96
+ render: (b) => { mountTry(b, { ...H, empty: '<p class="pm-meta">Nothing new to try. Each update you install brings its own list.</p>' }); } });
97
+ }
98
+
99
+ export function later() { return pmPost('/api/try/later', {}).catch(() => null); }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "initiative try-what-shipped: the changes to try after an update (lib/try-it.js, lib/routes-try.js, pm/try-view.js), the answers ledger, pmos try, Home's row and Settings › Updates (pure and scratch folders, no browser). scripts/tests/kit-changelog.test.js T1 covers the Try / Expect / Open parsing.",
3
+ "modules": [
4
+ "try-it.test.js"
5
+ ],
6
+ "seconds": {
7
+ "try-it.test.js": 1
8
+ }
9
+ }