create-pmos 0.473.0 → 0.475.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/bin/create-pmos.js +23 -1
- package/install.ps1 +2 -1
- package/install.sh +6 -1
- package/package.json +27 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/README.md +1 -1
- package/workspace/bin/pmos.js +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/fixtures/fake-claude-onboard.js +48 -0
- package/workspace/guide/briefing-premium.md +2 -7
- package/workspace/guide/index.md +2 -2
- package/workspace/guide/launcher.md +14 -32
- package/workspace/guide/layout.md +1 -1
- package/workspace/guide/published-board.md +1 -1
- package/workspace/guide/settings.md +3 -3
- package/workspace/guide/welcome.md +64 -21
- package/workspace/lib/claude-readiness.js +143 -0
- package/workspace/lib/engine/calendar-import.js +5 -0
- package/workspace/lib/freshness.js +5 -3
- package/workspace/lib/launcher-cli.js +83 -8
- package/workspace/lib/onboarding-progress.js +36 -0
- package/workspace/lib/project-onboard.js +363 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-onboard.js +188 -0
- package/workspace/lib/routes-onboarding.js +5 -4
- package/workspace/lib/routes-setup.js +88 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/project-onboard-flow-test.js +135 -0
- package/workspace/public/pm/cozy-claude-setup.js +90 -0
- package/workspace/public/pm/cozy-onboard.css +60 -0
- package/workspace/public/pm/cozy-onboard.js +226 -0
- package/workspace/public/pm/cozy-settings.js +8 -2
- package/workspace/public/pm/home-app.js +10 -0
- package/workspace/public/pm/premium-first.js +1 -1
- package/workspace/public/pm/premium-welcome-model.js +1 -1
- package/workspace/public/pm/premium-welcome.js +107 -62
- package/workspace/public/pm/premium.css +16 -0
- package/workspace/public/pm/readonly.js +1 -1
- package/workspace/public/pm/setup-checklist.js +22 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/server.js +28 -6
- package/workspace/skills/calendar-sync.skill +1 -1
- package/workspace/test-files.json +6 -3
- package/workspace/test-lists/briefing-premium.json +1 -3
- package/workspace/test-lists/claude-onboarding-build.json +9 -0
- package/workspace/premium-welcome-test.js +0 -219
|
@@ -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) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[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
|
+
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* 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
24
|
* PMOS reads the sources and never posts to them.
|
|
25
25
|
* openSettings(section?) */
|
|
26
|
+
import { mountClaudeSetup } from './cozy-claude-setup.js';
|
|
26
27
|
import { pmGet, pmPost, pressFetch } from './http.js';
|
|
27
28
|
import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
|
|
28
29
|
import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
|
|
@@ -237,11 +238,12 @@ function claudeSec() {
|
|
|
237
238
|
const k = C.key || {};
|
|
238
239
|
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
240
|
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
|
|
241
|
+
return '<h4>Claude login and profile</h4><div data-claude-setup></div>'
|
|
241
242
|
+ trow('API key', keySub, keyRight)
|
|
242
243
|
+ (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
244
|
}
|
|
244
245
|
const BODY = { general, claude: claudeSec, adler: adlerSec, connectors, workspaces, updates };
|
|
246
|
+
let disposeClaudeSetup = null;
|
|
245
247
|
function draw() {
|
|
246
248
|
const el = T.el; if (!el || el.hidden) return;
|
|
247
249
|
// 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 +255,9 @@ function draw() {
|
|
|
253
255
|
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
256
|
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
257
|
+ 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>`;
|
|
258
|
+
if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
|
|
259
|
+
const setup = el.querySelector('[data-claude-setup]');
|
|
260
|
+
if (setup) disposeClaudeSetup = mountClaudeSetup(setup, { ws: wsParam() || (T.ws && T.ws[0] && T.ws[0].id) || '', onReady: () => {} });
|
|
256
261
|
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
262
|
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
263
|
}
|
|
@@ -263,7 +268,7 @@ function mount() {
|
|
|
263
268
|
document.body.append(...d.childNodes);
|
|
264
269
|
T.el = document.getElementById('evSettings');
|
|
265
270
|
document.getElementById('evStScrim').addEventListener('click', closeSettings);
|
|
266
|
-
T.el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSettings(); } });
|
|
271
|
+
T.el.addEventListener('keydown', (e) => { if (e.target.closest('.cs-term')) return; if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeSettings(); } });
|
|
267
272
|
// the dialog is modal: Escape closes it even when focus is outside it (a click on the scrim's edge, a redraw)
|
|
268
273
|
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
274
|
T.el.addEventListener('change', async (e) => {
|
|
@@ -434,6 +439,7 @@ export function openSettings(section) {
|
|
|
434
439
|
}
|
|
435
440
|
export function closeSettings() {
|
|
436
441
|
if (!T.el || T.el.hidden) return;
|
|
442
|
+
if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
|
|
437
443
|
T.el.hidden = true; document.getElementById('evStScrim').hidden = true; T.el.removeAttribute('data-esc-layer');
|
|
438
444
|
const b = T.back; T.back = null; if (b && b.isConnected) { try { b.focus(); } catch { /* gone */ } }
|
|
439
445
|
}
|
|
@@ -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';
|
|
@@ -63,6 +65,7 @@ const $ = (s, r = document) => r.querySelector(s);
|
|
|
63
65
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
64
66
|
const P = new URLSearchParams(location.search);
|
|
65
67
|
const WS = P.get('ws') || '';
|
|
68
|
+
const SETUP_CHECKLIST = mountSetupChecklist(WS);
|
|
66
69
|
let PHC = null; // the phone moment card (home-phone-card.js): the top of the phone's sheet
|
|
67
70
|
const FST = mountFirst(); // the first-run card after an import (?first=<import id>, premium-first.js): the top of the list
|
|
68
71
|
const wsQ = (pre = '?') => (WS ? pre + 'ws=' + encodeURIComponent(WS) : '');
|
|
@@ -588,6 +591,7 @@ function drawList() {
|
|
|
588
591
|
// 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
592
|
// 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
593
|
if (FST && sc.firstElementChild !== FST) sc.prepend(FST);
|
|
594
|
+
if (SETUP_CHECKLIST && !sc.contains(SETUP_CHECKLIST)) sc.prepend(SETUP_CHECKLIST);
|
|
591
595
|
if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
|
|
592
596
|
document.body.classList.toggle('hm-folded', S.folded && !isPhone());
|
|
593
597
|
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 +716,12 @@ const chat = mountChat($('#hmChat'), {
|
|
|
712
716
|
reopenViewer: () => reopenViewer(),
|
|
713
717
|
head: (t) => (isPhone() ? '' : TD.chatHeadHtml(chatHead(t))), // the phone names it in its top bar (#hmTop)
|
|
714
718
|
});
|
|
719
|
+
/* 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
|
|
720
|
+
* 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. */
|
|
721
|
+
const startOnboard = (done) => { document.body.classList.add('ob-on'); mountOnboard($('#hmChat'), { ws: WS, done }); };
|
|
722
|
+
if (P.get('onboard') === '1' || P.get('onboarded') === '1') startOnboard(P.get('onboarded') === '1');
|
|
723
|
+
else if (!WS) pmGet('/api/onboard/state').then((r) => { if (r && r.ok && !r.has_projects) startOnboard(false); }).catch(() => {});
|
|
724
|
+
|
|
715
725
|
/* 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
726
|
* its program. Home's own chat names nothing. */
|
|
717
727
|
function chatHead(t) {
|
|
@@ -32,7 +32,7 @@ export function mountFirst() {
|
|
|
32
32
|
b.disabled = true;
|
|
33
33
|
const u = await pmPost('/api/onboarding/undo', { ws, import_id: id });
|
|
34
34
|
if (!u || !u.ok) { b.disabled = false; const m = sec.querySelector('#wlUndoErr'); m.textContent = (u && u.error) || 'Undo did not work.'; m.hidden = false; return; }
|
|
35
|
-
location.assign('/premium
|
|
35
|
+
location.assign('/premium.html?onboard=1');
|
|
36
36
|
};
|
|
37
37
|
return sec;
|
|
38
38
|
}
|
|
@@ -10,7 +10,7 @@ export const TOOLS = [
|
|
|
10
10
|
{ source: 'inbox', brief: 'mail', name: 'Inbox', adds: 'The threads waiting on you, by subject and sender only. No message text is kept.' },
|
|
11
11
|
{ source: 'slack', brief: 'slack', name: 'Slack', adds: 'Messages that mention you and your direct messages, as short summaries.' },
|
|
12
12
|
];
|
|
13
|
-
export const STEPS = [['
|
|
13
|
+
export const STEPS = [['claude', 'Connect Claude'], ['sources', 'Add your work'], ['found', 'Review and start']];
|
|
14
14
|
export const FIELDS = ['name', 'role', 'work', 'duties'];
|
|
15
15
|
|
|
16
16
|
const str = (v) => (typeof v === 'string' ? v : '');
|