create-pmos 0.546.0 → 0.548.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/package.json +27 -45
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/README.md +1 -1
- package/workspace/bin/pmos.js +22 -0
- package/workspace/changelog.json +26 -0
- package/workspace/guide/cli.md +10 -0
- package/workspace/guide/home.md +9 -4
- package/workspace/guide/layout.md +1 -1
- package/workspace/lib/artefacts.js +12 -0
- package/workspace/lib/autonomy.js +27 -7
- package/workspace/lib/driver-decide.js +6 -1
- package/workspace/lib/launcher-cli.js +147 -13
- package/workspace/lib/routes-artefacts.js +18 -1
- package/workspace/lib/routes-autonomy.js +56 -8
- package/workspace/lib/routes-proposals.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-today.css +7 -0
- package/workspace/public/pm/good-morning.js +72 -14
- package/workspace/public/pm/home-app.js +4 -3
- package/workspace/public/pm/home-day.js +11 -6
- package/workspace/public/pm/ini-agent.js +164 -0
- package/workspace/public/pm/ini-view.css +32 -3
- package/workspace/public/pm/ini-view.js +25 -2
- package/workspace/public/pm/move-rank.js +6 -3
- package/workspace/stage-card-tasks-test.js +3 -0
- package/workspace/test-lists/agent-run-workspace.json +9 -0
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
* opens the browser. The login item passes --no-open, so a login starts the server and opens nothing.
|
|
10
10
|
*
|
|
11
11
|
* macOS ~/Applications/PMOS.app Spotlight, Launchpad, drag it to the Dock
|
|
12
|
-
* ~/Library/LaunchAgents/com.pmos.workspace.plist runs at login
|
|
12
|
+
* ~/Library/LaunchAgents/com.pmos.workspace.plist runs at login and then every minute: `pmos up --keep`
|
|
13
|
+
* starts the server when it is down (a crash, an update that
|
|
14
|
+
* did not bring it back) and does nothing when it is up
|
|
15
|
+
* ~/Library/LaunchAgents/com.pmos.remote-control.plist with --remote-control: keeps `claude remote-control`
|
|
16
|
+
* running in a tmux session named pmos-remote-control, so
|
|
17
|
+
* Claude can reach this Mac when the desktop app is closed.
|
|
18
|
+
* A later `on` without the flag leaves it; `off` removes it.
|
|
13
19
|
* Linux $XDG_DATA_HOME/applications/pmos.desktop the app menu
|
|
14
20
|
* $XDG_CONFIG_HOME/autostart/pmos-workspace.desktop
|
|
15
21
|
*
|
|
@@ -18,6 +24,11 @@
|
|
|
18
24
|
* `off` deletes a file only when it carries MARK, so a file of the same name that the PM wrote is left alone.
|
|
19
25
|
* Windows uses a Start-menu shortcut and hidden Windows Script Host launchers, including a Startup entry.
|
|
20
26
|
*
|
|
27
|
+
* --profile=<id> names the Claude profile unattended work runs under: Remote Control starts with that profile's
|
|
28
|
+
* CLAUDE_CONFIG_DIR, and the workspace's own Claude preference (prefs.json `claude`, Settings → Claude) is set to it.
|
|
29
|
+
* Only CLAUDE_CONFIG_DIR is written into a script. Any other variable a profile sets (a key, a proxy) is never written.
|
|
30
|
+
* On macOS `on` loads the LaunchAgents with launchctl at once, and `off` unloads them, so no logout is needed.
|
|
31
|
+
*
|
|
21
32
|
* plan() is pure: every input is injected, so each platform's files are assertable from any machine.
|
|
22
33
|
*/
|
|
23
34
|
const fs = require('fs');
|
|
@@ -29,9 +40,14 @@ const stateRoot = require('./state-root');
|
|
|
29
40
|
const COMMANDS = { launcher: ['on', 'off', 'status'] };
|
|
30
41
|
const MARK = 'pmos-launcher: written by `pmos launcher on`';
|
|
31
42
|
const LABEL = 'com.pmos.workspace';
|
|
43
|
+
const RC_LABEL = 'com.pmos.remote-control';
|
|
44
|
+
const RC_SESSION = 'pmos-remote-control';
|
|
45
|
+
const KEEP_SECONDS = 60;
|
|
32
46
|
const USAGE = [
|
|
33
47
|
'usage: pmos launcher on|off|status — start the workspace without a terminal',
|
|
34
|
-
' pmos launcher on [<path>] [--no-login] a PMOS app for this repository, and a login item that
|
|
48
|
+
' pmos launcher on [<path>] [--no-login] a PMOS app for this repository, and a login item that keeps the server up',
|
|
49
|
+
' --profile=<id> unattended Claude work uses this Claude profile (such as claude-personal)',
|
|
50
|
+
' --remote-control macOS: keep `claude remote-control` running, so Claude reaches this Mac with the app closed',
|
|
35
51
|
' pmos launcher off remove the app and the login item',
|
|
36
52
|
' pmos launcher status what is installed, and for which repository',
|
|
37
53
|
];
|
|
@@ -54,9 +70,30 @@ function script({ node, bin, repo, pathEnv, log }) {
|
|
|
54
70
|
].join('\n');
|
|
55
71
|
}
|
|
56
72
|
|
|
73
|
+
// The Remote Control keeper. launchd runs it every minute; it does nothing while the tmux session is there. Inside tmux,
|
|
74
|
+
// `claude remote-control` has the terminal it expects, and when it exits the session ends and the next minute starts it
|
|
75
|
+
// again. --permission-mode auto: nobody is at this Mac to answer a permission question.
|
|
76
|
+
function rcScript({ repo, pathEnv, log, configDir, name }) {
|
|
77
|
+
const inner = [
|
|
78
|
+
`PATH=${shq(pathEnv)}; export PATH;`,
|
|
79
|
+
...(configDir ? [`CLAUDE_CONFIG_DIR=${shq(configDir)}; export CLAUDE_CONFIG_DIR;`] : []),
|
|
80
|
+
`exec claude remote-control --name ${shq(name)} --permission-mode auto`,
|
|
81
|
+
].join(' ');
|
|
82
|
+
return [
|
|
83
|
+
'#!/bin/sh',
|
|
84
|
+
`# ${MARK} (workspace/lib/launcher-cli.js). \`pmos launcher off\` removes it.`,
|
|
85
|
+
`# It keeps \`claude remote-control\` running in the tmux session ${RC_SESSION}. \`tmux attach -t ${RC_SESSION}\` shows it.`,
|
|
86
|
+
`PATH=${shq(pathEnv)}; export PATH`,
|
|
87
|
+
`tmux has-session -t ${RC_SESSION} 2>/dev/null && exit 0`,
|
|
88
|
+
`echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) remote-control: starting" >>${shq(log)}`,
|
|
89
|
+
`exec tmux new-session -d -s ${RC_SESSION} -c ${shq(repo)} ${shq(inner)} >>${shq(log)} 2>&1`,
|
|
90
|
+
'',
|
|
91
|
+
].join('\n');
|
|
92
|
+
}
|
|
93
|
+
|
|
57
94
|
function plist(dict) {
|
|
58
95
|
const v = (x) => Array.isArray(x) ? `<array>${x.map((s) => `<string>${xml(s)}</string>`).join('')}</array>`
|
|
59
|
-
: typeof x === 'boolean' ? (x ? '<true/>' : '<false/>') : `<string>${xml(x)}</string>`;
|
|
96
|
+
: typeof x === 'boolean' ? (x ? '<true/>' : '<false/>') : typeof x === 'number' ? `<integer>${x}</integer>` : `<string>${xml(x)}</string>`;
|
|
60
97
|
return [
|
|
61
98
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
62
99
|
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
@@ -80,7 +117,7 @@ function desktop(entries) {
|
|
|
80
117
|
* → { files: [{ role: 'app'|'login', path, content, mode }], app, login } or { refused: '<reason>' }
|
|
81
118
|
* `login: false` leaves the login item out.
|
|
82
119
|
*/
|
|
83
|
-
function plan({ platform, home, env = {}, node, bin, repo, login = true }) {
|
|
120
|
+
function plan({ platform, home, env = {}, node, bin, repo, login = true, remoteControl = null }) {
|
|
84
121
|
if (platform === 'win32') {
|
|
85
122
|
const wp = path.win32;
|
|
86
123
|
const appData = env.APPDATA || wp.join(home, 'AppData', 'Roaming');
|
|
@@ -110,6 +147,7 @@ function plan({ platform, home, env = {}, node, bin, repo, login = true }) {
|
|
|
110
147
|
host: wp.join(env.SystemRoot || 'C:\\Windows', 'System32', 'wscript.exe') } };
|
|
111
148
|
}
|
|
112
149
|
if (platform !== 'darwin' && platform !== 'linux') return { refused: `no launcher is made for ${platform}. Start the workspace with \`pmos\`.` };
|
|
150
|
+
if (remoteControl && platform !== 'darwin') return { refused: '--remote-control is made for macOS only. Run `claude remote-control` in a terminal.' };
|
|
113
151
|
const log = path.join(stateRoot.defaultRoot({ env, platform, home }), 'launcher.log');
|
|
114
152
|
const body = script({ node, bin, repo, pathEnv: env.PATH || '/usr/bin:/bin', log });
|
|
115
153
|
const files = [];
|
|
@@ -125,11 +163,25 @@ function plan({ platform, home, env = {}, node, bin, repo, login = true }) {
|
|
|
125
163
|
}) });
|
|
126
164
|
const agent = path.join(home, 'Library', 'LaunchAgents', `${LABEL}.plist`);
|
|
127
165
|
if (login) files.push({ role: 'login', path: agent, mode: 0o644, content: plist({
|
|
128
|
-
Label: LABEL, ProgramArguments: ['/bin/sh', exe, '--no-open'], RunAtLoad: true,
|
|
166
|
+
Label: LABEL, ProgramArguments: ['/bin/sh', exe, '--no-open', '--keep'], RunAtLoad: true,
|
|
167
|
+
// Every minute, not KeepAlive: `pmos up` detaches the server and exits, so launchd cannot watch the server itself.
|
|
168
|
+
StartInterval: KEEP_SECONDS,
|
|
129
169
|
// `pmos up` detaches the server and exits; launchd must not reap the group it leaves behind.
|
|
130
170
|
AbandonProcessGroup: true,
|
|
131
171
|
}) });
|
|
132
|
-
|
|
172
|
+
const rcAgent = path.join(home, 'Library', 'LaunchAgents', `${RC_LABEL}.plist`);
|
|
173
|
+
const rcExe = path.join(appDir, 'Contents', 'MacOS', 'pmos-remote-control');
|
|
174
|
+
if (remoteControl) {
|
|
175
|
+
files.push({ role: 'app', path: rcExe, mode: 0o755, content: rcScript({ repo, pathEnv: env.PATH || '/usr/bin:/bin', log,
|
|
176
|
+
configDir: remoteControl.configDir || null, name: remoteControl.name || `${path.basename(repo)} (PMOS)` }) });
|
|
177
|
+
files.push({ role: 'remote-control', path: rcAgent, mode: 0o644, content: plist({
|
|
178
|
+
Label: RC_LABEL, ProgramArguments: ['/bin/sh', rcExe], RunAtLoad: true, StartInterval: KEEP_SECONDS,
|
|
179
|
+
// The tmux session outlives this script on purpose.
|
|
180
|
+
AbandonProcessGroup: true,
|
|
181
|
+
}) });
|
|
182
|
+
}
|
|
183
|
+
return { files, app: appDir, login: login ? agent : null, remoteControl: remoteControl ? rcAgent : null,
|
|
184
|
+
removable: [appDir, agent, rcAgent], agents: [[LABEL, agent], [RC_LABEL, rcAgent]] };
|
|
133
185
|
}
|
|
134
186
|
const data = env.XDG_DATA_HOME && path.isAbsolute(env.XDG_DATA_HOME) ? env.XDG_DATA_HOME : path.join(home, '.local', 'share');
|
|
135
187
|
const conf = env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : path.join(home, '.config');
|
|
@@ -192,11 +244,56 @@ function shortcutAction(shortcut, action) {
|
|
|
192
244
|
if (r.error || r.status !== 0) throw new Error(String(r.stderr || r.error || 'Could not manage PMOS shortcut').trim());
|
|
193
245
|
}
|
|
194
246
|
|
|
247
|
+
// Load or unload one LaunchAgent in this user's GUI session, so a change takes effect without a logout. Best effort:
|
|
248
|
+
// the file on disk is what counts at the next login.
|
|
249
|
+
function launchctlAction(label, file, action, { uid = process.getuid ? process.getuid() : 0 } = {}) {
|
|
250
|
+
const domain = `gui/${uid}`;
|
|
251
|
+
spawnSync('launchctl', ['bootout', `${domain}/${label}`], { stdio: 'ignore' });
|
|
252
|
+
// The Remote Control keeper's tmux session outlives launchd's job: end it too, or the old profile keeps serving.
|
|
253
|
+
if (label === RC_LABEL && action !== 'load') spawnSync('tmux', ['kill-session', '-t', RC_SESSION], { stdio: 'ignore' });
|
|
254
|
+
if (action !== 'load') return { ok: true };
|
|
255
|
+
const r = spawnSync('launchctl', ['bootstrap', domain, file], { encoding: 'utf8' });
|
|
256
|
+
return r.status === 0 ? { ok: true } : { ok: false, error: String(r.stderr || r.error || `exit ${r.status}`).trim() };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// The Claude profile named by --profile=<id>: a descriptor or a detected profile (lib/profiles.js). Only its
|
|
260
|
+
// CLAUDE_CONFIG_DIR is used, and a profile that names Claude's own folder needs none.
|
|
261
|
+
function resolveProfile(id, home) {
|
|
262
|
+
const read = require('./profiles').readProfiles(home, { detect: true });
|
|
263
|
+
const p = (read.profiles || []).find((x) => x.id === id);
|
|
264
|
+
if (!p) {
|
|
265
|
+
const ids = (read.profiles || []).map((x) => x.id);
|
|
266
|
+
return { error: `no Claude profile named ${id}${ids.length ? ` (found: ${ids.join(', ')})` : ' was found'}` };
|
|
267
|
+
}
|
|
268
|
+
const dir = p.env && p.env.CLAUDE_CONFIG_DIR ? String(p.env.CLAUDE_CONFIG_DIR) : null;
|
|
269
|
+
const configDir = dir && !require('./claude-home').isDefaultDir(dir, home) ? dir : null;
|
|
270
|
+
const skipped = Object.keys(p.env || {}).filter((k) => k !== 'CLAUDE_CONFIG_DIR');
|
|
271
|
+
return { id: p.id, configDir, skipped };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// prefs.json `claude` is the profile every Claude call of the workspace starts under (Settings → Claude). Other keys stay.
|
|
275
|
+
function preferProfile(stateDir, id) {
|
|
276
|
+
const f = path.join(stateDir, 'prefs.json');
|
|
277
|
+
let prefs = {};
|
|
278
|
+
try { const o = JSON.parse(fs.readFileSync(f, 'utf8')); if (o && typeof o === 'object' && !Array.isArray(o)) prefs = o; } catch { /* none yet */ }
|
|
279
|
+
if (prefs.claude === id) return false;
|
|
280
|
+
prefs.claude = id;
|
|
281
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
282
|
+
const tmp = `${f}.${process.pid}.tmp`;
|
|
283
|
+
fs.writeFileSync(tmp, JSON.stringify(prefs));
|
|
284
|
+
fs.renameSync(tmp, f);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
|
|
195
288
|
function run(argv, { say = console.log, platform = process.platform, home = os.homedir(), env = process.env,
|
|
196
|
-
manageShortcut = shortcutAction, node = process.execPath, bin = path.join(__dirname, '..', 'bin', 'pmos.js'), cwd = process.cwd()
|
|
289
|
+
manageShortcut = shortcutAction, node = process.execPath, bin = path.join(__dirname, '..', 'bin', 'pmos.js'), cwd = process.cwd(),
|
|
290
|
+
launchctl = launchctlAction, hostname = os.hostname() } = {}) {
|
|
197
291
|
const pos = argv.slice(1).filter((a) => !a.startsWith('--'));
|
|
198
|
-
const
|
|
199
|
-
const
|
|
292
|
+
const opts = {};
|
|
293
|
+
for (const a of argv.slice(1)) { const m = a.match(/^--([a-z-]+)=(.*)$/); if (m) opts[m[1]] = m[2]; }
|
|
294
|
+
const flags = new Set(argv.slice(1).filter((a) => a.startsWith('--') && !a.includes('=')).map((a) => a.slice(2)));
|
|
295
|
+
const unknown = [...flags].filter((f) => !['no-login', 'help', 'remote-control'].includes(f))
|
|
296
|
+
.concat(Object.keys(opts).filter((k) => k !== 'profile'));
|
|
200
297
|
if (unknown.length) { say(`✗ unknown option --${unknown[0]}`); for (const l of USAGE) say(l); return 2; }
|
|
201
298
|
const sub = pos[0];
|
|
202
299
|
if (!sub || flags.has('help') || sub === 'help') { for (const l of USAGE) say(l); return sub ? 0 : 2; }
|
|
@@ -206,7 +303,14 @@ function run(argv, { say = console.log, platform = process.platform, home = os.h
|
|
|
206
303
|
const dir = pos[1] ? path.resolve(cwd, pos[1]) : cwd;
|
|
207
304
|
if (!fs.existsSync(dir)) { say(`✗ ${dir} does not exist`); return 1; }
|
|
208
305
|
const repo = repoRootOf(dir);
|
|
209
|
-
|
|
306
|
+
let profile = null;
|
|
307
|
+
if (opts.profile !== undefined) {
|
|
308
|
+
profile = resolveProfile(opts.profile, home);
|
|
309
|
+
if (profile.error) { say(`✗ ${profile.error}`); return 1; }
|
|
310
|
+
}
|
|
311
|
+
const remoteControl = flags.has('remote-control')
|
|
312
|
+
? { configDir: profile ? profile.configDir : null, name: `${String(hostname).replace(/\.local$/, '')} (${path.basename(repo)})` } : null;
|
|
313
|
+
const p = plan({ platform, home, env, node, bin, repo, login: !flags.has('no-login'), remoteControl });
|
|
210
314
|
if (p.refused) { say(`✗ ${p.refused}`); return 1; }
|
|
211
315
|
// Never write over a file of the same name that the launcher did not write.
|
|
212
316
|
const foreign = p.files.filter((f) => fs.existsSync(f.path) && !marked(f.path));
|
|
@@ -216,6 +320,10 @@ function run(argv, { say = console.log, platform = process.platform, home = os.h
|
|
|
216
320
|
catch (e) { say(`✗ not written: ${e.message}`); return 1; }
|
|
217
321
|
}
|
|
218
322
|
fs.mkdirSync(stateRoot.defaultRoot({ env, platform, home }), { recursive: true });
|
|
323
|
+
// A keeper whose script changes (another profile, another repository) restarts its tmux session below.
|
|
324
|
+
const rcFile = p.files.find((f) => f.role === 'app' && f.path.endsWith('pmos-remote-control'));
|
|
325
|
+
let rcChanged = false;
|
|
326
|
+
if (rcFile) { try { rcChanged = readSource(rcFile.path) !== rcFile.content; } catch { rcChanged = false; } }
|
|
219
327
|
for (const f of p.files) {
|
|
220
328
|
fs.mkdirSync(path.dirname(f.path), { recursive: true });
|
|
221
329
|
// WSH requires a UTF-16 BOM for paths containing non-ASCII characters.
|
|
@@ -231,9 +339,27 @@ function run(argv, { say = console.log, platform = process.platform, home = os.h
|
|
|
231
339
|
say(` ${p.app}`);
|
|
232
340
|
say(platform === 'darwin' ? ' Open it from Spotlight or Launchpad, or drag it to the Dock.' : platform === 'win32' ? ' Open Start and choose PMOS.' : ' Open it from the app menu.');
|
|
233
341
|
if (p.login) {
|
|
234
|
-
say('✓ login item: the workspace server starts when you log in,
|
|
342
|
+
say('✓ login item: the workspace server starts when you log in, and starts again within a minute if it stops');
|
|
235
343
|
say(` ${p.login}`);
|
|
236
344
|
} else say(' no login item (--no-login): the server starts when you open the app');
|
|
345
|
+
if (profile) {
|
|
346
|
+
if (preferProfile(stateRoot.defaultRoot({ env, platform, home }), profile.id)) say(`✓ Claude profile: the workspace's Claude work now runs as ${profile.id}`);
|
|
347
|
+
else say(`✓ Claude profile: ${profile.id} (already chosen)`);
|
|
348
|
+
if (profile.skipped.length) say(` only CLAUDE_CONFIG_DIR is used here; ${profile.skipped.join(', ')} from the profile is not written to any file`);
|
|
349
|
+
}
|
|
350
|
+
if (p.remoteControl) {
|
|
351
|
+
say(`✓ Remote Control: \`claude remote-control\`${profile ? ` as ${profile.id}` : ''} runs in tmux session ${RC_SESSION}, and starts again within a minute if it stops`);
|
|
352
|
+
say(` ${p.remoteControl}`);
|
|
353
|
+
say(` To see it: tmux attach -t ${RC_SESSION} (leave it with Ctrl-b d)`);
|
|
354
|
+
}
|
|
355
|
+
if (platform === 'darwin') {
|
|
356
|
+
for (const [label, file] of p.agents) {
|
|
357
|
+
if (!fs.existsSync(file) || !p.files.some((f) => f.path === file)) continue;
|
|
358
|
+
if (label === RC_LABEL && rcChanged) launchctl(label, file, 'unload');
|
|
359
|
+
const r = launchctl(label, file, 'load');
|
|
360
|
+
if (!r.ok) say(`· ${label} starts at the next login (launchctl: ${r.error})`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
237
363
|
say(' The app opens the browser on the running workspace and starts the server when none runs.');
|
|
238
364
|
say(' If you move or upgrade node, run `pmos launcher on` again.');
|
|
239
365
|
return 0;
|
|
@@ -244,6 +370,7 @@ function run(argv, { say = console.log, platform = process.platform, home = os.h
|
|
|
244
370
|
|
|
245
371
|
if (sub === 'off') {
|
|
246
372
|
let removed = 0;
|
|
373
|
+
if (platform === 'darwin' && p.agents) for (const [label, file] of p.agents) if (fs.existsSync(file) && marked(file)) launchctl(label, file, 'unload');
|
|
247
374
|
if (p.shortcut && fs.existsSync(p.shortcut.path)) {
|
|
248
375
|
try { manageShortcut(p.shortcut, 'remove'); say(`✓ removed ${p.shortcut.path}`); removed++; }
|
|
249
376
|
catch (e) { say(`· left ${p.shortcut.path}: ${e.message}`); }
|
|
@@ -276,7 +403,14 @@ function run(argv, { say = console.log, platform = process.platform, home = os.h
|
|
|
276
403
|
say(` node: ${t.node}${fs.existsSync(t.node) ? '' : ' ✗ not found — run `pmos launcher on` again'}`);
|
|
277
404
|
say(` pmos: ${t.bin}${fs.existsSync(t.bin) ? '' : ' ✗ not found — run `pmos launcher on` again'}`);
|
|
278
405
|
say(login ? `✓ login item — ${loginPath}` : '○ no login item: the server starts when you open the app');
|
|
279
|
-
|
|
406
|
+
// A macOS login item from before the minute check runs once at login only. Exit 1, so setup writes it again.
|
|
407
|
+
const oldLogin = login && platform === 'darwin' && !readSource(loginPath).includes('<string>--keep</string>');
|
|
408
|
+
if (oldLogin) say('✗ the login item starts the server at login only — run `pmos launcher on` again so it restarts a stopped server');
|
|
409
|
+
if (p.remoteControl === null && p.agents) {
|
|
410
|
+
const rc = p.agents.find(([l]) => l === RC_LABEL)[1];
|
|
411
|
+
if (fs.existsSync(rc) && marked(rc)) say(`✓ Remote Control keeper — ${rc} (tmux attach -t ${RC_SESSION})`);
|
|
412
|
+
}
|
|
413
|
+
return [t.repo, t.node, t.bin].every((x) => fs.existsSync(x)) && !oldLogin ? 0 : 1;
|
|
280
414
|
}
|
|
281
415
|
|
|
282
|
-
module.exports = { run, plan, readTarget, COMMANDS, USAGE, MARK };
|
|
416
|
+
module.exports = { run, plan, readTarget, resolveProfile, preferProfile, COMMANDS, USAGE, MARK, RC_SESSION };
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* GET /api/artefacts?ws&scope → { ok, ws, scope, kind, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
|
|
5
5
|
* scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
|
|
6
6
|
* GET /api/artefacts/map → { ok, artefacts, rows: [{ from, name, artefact, field, note }] } what every older shape became
|
|
7
|
+
* POST /api/artefacts/set { ws, scope, artefact, field, text } → { ok, line } the PM edits one line from the Viewer (board AwB: "You edit
|
|
8
|
+
* any line"). A page press (pm-guard requirePagePress); the actor is the PM, so Claude asks before it
|
|
9
|
+
* changes that line again (lib/artefacts.js pmEdited, lib/driver-decide.js autoApply).
|
|
7
10
|
*
|
|
8
11
|
* THE MIGRATION. Every read of a repository carries its older records (core documents, kept driver proposals,
|
|
9
12
|
* report drafts) under their artefacts: lib/artefacts.js migrateRepo. It is idempotent and only appends pointers; nothing is deleted or
|
|
@@ -24,8 +27,22 @@ const pageBy = (x) => (x && x.by ? { ...x, by: actorLib.pageName(x.by) } : x);
|
|
|
24
27
|
|
|
25
28
|
async function handle(req, res, url, ctx) {
|
|
26
29
|
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
27
|
-
if (req.method !== 'GET') return send(405, { ok: false, error: 'the artefacts are read here; agents write them through the driver' });
|
|
28
30
|
const sub = url.pathname.replace(/^\/api\/artefacts\/?/, '');
|
|
31
|
+
if (sub === 'set' && req.method === 'POST') {
|
|
32
|
+
const read = await ctx.readJson(req);
|
|
33
|
+
if (!read.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
34
|
+
const b = read.body || {};
|
|
35
|
+
const g = require('./pm-guard.js').requirePagePress(req, b);
|
|
36
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
37
|
+
if (!/^pm:/.test(String((g.actor && g.actor.by) || ''))) return send(403, { ok: false, error: 'the Viewer edits a line for the PM; agents propose through the driver' });
|
|
38
|
+
const w = wsOf(ctx, typeof b.ws === 'string' ? b.ws : '');
|
|
39
|
+
if (!w || !w.root) return send(404, { ok: false, error: 'no such workspace' });
|
|
40
|
+
let dir;
|
|
41
|
+
try { dir = A.dirOf(w.root); } catch (e) { return send(409, { ok: false, error: String((e && e.message) || e) }); }
|
|
42
|
+
const r = A.set(A.file(dir), { scope: b.scope, artefact: b.artefact, field: b.field, text: typeof b.text === 'string' ? b.text : '' }, g.actor);
|
|
43
|
+
return r.ok ? send(200, { ok: true, line: pageBy(r.line) }) : send(r.status, { ok: false, error: r.error });
|
|
44
|
+
}
|
|
45
|
+
if (req.method !== 'GET') return send(405, { ok: false, error: 'the artefacts are read here; the PM edits a line with POST /api/artefacts/set' });
|
|
29
46
|
if (sub === 'map') return send(200, { ok: true, artefacts: A.KEYS, rows: require('./artefacts-cli.js').mapRows() });
|
|
30
47
|
if (sub) return send(404, { ok: false, error: 'no such artefacts route' });
|
|
31
48
|
const q = url.searchParams;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-autonomy.js — what agents did by themselves, and its Undo (D106, "Full autonomy now").
|
|
3
3
|
*
|
|
4
|
-
* GET /api/autonomy?ws → { ok, ws, done: [change], notices: [demotion] }
|
|
5
|
-
* change: { ref, job, title, cls, at, undo_until } the changes agents applied by themselves in the last 14 days that
|
|
6
|
-
* newest first: the Done group
|
|
4
|
+
* GET /api/autonomy?ws → { ok, ws, done: [change], notices: [demotion], failed: [run] }
|
|
5
|
+
* change: { ref, job, title, cls, at, undo_until, ini, reason } the changes agents applied by themselves in the last 14 days that
|
|
6
|
+
* nobody undid, newest first: the Done group ("Claude did" on Your day, "Claude's work" in the Viewer; agent-run workspace, boards
|
|
7
|
+
* AwA and AwB). title is said as an act ("Wrote the problem: …"); reason is lib/autonomy.js reasonOf, one line.
|
|
8
|
+
* notices: the jobs that fell back to propose and Home has not said so yet (say it once).
|
|
9
|
+
* failed: the agent runs of the last 7 days that ended with an error and that no later run of the same target answered:
|
|
10
|
+
* { run, ini, at, why, source: 'driver' | 'team' }, newest first. Requirement R4: a failure is never the PM's work; it is one amber
|
|
11
|
+
* line where the work is.
|
|
7
12
|
* POST /api/autonomy/undo { ws, ref } → { ok, back, demoted? } Undo of one change: a Driver proposal (p-…) or a ✦ batch (pk-…)
|
|
8
13
|
* POST /api/autonomy/seen { ws, job, product, until } → { ok } Home said the demotion once
|
|
9
14
|
*
|
|
@@ -59,19 +64,62 @@ async function undoRef(ctx, w, ref, g) {
|
|
|
59
64
|
return bad(400, 'ref is a Driver proposal id (p-…) or a ✦ batch id (pk-…)');
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
/* the Driver's kinds said as an act: "problem: Scarlet tickets lack…" reads "Wrote the problem: Scarlet tickets lack…" */
|
|
68
|
+
const ACT = { problem: 'Wrote the problem', evidence: 'Added evidence', sizing: 'Sized it', assumption: 'Wrote an assumption', stakeholders: 'Named the people',
|
|
69
|
+
move: 'Moved it', note: 'Added a note', doc: 'Drafted a document', overlap: 'Noted an overlap', artefact: 'Wrote the experiment', 'next-step': 'Set the next step', 'follow-up': 'Set a follow-up' };
|
|
70
|
+
function sayOf(a) {
|
|
71
|
+
const m = /^driver:([a-z-]+)$/.exec(String(a.job || ''));
|
|
72
|
+
const t = String(a.title || '').trim();
|
|
73
|
+
if (!m || !ACT[m[1]]) return t;
|
|
74
|
+
const rest = t.startsWith(m[1] + ': ') ? t.slice(m[1].length + 2) : t;
|
|
75
|
+
return rest ? ACT[m[1]] + ': ' + rest : ACT[m[1]];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The runs that stopped (R4): the Driver's runs (run-end ok false) and the role agents' steps (state failed) of the last `days` days whose
|
|
79
|
+
* target no later run answered. Never throws: an unreadable ledger is no failure to show. */
|
|
80
|
+
function failedOf(w, dirs, { now = Date.now(), days = 7 } = {}) {
|
|
81
|
+
const since = now - days * DAY, out = [];
|
|
82
|
+
try {
|
|
83
|
+
const stateDir = D.stateDirOf(w.root);
|
|
84
|
+
const file = stateDir ? D.ledgerFile(stateDir) : null;
|
|
85
|
+
if (file) {
|
|
86
|
+
const runs = [...D.fold(D.readLines(file)).runs.values()].filter((r) => r.end && r.target);
|
|
87
|
+
const lastOk = new Map();
|
|
88
|
+
for (const r of runs) if (r.ok) { const k = r.target.id; if (!lastOk.has(k) || r.end > lastOk.get(k)) lastOk.set(k, r.end); }
|
|
89
|
+
for (const r of runs) {
|
|
90
|
+
if (r.ok || Date.parse(r.end) < since) continue;
|
|
91
|
+
if (lastOk.has(r.target.id) && lastOk.get(r.target.id) > r.end) continue;
|
|
92
|
+
out.push({ run: r.run, ini: r.target.kind === 'initiative' ? r.target.id : null, at: r.end, why: r.reason || '', source: 'driver' });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch { /* no driver ledger */ }
|
|
96
|
+
try {
|
|
97
|
+
const TR = require('./team-runs.js');
|
|
98
|
+
for (const d of dirs) {
|
|
99
|
+
const steps = TR.fold(TR.read(d)).steps;
|
|
100
|
+
for (const s of steps) {
|
|
101
|
+
if (s.state !== 'failed' || Date.parse(s.at) < since) continue;
|
|
102
|
+
if (steps.some((x) => x.state === 'done' && x.ini === s.ini && x.role === s.role && String(x.at) > String(s.at))) continue;
|
|
103
|
+
out.push({ run: s.id, ini: s.ini || null, at: s.at, why: s.why || '', source: 'team' });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch { /* no team ledger */ }
|
|
107
|
+
return out.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
108
|
+
}
|
|
109
|
+
|
|
62
110
|
async function handle(req, res, url, ctx) {
|
|
63
111
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
64
112
|
const sub = url.pathname.replace(/^\/api\/autonomy\/?/, '');
|
|
65
113
|
if (sub === '' && req.method === 'GET') {
|
|
66
114
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
67
115
|
if (!w) return send(bad(404, 'no such workspace'));
|
|
68
|
-
const done = [], notices = [];
|
|
69
|
-
for (const d of
|
|
70
|
-
for (const a of A.done(d)) done.push({ ref: a.ref, job: a.job, title: a
|
|
116
|
+
const done = [], notices = [], dirs = dirsOf(ctx, w);
|
|
117
|
+
for (const d of dirs) {
|
|
118
|
+
for (const a of A.done(d)) done.push({ ref: a.ref, job: a.job, title: sayOf(a), cls: a.cls, at: a.at, undo_until: new Date(Date.parse(a.at) + A.UNDO_DAYS * DAY).toISOString(), ini: a.ini || null, reason: a.reason });
|
|
71
119
|
for (const n of A.notices(d)) notices.push(n);
|
|
72
120
|
}
|
|
73
121
|
done.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
74
|
-
return send({ status: 200, body: { ok: true, ws: w.id, done, notices } });
|
|
122
|
+
return send({ status: 200, body: { ok: true, ws: w.id, done, notices, failed: failedOf(w, dirs) } });
|
|
75
123
|
}
|
|
76
124
|
if (sub !== 'undo' && sub !== 'seen') return send(bad(404, 'no such autonomy route'));
|
|
77
125
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
@@ -92,4 +140,4 @@ async function handle(req, res, url, ctx) {
|
|
|
92
140
|
return send({ status: 200, body: { ok: true } });
|
|
93
141
|
}
|
|
94
142
|
|
|
95
|
-
module.exports = { prefixes: ['/api/autonomy'], handle, undoRef };
|
|
143
|
+
module.exports = { prefixes: ['/api/autonomy'], handle, undoRef, failedOf, sayOf };
|
|
@@ -154,7 +154,7 @@ function autoKeep(ctx, w, { modeOf = () => 'auto', now } = {}) {
|
|
|
154
154
|
if (!d.apply) { out.held++; continue; }
|
|
155
155
|
try {
|
|
156
156
|
const r = keepCore(ctx, p, g, f, ini, [x], {}, { auto: true, group: x.group });
|
|
157
|
-
A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls }, { now });
|
|
157
|
+
A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls, ini, why: x.title && x.why && x.why !== x.title ? x.why : '' }, { now });
|
|
158
158
|
out.applied.push({ ini, batch: r.batch, group: x.group, title: x.title || x.why || '' });
|
|
159
159
|
} catch { out.held++; }
|
|
160
160
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.548.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.548.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -652,6 +652,13 @@ body.cz-home .hm-hd.hv-bar > .hv-hi { flex: 1 0 auto; max-width: 100%; }
|
|
|
652
652
|
.gm-more { display: flex; flex-wrap: wrap; gap: 4px 18px; padding-top: 8px; }
|
|
653
653
|
.gm-more button { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; border: 0; background: none; padding: 0; font: inherit; font-size: var(--fs-body); color: var(--cz-ink2); cursor: pointer; }
|
|
654
654
|
.gm-more b { color: var(--cz-ink); font-weight: var(--fw-strong); }
|
|
655
|
+
/* agent-run (AwA, AwAPhone): each call says its kind; Claude did lists each change with its reason and Undo; a run that stopped is one amber line */
|
|
656
|
+
.gm-rt .gm-k2 { color: var(--cz-ink2); font-weight: var(--fw-strong); }
|
|
657
|
+
.gm-didl { margin-top: 18px; }
|
|
658
|
+
.gm-r .gm-undo { flex: none; margin-top: 4px; }
|
|
659
|
+
.gm-fail { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0 2px; padding: 10px 12px; border-radius: 14px; background: var(--cz-latebg); color: var(--cz-late); font-size: var(--fs-label); line-height: 1.45; }
|
|
660
|
+
.gm-fail svg { flex: none; margin-top: 2px; }
|
|
661
|
+
.gm-fail b { font-weight: var(--fw-strong); }
|
|
655
662
|
/* Since yesterday: neutral dots; orange only for a real rise */
|
|
656
663
|
.gm-sl { display: flex; flex-direction: column; }
|
|
657
664
|
.gm-si { display: flex; align-items: baseline; gap: 10px; min-height: 44px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--cz-hair); background: none; text-align: left; font: inherit; font-size: var(--fs-body); color: var(--cz-ink); cursor: pointer; line-height: 1.4; }
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
* morning (zero is silence); past items fade and their notes fold under them. After 17:00 (G3) the strip says how the quarter moved since
|
|
20
20
|
* the morning, "Today made possible" lists what the day moved, "Still yours" what is left, and the rail turns to tomorrow.
|
|
21
21
|
*
|
|
22
|
+
* AGENT-RUN (agreed 2026-11-10, boards AwA and AwAPhone on the main canvas, In development; requirements R1, R2, R4). Your move holds only
|
|
23
|
+
* the calls that always wait for the PM (callKindOf: a verdict, a new request or decision, a message to people, a move the team reads, a
|
|
24
|
+
* merge, a delete or spend), each with its kind and why, in W3's order; at most 5 show and the rest fold under one line. Can wait is gone:
|
|
25
|
+
* Claude acts on the rest. "Claude did" lists what Claude finished by itself (GET /api/autonomy done), each with its one-line reason and
|
|
26
|
+
* Undo (14 days); a run that stopped is one amber line there, never a row of Your move. The lead says it straight: "N calls are yours. I
|
|
27
|
+
* did the other M." Your call is no longer a section of its own: it is a row of Your move (say it once).
|
|
28
|
+
*
|
|
22
29
|
* PROVEN ONLY. The quarter's goal states, the PM's line, the morning's snapshot, a row's goal tag and what Yes does to a goal come from the
|
|
23
30
|
* Good morning goal data (GM1), passed in o.quarter, o.tags and the call's effect. Each part that is missing is left out: no goals, no strip;
|
|
24
31
|
* no line, no tick and the verdict counts only; no morning snapshot, no "up from"; no effect, no goal clause. Nothing is guessed.
|
|
@@ -196,6 +203,26 @@ export function notesOf(rows, now, o = {}) {
|
|
|
196
203
|
});
|
|
197
204
|
}
|
|
198
205
|
|
|
206
|
+
/** The kind of a ranked row that always waits for the PM (the six kinds of requirement R2, as the rows of W3 name them), or null: Claude
|
|
207
|
+
* acts on that row by itself. A call that is not a message is the PM's decision, a blocked one says so. Pure. */
|
|
208
|
+
export function callKindOf(r) {
|
|
209
|
+
if (!r) return null;
|
|
210
|
+
if (r.kind === 'verdict') return 'Verdict';
|
|
211
|
+
if (r.kind === 'mention' || r.kind === 'outbox') return 'Message';
|
|
212
|
+
if (r.kind === 'meeting') return 'Move the team reads';
|
|
213
|
+
if (r.kind !== 'call' || !r.call) return null;
|
|
214
|
+
const c = r.call, t = String(c.name || '') + ' ' + String((c.row && c.row.title) || '');
|
|
215
|
+
if (c.kind === 'update') return 'Message';
|
|
216
|
+
if (/\b(intake|new request|request)\b/i.test(t)) return 'New request';
|
|
217
|
+
if (/\b(merge|pull request)\b/i.test(t)) return 'Merge';
|
|
218
|
+
if (/\b(delete|spend|budget)\b/i.test(t)) return 'Delete or spend';
|
|
219
|
+
if (c.state === 'blocked') return 'Blocked';
|
|
220
|
+
return 'Your call';
|
|
221
|
+
}
|
|
222
|
+
/** At most this many of the PM's calls show; the rest fold under one line ("N more of your calls"). */
|
|
223
|
+
export const MOVE_CAP = 5;
|
|
224
|
+
const SINCE_MS = 24 * 3600e3;
|
|
225
|
+
|
|
199
226
|
/** The page's model. Y: dayModel's answer (Y.rank from W3); D: Home's data; o: { quarter, tags, notes, picks, today: meetings }. */
|
|
200
227
|
export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
201
228
|
D = D || {};
|
|
@@ -214,10 +241,20 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
214
241
|
why: [meet ? 'Yes puts it on the ' + hm(meet.start) + ' agenda.' : '', fx ? fx.goal + ' moves from ' + WORD[fx.from] + ' to ' + WORD[fx.to] + '.' : ''].filter(Boolean).join(' ')
|
|
215
242
|
|| (c.pick ? 'I’d ' + c.pick.charAt(0).toLowerCase() + c.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : c.when ? 'Goes out ' + c.when + '.' : c.sub || '') } : null;
|
|
216
243
|
|
|
217
|
-
// Your move: the
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
const
|
|
244
|
+
// Your move (agent-run, AwA): only the calls that always wait for the PM, in W3's order (its Can wait included: a call is never "can
|
|
245
|
+
// wait"), each with its kind and why; the rest of W3's list is Claude's to do. With no ranked list, the calls Your day holds.
|
|
246
|
+
const all = Y.rank ? [...Y.rank.rows, ...(Y.rank.wait || [])] : (Y.calls || []).map((x) => ({ key: 'call:' + x.id, kind: 'call', call: x, title: x.name, sub: '', age: '' }));
|
|
247
|
+
const callWhy = (x) => (c && x.id === c.id && call && call.why) || (x.pick ? 'I’d ' + x.pick.charAt(0).toLowerCase() + x.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : x.when ? 'Goes out ' + x.when + '.' : x.sub || x.hint || '');
|
|
248
|
+
const mine = all.map((r) => ({ r, k: callKindOf(r) })).filter((x) => x.k)
|
|
249
|
+
.map(({ r, k }) => ({ ...r, callKind: k, sub: r.kind === 'call' ? callWhy(r.call) : r.sub, goal: tagOf(o.tags, r.ws, r.ini), late: r.days != null && r.days > 0 }));
|
|
250
|
+
const move = mine.slice(0, MOVE_CAP), more = mine.length - move.length;
|
|
251
|
+
// Claude did (AwA): what Claude finished by itself, newest first, each with its reason and Undo; a run that stopped is one amber line
|
|
252
|
+
const R = Y.rank || {}, recent = (x) => { const t = Date.parse(x.at || ''); return Number.isFinite(t) && now - t <= SINCE_MS; };
|
|
253
|
+
const did = (R.done || []).map((d) => ({ ...d, title: d.via === 'proposals' && d.name ? d.name + ': ' + (d.said || 'done') : d.said || 'done',
|
|
254
|
+
why: d.reason || 'Done by itself. You can undo it for 14 days.' }));
|
|
255
|
+
const didN = did.filter(recent).length;
|
|
256
|
+
const fl = (R.failed || []).filter(recent);
|
|
257
|
+
const failed = fl.length ? { n: fl.length, names: [...new Set(fl.map((x) => x.name).filter(Boolean))], why: fl[0].why || '' } : null;
|
|
221
258
|
|
|
222
259
|
// the lead: honest first; a call that moves a goal ties today to the quarter; else Your day's own line. A failed source is one quiet line
|
|
223
260
|
// under the lead, never the lead itself (G1, G3), and the face is never happier than the data
|
|
@@ -235,6 +272,13 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
235
272
|
// the header already greets: the lead never says "Morning, Wawan." again (say it once); a festival's wish stays
|
|
236
273
|
const g = /^(?:Morning|Afternoon|Evening)(?:, [^.]+)?\.\s*/;
|
|
237
274
|
if (g.test(line)) { line = line.replace(g, ''); if (!line) { line = sub || ''; sub = ''; } }
|
|
275
|
+
// the straight answer (AwA): how many calls are the PM's and how much Claude did since yesterday; Your day's own line when nothing is read
|
|
276
|
+
if (state !== 'soon' && B.mood !== 'concerned' && Y.rank && (mine.length || didN)) {
|
|
277
|
+
const n = mine.length, yours = n === 1 ? '1 call is yours.' : n + ' calls are yours.', prev = line;
|
|
278
|
+
const wish = /^Happy [^.]+\./.exec(prev); // a festival's wish stays first (AsPlaces); the straight answer follows it
|
|
279
|
+
line = (wish ? wish[0] + ' ' : '') + (n && didN ? 'Straight answer: ' + yours + ' I did the other ' + didN + '.' : n ? 'Straight answer: ' + yours : 'Straight answer: nothing needs you. I did ' + plural(didN, 'thing', 'things') + '.');
|
|
280
|
+
sub = didN ? 'Each one says why. You can undo any of them for 14 days.' : prev || sub; // Your day's own line (or the gap line) follows
|
|
281
|
+
}
|
|
238
282
|
const lead = { ...Y, mood: B.mood, face: B === Y ? Y.face : B.mood, failLead: false, line, sub, did: Y.chips.length ? 'Done for you: ' + Y.chips.join(', ') : '' };
|
|
239
283
|
|
|
240
284
|
// the next meeting's prep card (G2): what to agree, its bullets, Record as an icon
|
|
@@ -267,7 +311,7 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
267
311
|
|
|
268
312
|
// Since yesterday: up to 3 of New for you, neutral dots; orange only for a real rise (an item that says so)
|
|
269
313
|
const since = state === 'soon' ? [] : (Y.news || []).slice(0, 3); // the hour before a meeting shows no Since yesterday at all (G2)
|
|
270
|
-
return { state, date, hello, quarter, lead, call, move, more, made, prep, rail, notes, since, newsN: state === 'soon' ? 0 : (Y.news || []).length + (Y.digests || 0),
|
|
314
|
+
return { state, date, hello, quarter, lead, call, move, more, rest: mine.slice(MOVE_CAP), did, didN, failed, made, prep, rail, notes, since, newsN: state === 'soon' ? 0 : (Y.news || []).length + (Y.digests || 0),
|
|
271
315
|
drafts: Y.drafts.length, wait: Y.wait.length, concerned: B.mood === 'concerned', confirm: state === 'evening' && rc && rc.to_confirm > 0 ? rc.to_confirm : 0 };
|
|
272
316
|
}
|
|
273
317
|
|
|
@@ -289,10 +333,23 @@ function quarterHtml(Q) {
|
|
|
289
333
|
function rowHtml(r) {
|
|
290
334
|
const yes = r.yes ? `<button type="button" class="gm-tc" data-yd="mv-yes" data-key="${esc(r.key)}" aria-label="${esc(r.yes + ': ' + r.title)}" title="${esc(r.yes)}"></button>`
|
|
291
335
|
: r.kind === 'call' ? `<button type="button" class="gm-tc" data-yd="mv-open" data-key="${esc(r.key)}" aria-label="${esc('Open: ' + r.title)}" title="Open"></button>` : '<span class="gm-tc no" aria-hidden="true"></span>';
|
|
292
|
-
const tag = r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` :
|
|
336
|
+
const tag = r.callKind ? `<em><span class="gm-k2">${esc(r.callKind)}</span>${r.sub ? ' · ' + esc(r.sub) : ''}</em>${r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` : ''}`
|
|
337
|
+
: r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` : r.sub ? `<em>${esc(r.sub)}</em>` : '';
|
|
293
338
|
return `<div class="gm-r" data-key="${esc(r.key)}"${r.kind === 'call' && r.call ? ` data-id="${esc(r.call.id)}"` : ''}>${yes}<button type="button" class="gm-rt" data-yd="mv-open" data-key="${esc(r.key)}"><b>${esc(r.title)}</b>${tag}</button>${r.age ? `<span class="gm-due${r.late ? ' late' : ''}">${esc(r.age)}</span>` : ''}</div>`;
|
|
294
339
|
}
|
|
295
340
|
const doneHtml = (r) => `<div class="gm-r done"><span class="gm-tc dn" aria-hidden="true">${svg(CHECK, 13, 2.6)}</span><span class="gm-rt"><b>${esc(r.title)}</b>${r.goal ? `<span class="gm-gt"><i class="d-o"></i>${esc(r.goal)}</span>` : r.sub ? `<em>${esc(r.sub)}</em>` : ''}</span></div>`;
|
|
341
|
+
const UNDO = 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', WARN = 'M12 8v5M12 16.5v.01M10.3 3.9L2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z';
|
|
342
|
+
/** One change Claude made by itself (AwA): ✓, what it did, its one-line reason, and Undo as an icon. Your day's Done fold draws it too. */
|
|
343
|
+
export function didRowHtml(d) {
|
|
344
|
+
return `<div class="gm-r done" data-ref="${esc(d.ref)}"><span class="gm-tc dn" aria-hidden="true">${svg(CHECK, 13, 2.6)}</span><span class="gm-rt"><b>${esc(d.title)}</b>${d.why ? `<em>${esc(d.why)}</em>` : ''}</span>`
|
|
345
|
+
+ `<button type="button" class="yd-alt sm gm-undo" data-yd="done-undo" data-ref="${esc(d.ref)}" data-via="${esc(d.via || 'proposals')}" data-ws="${esc(d.ws || '')}" data-board="${esc(d.board || '')}" aria-label="${esc('Undo: ' + d.title)}" title="Undo">${svg(UNDO, 16, 2)}</button></div>`;
|
|
346
|
+
}
|
|
347
|
+
/** A run that stopped, said once as one amber line (R4): never a row of Your move. */
|
|
348
|
+
export function failHtml(F) {
|
|
349
|
+
if (!F) return '';
|
|
350
|
+
const who = F.names.length === 1 ? F.names[0] + ' ' : '';
|
|
351
|
+
return `<div class="gm-fail" role="status">${svg(WARN, 14, 2)}<span><b>${esc(plural(F.n, who + 'run', who + 'runs') + ' stopped.')}</b>${F.why ? ' ' + esc(String(F.why).replace(/\.?$/, '.')) : ''} I run ${F.n === 1 ? 'it' : 'them'} again on the next wake. Nothing ${F.n === 1 ? 'it' : 'they'} made was kept.</span></div>`;
|
|
352
|
+
}
|
|
296
353
|
function agendaHtml(rows) {
|
|
297
354
|
return rows.map((x) => {
|
|
298
355
|
if (x.kind === 'allday') return `<div class="gm-ar"><span class="gm-tm">All day</span><div class="gm-ad">${esc(x.title)}</div></div>`;
|
|
@@ -317,19 +374,20 @@ export function gmHtml(G, openHtml, o = {}) {
|
|
|
317
374
|
a += `<section class="gm-prep"><span class="gm-k">${esc(P.k)}</span>${P.head ? `<h2>${esc(P.head)}</h2>` : ''}${P.bullets.length ? `<ul>${P.bullets.map((b) => `<li>${esc(b)}</li>`).join('')}</ul>` : ''}`
|
|
318
375
|
+ `<div class="gm-pr"><button type="button" class="gm-rec" data-yd="gm-rec" data-id="${esc(P.meeting.id || '')}" aria-label="Record this meeting" title="Record">${svg(MIC, 18, 2)}</button>${P.files ? `<em>${esc(P.files)}</em>` : ''}</div></section>`;
|
|
319
376
|
}
|
|
320
|
-
|
|
321
|
-
a += `<section class="gm-sec"><h3 class="gm-sh">Your call</h3><div class="gm-call yd-call${G.call.blocked ? ' am' : ''}" data-id="${esc(G.call.id)}"><div><b>${esc(G.call.name)}</b>${G.call.why ? `<em>${esc(G.call.why)}</em>` : ''}</div>`
|
|
322
|
-
+ `<button type="button" class="yd-alt" data-yd="sel" aria-label="${esc('Open: ' + G.call.name)}" title="Open">${svg(CHEV, 18, 2)}</button></div></section>`;
|
|
323
|
-
}
|
|
377
|
+
// Your call is a row of Your move now (AwA: say it once); its why rides on that row
|
|
324
378
|
// a decision caught in today's notes counts only once the PM confirms it (GET /api/phone-day recap.to_confirm): until then it is one quiet line
|
|
325
379
|
const conf = G.confirm ? `<div class="gm-more"><button type="button" data-yd="gm-notes"><b>${G.confirm}</b> ${G.confirm === 1 ? 'decision' : 'decisions'} from today’s notes to confirm${svg(CHEV, 14, 2)}</button></div>` : '';
|
|
326
380
|
if (G.made.length) a += `<section class="gm-sec"><h3 class="gm-sh">Today made possible</h3>${G.made.map(doneHtml).join('')}${conf}</section>`;
|
|
327
381
|
else a += conf;
|
|
328
|
-
const quiet = [G.more > 0
|
|
329
|
-
G.drafts ? `<button type="button" data-yd="gm-fold" data-fold="drafts"><b>${G.drafts}</b> drafted for you${svg(CHEV, 14, 2)}</button>` : ''
|
|
330
|
-
|
|
331
|
-
if (G.move.length) a += `<section class="gm-sec gm-move"><h3 class="gm-sh">${G.state === 'evening' ? 'Still yours' : 'Your move'} <span class="gm-n">${
|
|
382
|
+
const quiet = [G.more > 0 ? `<button type="button" data-yd="gm-fold" data-fold="more"><b>${G.more}</b> more ${G.more === 1 ? 'call' : 'calls'} of yours${svg(CHEV, 14, 2)}</button>` : '',
|
|
383
|
+
G.drafts ? `<button type="button" data-yd="gm-fold" data-fold="drafts"><b>${G.drafts}</b> drafted for you${svg(CHEV, 14, 2)}</button>` : ''].filter(Boolean).join('');
|
|
384
|
+
const nMine = G.move.length + (G.more || 0);
|
|
385
|
+
if (G.move.length) a += `<section class="gm-sec gm-move"><h3 class="gm-sh">${G.state === 'evening' ? 'Still yours' : 'Your move'} <span class="gm-n">${nMine}</span></h3>${G.move.map(rowHtml).join('')}${quiet ? `<div class="gm-more">${quiet}</div>` : ''}</section>`;
|
|
332
386
|
else if (quiet) a += `<div class="gm-more">${quiet}</div>`;
|
|
387
|
+
// Claude did (AwA): the amber line of a run that stopped, then the newest changes with their reasons and Undo; the rest fold
|
|
388
|
+
const dl = (G.did || []).slice(0, MOVE_CAP), dmore = (G.did || []).length - dl.length;
|
|
389
|
+
if (dl.length || G.failed) a += `<section class="gm-sec gm-didl"><h3 class="gm-sh">Claude did${G.didN ? ` <span class="gm-n">${G.didN} since yesterday</span>` : ''}</h3>${failHtml(G.failed)}${dl.map(didRowHtml).join('')}`
|
|
390
|
+
+ (dmore > 0 ? `<div class="gm-more"><button type="button" data-yd="gm-fold" data-fold="done"><b>${dmore}</b> more Claude did${svg(CHEV, 14, 2)}</button></div>` : '') + '</section>';
|
|
333
391
|
const b = G.since.length || G.newsN ? `<section class="gm-sec gm-since"><h3 class="gm-sh">Since yesterday${G.since.length ? `<button type="button" class="yd-all" data-yd="seen" aria-label="Mark all ${G.newsN} seen" title="Mark all seen">${svg(MARK2, 18, 1.9)}</button>` : ''}</h3>`
|
|
334
392
|
+ `<div class="gm-sl">${G.since.map((it) => `<button type="button" class="gm-si${it.rise ? ' hot' : ''}" data-yd="news" data-id="${esc(it.id)}"><i aria-hidden="true"></i><span>${esc(it.kind === 'task' ? String(it.title || '').replace(/^New task: /, '') : it.title)}</span>${it.at ? `<em>${esc(at(it.at))}</em>` : ''}</button>`).join('')}</div>`
|
|
335
393
|
+ `<button type="button" class="gm-lnk" data-yd="news-all">New for you · ${G.newsN}</button></section>` : '';
|