create-pmos 0.474.0 → 0.476.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.
Files changed (61) hide show
  1. package/README.md +5 -3
  2. package/bin/create-pmos.js +23 -1
  3. package/install.ps1 +2 -1
  4. package/install.sh +6 -1
  5. package/package.json +27 -33
  6. package/payload/KIT-VERSION +1 -1
  7. package/payload/planning/evals/eval-calibration.md +1 -1
  8. package/payload/planning/okrs/health-budgets.md +1 -1
  9. package/payload/state/discoveries.md +1 -1
  10. package/workspace/README.md +1 -1
  11. package/workspace/bin/pmos.js +1 -1
  12. package/workspace/changelog.json +26 -0
  13. package/workspace/fixtures/fake-claude-onboard.js +48 -0
  14. package/workspace/guide/briefing-premium.md +2 -7
  15. package/workspace/guide/claude-proposes.md +5 -1
  16. package/workspace/guide/index.md +2 -2
  17. package/workspace/guide/launcher.md +14 -32
  18. package/workspace/guide/layout.md +1 -1
  19. package/workspace/guide/settings.md +12 -3
  20. package/workspace/guide/welcome.md +64 -21
  21. package/workspace/lib/claude-readiness.js +143 -0
  22. package/workspace/lib/engine/calendar-import.js +5 -0
  23. package/workspace/lib/freshness.js +5 -3
  24. package/workspace/lib/launcher-cli.js +83 -8
  25. package/workspace/lib/onboarding-progress.js +36 -0
  26. package/workspace/lib/project-onboard.js +363 -0
  27. package/workspace/lib/proposals.js +4 -3
  28. package/workspace/lib/route-modules.js +3 -0
  29. package/workspace/lib/routes-grill.js +70 -0
  30. package/workspace/lib/routes-onboard.js +188 -0
  31. package/workspace/lib/routes-onboarding.js +5 -4
  32. package/workspace/lib/routes-proposals.js +8 -6
  33. package/workspace/lib/routes-setup.js +88 -0
  34. package/workspace/package-lock.json +2 -2
  35. package/workspace/package.json +1 -1
  36. package/workspace/project-onboard-flow-test.js +135 -0
  37. package/workspace/public/pm/cozy-claude-setup.js +90 -0
  38. package/workspace/public/pm/cozy-ev.css +6 -0
  39. package/workspace/public/pm/cozy-insights.css +2 -0
  40. package/workspace/public/pm/cozy-onboard.css +60 -0
  41. package/workspace/public/pm/cozy-onboard.js +226 -0
  42. package/workspace/public/pm/cozy-settings.js +35 -5
  43. package/workspace/public/pm/cozy-today.css +3 -0
  44. package/workspace/public/pm/grill-words.js +53 -0
  45. package/workspace/public/pm/home-app.js +41 -1
  46. package/workspace/public/pm/home-today.js +3 -1
  47. package/workspace/public/pm/ini-props.js +41 -8
  48. package/workspace/public/pm/ini-view.css +62 -37
  49. package/workspace/public/pm/premium-first.js +1 -1
  50. package/workspace/public/pm/premium-insights.js +43 -5
  51. package/workspace/public/pm/premium-welcome-model.js +1 -1
  52. package/workspace/public/pm/premium-welcome.js +107 -62
  53. package/workspace/public/pm/premium.css +16 -0
  54. package/workspace/public/pm/setup-checklist.js +22 -0
  55. package/workspace/public/premium.html +1 -0
  56. package/workspace/server.js +28 -6
  57. package/workspace/skills/calendar-sync.skill +1 -1
  58. package/workspace/test-files.json +6 -3
  59. package/workspace/test-lists/briefing-premium.json +1 -3
  60. package/workspace/test-lists/claude-onboarding-build.json +9 -0
  61. package/workspace/premium-welcome-test.js +0 -219
@@ -876,3 +876,5 @@ textarea.ins-dri { height: auto; padding: 6px 8px; font-weight: 500; resize: ver
876
876
  .ins-nomv .ins-cols > .mv, .ins-nomv .ins-cols > .ins-mvh { display: none; }
877
877
  .ins-row.vwo, .ins-row.vwo:hover { background: var(--cz-bluebg); box-shadow: inset 3px 0 0 var(--cz-blue); }
878
878
  .ins-card.vwo { background: var(--cz-bluebg); box-shadow: inset 3px 0 0 var(--cz-blue); border-color: transparent; }
879
+ /* the budget's burn under its pace (canvas FcIntel) */
880
+ .ins-burn { margin-top: 4px; }
@@ -0,0 +1,60 @@
1
+ /* cozy-onboard.css — the project-first setup conversation in the Home chat (initiative claude-onboarding-build). Only Cozy tokens; the turns,
2
+ * cards, buttons, chips and composer are the Home chat's own (cozy-home.css, cozy-today.css). */
3
+ body.ob-on #hmChat[hidden] { display: none; }
4
+ .ob-chat .hm-log { gap: 18px; }
5
+ .ob-chat .hm-ab { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1; }
6
+ .ob-chat .hm-ab > p { margin: 0; line-height: 1.5; }
7
+ .ob-hello { margin: 24px auto 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
8
+ .ob-hello p { margin: 0; }
9
+ .ob-hello b { color: var(--cz-ink); font-size: var(--fs-5); }
10
+ .ob-card { display: flex; flex-direction: column; gap: 2px; padding: 6px; max-width: 720px; }
11
+ .ob-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; cursor: pointer; min-height: 44px; box-sizing: border-box; }
12
+ .ob-opt.on { background: var(--cz-bluebg); }
13
+ .ob-opt.off { cursor: default; color: var(--cz-ink3); }
14
+ .ob-opt input { margin: 3px 0 0; accent-color: var(--cz-solid); flex: none; }
15
+ .ob-opt span { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-3); }
16
+ .ob-opt em { font-style: normal; font-size: var(--fs-2); color: var(--cz-ink2); }
17
+ .ob-opt code, .ob-chat code { font-size: var(--fs-2); word-break: break-all; }
18
+ .ob-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 6px 4px 2px; }
19
+ .ob-row a.hm-chip { text-decoration: none; }
20
+ .ob-note { margin: 0; font-size: var(--fs-2); color: var(--cz-ink3); padding: 0 4px; }
21
+ .ob-sub { margin: 0; font-size: var(--fs-2); color: var(--cz-ink2); }
22
+ .ob-live { text-align: center; }
23
+ .ob-good, .ob-bad { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-radius: 14px; padding: 10px 14px; max-width: 720px; box-sizing: border-box; }
24
+ .ob-good { background: var(--cz-okbg); color: var(--cz-ok); }
25
+ .ob-good span { color: var(--cz-ink2); font-size: var(--fs-2); }
26
+ .ob-bad { background: var(--cz-redbg); color: var(--cz-red); flex-direction: column; align-items: flex-start; gap: 4px; }
27
+ .ob-bad span { color: var(--cz-ink2); font-size: var(--fs-2); }
28
+ .ob-srcs { display: flex; gap: 6px; flex-wrap: wrap; }
29
+ .ob-src { font-size: var(--fs-2); font-weight: 700; border-radius: 999px; padding: 3px 10px; background: var(--cz-bluebg); color: var(--cz-blueink); }
30
+ .ob-src.empty { background: var(--cz-well); color: var(--cz-ink2); }
31
+ .ob-src.failed { background: var(--cz-redbg); color: var(--cz-red); }
32
+ .ob-ctx { padding: 12px 16px 8px; gap: 0; }
33
+ .ob-ctx > p { margin: 0 0 6px; font-size: var(--fs-3); }
34
+ .ob-fld { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--cz-hair); }
35
+ .ob-fld b { font-size: var(--fs-2); color: var(--cz-ink2); }
36
+ .ob-fld input { font: inherit; font-size: var(--fs-3); color: var(--cz-ink); border: 0; border-radius: 10px; background: var(--cz-well); padding: 8px 10px; width: 100%; box-sizing: border-box; min-height: 36px; }
37
+ .ob-tag { font-size: var(--fs-1); font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; background: var(--cz-bluebg); color: var(--cz-blueink); }
38
+ .ob-tag a { color: inherit; }
39
+ .ob-tag.you { background: var(--cz-well); color: var(--cz-ink2); }
40
+ .ob-tag.miss { background: var(--cz-riskbg, var(--cz-well)); color: var(--cz-ink2); }
41
+ .ob-done { list-style: none; margin: 0; padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; max-width: 720px; }
42
+ .ob-done li { display: flex; gap: 10px; align-items: center; font-size: var(--fs-3); }
43
+ .ob-done li svg { color: var(--cz-ok); flex: none; }
44
+ .ob-path { display: flex; gap: 8px; align-items: flex-end; padding: 6px 4px; flex-wrap: wrap; }
45
+ .ob-path .ut-field { flex: 1 1 260px; }
46
+ .ob-path .ut-field input { min-height: 40px; }
47
+ .ob-term { height: 280px; border-radius: 12px; overflow: hidden; background: var(--term-bg); }
48
+ @media (max-width: 760px) {
49
+ body.cz-home.ob-on.hm-plist .ob-chat { display: flex; padding: 16px 16px 0; }
50
+ body.cz-home.ob-on.hm-plist .hm-list { display: none; }
51
+ body.cz-home.ob-on.hm-plist .ob-chat .hm-foot { padding-bottom: 84px; } /* the floating menu button sits over the corner */
52
+ .ob-fld { grid-template-columns: minmax(0, 1fr) auto; }
53
+ .ob-fld input { grid-column: 1 / -1; grid-row: 2; }
54
+ .ob-chat .ut-btn { min-height: 44px; }
55
+ }
56
+ /* Home's Claude repair card (setup-checklist.js): only when the saved login failed */
57
+ .cs-checklist { margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
58
+ .cs-checklist[hidden] { display: none; }
59
+ .cs-checklist p { margin: 0; font-size: var(--fs-2); color: var(--cz-ink2); }
60
+ .cs-checklist .ut-btn { align-self: flex-start; text-decoration: none; }
@@ -0,0 +1,226 @@
1
+ /* pm/cozy-onboard.js — set up a project as one conversation in the Home chat (initiative claude-onboarding-build, direction B on the
2
+ * onboarding design canvas, In development; its link is in planning/prd/claude-onboarding-build-prd.md).
3
+ *
4
+ * One page: it draws in the Home chat's own place (same hm-a / hm-u turns, ut-card / ut-btn / hm-chip controls and the normal composer)
5
+ * and leaves the list where it is. Every step is a Claude turn with inline controls; the composer answers the project question.
6
+ * Order, enforced by the server: connect Claude → test that exact login → the project → the folder → the sources it may read →
7
+ * review → set up or reuse → the project open in My Work. Every press is the PM's (pmPost). Text from connectors is escaped. */
8
+ import { pmGet, pmPost } from './http.js';
9
+ import { adler } from './cozy-adler.js';
10
+ import { signInTerminal } from './cozy-claude-setup.js';
11
+
12
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
13
+ const CHECK = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
14
+ const UP = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"/></svg>';
15
+ const FIELD_LABELS = [['name', 'Name'], ['purpose', 'Purpose'], ['team', 'Team'], ['owner', 'Owner'], ['timeline', 'Timeline'], ['goals', 'Goals and metrics']];
16
+
17
+ /** The words of the project answer: the name is the first clause; a Jira key, a team and a folder path are picked up when written plainly. */
18
+ export function readAnswer(text) {
19
+ const t = String(text || '').trim();
20
+ const name = (t.split(/[,.;\n]| - /)[0] || '').trim().slice(0, 120);
21
+ const jira = (/\bjira(?:\s+(?:key|project))?(?:\s+is)?\s*[:=]?\s*([A-Z][A-Z0-9_]{1,9})\b/i.exec(t) || [])[1] || '';
22
+ const team = (/\b([\w&-]+(?:\s[\w&-]+)?)\s+team\b/i.exec(t) || [])[1] || '';
23
+ const folder = (/(?:^|\s)((?:~|\/|[A-Za-z]:\\)[^\s,;]+)/.exec(t) || [])[1] || '';
24
+ const link = (/https:\/\/\S+/.exec(t) || [])[0] || '';
25
+ return { name, jira: jira.toUpperCase(), team: /^(the|a|my|our)$/i.test(team) ? '' : team, folder, link, description: t };
26
+ }
27
+
28
+ export function mountOnboard(host, { ws = '', done = false } = {}) {
29
+ const sec = document.createElement('section');
30
+ sec.className = 'hm-chat ob-chat'; sec.id = 'obChat'; sec.setAttribute('aria-label', 'Set up a project');
31
+ sec.innerHTML = '<div class="hm-log ob-log" id="obLog" role="log" aria-live="polite"></div><div class="hm-foot" id="obFoot"></div>';
32
+ host.after(sec); host.hidden = true;
33
+ const log = sec.querySelector('#obLog'), foot = sec.querySelector('#obFoot');
34
+ const S = { data: null, busy: '', note: '', profile: null, said: '', session: null, folderInput: false, picked: null, stopTerm: null };
35
+ const post = async (verb, body = {}) => { const r = await pmPost('/api/onboard/' + verb, body); if (r && r.progress) S.data = { ...S.data, ...r }; return r || { ok: false, error: 'PMOS did not answer. Try again.' }; };
36
+
37
+ async function load() { const r = await pmGet('/api/onboard/state'); if (r && r.ok) S.data = r; draw(); }
38
+ const P = () => (S.data && S.data.progress) || {};
39
+ const claudeTurn = (body, mood, latest) => `<div class="hm-a ob-turn">${latest ? `<span class="hm-av hm-adler" aria-hidden="true">${adler(mood, 36, { label: false, id: 'ob', dress: true })}</span>` : '<span class="hm-av t-C s28" aria-hidden="true">C</span>'}<div class="hm-ab"><p class="hm-who">Claude</p>${body}</div></div>`;
40
+ const youTurn = (text) => `<div class="hm-u"><div class="hm-bub"><p>${esc(text)}</p></div><span class="hm-you">You</span></div>`;
41
+ const btn = (act, label, cls = '', extra = '') => `<button type="button" class="ut-btn ${cls}" data-ob="${act}"${S.busy ? ' disabled' : ''}${extra}>${esc(S.busy === act ? 'Working…' : label)}</button>`;
42
+
43
+ function turns() {
44
+ const p = P(), c = (S.data && S.data.claude) || { profiles: [] }, out = [];
45
+ // 1. connect and test
46
+ const profiles = c.profiles || [];
47
+ const pick = S.profile || p.profile || c.selected || (profiles[0] && profiles[0].id);
48
+ if (!p.verified) {
49
+ const failed = p.checked && p.checked.state && p.checked.state !== 'ready' && p.profile === pick;
50
+ const opts = profiles.map((x) => `<label class="ob-opt${x.id === pick ? ' on' : ''}"><input type="radio" name="ob-login" value="${esc(x.id)}"${x.id === pick ? ' checked' : ''}><span><b>${esc(x.id === '__default__' ? 'The Claude login on this computer' : x.label)}</b>${x.id === '__default__' ? '<em>Whatever account Claude Code uses in your usual terminal</em>' : ''}</span></label>`).join('');
51
+ out.push({ mood: failed ? 'honest' : 'needs-you', body: `<p>${failed ? '' : 'Let’s set up a product or project. First, which Claude login should PMOS use? I’ll run one short check on exactly that login.'}</p>`
52
+ + (failed ? `<div class="ob-bad" role="alert"><b>${esc(S.data.claude.status && S.data.claude.status.profile === p.profile ? S.data.claude.status.message : (p.checked.state === 'signed_out' ? 'This login needs signing in again.' : 'This login did not pass the check.'))}</b><span>I won’t switch to a different account on my own. Sign this one in, or pick another login.</span></div>` : '')
53
+ + `<div class="ut-card ob-card" role="radiogroup" aria-label="Claude login">${opts}<label class="ob-opt${pick === '__own__' ? ' on' : ''}"><input type="radio" name="ob-login" value="__own__"${pick === '__own__' ? ' checked' : ''}><span><b>A separate login just for PMOS</b><em>Keeps PMOS on its own account. You sign in once.</em></span></label>`
54
+ + `<div class="ob-row">${btn('check', 'Test this login', 'pri')}${btn('login', 'Sign in to it', '')}</div>`
55
+ + `<p class="ob-note">The test sends one short message to Claude with no tools. It uses a little of this account’s usage.</p>`
56
+ + (S.session ? '<p class="ob-note">Finish Claude’s sign-in below (type <code>/login</code> if it asks), then press Test this login.</p><div class="cs-term ob-term" aria-label="Claude sign-in terminal"></div>' : '')
57
+ + `</div>` });
58
+ return out;
59
+ }
60
+ const label = (profiles.find((x) => x.id === p.profile) || {}).label || p.profile;
61
+ out.push({ mood: 'handled', body: `<div class="ob-good">${CHECK}<b>Login works · ${esc(label)}</b><span>Tested ${p.checked && p.checked.at ? new Date(p.checked.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : 'just now'} · one test message, no tools</span></div>`
62
+ + (p.project ? '' : `<p>What product or project is this for? Its name is enough to start.</p><p class="ob-sub">If you have them, add the team, a Jira key, a link or the folder where it lives. They help me find the right sources, not a same-name one.</p><div class="ob-row"><button type="button" class="hm-chip loose" data-ob="relogin">Use another login</button></div>`) });
63
+ if (!p.project) return out;
64
+ // 2. the project, the folder, the sources
65
+ out.push({ you: S.said || p.project.description || p.project.name });
66
+ const f = p.folder;
67
+ const discovered = p.discovered && p.discovered.sources;
68
+ let body = `<p><b>${esc(p.project.name)}</b>, got it. Where should its PMOS project live?</p><div class="ut-card ob-card" role="radiogroup" aria-label="Project folder">`;
69
+ const ex = f && f.mode === 'existing';
70
+ if (ex) {
71
+ const fa = f.facts || {};
72
+ body += `<label class="ob-opt on"><input type="radio" name="ob-folder" value="existing" checked><span><b>Use the existing folder <code>${esc(f.root)}</code></b><em>${fa.pmos ? 'PMOS is already here. I’ll open it as it is; nothing is reinstalled.' : (fa.git ? 'Git repository, no PMOS yet. ' : 'No PMOS yet. ') + 'I add only what’s missing; files and history stay as they are.'}${fa.inside_other_git ? ' It is inside the Git repository ' + esc(fa.git_root) + '.' : ''}</em></span></label>`;
73
+ }
74
+ const proposed = f && f.mode === 'new' ? f.root : null;
75
+ body += `<label class="ob-opt${!ex ? ' on' : ''}"><input type="radio" name="ob-folder" value="new"${!ex ? ' checked' : ''}><span><b>Make a new folder${proposed ? ` <code>${esc(proposed)}</code>` : ''}</b><em>${proposed ? 'Empty folder with Git and PMOS. Nothing is created until you confirm.' : 'I’ll propose a place for it.'}${f && f.parent_in_git ? ' Its parent folder is inside a Git repository.' : ''}</em></span></label>`;
76
+ body += `<div class="ob-row">${btn('pick-existing', 'Choose an existing folder…', 'sm')}${btn('pick-parent', 'Put the new folder somewhere else…', 'sm ghost')}</div>`;
77
+ if (S.folderInput) body += `<form class="ob-path" data-ob-form="path"><label class="ut-field"><span>Folder path</span><input name="path" autocomplete="off" placeholder="${S.data.platform === 'win32' ? 'C:\\Users\\you\\Projects\\checkout' : '~/code/checkout'}"></label><button type="submit" class="ut-btn sm">Use this folder</button></form>`;
78
+ body += '</div>';
79
+ if (f && !p.found) {
80
+ if (!discovered) body += `<p>Next I’ll list what this login can read. That doesn’t use Claude.</p><div class="ob-row">${btn('discover', 'Show what I can read', 'pri')}</div>`;
81
+ else {
82
+ const rows = discovered.map((s) => `<label class="ob-opt${s.status !== 'connected' ? ' off' : ''}"><input type="checkbox" name="ob-src" value="${esc(s.id)}"${s.status === 'connected' ? ' checked' : ' disabled'}><span><b>${esc(s.label)}</b><em>${s.status === 'connected' ? 'Search for “' + esc(p.project.name) + '”' + (p.project.jira ? ' and ' + esc(p.project.jira) : '') : s.status === 'needs_auth' ? 'Needs signing in inside Claude first' : 'Not reachable right now'}</em></span></label>`).join('');
83
+ const local = ex ? `<label class="ob-opt"><input type="checkbox" name="ob-local" checked><span><b>The folder</b><em>README and Git history in ${esc(f.root)}</em></span></label>` : '';
84
+ body += `<p>I can look for existing context with <b>${esc(label)}</b>. Choose what I may read:</p><div class="ut-card ob-card">${rows || '<p class="ob-sub">This login has no connected tools.</p>'}${local}`
85
+ + `<div class="ob-row">${btn('search', 'Search, read-only', 'pri')}${btn('skip', 'Skip, use my description', 'ghost')}</div><p class="ob-note">Read-only. I won’t post, comment or change anything. Searching uses some of this account’s usage.</p></div>`;
86
+ }
87
+ }
88
+ out.push({ mood: f && p.found ? 'handled' : 'needs-you', body });
89
+ if (!p.found && !p.reviewed) return out;
90
+ // 3. review
91
+ const found = p.found || { sources: [], jira: [], findings: [] };
92
+ if (p.found) out.push({ you: 'Search these sources' });
93
+ const rv = p.review || { fields: {} };
94
+ let rb = '';
95
+ if (found.sources.length) rb += `<div class="ob-srcs">${found.sources.map((s) => `<span class="ob-src ${s.state}">${esc(s.label)} · ${s.state === 'found' ? (s.count ? s.count + ' found' : 'found') : s.state === 'empty' ? 'nothing found' : 'couldn’t read'}</span>`).join('')}</div>`;
96
+ const failed = found.sources.filter((s) => s.state === 'failed');
97
+ if (failed.length) rb += failed.map((s) => `<p class="ob-sub">${esc(s.label)}: ${esc(s.error || 'It could not be read.')} I used nothing from it.</p>`).join('') + `<div class="ob-row">${btn('retry', 'Retry', 'sm')}</div>`;
98
+ if (found.jira && found.jira.length > 1) {
99
+ rb += `<p><b>${found.jira.length} Jira projects could be this one.</b> Which is it?</p><div class="ut-card ob-card" role="radiogroup" aria-label="Jira project">${found.jira.map((j) => `<label class="ob-opt${rv.jira === j.key ? ' on' : ''}"><input type="radio" name="ob-jira" value="${esc(j.key)}"${rv.jira === j.key ? ' checked' : ''}><span><b>${esc(j.key)}${j.name ? ' · ' + esc(j.name) : ''}</b></span></label>`).join('')}<label class="ob-opt${rv.jira === 'none' ? ' on' : ''}"><input type="radio" name="ob-jira" value="none"${rv.jira === 'none' ? ' checked' : ''}><span>Neither. Don’t link Jira</span></label></div>`;
100
+ }
101
+ if (!found.findings.length && p.found && !failed.length) rb += '<p>I didn’t find much. Tell me in a sentence or two what this project is for, or fill in the fields below.</p>';
102
+ const fields = rv.fields || {};
103
+ rb += `<form class="ut-card ob-card ob-ctx" data-ob-form="review"><p><b>Project context</b> <span class="ob-sub">· saved to the project when you set it up. Edit anything.</span></p>`
104
+ + FIELD_LABELS.map(([k, l]) => { const v = fields[k]; const tag = !v ? '<span class="ob-tag miss">Missing</span>' : v.source === 'finding' ? `<span class="ob-tag">${v.url ? `<a href="${esc(v.url)}" target="_blank" rel="noopener noreferrer">${esc(v.source_label)}</a>` : esc(v.source_label)}</span>` : `<span class="ob-tag you">${v.source === 'folder' ? 'Folder' : 'You'}</span>`;
105
+ return `<label class="ob-fld"><b>${l}</b><input name="${k}" value="${esc(v ? v.value : '')}" placeholder="${!v ? 'Not found. Add it or leave blank' : ''}">${tag}</label>`; }).join('')
106
+ + (fields.code ? `<p class="ob-sub">Code: ${esc(fields.code.value)}</p>` : '')
107
+ + `</form>`;
108
+ const where = f && f.root ? f.root : 'the new folder';
109
+ const jiraNote = rv.jira && rv.jira !== 'none' ? ` and links Jira ${esc(rv.jira)}` : '';
110
+ rb += `<div class="ob-row">${btn('init', (f && f.facts && f.facts.pmos ? 'Open PMOS in ' : 'Set up PMOS in ') + where, 'pri')}${p.found ? btn('again', 'Search again', 'ghost') : ''}</div><p class="ob-note">${f && f.facts && f.facts.pmos ? 'Reuses the PMOS already there' : 'Adds PMOS to the folder'}${jiraNote}. No tasks, goals or schedules are created, and nothing changes in your tools.</p>`;
111
+ if (p.init && !p.init.ok) {
112
+ const steps = p.init.steps || {};
113
+ rb += `<div class="ob-bad" role="alert"><b>Setup stopped at “${esc(p.init.step || 'a step')}”.</b><span>${esc(p.init.error || '')} Nothing you had was removed. ${Object.keys(steps).filter((k) => steps[k].state === 'done').length} steps are done; I’ll only do the rest.</span></div><div class="ob-row">${btn('init', 'Finish setup', 'pri')}</div>`;
114
+ }
115
+ out.push({ mood: p.init && !p.init.ok ? 'honest' : 'needs-you', body: rb });
116
+ return out;
117
+ }
118
+
119
+ function doneTurns() {
120
+ const d = P().done;
121
+ if (!d) return [{ mood: 'honest', body: '<p>This project is not set up yet.</p>' }];
122
+ const steps = (P().init && P().init.steps) || {};
123
+ const say = (t) => `/premium.html?ws=${encodeURIComponent(d.ws)}&say=${encodeURIComponent(t)}`;
124
+ const rj = P().review && P().review.jira; const jira = rj && rj !== 'none' ? rj : (rj === 'none' ? '' : (P().project && P().project.jira) || '');
125
+ const line = (k, t) => (steps[k] ? `<li>${CHECK}<span>${t}</span></li>` : '');
126
+ return [{ mood: 'handled', body: `<p><b>${esc(d.name)}</b> is ready and open in My Work.</p><ul class="ut-card ob-done">${line('kit', steps.kit && steps.kit.detail === 'reused' ? 'PMOS already in <code>' + esc(d.root) + '</code>, reused as it is' : 'PMOS added to <code>' + esc(d.root) + '</code>' + (steps.git && steps.git.detail === 'initialized' ? '' : '; your files and history are untouched'))}${line('context', 'Project context saved to <code>' + esc(d.context || '') + '</code>')}${steps.git && steps.git.detail === 'initialized' ? `<li>${CHECK}<span>Git set up in the new folder</span></li>` : ''}</ul>`
127
+ + `<p>What would you like to do first?</p><div class="ob-row"><a class="hm-chip" href="${say('Walk me through the project context you saved')}">Check the project context</a>${jira ? `<a class="hm-chip" href="${say('Show what is open in Jira ' + jira)}">Show what’s open in Jira</a>` : ''}<a class="hm-chip" href="${say('Help me add my first piece of work')}">Add my first piece of work</a></div>` }];
128
+ }
129
+
130
+ function draw() {
131
+ if (!S.data) { log.innerHTML = `<div class="hm-empty hm-empty-ad">${adler('thinking', 'l', { id: 'obload' })}<p>Getting setup ready…</p></div>`; return; }
132
+ const list = done ? doneTurns() : turns();
133
+ const lastClaude = list.map((t, i) => (t.you ? -1 : i)).filter((i) => i >= 0).pop();
134
+ // No big Adler here: the latest reply carries his face, and the list may already show him (one Adler per screen, rule 21).
135
+ const intro = !done && !P().verified && !P().checked ? '<div class="hm-empty ob-hello"><p><b>Let’s set up your first project</b></p><p>It takes a few minutes. Nothing is created until you say so.</p></div>' : '';
136
+ if (S.stopTerm) { S.stopTerm(); S.stopTerm = null; }
137
+ log.innerHTML = intro + list.map((t, i) => (t.you ? youTurn(t.you) : claudeTurn(t.body, t.mood, i === lastClaude))).join('') + (S.note ? `<p class="ob-note ob-live" role="status">${esc(S.note)}</p>` : '');
138
+ const term = log.querySelector('.ob-term');
139
+ if (term && S.session) signInTerminal(term, S.session).then((stop) => { S.stopTerm = stop; }).catch((e) => { S.note = e.message; S.session = null; draw(); });
140
+ const p = P(), asks = !done && p.verified && !p.project;
141
+ foot.innerHTML = `<form class="hm-box" data-ob-form="say"><textarea rows="1" aria-label="Message Claude" placeholder="${asks ? 'e.g. Checkout redesign, payments team, Jira PAY' : done ? 'Message Claude' : !p.verified ? 'Test the login first, then tell me about your project' : 'Message Claude'}"${!asks ? ' disabled' : ''}></textarea><div class="hm-tb"><span class="sp"></span><span class="hm-key">Enter sends · Shift+Enter for a new line</span><button type="submit" class="hm-send" aria-label="Send"${!asks ? ' disabled' : ''}>${UP}</button></div></form>`;
142
+ if (asks) foot.querySelector('textarea').focus({ preventScroll: true });
143
+ log.scrollTop = log.scrollHeight;
144
+ }
145
+
146
+ async function act(a, b) {
147
+ const p = P();
148
+ const typed = readReview(); // before any redraw, so what the PM typed, ticked or chose is never lost
149
+ const ticked = [...log.querySelectorAll('input[name="ob-src"]:checked')].map((x) => x.value), localTicked = !!log.querySelector('input[name="ob-local"]:checked');
150
+ S.busy = a; S.note = ''; draw();
151
+ try {
152
+ if (a === 'check' || a === 'login') {
153
+ let profile = S.profile || p.profile || (S.data.claude && S.data.claude.selected);
154
+ if (profile === '__own__') { const own = await post('own'); if (!own.ok) throw new Error(own.error || 'The PMOS login could not be made.'); profile = own.id; S.profile = profile; await load(); }
155
+ const r = await post(a, { profile });
156
+ if (a === 'login') { if (r.ok) S.session = r.session; else S.note = r.error || 'Sign-in could not open.'; }
157
+ else { S.session = null; if (!r.ok) S.note = r.message || r.error || 'The test did not pass.'; await load(); }
158
+ } else if (a === 'relogin') { await post('reset'); S.profile = null; await load(); }
159
+ else if (a === 'pick-existing' || a === 'pick-parent') {
160
+ const mode = a === 'pick-existing' ? 'existing' : 'new';
161
+ const r = await post('folder', { mode, pick: true, parent: mode === 'new' && p.folder ? p.folder.parent : undefined, root: mode === 'existing' && p.folder ? p.folder.root : undefined });
162
+ if (r.unsupported) { S.folderInput = mode; S.note = r.error; } else if (!r.ok && !r.cancelled) S.note = r.error;
163
+ } else if (a === 'folder-mode') {
164
+ const r = await post('folder', b === 'new' ? { mode: 'new', parent: p.folder && p.folder.parent } : { mode: 'existing', root: p.folder && p.folder.root });
165
+ if (!r.ok) { if (b === 'existing') S.folderInput = 'existing'; S.note = r.error; }
166
+ } else if (a === 'discover') { const r = await post('discover'); if (!r.ok) S.note = r.error; }
167
+ else if (a === 'search' || a === 'retry') {
168
+ const ids = a === 'retry' ? ((p.found && p.found.sources) || []).filter((s) => s.id !== 'folder').map((s) => s.id) : ticked;
169
+ const local = a === 'retry' ? (p.found && p.found.sources || []).some((s) => s.id === 'folder') : localTicked;
170
+ S.note = 'Searching, read-only. This can take a minute or two…'; draw();
171
+ const r = await post('search', { sources: ids, local });
172
+ S.note = r.ok ? '' : r.error;
173
+ } else if (a === 'skip') { const r = await post('review', {}); if (!r.ok) S.note = r.error; }
174
+ else if (a === 'again') { await saveReview(typed); const r = await post('discover'); if (!r.ok) S.note = r.error; }
175
+ else if (a === 'init') {
176
+ await saveReview(typed);
177
+ S.note = 'Setting up the project…'; draw();
178
+ const r = await post('init');
179
+ if (r.ok && r.progress && r.progress.done) { location.assign('/premium.html?ws=' + encodeURIComponent(r.progress.done.ws) + '&onboarded=1'); return; }
180
+ S.note = r.error || 'Setup did not finish.';
181
+ await load();
182
+ }
183
+ } catch (e) { S.note = e.message || 'That did not finish. Try again.'; }
184
+ S.busy = ''; draw();
185
+ }
186
+ function readReview() {
187
+ const form = log.querySelector('form[data-ob-form="review"]'); if (!form) return null;
188
+ const fields = {}; for (const [k] of FIELD_LABELS) { const i = form.querySelector(`input[name="${k}"]`); if (i) fields[k] = i.value; }
189
+ const j = log.querySelector('input[name="ob-jira"]:checked');
190
+ return j ? { fields, jira: j.value } : { fields };
191
+ }
192
+ async function saveReview(typed) { if (typed) await post('review', typed); }
193
+
194
+ sec.addEventListener('click', (e) => {
195
+ const b = e.target.closest('[data-ob]'); if (!b || b.disabled || S.busy) return;
196
+ act(b.dataset.ob);
197
+ });
198
+ sec.addEventListener('change', (e) => {
199
+ const t = e.target;
200
+ if (t.name === 'ob-login') { S.profile = t.value; S.session = null; draw(); }
201
+ else if (t.name === 'ob-folder') act('folder-mode', t.value);
202
+ else if (t.name === 'ob-jira') log.querySelectorAll('input[name="ob-jira"]').forEach((x) => x.closest('.ob-opt').classList.toggle('on', x.checked)); // saved with the review, so typing is never redrawn away
203
+ });
204
+ sec.addEventListener('submit', async (e) => {
205
+ e.preventDefault();
206
+ const form = e.target.closest('form'); if (!form || S.busy) return;
207
+ if (form.dataset.obForm === 'say') {
208
+ const ta = form.querySelector('textarea'); const v = ta.value.trim(); if (!v) return;
209
+ const a = readAnswer(v); S.said = v; S.busy = 'say'; draw();
210
+ const r = await post('project', { name: a.name, team: a.team, jira: a.jira, link: a.link, description: a.description });
211
+ if (!r.ok) S.note = r.error;
212
+ else if (a.folder) { const f = await post('folder', { mode: 'existing', root: a.folder }); if (!f.ok) { S.note = 'I couldn’t use ' + a.folder + ': ' + (f.error || 'not found') + ' Choose the folder below.'; await post('folder', { mode: 'new' }); } }
213
+ else if (!P().folder) await post('folder', { mode: 'new' });
214
+ S.busy = ''; draw();
215
+ } else if (form.dataset.obForm === 'path') {
216
+ const v = form.querySelector('input').value.trim(); if (!v) return;
217
+ const mode = S.folderInput === 'new' ? 'new' : 'existing';
218
+ const r = await post('folder', mode === 'new' ? { mode, parent: v } : { mode, root: v });
219
+ if (!r.ok) S.note = r.error; else { S.folderInput = false; S.note = ''; }
220
+ draw();
221
+ }
222
+ });
223
+ sec.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey && e.target.matches('textarea')) { e.preventDefault(); e.target.closest('form').requestSubmit(); } });
224
+ load();
225
+ return { el: sec, close: () => { sec.remove(); host.hidden = false; } };
226
+ }
@@ -3,6 +3,8 @@
3
3
  * (this device), Product (which products Home reads: the Products card), Your day (when the end-of-day card shows:
4
4
  * time.workEnd, POST /api/settings), Your impact (impact.on, POST /api/settings; canvas GmP1Switch, batch 16 item 7: the one switch
5
5
  * for Adler's leaf, the impact log and the weekly check; the page hears `pmos:impact`), Agents write to Jira (fixed: only after Commit)
6
+ * Claude’s checks Grill by itself (Full, Only at stage exits, Off) and the monthly credit for checks with what this month used (grill.mode,
7
+ * grill.cap, POST /api/settings; GET /api/grill; canvas GrillEntry). At the cap Claude pauses and says so once here.
6
8
  * Adler how much of Claude's face shows, Motion, Celebrations, Quiet after (adler.*, POST /api/settings; canvas AdM5, batch 16 item 2)
7
9
  * › Dress for the day (adler.dress.*, canvas AsSet1, batch 18 item 8): the master switch, where you are, one switch per group,
8
10
  * "More festivals" with one switch per day, big sports and your colours, exam season, your days, Wear now (pm/cozy-seasons.js).
@@ -23,6 +25,7 @@
23
25
  * it with ↻ Read again, and the place menu opens Settings at Connectors. Every write is the PM's press (pmPost carries the launch nonce).
24
26
  * PMOS reads the sources and never posts to them.
25
27
  * openSettings(section?) */
28
+ import { mountClaudeSetup } from './cozy-claude-setup.js';
26
29
  import { pmGet, pmPost, pressFetch } from './http.js';
27
30
  import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
28
31
  import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
@@ -35,7 +38,7 @@ async function pmSend(method, path, body) {
35
38
  try { const res = await pressFetch(path, { method, ...(body === undefined ? {} : { body: JSON.stringify(body) }) }); const out = await res.json(); if (out && typeof out === 'object' && !res.ok) out.status = res.status; return out; }
36
39
  catch (e) { return { ok: false, error: 'could not reach the workspace server — ' + ((e && e.message) || String(e)) }; }
37
40
  }
38
- const SECTIONS = [['general', 'General'], ['claude', 'Claude'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates']];
41
+ const SECTIONS = [['general', 'General'], ['claude', 'Claude'], ['checks', 'Claude’s checks'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates']];
39
42
  const PAGE_LINKS = { workflows: '/premium-workflows.html' }; // a section that is a page of its own: the row goes there
40
43
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
41
44
  const VIEWER_KEY = 'pmos.cz.viewer';
@@ -237,11 +240,26 @@ function claudeSec() {
237
240
  const k = C.key || {};
238
241
  const keySub = k.present ? (k.source === 'environment' ? 'Set in ANTHROPIC_API_KEY. A key saved here is used first.' : 'Saved on this computer only. PMOS never shows it again.') : 'Not set. Claude\u2019s own runs, such as Grill, use a Claude session instead.';
239
242
  const keyRight = `<span class="ev-dr-pl"><label class="ev-vh" for="evKey">Anthropic API key</label><input id="evKey" class="ev-inp" type="password" autocomplete="off" spellcheck="false" placeholder="${k.present ? 'Replace the key' : 'sk-ant-\u2026'}" data-ev-key><button type="button" class="ev-btn sm pri" data-ev-keysave>Save</button>${k.source === 'settings' ? '<button type="button" class="ev-btn sm" data-ev-keyclear>Remove</button>' : ''}</span>`;
240
- return trow('Claude profile', profSub, `<label class="ev-vh" for="evProf">Claude profile</label><select id="evProf" class="ev-inp" data-ev-prof>${opts}</select>`)
243
+ return '<h4>Claude login and profile</h4><div data-claude-setup></div>'
241
244
  + trow('API key', keySub, keyRight)
242
245
  + (k.present && C.off ? trow('Runs on the API', 'Off: PMOS_GRILL_API is off in the environment.', '<span class="ev-pill">Off</span>') : '');
243
246
  }
244
- const BODY = { general, claude: claudeSec, adler: adlerSec, connectors, workspaces, updates };
247
+ /* Settings > Claude's checks (GrillEntry): Claude grills by itself, so this is the only control: when, and how much it may spend a month */
248
+ const CAPS = [5, 10, 20, 50];
249
+ const usd = (n) => '$' + (Math.round(Number(n) * 100) % 100 ? Number(n).toFixed(2) : String(Math.round(Number(n))));
250
+ function checksSec() {
251
+ const C = T.gr;
252
+ if (!C) return '<p class="ev-small ev-mut">Reading Claude’s checks.</p>';
253
+ if (C.ok === false) return `<p class="ev-small ev-mut">Claude’s checks could not be read: ${esc(C.error || 'the server did not answer')}.</p>`;
254
+ const caps = [...new Set(CAPS.concat(Number.isFinite(C.cap) ? [C.cap] : []))].sort((a, b) => a - b);
255
+ const modeSub = C.envOff ? 'Off: PMOS_GRILL is off in the environment.' : 'Before an initiative leaves a stage, when a forecast turns, when scope or dates move a lot, and once a month on running work that feels off. Findings wait under ✦.';
256
+ const used = Number.isFinite(C.cap) && C.cap > 0 ? Math.min(100, Math.round((C.spent / C.cap) * 100)) : 0;
257
+ return trow('Grill by itself', modeSub, C.envOff ? '<span class="ev-pill">Off</span>' : seg('Grill by itself', 'grill.mode', C.mode, [['full', 'Full'], ['exits', 'Only at stage exits'], ['off', 'Off']]))
258
+ + trow('Monthly credit for checks', C.paused ? 'Paused at the limit this month. Claude starts again next month, or when you raise it.' : 'At the limit Claude pauses and says so once. It never charges beyond it.', seg('Monthly credit for checks', 'grill.cap', C.cap, caps.map((v) => [v, usd(v)])))
259
+ + `<div class="ev-trow ev-gcap"><span class="ev-small"><b>${esc(usd(C.spent))}</b> of ${esc(usd(C.cap))} used this month</span><span class="ev-gbar" role="img" aria-label="${used}% of the monthly credit used"><i style="width:${used}%"></i></span></div>`;
260
+ }
261
+ const BODY = { general, claude: claudeSec, checks: checksSec, adler: adlerSec, connectors, workspaces, updates };
262
+ let disposeClaudeSetup = null;
245
263
  function draw() {
246
264
  const el = T.el; if (!el || el.hidden) return;
247
265
  // a redraw replaces the nodes: keep focus on the same control (by its data-ev-* key), else on the open section, never on the body
@@ -253,6 +271,9 @@ function draw() {
253
271
  const all = T.sec === 'connectors' ? `<button type="button" class="ev-ib" data-ev-readall aria-label="Read every source again" title="Read all again"${T.reading ? ' disabled' : ''}>${svg(RD, 18)}</button>` : '';
254
272
  el.querySelector('.ev-st-main').innerHTML = staleHtml() + `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3>${all}<button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
255
273
  + BODY[T.sec]() + `<p role="status"${T.msg && AD.moodOfText(T.msg) === 'honest' ? ' class="ev-say honest"' : ''}>${T.msg && AD.moodOfText(T.msg) === 'honest' ? AD.adler('honest', 24, { label: false }) : ''}${esc(T.msg)}</p>`;
274
+ if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
275
+ const setup = el.querySelector('[data-claude-setup]');
276
+ if (setup) disposeClaudeSetup = mountClaudeSetup(setup, { ws: wsParam() || (T.ws && T.ws[0] && T.ws[0].id) || '', onReady: () => {} });
256
277
  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
257
278
  if (had && !ae.isConnected) { const f = (key && el.querySelector(`[${key.name}="${CSS.escape(key.value)}"]`)) || el.querySelector('[aria-current="page"]'); if (f) f.focus(); }
258
279
  }
@@ -263,7 +284,7 @@ function mount() {
263
284
  document.body.append(...d.childNodes);
264
285
  T.el = document.getElementById('evSettings');
265
286
  document.getElementById('evStScrim').addEventListener('click', closeSettings);
266
- T.el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSettings(); } });
287
+ T.el.addEventListener('keydown', (e) => { if (e.target.closest('.cs-term')) return; if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSettings(); } });
267
288
  // the dialog is modal: Escape closes it even when focus is outside it (a click on the scrim's edge, a redraw)
268
289
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target)) { e.preventDefault(); e.stopPropagation(); closeSettings(); } }, true);
269
290
  T.el.addEventListener('change', async (e) => {
@@ -294,6 +315,13 @@ async function press(e) {
294
315
  if ('evArc' in t.dataset) { T.arc = !T.arc; draw(); return; }
295
316
  if (t.dataset.evGo) { T.sec = t.dataset.evGo; draw(); return; }
296
317
  if (t.dataset.evSeg === 'theme') { const M = await import('./cozy-nav.js'); M.setTheme(t.dataset.v); draw(); return; }
318
+ if (t.dataset.evSeg && t.dataset.evSeg.startsWith('grill.')) {
319
+ const key = t.dataset.evSeg, value = key === 'grill.cap' ? Number(t.dataset.v) : t.dataset.v;
320
+ const r = await pmPost('/api/settings', { key, value });
321
+ if (r && r.ok) T.gr = { ...T.gr, [key === 'grill.cap' ? 'cap' : 'mode']: r.value !== undefined ? r.value : value, ...(key === 'grill.cap' ? { paused: T.gr.paused && Number(value) <= T.gr.spent } : {}) };
322
+ T.msg = r && r.ok ? (key === 'grill.mode' ? (value === 'off' ? 'Saved. Claude no longer grills by itself.' : value === 'exits' ? 'Saved. Claude grills only before a stage ends.' : 'Saved. Claude grills by itself when it matters.') : 'Saved. Claude’s checks spend at most ' + usd(value) + ' a month.') : (r && r.error) || 'Not saved.';
323
+ draw(); return;
324
+ }
297
325
  if (t.dataset.evSeg && t.dataset.evSeg.startsWith('adler.')) { const r = await AD.savePref(pmPost, t.dataset.evSeg, t.dataset.v); T.msg = r && r.ok ? 'Saved.' : (r && r.error) || 'Not saved.'; draw(); return; }
298
326
  if (t.dataset.evDress) {
299
327
  const a = t.dataset.evDress;
@@ -408,6 +436,7 @@ async function readAgain(id) {
408
436
  }
409
437
  async function load() {
410
438
  readFresh();
439
+ pmGet('/api/grill').then((g) => { T.gr = g && g.ok ? g : { ok: false, error: (g && g.error) || '' }; draw(); }).catch(() => { T.gr = { ok: false }; draw(); });
411
440
  pmGet('/api/profiles').then(async (pr) => { const k = await pmGet('/api/anthropic'); T.cl = { profiles: pr && Array.isArray(pr.profiles) ? pr.profiles : [], prefs: (pr && pr.prefs) || {}, perr: pr && pr.ok === false ? (pr.error || 'the server did not answer') : '', key: k && k.ok ? k.key : { present: false, source: null }, off: !!(k && k.off) }; draw(); }).catch(() => { T.cl = { profiles: [], prefs: {}, perr: 'the server did not answer', key: { present: false, source: null } }; draw(); });
412
441
  const [w, p, s, b] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings'), pmGet('/api/settings'), pmGet('/api/briefing-premium')]);
413
442
  T.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
@@ -425,7 +454,7 @@ async function load() {
425
454
  export function openSettings(section) {
426
455
  const el = mount();
427
456
  if (section === 'dress') { T.sec = 'adler'; T.dress = true; } else if (section && BODY[section]) { T.sec = section; T.dress = false; }
428
- if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.dset = {}; T.cl = null; }
457
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.dset = {}; T.cl = null; T.gr = null; }
429
458
  el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
430
459
  draw();
431
460
  const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
@@ -434,6 +463,7 @@ export function openSettings(section) {
434
463
  }
435
464
  export function closeSettings() {
436
465
  if (!T.el || T.el.hidden) return;
466
+ if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
437
467
  T.el.hidden = true; document.getElementById('evStScrim').hidden = true; T.el.removeAttribute('data-esc-layer');
438
468
  const b = T.back; T.back = null; if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
439
469
  }
@@ -540,3 +540,6 @@ body.cz-home .hm-hd.hv-bar > .hv-hi { flex: 1 0 auto; max-width: 100%; }
540
540
  .hv-rcs { margin: 0 0 4px; padding: 4px; background: color-mix(in srgb, var(--cz-well) 55%, var(--cz-card)); border-radius: 14px; }
541
541
  .hv-rcs .hv-r::before { display: none; }
542
542
  .hv-rcs .hv-r.safe { background: var(--cz-bluebg); border-radius: 14px; }
543
+ /* Home's one grill line (canvas FcPhone, Home): quiet, with ✦ at its end */
544
+ .hv-gn { display: flex; align-items: center; gap: 8px; color: var(--cz-ink2); }
545
+ .hv-gn span { flex: 1; min-width: 0; }
@@ -0,0 +1,53 @@
1
+ /* pm/grill-words.js — the words and marks every page uses for Claude's checks (Grill and Forecast screens; canvas GrillResult, GrillLenses,
2
+ * FcIntel, FcPhone). Pure: Node can import it.
3
+ *
4
+ * ANGLE { [angle]: { label, icon (a 24-unit path) } }: premortem · redteam · voices · reframe · scope · whatif
5
+ * findingOf(p) a grill proposal (lib/grill.js finding) → { angle, label, icon, title, why, next, simulated }
6
+ * the title and why without the angle prefix and the "Next:" tail lib/grill.js writes into them
7
+ * whenWord(iso, now) 'overnight' · 'today' · 'yesterday' · 'on Oct 30'
8
+ * costWord(usd) '38¢' · '$1.20' · '' (unknown)
9
+ * whyWord(run) 'before it leaves its stage' · 'when its forecast turned' · 'after its scope or dates moved' · 'in the monthly look'
10
+ * runLine(run, now) "Claude grilled it overnight, when its forecast turned" (no cost; the page adds it quietly)
11
+ * turnWord(to) 'will miss' · 'is at risk' · '' */
12
+ export const ANGLE = Object.freeze({
13
+ premortem: { label: 'Premortem', icon: 'M12 3l9 16H3zM12 10v4M12 17v.5' },
14
+ redteam: { label: 'Red team', icon: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8' },
15
+ voices: { label: 'Voices', icon: 'M4 5h12v8H9l-4 3v-3H4zM19 9v7h-1v3l-3-3h-4' },
16
+ reframe: { label: 'Reframe', icon: 'M4 8V4h4M20 8V4h-4M4 16v4h4M20 16v4h-4M9 9h6v6H9z' },
17
+ scope: { label: 'Scope', icon: 'M4 6h16M7 12h10M10 18h4' },
18
+ whatif: { label: 'What-if', icon: 'M4 18c4 0 4-12 8-12s4 12 8 12M4 12c4 0 4-6 8-6' },
19
+ });
20
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
21
+
22
+ export function findingOf(p) {
23
+ const d = (p && p.data) || {}, angle = ANGLE[d.angle] ? d.angle : ANGLE[p && p.type] ? p.type : 'premortem';
24
+ const A = ANGLE[angle];
25
+ // lib/grill.js writes "Premortem (Simulated, not evidence): the finding" and "the evidence Next: the step"; the page shows them apart
26
+ const title = String((p && p.title) || '').replace(/^[^:]{1,60}:\s*/, '');
27
+ const next = String(d.next || '');
28
+ let why = String((p && p.why) || '');
29
+ if (next && why.endsWith(' Next: ' + next)) why = why.slice(0, -(' Next: ' + next).length);
30
+ return { angle, label: A.label, icon: A.icon, title: title || A.label, why, next, simulated: d.simulated || '' };
31
+ }
32
+ const dayKey = (t) => { const d = new Date(t); return d.getFullYear() * 400 + d.getMonth() * 32 + d.getDate(); };
33
+ export function whenWord(iso, now = Date.now()) {
34
+ const t = Date.parse(iso || '');
35
+ if (!Number.isFinite(t)) return '';
36
+ const h = new Date(t).getHours(), ago = now - t;
37
+ if (ago >= 0 && ago < 20 * 36e5 && (h >= 21 || h < 7)) return 'overnight';
38
+ if (dayKey(t) === dayKey(now)) return 'today';
39
+ if (dayKey(t) === dayKey(now - 864e5)) return 'yesterday';
40
+ const d = new Date(t); return 'on ' + MON[d.getMonth()] + ' ' + d.getDate();
41
+ }
42
+ export function costWord(usd) {
43
+ const n = Number(usd);
44
+ if (usd == null || !Number.isFinite(n)) return '';
45
+ return n < 1 ? Math.max(1, Math.round(n * 100)) + '¢' : '$' + n.toFixed(2);
46
+ }
47
+ const WHY = { exit: 'before it leaves its stage', forecast: 'when its forecast turned', move: 'after its scope or dates moved', monthly: 'in the monthly look' };
48
+ export const whyWord = (r) => (r && WHY[r.why]) || '';
49
+ export function runLine(r, now = Date.now()) {
50
+ if (!r) return '';
51
+ return ['Claude grilled it', whenWord(r.at, now)].filter(Boolean).join(' ') + (whyWord(r) ? ', ' + whyWord(r) : '');
52
+ }
53
+ export const turnWord = (to) => (to === 'will-miss' ? 'will miss' : to === 'at-risk' ? 'is at risk' : '');
@@ -15,6 +15,8 @@
15
15
  * The models are in home-data.js and home-list.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's
16
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
17
17
  import { mountNav } from './cozy-nav.js';
18
+ import { mountSetupChecklist } from './setup-checklist.js';
19
+ import { mountOnboard } from './cozy-onboard.js';
18
20
  import { mountLivePill } from './cozy-live-pill.js';
19
21
  import { mountPanels } from './cozy-panels.js';
20
22
  import { ownTab, bring, tabUrl } from './rec-tab-core.js';
@@ -39,6 +41,7 @@ import { mountPhoneCard } from './home-phone-card.js';
39
41
  import { mountFirst } from './premium-first.js';
40
42
  import * as L from './home-list.js';
41
43
  import * as TD from './home-today.js';
44
+ import * as GW from './grill-words.js'; // Home's one line when Claude grilled something by itself (canvas FcPhone, Home)
42
45
  import * as YD from './home-day.js';
43
46
  import * as AD from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2)
44
47
  import * as OKL from './okr-list.js'; // the product page's Goals line (batch 16 item 6, GsProduct)
@@ -63,6 +66,7 @@ const $ = (s, r = document) => r.querySelector(s);
63
66
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
64
67
  const P = new URLSearchParams(location.search);
65
68
  const WS = P.get('ws') || '';
69
+ const SETUP_CHECKLIST = mountSetupChecklist(WS);
66
70
  let PHC = null; // the phone moment card (home-phone-card.js): the top of the phone's sheet
67
71
  const FST = mountFirst(); // the first-run card after an import (?first=<import id>, premium-first.js): the top of the list
68
72
  const wsQ = (pre = '?') => (WS ? pre + 'ws=' + encodeURIComponent(WS) : '');
@@ -207,6 +211,7 @@ async function load() {
207
211
  NEED.refresh(); // an open ask: its agent finished, or it left Home while it was open
208
212
  loadImpact();
209
213
  readImpact();
214
+ loadGrillNews();
210
215
  // the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
211
216
  const others = await Promise.all(otherProducts(D).map((a) => getRetry('/api/board-premium?ws=' + encodeURIComponent(a.ws), 4).then((r) => (r && r.ok && r.model ? { ws: a.ws, name: a.name, model: r.model } : null))));
212
217
  const got = others.filter(Boolean);
@@ -216,6 +221,33 @@ async function load() {
216
221
  // an initiative of another product opened before its board was read (a link, a quick press): read it again from its own board
217
222
  if (S.ini && !S.IM && otherIni(S.ini)) goIni(S.ini, { page: VW.isOpen() });
218
223
  }
224
+ /* ── Home's one line (canvas FcPhone, Home: "only when something changed"): the newest grill this week that left findings, from GET /api/grill.
225
+ * "Checkout v2 will miss its date. I grilled it overnight: 3 findings." ✦ opens them on the initiative. Nothing to say is silence. ── */
226
+ async function loadGrillNews() {
227
+ const b0 = (S.D.board && S.D.board.board) || {};
228
+ const r = await pmGet('/api/grill' + (b0.ws ? '?ws=' + encodeURIComponent(b0.ws) : wsQ())).catch(() => null);
229
+ const n = r && r.ok && r.news ? r.news : null;
230
+ if (JSON.stringify(n) === JSON.stringify(S.gn || null)) return;
231
+ S.gn = n; drawList();
232
+ }
233
+ function grillNews() {
234
+ const n = S.gn; if (!n || !n.n) return null;
235
+ const row = H.boardRows(S.D).find((r) => r.id === n.ini), title = (row && row.title) || n.ini;
236
+ const t = n.turn && GW.turnWord(n.turn.to), when = GW.whenWord(n.at), f = n.n + (n.n === 1 ? ' finding' : ' findings');
237
+ const text = t ? (n.turn.scope === 'goal' ? 'A goal ' + title + ' moves ' + t + '. I grilled it ' + when + ': ' + f + '.' : title + ' ' + t + (t === 'will miss' ? ' its date' : '') + '. I grilled it ' + when + ': ' + f + '.')
238
+ : 'I grilled ' + title + ' ' + when + (GW.whyWord(n) ? ', ' + GW.whyWord(n) : '') + ': ' + f + '.';
239
+ return { id: n.ini, title, text, n: n.n };
240
+ }
241
+ /** ✦ on Home's grill line: the initiative opens, and its findings over it in the Viewer (pm/ini-props.js). */
242
+ async function openGrillNews(id) {
243
+ const g = grillNews(); if (!g || g.id !== id) return;
244
+ const b0 = (S.D.board && S.D.board.board) || {};
245
+ await goIni(id);
246
+ const r = await pmGet('/api/proposals?ws=' + encodeURIComponent(b0.ws || WS || '') + '&board=' + encodeURIComponent(b0.id || '') + '&initiative=' + encodeURIComponent(id)).catch(() => null);
247
+ if (!r || r.ok === false) { toast((r && r.error) || 'The findings could not be read.'); return; }
248
+ const IP = await import('./ini-props.js');
249
+ IP.open({ id, title: g.title, props: r.props }, { where: () => ({ ws: b0.ws || WS, board: b0.id }), reload: () => load(), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) });
250
+ }
219
251
  /** The products Home reads (Products, on) other than the board's own: each is a group of the list, read from its own board. At most four. */
220
252
  function otherProducts(D) {
221
253
  const av = (D.brief && D.brief.products && D.brief.products.available) || [];
@@ -310,7 +342,7 @@ function homeListHtml() {
310
342
  return TD.listHtml(M, todayModel(), {
311
343
  sel, selHead: S.head, ses: S.ses, pOpen, here: isPhone() ? null : TD.groupOfOpen(M, sel) || S.head, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
312
344
  pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) + (S.impact ? IMP.rowHtml(S.impact.c, { esc, sel: S.sel === 'impact' }) : '') : '',
313
- imFace: IM.faceHtml(S.im, { joy: S.imJoy }),
345
+ imFace: IM.faceHtml(S.im, { joy: S.imJoy }), grill: S.ready ? grillNews() : null,
314
346
  });
315
347
  }
316
348
  /** Your day (XvAPhDay): "Good morning" opens it in the Viewer on a phone and a desktop alike (batch 16, Wawan: the same press must lead to
@@ -588,6 +620,7 @@ function drawList() {
588
620
  // the first-run card after an import tops the list. The phone moment card is not in the list: it is the detail of the greeting
589
621
  // at the top, and opens in the Viewer when the greeting is pressed (testing fixes: in the list it took a screen of room)
590
622
  if (FST && sc.firstElementChild !== FST) sc.prepend(FST);
623
+ if (SETUP_CHECKLIST && !sc.contains(SETUP_CHECKLIST)) sc.prepend(SETUP_CHECKLIST);
591
624
  if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
592
625
  document.body.classList.toggle('hm-folded', S.folded && !isPhone());
593
626
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
@@ -712,6 +745,12 @@ const chat = mountChat($('#hmChat'), {
712
745
  reopenViewer: () => reopenViewer(),
713
746
  head: (t) => (isPhone() ? '' : TD.chatHeadHtml(chatHead(t))), // the phone names it in its top bar (#hmTop)
714
747
  });
748
+ /* claude-onboarding-build: set up a project as a conversation in this chat's place (cozy-onboard.js). It opens on ?onboard=1, shows the
749
+ * finished project's next steps on ?onboarded=1, and opens by itself only on a first run: no workspace named and no PMOS project registered. */
750
+ const startOnboard = (done) => { document.body.classList.add('ob-on'); mountOnboard($('#hmChat'), { ws: WS, done }); };
751
+ if (P.get('onboard') === '1' || P.get('onboarded') === '1') startOnboard(P.get('onboarded') === '1');
752
+ else if (!WS) pmGet('/api/onboard/state').then((r) => { if (r && r.ok && !r.has_projects) startOnboard(false); }).catch(() => {});
753
+
715
754
  /* The chat's header line on a desktop (HvACDesk): the open row's mark and title, and where it sits: its initiative with the stage track, or
716
755
  * its program. Home's own chat names nothing. */
717
756
  function chatHead(t) {
@@ -1732,6 +1771,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1732
1771
  if ('hrImpact' in d) { if (S.day) S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; } // Your impact: Home's own chat, on the weekly check
1733
1772
  if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
1734
1773
  if ('hmImpact' in d) { if (S.day) day(false); IM.openWeek(); return; }
1774
+ if (d.hmGn) { openGrillNews(d.hmGn); return; }
1735
1775
  if ('hmDay' in d) { day(!S.day); return; }
1736
1776
  if ('hmDayx' in d) { day(false); return; }
1737
1777
  if ('hmFlt' in d) { filterMenu(b); return; }