create-pmos 0.661.0 → 0.663.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 +15 -9
- 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/changelog.json +14 -8
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/cli.md +3 -0
- package/workspace/guide/routine.md +4 -5
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/design-critic.js +271 -0
- package/workspace/lib/idle-lab-engine.js +9 -4
- package/workspace/lib/lab-cli.js +48 -1
- package/workspace/lib/live-round.js +40 -5
- package/workspace/lib/routes-lab.js +31 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-routine-detail.js +99 -0
- package/workspace/public/pm/cozy-routine-model.js +2 -2
- package/workspace/public/pm/cozy-routine.css +64 -66
- package/workspace/public/pm/cozy-routine.js +127 -38
- package/workspace/public/premium-routine.html +16 -10
- package/workspace/server.js +2 -0
- package/workspace/test-lists/design-critic.json +7 -0
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
* each rule the chat's agent adds from a correction). A version that breaks one gets ONE fix run (fixPromptOf) given only the failed lines;
|
|
36
36
|
* then it is rendered and checked again. It opens either way: fixed ("PMOS fixed n things before showing you this"), or with the rule it
|
|
37
37
|
* still breaks, never hidden. A fix that breaks the render puts the draft back. The draft is kept next to it as <key>.draft.html.
|
|
38
|
+
* THE CRITIC (initiative design-critic-pass, bet 4 of the factory line). After the rules, a read-only critic run (lib/design-critic.js, deps.critic:
|
|
39
|
+
* the server's ask path) reads the version's desk and phone screenshots and its HTML against every standing design rule of the product, each
|
|
40
|
+
* a named check. Its findings join the same one fix run; after the fix it reads only the flagged checks again, so "fixed" is never claimed
|
|
41
|
+
* unchecked. A critic that cannot run never holds the version. PMOS_CRITIC=off, or no deps.critic, runs none.
|
|
38
42
|
* LESSONS. Every feedback sentence is a Lessons line of the experiment (lib/artefacts.js); ✓ and ✕ add theirs (lib/routes-proposals.js).
|
|
39
43
|
* The specimens a round made are Specimens lines; the one the PM keeps is its `kept` field.
|
|
40
44
|
*
|
|
@@ -62,6 +66,7 @@ const PR = require('./proposals.js');
|
|
|
62
66
|
const LAB = require('./idle-lab.js');
|
|
63
67
|
const E = require('./idle-lab-engine.js');
|
|
64
68
|
const RULES = require('./prototype-rules.js');
|
|
69
|
+
const CR = require('./design-critic.js');
|
|
65
70
|
const DS = require('./design-system.js');
|
|
66
71
|
|
|
67
72
|
const JOB = 'live-round';
|
|
@@ -315,7 +320,7 @@ function fixPromptOf({ file, dir, failed }) {
|
|
|
315
320
|
const L = ['You fix ONE prototype before the product manager sees it. It renders, but it breaks rules the PM set for every prototype. Be quick: no planning, no questions, no summary.',
|
|
316
321
|
'', `The prototype: ${file}. Read it, then overwrite it with the Write tool.`, '', 'The rules it breaks, each with the lines that broke it:'];
|
|
317
322
|
for (const f of failed || []) {
|
|
318
|
-
L.push(`- ${one(f.title, 80)}${f.words ? ' (the PM said: "' + one(f.words, 200) + '")' : ''}`);
|
|
323
|
+
L.push(`- ${one(f.title, 80)}${f.words ? (f.critic ? ' (the design rule: "' : ' (the PM said: "') + one(f.words, 200) + '")' : ''}`);
|
|
319
324
|
for (const l of f.lines || []) L.push(` > ${one(l, 160)}`);
|
|
320
325
|
}
|
|
321
326
|
L.push('', 'Change only what these lines need. Keep everything else as it is: the screens, their ids, every data-* attribute and copy key, the CSS and <meta name="pmos-changed">.',
|
|
@@ -530,15 +535,17 @@ function roundLine(R, now) {
|
|
|
530
535
|
/**
|
|
531
536
|
* deps: { runtimeDir() → folder, product(ws) → { w: { id, root }, dir } | null, info(ws, ini) → { title, board, description?, intent? } | null,
|
|
532
537
|
* spawn(spec) → session (server spawnSession: { name, agent, ws, origin, initialInput, initiative, writePaths, addDirs, onDone }),
|
|
533
|
-
* stop(session), render?(abs) → Promise<{ ok, w, h, why? }>, artefact?(dir, line) (lib/artefacts.js set, as agent:live-round),
|
|
538
|
+
* stop(session), render?(abs, { shots? }) → Promise<{ ok, w, h, why?, shots? }>, critic?(prompt, { key, addDirs }) → Promise<text | null>, artefact?(dir, line) (lib/artefacts.js set, as agent:live-round),
|
|
534
539
|
* ownRoot? (PMOS's own folder, for the scaffold), pollMs?, stallMs?, now?() , warn(what, e) }
|
|
535
540
|
*/
|
|
536
541
|
function create(deps) {
|
|
537
542
|
const warn = deps.warn || (() => {});
|
|
538
543
|
const now = () => (deps.now ? deps.now() : Date.now());
|
|
539
|
-
const render = deps.render || ((abs) => E.renderCheck(abs, { phone: true })); // proven at 390 px too: the viewport pin
|
|
544
|
+
const render = deps.render || ((abs, o = {}) => E.renderCheck(abs, { phone: true, ...o })); // proven at 390 px too: the viewport pin; o.shots: the critic's screenshots
|
|
540
545
|
// the PM's prototype rules (lib/prototype-rules.js), read for each version so an Undo in Settings counts at once
|
|
541
546
|
const rulesOf = deps.rules || (() => { try { return RULES.active(deps.runtimeDir ? deps.runtimeDir() : null); } catch (e) { warn('prototype rules', e); return []; } });
|
|
547
|
+
// the design critic (lib/design-critic.js, initiative design-critic-pass): deps.critic is the server's read-only ask path; none, no critic
|
|
548
|
+
const ask = typeof deps.critic === 'function' ? deps.critic : null;
|
|
542
549
|
const pollMs = deps.pollMs || 1000;
|
|
543
550
|
const rounds = new Map(); // id → round
|
|
544
551
|
|
|
@@ -684,7 +691,7 @@ function create(deps) {
|
|
|
684
691
|
let v;
|
|
685
692
|
if (!st || !st.isFile()) v = { ok: false, why: 'the run ended without writing its file' };
|
|
686
693
|
else if (st.size > 2e6) v = { ok: false, why: 'the file is over 2 MB' };
|
|
687
|
-
else { try { v = await render(s.abs); } catch (e) { v = { ok: false, why: 'it did not open: ' + one(e && e.message, 120) }; } }
|
|
694
|
+
else { try { v = await render(s.abs, { shots: shotsDir(R, s) }); } catch (e) { v = { ok: false, why: 'it did not open: ' + one(e && e.message, 120) }; } }
|
|
688
695
|
if (s.state !== 'proving') return; // stopped while it rendered (Undo, the budget)
|
|
689
696
|
const fx = s.fixing || null;
|
|
690
697
|
if ((!v || !v.ok) && fx && fx.draft) {
|
|
@@ -695,9 +702,21 @@ function create(deps) {
|
|
|
695
702
|
if (!v || !v.ok) { s.state = 'working'; return notMade(R, s, 'not proven: ' + ((v && v.why) || 'it did not render')); }
|
|
696
703
|
if (!fx) {
|
|
697
704
|
let failed = []; try { failed = RULES.run(fs.readFileSync(s.abs, 'utf8'), rulesOf()); } catch (e) { warn('prototype rules', e); failed = []; }
|
|
705
|
+
// then the critic: every standing design rule of the product as a named check; its findings join the one fix run
|
|
706
|
+
const crit = await critic(R, s, v);
|
|
707
|
+
if (s.state !== 'proving') return;
|
|
708
|
+
if (crit) failed = failed.concat(crit);
|
|
698
709
|
if (failed.length && fix(R, s, failed, v, cost)) return;
|
|
699
710
|
} else if (!fx.left) {
|
|
700
|
-
|
|
711
|
+
const plain = fx.failed.filter((f) => !f.critic), cf = fx.failed.filter((f) => f.critic);
|
|
712
|
+
try { fx.left = RULES.run(fs.readFileSync(s.abs, 'utf8'), plain.map((f) => rulesOf().find((r) => r.id === f.id)).filter(Boolean)); } catch (e) { warn('prototype rules', e); fx.left = plain; }
|
|
713
|
+
if (cf.length) {
|
|
714
|
+
// the critic reads only the checks it flagged; a fix is never counted as done unless it read the version again
|
|
715
|
+
const again = await critic(R, s, v, cf.map((f) => f.check));
|
|
716
|
+
if (s.state !== 'proving') return;
|
|
717
|
+
const still = again ? new Set(again.map((f) => f.check)) : null;
|
|
718
|
+
fx.left = fx.left.concat(still ? cf.filter((f) => still.has(f.check)) : cf);
|
|
719
|
+
}
|
|
701
720
|
}
|
|
702
721
|
const fd = s.fixing || null; // set by fix(), also when its run could not start
|
|
703
722
|
if (fd) {
|
|
@@ -717,6 +736,22 @@ function create(deps) {
|
|
|
717
736
|
if (deps.artefact && R.slots.length === 1 && R.from !== 'cli') try { deps.artefact(R.dir, { scope: 'experiment:' + R.ini, artefact: 'specimens', field: 'kept', text: one(`Version ${R.n}: ${s.said || s.title} (${LAB.specimenUrl(s.file)})`, 600), sources: [{ label: 'live round', ref: LAB.specimenUrl(s.file) }] }, 'agent:live-round'); } catch (e) { warn('live round kept', e); }
|
|
718
737
|
write(R); settle(R);
|
|
719
738
|
}
|
|
739
|
+
/** The critic's screenshots of a version: <runtime>/idle-lab/critic/<round>/<key>/ (desk.png, phone.png), never in the run's own folder. */
|
|
740
|
+
function shotsDir(R, s) { return ask && R.rt && !CR.off(process.env) ? path.join(R.rt, 'idle-lab', 'critic', String(R.id), String(s.key)) : ''; }
|
|
741
|
+
/** One critic pass on a rendered version (only: the checks to read again after the fix). → failed entries, or null when it did not run.
|
|
742
|
+
* It never holds the version: no session, a timeout or an unreadable answer is null, and the ledger says so. */
|
|
743
|
+
async function critic(R, s, v, only = null) {
|
|
744
|
+
if (!ask || CR.off(process.env)) return null;
|
|
745
|
+
let root = ''; try { const p = deps.product ? deps.product(R.ws) : null; root = (p && p.w && p.w.root) || ''; } catch { root = ''; }
|
|
746
|
+
let checks = []; try { checks = CR.checksFor(root).checks; } catch (e) { warn('design critic checks', e); return null; }
|
|
747
|
+
const targets = [...((v && Array.isArray(v.shots)) ? v.shots : []), { abs: s.abs, label: 'page source' }];
|
|
748
|
+
s.progress = { now: only ? 'Checking the fix against your design rules' : 'Checking it against your design rules', done: 0, total: 0 };
|
|
749
|
+
write(R);
|
|
750
|
+
let r; try { r = await CR.critique(ask, { checks, targets, only }); } catch (e) { r = { ok: false, why: one(e && e.message, 120) }; }
|
|
751
|
+
try { CR.record(R.rt, { from: 'live-round', ws: R.ws, ini: R.ini, version: R.n, key: s.key, recheck: !!only, read: targets.map((t) => t.label + ': ' + t.abs), checks: r.checks || [], ok: r.ok, why: r.why, findings: r.findings, ms: r.ms }); } catch (e) { warn('design critic ledger', e); }
|
|
752
|
+
if (s.state === 'proving') s.progress = null;
|
|
753
|
+
return r.ok ? CR.asFailed(r.findings, checks) : null;
|
|
754
|
+
}
|
|
720
755
|
/** The one fix run: the draft is kept, the run gets only the failed lines and writes the same file. false when it could not start. */
|
|
721
756
|
function fix(R, s, failed, v, cost) {
|
|
722
757
|
const fx = { failed, v, cost: Number.isFinite(cost) ? cost : null, draft: s.abs.replace(/\.html$/, '.draft.html'), session: null, run: s.run + '-fix', done: false, left: null };
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
* GET /api/lab/rules → { ok, rules: [{ id, title, words, at, on, seed, undoneAt? }] } the PM's prototype rules (lib/prototype-rules.js)
|
|
27
27
|
* POST /api/lab/rules { op: add, rule, again? } | { op: undo | restore, id } → { ok, rule } add: `pmos lab rule add` (the chat's agent, no
|
|
28
28
|
* Origin, D98); undo and restore: Settings › PMOS › Prototype rules (a page press)
|
|
29
|
+
* POST /api/lab/critic { files: [abs], ws? } → { ok, run, findings, checks, from, base } | { ok: false, error } the design critic
|
|
30
|
+
* (lib/design-critic.js) on any screenshots or HTML, against the workspace product's own rules:
|
|
31
|
+
* `pmos lab critic` (no Origin, D98, like the live round); a read-only ask run, recorded in its ledger
|
|
29
32
|
* POST /api/lab/comment { ws, ini, file, el?, label?, text, x?, y?, send? } → { ok, id } a comment pinned to an element (send: it was
|
|
30
33
|
* sent to PMOS as the next change; else it is kept for the team)
|
|
31
34
|
*
|
|
@@ -344,6 +347,28 @@ function protoRules(ctx, res, b, by) {
|
|
|
344
347
|
ctx.json(res, r);
|
|
345
348
|
return true;
|
|
346
349
|
}
|
|
350
|
+
/** POST /api/lab/critic: one critic pass on the files, against the product's own design rules; recorded in <runtime>/design-critic.jsonl. */
|
|
351
|
+
async function designCritic(ctx, res, b) {
|
|
352
|
+
const CR = require('./design-critic.js'), path = require('path');
|
|
353
|
+
const w = wsOf(ctx, typeof b.ws === 'string' && b.ws ? b.ws : null);
|
|
354
|
+
const files = Array.isArray(b.files) ? b.files.slice(0, 8) : [];
|
|
355
|
+
const targets = [];
|
|
356
|
+
for (const f of files) {
|
|
357
|
+
const abs = typeof f === 'string' && path.isAbsolute(f) ? path.resolve(f) : '';
|
|
358
|
+
if (!abs || !(CR.IMAGE_RE.test(abs) || CR.HTML_RE.test(abs))) return fail(ctx, res, 400, `${String(f).slice(0, 120)}: give the full path of a screenshot (.png, .jpg, .webp) or an HTML file`);
|
|
359
|
+
let st = null; try { st = fs.statSync(abs); } catch { st = null; }
|
|
360
|
+
if (!st || !st.isFile() || st.size > 15e6) return fail(ctx, res, 400, `${abs}: no such file, or over 15 MB`);
|
|
361
|
+
targets.push({ abs, label: path.basename(abs) });
|
|
362
|
+
}
|
|
363
|
+
if (!targets.length) return fail(ctx, res, 400, 'files lists the screenshots or HTML files to check');
|
|
364
|
+
if (CR.off(process.env)) return fail(ctx, res, 409, 'the design critic is off (PMOS_CRITIC=off)');
|
|
365
|
+
const K = CR.checksFor(w ? w.root : '');
|
|
366
|
+
const r = await CR.critique(typeof ctx.critic === 'function' ? ctx.critic : CR.askVia(ctx.spawnSession), { checks: K.checks, targets });
|
|
367
|
+
const run = ctx.runtimeDir ? CR.record(ctx.runtimeDir, { from: 'cli', ws: w ? w.id : '', read: targets.map((t) => t.abs), checks: r.checks || [], ok: r.ok, why: r.why, findings: r.findings, ms: r.ms }) : null;
|
|
368
|
+
if (!r.ok) return fail(ctx, res, 502, r.why);
|
|
369
|
+
ctx.json(res, { ok: true, run, findings: r.findings, checks: r.checks.length, from: K.from, base: K.base });
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
347
372
|
const readsDrop = (dir, b) => LAB.readLines(LAB.ledgerFile(dir)).some((l) => l.kind === 'drop' && l.batch === b);
|
|
348
373
|
|
|
349
374
|
module.exports = {
|
|
@@ -353,12 +378,17 @@ module.exports = {
|
|
|
353
378
|
if (req.method === 'GET') { const fn = READS[p0]; if (!fn) return fail(ctx, res, 404, 'not found'); return fn(ctx, res, url); }
|
|
354
379
|
if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
|
|
355
380
|
const fn = WRITES[p0];
|
|
356
|
-
if (!fn && !['/api/lab/round', '/api/lab/delete', '/api/lab/restore', '/api/lab/rules'].includes(p0)) return fail(ctx, res, 404, 'not found');
|
|
381
|
+
if (!fn && !['/api/lab/round', '/api/lab/delete', '/api/lab/restore', '/api/lab/rules', '/api/lab/critic'].includes(p0)) return fail(ctx, res, 404, 'not found');
|
|
357
382
|
const got = await ctx.readJson(req);
|
|
358
383
|
if (!got.ok || !isObj(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
|
|
359
384
|
// the live round (lib/live-round.js): `pmos lab round` reaches it with no Origin (D98: an agent does what it was asked; the PM's own
|
|
360
385
|
// terminal too). It starts a round, or with propose: true only files the ✦ ask the PM's ✓ starts. Never a write of a record.
|
|
361
386
|
if (p0 === '/api/lab/round') return liveRound(ctx, res, got.body);
|
|
387
|
+
// the design critic on any screenshots or HTML: `pmos lab critic` (no Origin, D98); from a page, a page press
|
|
388
|
+
if (p0 === '/api/lab/critic') {
|
|
389
|
+
if (req.headers.origin) { const g = guard.requirePagePress(req, got.body); if (!g.ok) return fail(ctx, res, g.status, g.error); }
|
|
390
|
+
return designCritic(ctx, res, got.body);
|
|
391
|
+
}
|
|
362
392
|
// the PM's prototype rules: the chat's agent adds one (no Origin, D98, like the live round); a page's Undo and Restore are page presses
|
|
363
393
|
if (p0 === '/api/lab/rules') {
|
|
364
394
|
let by;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.663.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.663.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* pm/cozy-routine-detail.js — a routine in the Detail at the right of Routine (initiative routine-ds-page; board RoutineDS on Exploring 3,
|
|
2
|
+
* page "pages"; done test planning/done-tests/routine-ds-page.md C3, C4). PURE: no DOM and no fetch, so node tests it (routine-place.test.js).
|
|
3
|
+
*
|
|
4
|
+
* Main + open item (Komorebi MainItem): the table stays, the pressed row opens here. The Detail part: the name, the row's own switch, then
|
|
5
|
+
* icon buttons Chat (the chat slide-over about this routine), Open in full (the full popup, pm/cozy-routine-pop.js or pm/cozy-routine-job.js,
|
|
6
|
+
* where every value edits, ▶ runs it now and ⋯ deletes it) and Close. Then what it does, the fields (Product, When, Reads, Tells, Next) and
|
|
7
|
+
* Last runs: a report's issues, each opens the issue; a read's, job's or task's runs, a failed one says why.
|
|
8
|
+
*
|
|
9
|
+
* One expanded Suggestion (pm-sug x, the shared sugHtml of pm/bd-stands.js) only when PMOS sees a pattern in the records:
|
|
10
|
+
* wait a report PMOS proposes (its row waits in Waits for you): Yes starts it (confirm, or move to the product it is about), No drops it.
|
|
11
|
+
* fail a read, a job or your task whose last two runs failed: Yes runs it once now, No hides the line for those runs on this computer.
|
|
12
|
+
* Every word comes from a field of a record; a field the record leaves silent is not drawn.
|
|
13
|
+
* detailHtml(D) · patternOf(D) · fieldsOf(D) · lastOf(D) D = { row, rep?, job?: { raw, tools, own, svc, extra }, hide?: Set } */
|
|
14
|
+
import { runsOf } from './cozy-routine-job.js';
|
|
15
|
+
import { builtFrom, dayMon, issueName } from './cozy-routine-pop.js';
|
|
16
|
+
import { dayTime } from './cozy-routine-model.js';
|
|
17
|
+
import { sugHtml } from './bd-stands.js';
|
|
18
|
+
|
|
19
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
20
|
+
const svg = (d, n = 16) => `<svg class="pm-ic" viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
21
|
+
export const DI = {
|
|
22
|
+
chat: 'M4 5h16v11H9l-5 4z', full: 'M14 4h6v6M20 4l-7 7M10 20H4v-6M4 20l7-7', x: 'M6 6l12 12M18 6L6 18', open: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
|
|
23
|
+
};
|
|
24
|
+
const KIND = { reports: 'Report', reads: 'PMOS reads', jobs: 'PMOS job', tasks: 'Your task' };
|
|
25
|
+
|
|
26
|
+
/** What it does, in one paragraph: a report's purpose (or who it tells), a read's or job's own words, your task's instruction. */
|
|
27
|
+
export function doesOf(D) {
|
|
28
|
+
const r = D.row || {}, raw = (D.job && D.job.raw) || {};
|
|
29
|
+
if (r.kind === 'reports') return String((D.rep && D.rep.purpose) || r.does || '');
|
|
30
|
+
if (r.kind === 'tasks') return String(raw.args || r.does || '');
|
|
31
|
+
if (r.svc) return 'Reads what is new in ' + r.name + ' and puts it into Today. It reads only; it sends nothing.';
|
|
32
|
+
return String(raw.what || r.does || '');
|
|
33
|
+
}
|
|
34
|
+
/** The fields, as [label, words]: only what the records say. */
|
|
35
|
+
export function fieldsOf(D) {
|
|
36
|
+
const r = D.row || {}, rep = D.rep || null, J = D.job || {}, raw = J.raw || {};
|
|
37
|
+
const out = [];
|
|
38
|
+
out.push(['Product', (r.wss && r.wss.length ? r.wss.join(', ') : r.kind === 'reads' || r.kind === 'jobs' ? 'Every product' : '')]);
|
|
39
|
+
out.push(['When', r.when || '']);
|
|
40
|
+
const reads = r.kind === 'reports' ? (rep && rep.source ? builtFrom(rep) : '') : r.kind === 'tasks' ? String(raw.skill || raw.task || '') : (raw.inputs || []).map((i) => i && i.label).filter(Boolean).join(', ');
|
|
41
|
+
out.push(['Reads', reads]);
|
|
42
|
+
if (r.kind === 'reports') out.push(['Tells', String((rep && rep.audience) || 'You')]);
|
|
43
|
+
if (!r.proposed) out.push(['Next', r.next || '']); // a proposal has no Next: its Suggestion says what starts it
|
|
44
|
+
return out.filter(([, v]) => v);
|
|
45
|
+
}
|
|
46
|
+
/** Last runs, newest first (at most 5): { when, said, ok, path? }. A report's are its issues (Draft or Issued); the rest come from runsOf. */
|
|
47
|
+
export function lastOf(D) {
|
|
48
|
+
const r = D.row || {};
|
|
49
|
+
if (r.kind === 'reports') {
|
|
50
|
+
const L = ((D.rep && D.rep.issues) || []).filter((x) => x && !x.archived && x.path).slice().sort((a, b) => (a.slot < b.slot ? 1 : -1)).slice(0, 5);
|
|
51
|
+
return L.map((x) => ({ when: dayMon(x.slot), said: (issueName(D.rep.issues, x.path) || 'Issue').replace(/ · .*$/, '') + (x.state === 'issued' ? ' · issued' : ' · a draft'), ok: true, path: x.path }));
|
|
52
|
+
}
|
|
53
|
+
if (!D.job) return [];
|
|
54
|
+
return runsOf({ row: r, raw: D.job.raw || {}, tools: D.job.tools || null, svc: D.job.svc || null }).map((u) => ({ when: dayTime(u.at), said: u.said, ok: u.ok }));
|
|
55
|
+
}
|
|
56
|
+
/** The one pattern PMOS sees in the records, as an expanded Suggestion's words, or null. */
|
|
57
|
+
export function patternOf(D) {
|
|
58
|
+
const r = D.row || {};
|
|
59
|
+
if (r.proposed && r.kind === 'reports') {
|
|
60
|
+
const act = (D.rep && D.rep.act) || {}, move = act.act === 'move';
|
|
61
|
+
if (!act.act) return null;
|
|
62
|
+
return { id: 'wait', title: move ? 'Move ' + r.name + ' to ' + (act.toName || act.to) + ' and start it?' : 'Start ' + r.name + '?',
|
|
63
|
+
why: 'PMOS wrote its definition and it waits for your word. Until then nothing drafts it.',
|
|
64
|
+
will: [move ? 'Move the definition to ' + (act.toName || act.to) : 'Turn the switch on', 'Draft it ' + (r.when ? r.when.replace(/^Every/, 'every') : 'on its schedule') + ' and put each issue in Library'],
|
|
65
|
+
changes: 'It moves from Waits for you to Reports, switched on. Nothing is sent: you send each issue yourself.',
|
|
66
|
+
basis: D.rep && D.rep.definition ? 'Its definition, ' + D.rep.definition : 'Its definition' };
|
|
67
|
+
}
|
|
68
|
+
if (r.kind === 'reports' || !D.job) return null;
|
|
69
|
+
const runs = runsOf({ row: r, raw: D.job.raw || {}, tools: D.job.tools || null, svc: D.job.svc || null });
|
|
70
|
+
const fails = [];
|
|
71
|
+
for (const u of runs) { if (u.ok || u.said === 'Running') break; fails.push(u); }
|
|
72
|
+
if (fails.length < 2) return null;
|
|
73
|
+
const sig = 'fail:' + r.key + ':' + fails[0].at;
|
|
74
|
+
if (D.hide && D.hide.has(sig)) return null;
|
|
75
|
+
return { id: 'fail', sig, title: 'Run ' + r.name + ' again now?',
|
|
76
|
+
why: 'The last ' + fails.length + ' runs failed. The newest says: ' + fails[0].said.replace(/^Failed:?\s*/, '') + '.',
|
|
77
|
+
will: [r.kind === 'reads' ? 'Read it once now' : 'Run it once now', 'Show what came out under Last runs'],
|
|
78
|
+
changes: 'Nothing else. Its schedule and its switch stay as they are.',
|
|
79
|
+
basis: 'Its last ' + fails.length + ' runs, ' + dayTime(fails[fails.length - 1].at) + ' to ' + dayTime(fails[0].at) };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The Detail, as html. */
|
|
83
|
+
export function detailHtml(D) {
|
|
84
|
+
const r = D.row || {}, busy = !!D.busy;
|
|
85
|
+
const label = r.proposed ? r.name + ': proposed by PMOS. Press to start it' : r.name + (r.on ? ': on. Press to pause it' : ': paused. Press to start it again');
|
|
86
|
+
const sw = r.on === null || r.on === undefined ? '' : `<button type="button" class="pm-switch" role="switch" aria-checked="${!!r.on}" data-sw="${esc(r.key)}" aria-label="${esc(label)}" title="${r.proposed ? 'Proposed. Turn on to start it' : r.on ? 'On' : 'Paused'}"${busy ? ' disabled' : ''}></button>`;
|
|
87
|
+
const btn = (k, icon, l) => `<button type="button" class="pm-btn" data-rd="${k}" aria-label="${esc(l)}" title="${esc(l)}">${svg(icon)}</button>`;
|
|
88
|
+
const head = `<div class="head"><h2 class="pm-h rt-dt">${esc(r.name)}</h2>${sw}${btn('chat', DI.chat, 'Chat about ' + r.name)}${btn('full', DI.full, 'Open in full')}${btn('close', DI.x, 'Close')}</div>`;
|
|
89
|
+
const does = doesOf(D);
|
|
90
|
+
const f = fieldsOf(D);
|
|
91
|
+
const fields = f.length ? `<dl class="pm-field">${f.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('')}</dl>` : '';
|
|
92
|
+
const L = lastOf(D);
|
|
93
|
+
const runs = `<div class="rt-runs"><h3 class="pm-meta rt-dh">Last runs</h3>${L.length ? `<div class="rows">${L.map((u) => `<div class="pm-li"><span class="pm-meta rt-when">${esc(u.when)}</span><span class="txt"><span class="w${u.ok ? '' : ' bad'}">${esc(u.said)}</span></span>`
|
|
94
|
+
+ (u.path ? `<span class="acts"><button type="button" class="pm-btn" data-rd="issue" data-path="${esc(u.path)}" aria-label="${esc('Open ' + u.said)}" title="Open it">${svg(DI.open)}</button></span>` : '') + '</div>').join('')}</div>` : '<p class="pm-meta">It has not run yet.</p>'}</div>`;
|
|
95
|
+
const p = patternOf(D);
|
|
96
|
+
const sug = p ? sugHtml(p, `data-pat="${esc(p.id)}" data-key="${esc(r.key)}"${p.sig ? ` data-sig="${esc(p.sig)}"` : ''}`, 'data-rsug') : '';
|
|
97
|
+
const msg = D.msg ? `<p class="pm-meta" role="status">${esc(D.msg)}</p>` : '';
|
|
98
|
+
return `<section class="pm-block rt-detail pm-motion-enter" aria-label="${esc(KIND[r.kind] + ': ' + r.name)}">${head}${does ? `<p class="rt-does">${esc(does)}</p>` : ''}${fields}${runs}${sug}${msg}</section>`;
|
|
99
|
+
}
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
* wait { act, label, say } on a row of Waits for you: its one ✓ (confirm the definition, or move it to the product it is about)
|
|
16
16
|
* routineGroups(rows, kind) → [{ id, title, rows }] the groups in order; a group with no row is left out (zero is silence)
|
|
17
17
|
* didLine(done, now) → { n, recent, shown, text } | null the one "PMOS did" line over GET /api/autonomy done of every product
|
|
18
|
-
* KINDS the filter: All, Reports, Reads,
|
|
18
|
+
* KINDS the filter (the Tabs): All, Reports, Reads, Jobs, Your tasks
|
|
19
19
|
*
|
|
20
20
|
* Every word comes from a field of a record. A field the record leaves silent is '' and its cell is empty; nothing is filled with a guess. */
|
|
21
21
|
import { atOf, everyLine } from './cozy-evmodel.js';
|
|
22
22
|
|
|
23
|
-
export const KINDS = [['all', 'All'], ['reports', 'Reports'], ['reads', 'Reads'], ['jobs', '
|
|
23
|
+
export const KINDS = [['all', 'All'], ['reports', 'Reports'], ['reads', 'Reads'], ['jobs', 'Jobs'], ['tasks', 'Your tasks']];
|
|
24
24
|
/** A work copy's product: "pmos-idpf ⑂ initiative/psle-paywall-lock" → "pmos-idpf". A branch name never shows (round 3 item 2). */
|
|
25
25
|
export const productName = (n) => String(n || '').split(' ⑂ ')[0].trim();
|
|
26
26
|
/** The Type word of each kind (round 2): the first column after the name. */
|
|
@@ -1,69 +1,63 @@
|
|
|
1
|
-
/* pm/cozy-routine.css — Routine (initiative routine-place, board 11
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
/* pm/cozy-routine.css — Routine (initiative routine-place, board 11; rebuilt from blocks by routine-ds-page, board RoutineDS) and a routine
|
|
2
|
+
* in the popup (board 10).
|
|
3
|
+
* The page is drawn from the PMOS design system (Komorebi, ui/pages.md: Main + open item). Its parts come from pm/komorebi.css: the top line
|
|
4
|
+
* is pm-path and icon pm-btn, "PMOS did" a pm-block flat, the table a pm-block holding pm-tabs and one pm-table whose group rows are
|
|
5
|
+
* pm-group, the switch pm-switch, a late Next the alert pm-badge, the fold line pm-fold, the Detail a pm-block with pm-field, pm-li and the
|
|
6
|
+
* expanded Suggestion (pm-sug x), and the toast pm-toast. This first part only places them. The popup (board 10, below) opens outside the
|
|
7
|
+
* page and keeps cozy.css's tokens. */
|
|
6
8
|
.rt-page { gap: var(--space-16); }
|
|
7
|
-
|
|
8
|
-
.rt-page
|
|
9
|
-
.rt-page .rt-toast { width: auto; max-width: none; }
|
|
9
|
+
.rt-page > * { width: 100%; }
|
|
10
|
+
.rt-page .rt-toast { width: auto; }
|
|
10
11
|
.rt-pick:empty { display: none; }
|
|
11
|
-
.rt-
|
|
12
|
-
.rt-
|
|
13
|
-
|
|
14
|
-
.rt-
|
|
15
|
-
.rt-page
|
|
16
|
-
.rt-
|
|
17
|
-
.rt-
|
|
18
|
-
.rt-
|
|
19
|
-
|
|
20
|
-
.rt-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.rt-
|
|
24
|
-
.rt-
|
|
25
|
-
.rt-page .rt-
|
|
26
|
-
|
|
27
|
-
.rt-
|
|
28
|
-
.rt-
|
|
29
|
-
.rt-tbl
|
|
30
|
-
.rt-
|
|
31
|
-
|
|
32
|
-
.rt-
|
|
33
|
-
.rt-
|
|
34
|
-
.rt-
|
|
35
|
-
.rt-
|
|
36
|
-
.rt-
|
|
37
|
-
.rt-
|
|
38
|
-
.rt-
|
|
39
|
-
.rt-
|
|
40
|
-
.rt-
|
|
41
|
-
.rt-
|
|
42
|
-
.rt-
|
|
43
|
-
|
|
44
|
-
.rt-r .n, .rt-r .c { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 0; line-height: 1.35; }
|
|
45
|
-
.rt-r .c { color: var(--muted); }
|
|
46
|
-
.rt-r .c .w { white-space: normal; height: auto; min-height: 22px; }
|
|
47
|
-
.rt-r.off .n, .rt-r.off .c { color: var(--muted); }
|
|
48
|
-
.rt-r.off .n { font-weight: var(--fw-regular); }
|
|
49
|
-
.rt-page .rt-sw { justify-self: end; }
|
|
50
|
-
.rt-page .rt-sw[disabled] { opacity: .5; cursor: default; }
|
|
51
|
-
/* one-time reports and loose drafts: one fold line at the end of Reports (round 3 item 1) */
|
|
52
|
-
.rt-page .rt-r.rt-fold { display: block; min-height: 0; padding: 0; }
|
|
53
|
-
.rt-page .rt-fold .pm-fold { border-top: 0; padding: 0 18px; }
|
|
54
|
-
.rt-page .rt-fold .pm-ic, .rt-gf .pm-ic { width: 14px; height: 14px; transition: transform var(--duration-quick) var(--ease-drift); }
|
|
12
|
+
.rt-top { display: flex; align-items: center; gap: var(--space-12); min-height: 32px; }
|
|
13
|
+
.rt-top .rt-sp { flex: 1; }
|
|
14
|
+
/* Main + open item: the table stays, the open routine sits at the right */
|
|
15
|
+
.rt-mi { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-16); align-items: start; }
|
|
16
|
+
.rt-page.rt-open .rt-mi { grid-template-columns: minmax(0, 1fr) 400px; }
|
|
17
|
+
.rt-main { display: flex; flex-direction: column; gap: var(--space-12); min-width: 0; }
|
|
18
|
+
.rt-aside:empty { display: none; }
|
|
19
|
+
.rt-aside { position: sticky; top: var(--space-16); min-width: 0; }
|
|
20
|
+
/* PMOS did */
|
|
21
|
+
.rt-page .rt-did { flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; }
|
|
22
|
+
.rt-did .rt-say { flex: 1; min-width: 0; }
|
|
23
|
+
/* the table */
|
|
24
|
+
.rt-tbl .head .pm-tabs { flex-wrap: wrap; }
|
|
25
|
+
.rt-tbl .pm-tab .rt-n { font-weight: var(--fw-regular); color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
26
|
+
.rt-page .pm-tab:focus-visible, .rt-page .rt-row:focus-visible { outline: none; box-shadow: var(--glow); }
|
|
27
|
+
.rt-tbl .pm-table th.pm-group { display: table-cell; height: 32px; }
|
|
28
|
+
.rt-tbl .pm-table th.pm-group b { color: var(--ink); }
|
|
29
|
+
.rt-tbl .pm-table .rt-g:hover th { background: var(--well); }
|
|
30
|
+
.rt-tbl .rt-row { cursor: pointer; }
|
|
31
|
+
.rt-tbl .rt-row td:first-child { padding-left: var(--space-16); }
|
|
32
|
+
.rt-tbl .rt-name { white-space: nowrap; }
|
|
33
|
+
.rt-tbl .rt-name b { font-weight: var(--fw-strong); }
|
|
34
|
+
.rt-tbl .rt-does { color: var(--muted); }
|
|
35
|
+
.rt-tbl .rt-when, .rt-tbl .rt-nx { white-space: nowrap; }
|
|
36
|
+
.rt-tbl .rt-next { font-family: var(--font-mono); }
|
|
37
|
+
.rt-tbl .rt-on { width: 1%; white-space: nowrap; }
|
|
38
|
+
.rt-tbl .rt-on .pm-row { justify-content: flex-end; flex-wrap: nowrap; }
|
|
39
|
+
.rt-tbl .rt-row.off .rt-name b { font-weight: var(--fw-regular); color: var(--muted); }
|
|
40
|
+
.rt-tbl .rt-drop { visibility: hidden; color: var(--muted); }
|
|
41
|
+
.rt-tbl .rt-row:hover .rt-drop, .rt-tbl .rt-drop:focus-visible { visibility: visible; }
|
|
42
|
+
.rt-tbl .pm-switch[disabled] { opacity: .5; cursor: default; }
|
|
43
|
+
.rt-tbl .rt-fold td { padding: 0; }
|
|
44
|
+
.rt-page .rt-fold .pm-ic, .rt-gf .pm-ic { transition: transform var(--duration-quick) var(--ease-drift); }
|
|
55
45
|
.rt-page .rt-fold button[aria-expanded="true"] .pm-ic, .rt-gf[aria-expanded="true"] .pm-ic { transform: rotate(90deg); }
|
|
56
|
-
.rt-page .rt-fold button:focus-visible { outline: none; box-shadow: var(--glow); }
|
|
57
|
-
/* ✕ on a proposed report: shown on hover, where the chevron is */
|
|
58
|
-
.rt-page .rt-r .go .rt-drop { width: 28px; height: 28px; margin: -7px; color: var(--muted); }
|
|
59
|
-
.rt-r .go:has(.rt-drop) { opacity: 0; }
|
|
60
|
-
.rt-r.rt-row:hover .go:has(.rt-drop), .rt-r .go:has(.rt-drop:focus-visible) { opacity: 1; }
|
|
61
|
-
/* PMOS reads and PMOS jobs fold to their heading while a program or project is picked */
|
|
62
46
|
.rt-gf { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
|
|
63
|
-
.rt-gf
|
|
64
|
-
.rt-
|
|
65
|
-
.rt-
|
|
66
|
-
.rt-page .rt-msg { margin: 0
|
|
47
|
+
.rt-gf:focus-visible, .rt-page .rt-fold button:focus-visible { box-shadow: var(--glow); border-radius: var(--radius-sm); }
|
|
48
|
+
.rt-hid { margin: 0; }
|
|
49
|
+
.rt-hid .pm-chip { border: 0; font: inherit; font-weight: var(--fw-strong); color: var(--blue); background: var(--blue-tint); cursor: pointer; }
|
|
50
|
+
.rt-page .rt-quiet, .rt-page .rt-msg { margin: 0; min-height: 1em; }
|
|
51
|
+
/* the Detail */
|
|
52
|
+
.rt-detail .head .rt-dt { flex: 1; min-width: 0; }
|
|
53
|
+
.rt-detail .rt-does { margin: 0; font-size: var(--fs-body); line-height: 22px; }
|
|
54
|
+
.rt-detail .pm-field { margin: 0; }
|
|
55
|
+
.rt-detail .rt-dh { margin: 0 0 4px; font-weight: var(--fw-regular); }
|
|
56
|
+
.rt-detail .rt-when { width: 96px; flex: none; font-family: var(--font-mono); white-space: nowrap; }
|
|
57
|
+
.rt-detail .pm-li { min-height: 44px; }
|
|
58
|
+
.rt-detail .pm-li .w { color: var(--ink); white-space: normal; }
|
|
59
|
+
.rt-detail .pm-li .w.bad { color: var(--alert); }
|
|
60
|
+
.rt-detail .pm-sug.x dd { overflow-wrap: anywhere; }
|
|
67
61
|
/* the toast: the Toast part, bottom centre; the leaf line counts down the time the Undo has */
|
|
68
62
|
.rt-page .rt-toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--duration-enter) var(--ease-out), transform var(--duration-enter) var(--ease-out); }
|
|
69
63
|
.rt-page .rt-toast:empty { display: none; }
|
|
@@ -74,11 +68,15 @@
|
|
|
74
68
|
.rt-page .rt-toast.on .timer { animation: rtTimer 4.2s linear both; }
|
|
75
69
|
@keyframes rtTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
|
|
76
70
|
@media (prefers-reduced-motion: reduce) { .rt-page .rt-toast { transform: translate(-50%, 0); } .rt-page .rt-toast.on .timer { animation: none; } }
|
|
71
|
+
@media (max-width: 1100px) { .rt-page.rt-open .rt-mi { grid-template-columns: minmax(0, 1fr) 340px; } }
|
|
72
|
+
/* a phone: the Table reads as a List (the name, Next and the switch); a row opens the popup, so the Detail never shows */
|
|
77
73
|
@media (max-width: 760px) {
|
|
78
|
-
.rt-
|
|
79
|
-
.rt-
|
|
80
|
-
.rt-
|
|
81
|
-
.rt-
|
|
74
|
+
body.cz-phmore .rt-top { padding-right: 48px; }
|
|
75
|
+
.rt-page.rt-open .rt-mi { grid-template-columns: minmax(0, 1fr); }
|
|
76
|
+
.rt-aside { display: none; }
|
|
77
|
+
.rt-tbl .rt-does, .rt-tbl .rt-when, .rt-tbl .rt-prod { display: none; }
|
|
78
|
+
.rt-tbl .rt-name { white-space: normal; }
|
|
79
|
+
.rt-tbl .rt-row td { padding-top: 12px; padding-bottom: 12px; }
|
|
82
80
|
.rt-page .pm-btn { width: 44px; height: 44px; }
|
|
83
81
|
}
|
|
84
82
|
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|