create-pmos 0.730.0 → 0.731.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 +20 -32
- package/payload/KIT-VERSION +1 -1
- package/payload/design-system/brand/icons.json +59 -0
- 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 +19 -0
- package/workspace/design-system/brand/icons.json +59 -0
- package/workspace/guide/agent-capabilities.md +1 -0
- package/workspace/guide/cli.md +10 -0
- package/workspace/guide/initiatives-and-next-steps.md +6 -0
- package/workspace/guide/layout.md +2 -0
- package/workspace/lib/headless.js +1 -0
- package/workspace/lib/icon-check.js +280 -0
- package/workspace/lib/job-graph.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/principles-cli.js +109 -0
- package/workspace/lib/principles.js +165 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-principles.js +109 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/agenda-live.js +1 -1
- package/workspace/public/pm/bd-principles.js +64 -0
- package/workspace/public/pm/bd-span.js +1 -1
- package/workspace/public/pm/bd-sprint-ds.js +1 -1
- package/workspace/public/pm/bd-sprint.js +1 -1
- package/workspace/public/pm/bd-work.js +1 -1
- package/workspace/public/pm/cozy-day-pick.js +1 -1
- package/workspace/public/pm/cozy-events-view.js +1 -1
- package/workspace/public/pm/cozy-popup.js +1 -1
- package/workspace/public/pm/cozy-rec-present.js +1 -1
- package/workspace/public/pm/goal-chat.js +1 -1
- package/workspace/public/pm/home-chat.js +1 -1
- package/workspace/public/pm/home-rec-row.js +1 -1
- package/workspace/public/pm/home-today.js +3 -3
- package/workspace/public/pm/ini-agent.js +1 -1
- package/workspace/public/pm/ini-edit.js +2 -2
- package/workspace/public/pm/ini-groups.js +1 -1
- package/workspace/public/pm/ini-versions.js +1 -1
- package/workspace/public/pm/ini-view.js +2 -2
- package/workspace/public/pm/intent.js +2 -2
- package/workspace/public/pm/okr-list.js +2 -2
- package/workspace/public/pm/pinned-views.js +1 -1
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/premium-insights.js +3 -3
- package/workspace/public/pm/premium-mtg-present.js +2 -2
- package/workspace/public/pm/premium-mtg-replay.js +1 -1
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +1 -1
- package/workspace/public/pm/premium-vw-slides.js +3 -3
- package/workspace/public/pm/task-card.js +1 -1
- package/workspace/public/pm/wf-page.js +1 -1
- package/workspace/public/premium-board.html +2 -0
- package/workspace/public/premium-events.html +2 -2
- package/workspace/skills/principles-draft.skill +23 -0
- package/workspace/test-lists/icon-check.json +9 -0
- package/workspace/test-lists/principles.json +9 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* principles-cli.js — `pmos principles`: a product's principles, drafted from its past decisions, each citing the decisions it came from, kept or
|
|
3
|
+
* dropped by the PM (bet A352, initiative product-principles-draft; the store is lib/principles.js).
|
|
4
|
+
*
|
|
5
|
+
* pmos principles list [--all] [--json] the kept principles, then the drafts that wait; --all adds the dropped ones
|
|
6
|
+
* pmos principles sources [--json] the decisions a draft may cite (DECISIONS.md and its ADRs, and the decision journal)
|
|
7
|
+
* pmos principles draft --text "<principle>" --why "<the pattern in the decisions>" --source <id> [--source <id> …]
|
|
8
|
+
* one draft; refused when a source is not a decision of this product (the drafting run's write)
|
|
9
|
+
* pmos principles keep|drop|undo <id> the PM's answer to a draft (the chat writes it for the PM; the Board shows it)
|
|
10
|
+
* pmos principles add --text "<principle>" [--why "<text>"] [--source <id> …] the PM's own principle, kept at once
|
|
11
|
+
* every command: [--root <dir>] (default: this repository)
|
|
12
|
+
*
|
|
13
|
+
* The principles live in principles.jsonl in the product's records folder, so what the chat writes shows on the Board.
|
|
14
|
+
* Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execFileSync } = require('child_process');
|
|
17
|
+
const P = require('./principles.js');
|
|
18
|
+
|
|
19
|
+
const COMMANDS = { principles: ['list', 'sources', 'draft', 'keep', 'drop', 'undo', 'add'] };
|
|
20
|
+
const USAGE = [
|
|
21
|
+
'usage: pmos principles list|sources|draft|keep|drop|undo|add — the product\'s principles, drafted from its decisions, each citing them',
|
|
22
|
+
' pmos principles list [--all] [--json] the kept principles, then the drafts that wait for you',
|
|
23
|
+
' pmos principles sources [--json] the decisions a principle may cite',
|
|
24
|
+
' pmos principles draft --text "<principle>" --why "<the pattern>" --source <id> [--source <id> …] one draft, 1 to ' + P.MAX_SOURCES + ' sources',
|
|
25
|
+
' pmos principles keep|drop|undo <id> keep or drop a draft, or put it back to open',
|
|
26
|
+
' pmos principles add --text "<principle>" [--why "<text>"] [--source <id> …] your own principle, kept at once',
|
|
27
|
+
'Run it in the product\'s repository, or pass --root <dir>.',
|
|
28
|
+
];
|
|
29
|
+
const ALLOWED = { list: ['json', 'root', 'all'], sources: ['json', 'root'], draft: ['json', 'root', 'text', 'why', 'source'], keep: ['json', 'root'], drop: ['json', 'root'],
|
|
30
|
+
undo: ['json', 'root'], add: ['json', 'root', 'text', 'why', 'source'] };
|
|
31
|
+
const BOOL = new Set(['json', 'all']);
|
|
32
|
+
|
|
33
|
+
function parse(args) {
|
|
34
|
+
const pos = [], flags = {};
|
|
35
|
+
for (let i = 0; i < args.length; i++) {
|
|
36
|
+
const a = args[i];
|
|
37
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
38
|
+
const k = a.slice(2);
|
|
39
|
+
if (BOOL.has(k)) { flags[k] = true; continue; }
|
|
40
|
+
const v = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
41
|
+
if (k === 'source') (flags.source = flags.source || []).push(...String(v).split(/[\s,]+/).filter(Boolean));
|
|
42
|
+
else flags[k] = v;
|
|
43
|
+
}
|
|
44
|
+
return { pos, flags };
|
|
45
|
+
}
|
|
46
|
+
function repoRoot(cwd) {
|
|
47
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
48
|
+
}
|
|
49
|
+
function recordsDirOf(root) {
|
|
50
|
+
try { const { repoScript } = require('./repo-script.js'); return require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { return path.join(root, 'planning', 'records'); }
|
|
51
|
+
}
|
|
52
|
+
const pub = (x) => ({ id: x.id, state: x.state, own: !!x.own, text: x.text, why: x.why || null, sources: x.sources });
|
|
53
|
+
const lineOf = (x) => ` ${x.id} — ${x.text}${x.why ? `\n why: ${x.why}` : ''}${x.sources.length ? `\n from: ${x.sources.join(', ')}` : ''}`;
|
|
54
|
+
|
|
55
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY } = {}) {
|
|
56
|
+
const args = argv[0] === 'principles' ? argv.slice(1) : argv.slice();
|
|
57
|
+
const sub = args[0];
|
|
58
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
59
|
+
if (!COMMANDS.principles.includes(sub)) { say(`unknown principles command "${sub}". Use one of: ${COMMANDS.principles.join(', ')}`); return 2; }
|
|
60
|
+
const { pos, flags } = parse(args.slice(1));
|
|
61
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos principles ${sub}`); return 2; }
|
|
62
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
63
|
+
const dir = recordsDirOf(root);
|
|
64
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
65
|
+
const by = () => { try { return require('./actor.js').fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env }).by; } catch { return 'unknown'; } };
|
|
66
|
+
|
|
67
|
+
if (sub === 'list') {
|
|
68
|
+
if (pos.length) return fail('pmos principles list takes no argument', 2);
|
|
69
|
+
const all = P.read(dir);
|
|
70
|
+
const kept = all.filter((x) => x.state === 'kept'), open = all.filter((x) => x.state === 'open'), dropped = all.filter((x) => x.state === 'dropped');
|
|
71
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principles: [...kept, ...open, ...(flags.all ? dropped : [])].map(pub) })); return 0; }
|
|
72
|
+
if (!all.length) { say('No principles yet. PMOS drafts them from the decisions once the product has ' + P.MIN_DECISIONS + ' or more (pmos principles sources).'); return 0; }
|
|
73
|
+
say(`${kept.length} kept · ${open.length} waiting for you · ${dropped.length} dropped`);
|
|
74
|
+
if (kept.length) say('\nKept:\n' + kept.map(lineOf).join('\n'));
|
|
75
|
+
if (open.length) say('\nDrafts:\n' + open.map(lineOf).join('\n') + '\n\nKeep or drop one: pmos principles keep|drop <id>');
|
|
76
|
+
if (flags.all && dropped.length) say('\nDropped:\n' + dropped.map(lineOf).join('\n'));
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (sub === 'sources') {
|
|
81
|
+
if (pos.length) return fail('pmos principles sources takes no argument', 2);
|
|
82
|
+
const D = P.decisionsOf(root, { now });
|
|
83
|
+
if (flags.json) { say(JSON.stringify({ ok: true, decisions: D })); return 0; }
|
|
84
|
+
if (!D.length) { say('No decisions in this repository yet (DECISIONS.md or pmos decisions).'); return 0; }
|
|
85
|
+
say(D.map((d) => ` ${d.id} — ${d.title} (${d.from})`).join('\n'));
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (sub === 'draft' || sub === 'add') {
|
|
90
|
+
if (pos.length) return fail(`usage: pmos principles ${sub} --text "<principle>" ${sub === 'draft' ? '--why "<the pattern>" --source <id>' : '[--why "<text>"]'}`, 2);
|
|
91
|
+
const input = { text: flags.text, why: flags.why, sources: flags.source || [] };
|
|
92
|
+
const D = P.decisionsOf(root, { now });
|
|
93
|
+
const r = sub === 'draft' ? P.draft(dir, input, D, { by: by(), now }) : P.add(dir, input, D, { by: by(), now });
|
|
94
|
+
if (!r.ok) return r.code === 'dropped' && !flags.json ? (say('dropped: ' + r.error), 1) : fail(r.error);
|
|
95
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principle: pub(r.item) })); return 0; }
|
|
96
|
+
say(`✓ ${r.item.id}: ${sub === 'draft' ? 'drafted; it waits on the Board for a keep or a drop' : 'kept'}.`);
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// keep · drop · undo
|
|
101
|
+
if (pos.length !== 1) return fail(`usage: pmos principles ${sub} <id>`, 2);
|
|
102
|
+
const r = P.act(dir, sub, pos[0], { by: by(), now });
|
|
103
|
+
if (!r.ok) return fail(r.error);
|
|
104
|
+
if (flags.json) { say(JSON.stringify({ ok: true, principle: pub(r.item) })); return 0; }
|
|
105
|
+
say(`✓ ${r.item.id}: ${r.item.state === 'open' ? 'back to a draft' : r.item.state}. The Board shows it.`);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* principles.js — a product's principles, drafted by PMOS from its past decisions, each citing the decisions it came from, kept or dropped by
|
|
3
|
+
* the PM (bet A352, initiative product-principles-draft). THE ONE WRITER and THE ONE FOLD of principles.jsonl. lib/principles-cli.js is the
|
|
4
|
+
* verb (`pmos principles`), lib/routes-principles.js the routes and the once-a-day drafting run, public/pm/bd-principles.js the Board's block.
|
|
5
|
+
*
|
|
6
|
+
* decisionsOf(root, { now }) → [{ id, title, from }] the decisions a draft may cite: the ones that still stand in DECISIONS.md and its
|
|
7
|
+
* ADRs (lib/decision-ledger.js; at the root, or under pmos/ in a kit product) and the entries of the decision
|
|
8
|
+
* journal (`pmos decisions`, lib/decision-journal.js) that no later decision replaced
|
|
9
|
+
* readLines(dir) · fold(lines) → [item] item: { id, text, why, sources, state: open | kept | dropped, own, at }
|
|
10
|
+
* read(dir) → fold(readLines(dir))
|
|
11
|
+
* draft(dir, input, decisions, { by, now }) → { ok, item } | { ok: false, error, code? } code 'dropped': the PM dropped this text before
|
|
12
|
+
* act(dir, kind, id, { by, now }) → { ok, item } | { ok: false, error } kind ∈ keep · drop · undo
|
|
13
|
+
* add(dir, input, decisions, { by, now }) → { ok, item } | { ok: false, error } the PM's own principle, kept at once
|
|
14
|
+
* idOf(text) → 'p-<8 hex>' the same text gives the same id, so a new run cannot bring back a dropped draft
|
|
15
|
+
* count(dir) → the number of kept principles (the health number)
|
|
16
|
+
*
|
|
17
|
+
* WHERE. `dir` is the product's records folder (lib/records-dir.js): planning/records in the PMOS repo, pmos/state/records in a kit product.
|
|
18
|
+
* Append-only: one line per event { at, by, kind, id, ... }; nothing rewrites it.
|
|
19
|
+
* draft { text, why, sources } PMOS's draft: one line of text, one line of why, 1 to 5 decision ids it came from
|
|
20
|
+
* add { text, why?, sources? } the PM's own principle (sources optional), kept at once
|
|
21
|
+
* keep · drop · undo the PM's press, or the chat for the PM; undo puts a kept or dropped principle back to open
|
|
22
|
+
* A draft is refused when a source is not a decision the product has, so every draft cites real decisions. Nothing here sends anything. */
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const crypto = require('crypto');
|
|
26
|
+
|
|
27
|
+
const FILE = 'principles.jsonl';
|
|
28
|
+
const KINDS = ['draft', 'add', 'keep', 'drop', 'undo'];
|
|
29
|
+
const MAX_TEXT = 140;
|
|
30
|
+
const MAX_WHY = 240;
|
|
31
|
+
const MAX_SOURCES = 5;
|
|
32
|
+
const MAX_OPEN = 6;
|
|
33
|
+
const MIN_DECISIONS = 3; // fewer decisions than this: nothing to draw principles from, so no run starts
|
|
34
|
+
const say = (s) => { try { console.log('[principles] ' + s); } catch { /* no console */ } };
|
|
35
|
+
|
|
36
|
+
const one = (v, max) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > max ? s.slice(0, max - 1).trimEnd() + '…' : s; };
|
|
37
|
+
const idOf = (text) => 'p-' + crypto.createHash('sha256').update(one(text, MAX_TEXT).toLowerCase()).digest('hex').slice(0, 8);
|
|
38
|
+
const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
|
|
39
|
+
|
|
40
|
+
/** The decisions a draft may cite, for the product checked out at `root`. */
|
|
41
|
+
function decisionsOf(root, { now = Date.now() } = {}) {
|
|
42
|
+
const out = [];
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
const push = (id, title, from) => { if (id && !seen.has(id)) { seen.add(id); out.push({ id, title: one(title, 160), from }); } };
|
|
45
|
+
if (!root) return out;
|
|
46
|
+
const DL = require('./decision-ledger.js');
|
|
47
|
+
for (const [r, rel] of [[root, 'DECISIONS.md'], [path.join(root, 'pmos'), 'pmos/DECISIONS.md']]) {
|
|
48
|
+
let L = null;
|
|
49
|
+
try { L = DL.load(r); } catch { L = null; }
|
|
50
|
+
if (!L) continue;
|
|
51
|
+
for (const d of L.decisions.values()) if (d.status !== 'reverted' && (d.status !== 'superseded' || d.partial)) push(d.id, d.title, rel);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const J = require('./decision-journal.js');
|
|
56
|
+
const { rows } = J.read(root);
|
|
57
|
+
for (const e of J.fold(rows, { today: new Date(now).toISOString().slice(0, 10) })) if (e.state !== 'replaced') push(e.id, e.decided, 'journal');
|
|
58
|
+
} catch { /* no journal */ }
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function readLines(dir) {
|
|
63
|
+
const f = fileOf(dir);
|
|
64
|
+
if (!f) return [];
|
|
65
|
+
let text = '';
|
|
66
|
+
try { text = fs.readFileSync(f, 'utf8'); } catch { return []; }
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const l of text.split('\n')) {
|
|
69
|
+
if (!l.trim()) continue;
|
|
70
|
+
try { const o = JSON.parse(l); if (o && KINDS.includes(o.kind) && typeof o.id === 'string') out.push(o); } catch { /* a torn line is skipped */ }
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** One item per principle, in the order first filed. The last line for an id wins. */
|
|
76
|
+
function fold(lines) {
|
|
77
|
+
const by = new Map();
|
|
78
|
+
for (const l of lines || []) {
|
|
79
|
+
const cur = by.get(l.id);
|
|
80
|
+
if (l.kind === 'draft' || l.kind === 'add') {
|
|
81
|
+
const own = l.kind === 'add';
|
|
82
|
+
const base = cur || { id: l.id, state: own ? 'kept' : 'open', own, at: l.at || null };
|
|
83
|
+
// A draft filed again keeps the PM's answer; the newer wording and sources replace the old ones.
|
|
84
|
+
by.set(l.id, Object.assign(base, { text: one(l.text, MAX_TEXT), why: one(l.why, MAX_WHY), sources: Array.isArray(l.sources) ? l.sources.map(String) : [] }, own ? { state: 'kept', own: true } : {}));
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (!cur) continue;
|
|
88
|
+
cur.state = l.kind === 'keep' ? 'kept' : l.kind === 'drop' ? 'dropped' : 'open';
|
|
89
|
+
cur.at = l.at || cur.at;
|
|
90
|
+
}
|
|
91
|
+
return [...by.values()];
|
|
92
|
+
}
|
|
93
|
+
const read = (dir) => fold(readLines(dir));
|
|
94
|
+
|
|
95
|
+
function append(dir, line) {
|
|
96
|
+
const f = fileOf(dir);
|
|
97
|
+
if (!f) return { ok: false, error: 'This product has no records folder.' };
|
|
98
|
+
try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(f, JSON.stringify(line) + '\n'); } catch (e) { return { ok: false, error: 'could not save: ' + ((e && e.message) || e) }; }
|
|
99
|
+
return { ok: true };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Check text, why and sources against the product's decisions. needSources: a draft must cite 1 to 5; the PM's own may cite none. */
|
|
103
|
+
function clean(input, decisions, { needSources }) {
|
|
104
|
+
const i = input && typeof input === 'object' ? input : {};
|
|
105
|
+
const text = one(i.text, MAX_TEXT);
|
|
106
|
+
if (!text) return { error: 'Say the principle in one line (--text).' };
|
|
107
|
+
const why = one(i.why, MAX_WHY);
|
|
108
|
+
if (needSources && !why) return { error: 'Say in one line which pattern in the decisions it comes from (--why).' };
|
|
109
|
+
const raw = Array.isArray(i.sources) ? i.sources : i.sources ? String(i.sources).split(/[\s,]+/) : [];
|
|
110
|
+
const sources = [...new Set(raw.map((s) => String(s).trim()).filter(Boolean))];
|
|
111
|
+
if (needSources && !sources.length) return { error: 'Cite the decisions it came from (--source <id>, 1 to ' + MAX_SOURCES + ').' };
|
|
112
|
+
if (sources.length > MAX_SOURCES) return { error: 'Cite at most ' + MAX_SOURCES + ' decisions.' };
|
|
113
|
+
const known = new Set((decisions || []).map((d) => d.id));
|
|
114
|
+
const unknown = sources.filter((s) => !known.has(s));
|
|
115
|
+
if (unknown.length) return { error: 'Not a decision of this product: ' + unknown.join(', ') + '. `pmos principles sources` lists the ones you may cite.' };
|
|
116
|
+
return { text, why, sources };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function draft(dir, input, decisions, { by = 'agent', now = Date.now() } = {}) {
|
|
120
|
+
const c = clean(input, decisions, { needSources: true });
|
|
121
|
+
if (c.error) return { ok: false, error: c.error };
|
|
122
|
+
const id = idOf(c.text);
|
|
123
|
+
const items = read(dir);
|
|
124
|
+
const cur = items.find((x) => x.id === id);
|
|
125
|
+
if (cur && cur.state === 'dropped') return { ok: false, code: 'dropped', error: 'The PM dropped this principle before; it is not filed again.' };
|
|
126
|
+
if (cur && cur.state === 'kept') return { ok: false, code: 'kept', error: 'This principle is already kept.' };
|
|
127
|
+
if (!cur && items.filter((x) => x.state === 'open').length >= MAX_OPEN) return { ok: false, error: MAX_OPEN + ' drafts already wait for the PM. File no more.' };
|
|
128
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind: 'draft', id, text: c.text, why: c.why, sources: c.sources });
|
|
129
|
+
if (!r.ok) return r;
|
|
130
|
+
say('drafted ' + id + ' from ' + c.sources.join(', '));
|
|
131
|
+
return { ok: true, item: read(dir).find((x) => x.id === id) };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function add(dir, input, decisions, { by = 'pm', now = Date.now() } = {}) {
|
|
135
|
+
const c = clean(input, decisions, { needSources: false });
|
|
136
|
+
if (c.error) return { ok: false, error: c.error };
|
|
137
|
+
const id = idOf(c.text);
|
|
138
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind: 'add', id, text: c.text, why: c.why, sources: c.sources });
|
|
139
|
+
if (!r.ok) return r;
|
|
140
|
+
say('added ' + id);
|
|
141
|
+
return { ok: true, item: read(dir).find((x) => x.id === id) };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function act(dir, kind, id, { by = 'pm', now = Date.now() } = {}) {
|
|
145
|
+
if (!['keep', 'drop', 'undo'].includes(kind)) return { ok: false, error: 'keep, drop or undo' };
|
|
146
|
+
const cur = read(dir).find((x) => x.id === String(id || ''));
|
|
147
|
+
if (!cur) return { ok: false, error: 'No principle ' + JSON.stringify(String(id || '')) + '. `pmos principles list` shows the ids.' };
|
|
148
|
+
const r = append(dir, { at: new Date(now).toISOString(), by, kind, id: cur.id });
|
|
149
|
+
if (!r.ok) return r;
|
|
150
|
+
say(kind + ' ' + cur.id);
|
|
151
|
+
return { ok: true, item: read(dir).find((x) => x.id === cur.id) };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const count = (dir) => read(dir).filter((x) => x.state === 'kept').length;
|
|
155
|
+
|
|
156
|
+
module.exports = { FILE, KINDS, MAX_TEXT, MAX_WHY, MAX_SOURCES, MAX_OPEN, MIN_DECISIONS, idOf, decisionsOf, readLines, fold, read, draft, add, act, count };
|
|
157
|
+
|
|
158
|
+
if (require.main === module) {
|
|
159
|
+
const cmd = process.argv[2];
|
|
160
|
+
if (cmd !== 'count') { console.error('usage: node workspace/lib/principles.js count [<product checkout>] (principles kept)'); process.exit(2); }
|
|
161
|
+
const root = process.argv[3] || process.cwd();
|
|
162
|
+
let dir = null;
|
|
163
|
+
try { const { repoScript } = require('./repo-script.js'); dir = require(repoScript('signals/layout-paths.js')).pathsFor(root).recordsDir; } catch { dir = path.join(root, 'planning', 'records'); }
|
|
164
|
+
console.log(String(count(dir)));
|
|
165
|
+
}
|
|
@@ -140,6 +140,7 @@ const MODULES = Object.freeze([
|
|
|
140
140
|
'routes-jira-epics', // work-subtasks: the epic check's fix, direct on tickets assigned to the PM, the day's draft for the rest (tracker/jira/epics.jsonl; page-press POST)
|
|
141
141
|
'routes-use-log', // bet A466: the local use log, page opens and controls pressed, on this computer only (runtime use-log.jsonl; page-press POST)
|
|
142
142
|
'routes-strategy-card', // bet A458: a product's five-line strategy above its Board, and the gentle "doesn't fit" note on new work (records strategy-card.jsonl; page-press POST)
|
|
143
|
+
'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
|
|
143
144
|
'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
|
|
144
145
|
]);
|
|
145
146
|
const PM_DIR = path.join(__dirname, '..', 'public', 'pm');
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-principles.js — a product's principles over HTTP, and the run that drafts them by itself (bet A352, initiative product-principles-draft).
|
|
3
|
+
* The store is lib/principles.js (principles.jsonl in the product's records folder, lib/records-dir.js); the verb is `pmos principles`.
|
|
4
|
+
*
|
|
5
|
+
* GET /api/principles?ws=<id> → { ok, items, decisions, drafting } items: kept, then open drafts; decisions: how many it may cite
|
|
6
|
+
* POST /api/principles { ws, act, id } → { ok, item } | 400 act ∈ keep · drop · undo
|
|
7
|
+
*
|
|
8
|
+
* THE DRAFTING RUN. When a GET finds a product with MIN_DECISIONS or more decisions and no principle line at all, it starts ONE lean background
|
|
9
|
+
* run of the built-in `principles-draft` skill (headless kind `skill`, `claude -p` under the PM's own login), whose only write is
|
|
10
|
+
* `pmos principles draft`. At most one start per product per day (kept in <state folder>/principles-seed.json, so a restart does not start
|
|
11
|
+
* it again) and one run at a time. Off with `pmos ai off principles-draft`, PMOS_HEADLESS=off, or on a scratch server (PMOS_STATE_DIR set).
|
|
12
|
+
*
|
|
13
|
+
* WHO WRITES. A page press: pm-guard requirePagePress checks the page's Origin and launch nonce. The chat writes with `pmos principles`.
|
|
14
|
+
* Nothing here is sent anywhere. */
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const guard = require('./pm-guard.js');
|
|
18
|
+
const P = require('./principles.js');
|
|
19
|
+
const { recordsDirFor } = require('./records-dir.js');
|
|
20
|
+
|
|
21
|
+
const JOB = 'principles-draft';
|
|
22
|
+
const SEED_FILE = 'principles-seed.json';
|
|
23
|
+
const RETRY_MS = 24 * 3600000;
|
|
24
|
+
const SKILL = path.join(__dirname, '..', 'skills', 'principles-draft.skill');
|
|
25
|
+
const CHECKOUT = path.join(__dirname, '..', '..');
|
|
26
|
+
|
|
27
|
+
function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
|
|
28
|
+
/** The product checkout whose decisions are read. */
|
|
29
|
+
const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
|
|
30
|
+
|
|
31
|
+
/** The seed: deps { env, headlessOff() → bool, aiOff() → reason | null, stateDirFor(w) → dir | null, start(w, { onDone }) → { ok, session?, error? } }. */
|
|
32
|
+
function createSeed(deps) {
|
|
33
|
+
const running = new Set();
|
|
34
|
+
const fileOf = (w) => { const d = deps.stateDirFor ? deps.stateDirFor(w) : null; return d ? path.join(d, SEED_FILE) : null; };
|
|
35
|
+
const readAll = (f) => { try { const o = JSON.parse(fs.readFileSync(f, 'utf8')); return o && typeof o === 'object' ? o : {}; } catch { return {}; } };
|
|
36
|
+
function seed(w, { now = Date.now() } = {}) {
|
|
37
|
+
if (!w || !w.id) return { started: false, why: 'no product' };
|
|
38
|
+
const env = deps.env || {};
|
|
39
|
+
if (String(env.PMOS_STATE_DIR || '').trim()) return { started: false, why: 'scratch server' };
|
|
40
|
+
if (deps.headlessOff && deps.headlessOff()) return { started: false, why: 'background runs are off' };
|
|
41
|
+
let ai = null; try { ai = deps.aiOff ? deps.aiOff() : null; } catch { ai = null; }
|
|
42
|
+
if (ai) return { started: false, why: ai };
|
|
43
|
+
if (running.has(w.id)) return { started: false, why: 'running' };
|
|
44
|
+
const f = fileOf(w);
|
|
45
|
+
if (!f) return { started: false, why: 'no state folder' };
|
|
46
|
+
const all = readAll(f);
|
|
47
|
+
const last = Date.parse(all[w.id] || '');
|
|
48
|
+
if (Number.isFinite(last) && now - last < RETRY_MS) return { started: false, why: 'tried in the last day' };
|
|
49
|
+
try { all[w.id] = new Date(now).toISOString(); fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, JSON.stringify(all) + '\n'); } catch { return { started: false, why: 'could not record the start' }; }
|
|
50
|
+
let r = null;
|
|
51
|
+
try { r = deps.start(w, { onDone: () => running.delete(w.id) }); } catch { r = null; }
|
|
52
|
+
if (!r || !r.ok) return { started: false, why: (r && r.error) || 'the run could not start' };
|
|
53
|
+
running.add(w.id);
|
|
54
|
+
return { started: true, session: r.session || null };
|
|
55
|
+
}
|
|
56
|
+
return { seed, running: (id) => running.has(id) };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let shared = null;
|
|
60
|
+
function seedFor(ctx) {
|
|
61
|
+
if (ctx && ctx.principlesSeed) return ctx.principlesSeed;
|
|
62
|
+
if (shared) return shared;
|
|
63
|
+
if (!ctx || typeof ctx.spawnSession !== 'function' || typeof ctx.stateDirFor !== 'function') return null;
|
|
64
|
+
shared = createSeed({
|
|
65
|
+
env: process.env,
|
|
66
|
+
headlessOff: () => require('./headless.js').switchedOff(process.env),
|
|
67
|
+
aiOff: () => require('./ai-guard.js').off(JOB, { settingsDir: ctx.runtimeDir || null }),
|
|
68
|
+
stateDirFor: (w) => ctx.stateDirFor(w, { create: true }),
|
|
69
|
+
start: (w, { onDone } = {}) => {
|
|
70
|
+
let prompt = '';
|
|
71
|
+
try { prompt = require('./skill-store.js').parseSkill(fs.readFileSync(SKILL, 'utf8')).body || ''; } catch { prompt = ''; }
|
|
72
|
+
if (!prompt) return { ok: false, error: 'the principles-draft skill is not installed' };
|
|
73
|
+
const s = ctx.spawnSession({ name: 'Drafting the principles', agent: 'claude', ws: w.id, origin: JOB + ':' + w.id, initialInput: prompt + '\r', autoDelete: undefined, onDone,
|
|
74
|
+
modelAsk: { scheduleTier: null, skillTier: null, skill: JOB } });
|
|
75
|
+
if (!s || s.state === 'exited') return { ok: false, error: (s && s.note) || 'the run could not start' };
|
|
76
|
+
return { ok: true, session: s.id };
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return shared;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const pub = (x) => ({ id: x.id, state: x.state, own: !!x.own, text: x.text, why: x.why || '', sources: x.sources });
|
|
83
|
+
|
|
84
|
+
async function handle(req, res, url, ctx) {
|
|
85
|
+
if (url.pathname !== '/api/principles') return false;
|
|
86
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
87
|
+
if (req.method === 'GET') {
|
|
88
|
+
const wsId = url.searchParams.get('ws') || null;
|
|
89
|
+
const w = wsOf(ctx, wsId);
|
|
90
|
+
const dir = recordsDirFor(ctx, wsId);
|
|
91
|
+
const lines = P.readLines(dir);
|
|
92
|
+
const decisions = P.decisionsOf(rootFor(ctx, w)).length;
|
|
93
|
+
const seeder = seedFor(ctx);
|
|
94
|
+
if (!lines.length && decisions >= P.MIN_DECISIONS && seeder && w) seeder.seed(w);
|
|
95
|
+
const items = P.fold(lines).filter((x) => x.state !== 'dropped');
|
|
96
|
+
items.sort((a, b) => (a.state === b.state ? 0 : a.state === 'kept' ? -1 : 1));
|
|
97
|
+
return send(200, { ok: true, items: items.map(pub), decisions, drafting: !!(seeder && w && seeder.running && seeder.running(w.id)) });
|
|
98
|
+
}
|
|
99
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
|
|
100
|
+
const rd = await ctx.readJson(req);
|
|
101
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
102
|
+
const body = rd.body || {};
|
|
103
|
+
const g = guard.requirePagePress(req, body);
|
|
104
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
105
|
+
const r = P.act(recordsDirFor(ctx, body.ws || null), String(body.act || ''), body.id, { by: (g.actor && g.actor.by) || 'pm' });
|
|
106
|
+
return r.ok ? send(200, { ok: true, item: pub(r.item) }) : send(400, { ok: false, error: r.error });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = { prefixes: ['/api/principles'], handle, createSeed, seedFor, JOB, SEED_FILE, RETRY_MS };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.731.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.731.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -15,7 +15,7 @@ const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&':
|
|
|
15
15
|
const pad = (n) => String(n).padStart(2, '0');
|
|
16
16
|
const hm = (ms) => { const d = new Date(ms); return Number.isFinite(d.getTime()) ? pad(d.getHours()) + ':' + pad(d.getMinutes()) : ''; };
|
|
17
17
|
const svg = (d, n = 16, w = 1.9) => `<svg width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
18
|
-
const P = { check: 'M5 12.5l4.5 4.5L19 7.5', undo: 'M9 14L4 9l5-5M4
|
|
18
|
+
const P = { check: 'M5 12.5l4.5 4.5L19 7.5', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
|
|
19
19
|
spark: 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z' };
|
|
20
20
|
|
|
21
21
|
export function ensureCss() {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* pm/bd-principles.js — the product's principles, drafted by PMOS from its past decisions, below the strategy on its Board (bet A352,
|
|
2
|
+
* initiative product-principles-draft).
|
|
3
|
+
*
|
|
4
|
+
* mount(host, { ws, single, say }) → draws the block into `host`; a Board that shows several products at once shows none
|
|
5
|
+
*
|
|
6
|
+
* Built only from Komorebi parts: a Detail block (pm-block, its head), pm-li rows, pm-btn icon buttons. It reads and writes GET and POST
|
|
7
|
+
* /api/principles (lib/routes-principles.js) and nothing else.
|
|
8
|
+
* · Kept principles first, each with the decisions it came from.
|
|
9
|
+
* · Drafts after them, each with ✦, its why, its sources, and ✓ keep / ✕ drop. A press offers Undo in the Board's toast.
|
|
10
|
+
* · While PMOS drafts them: one quiet line. No principle and no draft: no block (zero is silence).
|
|
11
|
+
* The controls are named bdPrinKeep and bdPrinDrop (the button's name, its value the principle's id; one per row, so no id) and each press
|
|
12
|
+
* notes that name in the local use log (noteUse), which counts their use (the bet's kill line). */
|
|
13
|
+
import { pmPost } from './http.js';
|
|
14
|
+
import { noteUse } from './use-log.js';
|
|
15
|
+
|
|
16
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
17
|
+
const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
18
|
+
const I = { scale: 'M12 4v16M5 20h14M6 8h12M6 8l-3 6a3 3 0 0 0 6 0zM18 8l-3 6a3 3 0 0 0 6 0z', ok: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18' };
|
|
19
|
+
|
|
20
|
+
/** "from D12, D31". */
|
|
21
|
+
export const fromLine = (sources) => (Array.isArray(sources) && sources.length ? 'from ' + sources.join(', ') : '');
|
|
22
|
+
|
|
23
|
+
/** The block's markup. state = { items, drafting }. Pure, so the test reads it. '' when there is nothing to show. */
|
|
24
|
+
export function blockHtml(state) {
|
|
25
|
+
const items = Array.isArray(state && state.items) ? state.items : [];
|
|
26
|
+
const kept = items.filter((x) => x.state === 'kept'), open = items.filter((x) => x.state === 'open');
|
|
27
|
+
if (!kept.length && !open.length) {
|
|
28
|
+
return state && state.drafting ? `<section class="pm-block flat" aria-label="Principles"><div class="head">${SV(I.scale)}<h3 class="pm-h-sm" style="flex:1">Principles <span class="pm-meta">· PMOS is drafting them from your decisions</span></h3></div></section>` : '';
|
|
29
|
+
}
|
|
30
|
+
const btn = (name, icon, label, x, kind) => `<button type="button" class="pm-btn${kind ? ' ' + kind : ''}" name="${name}" value="${esc(x.id)}" aria-label="${esc(label)}" title="${esc(label)}">${SV(icon)}</button>`;
|
|
31
|
+
const row = (x) => {
|
|
32
|
+
const from = fromLine(x.sources);
|
|
33
|
+
const sub = [x.state === 'open' ? x.why : '', from].filter(Boolean).join(' · ');
|
|
34
|
+
const acts = x.state === 'open' ? `<span class="acts">${btn('bdPrinDrop', I.x, 'Drop this principle', x, 'outline')}${btn('bdPrinKeep', I.ok, 'Keep this principle', x, 'primary')}</span>` : '';
|
|
35
|
+
return `<div class="pm-li" role="listitem" data-prin-row="${esc(x.id)}"><span class="txt"><span class="t">${x.state === 'open' ? '<span aria-label="Drafted by PMOS">✦</span> ' : ''}${esc(x.text)}</span>${sub ? `<span class="w">${esc(sub)}</span>` : ''}</span>${acts}</div>`;
|
|
36
|
+
};
|
|
37
|
+
const meta = open.length ? (open.length === 1 ? '1 draft to keep or drop' : open.length + ' drafts to keep or drop') : '';
|
|
38
|
+
return `<section class="pm-block" aria-label="Principles"><div class="head">${SV(I.scale)}<h3 class="pm-h-sm" style="flex:1">Principles${meta ? ` <span class="pm-meta">· ${esc(meta)}</span>` : ''}</h3></div>`
|
|
39
|
+
+ `<div role="list">${kept.map(row).join('')}${open.map(row).join('')}</div></section>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Draw the block into `host` and wire its presses. */
|
|
43
|
+
export async function mount(host, opts = {}) {
|
|
44
|
+
if (!host) return;
|
|
45
|
+
const { ws = null, single = true, say = null } = opts;
|
|
46
|
+
if (!single) { host.hidden = true; host.innerHTML = ''; return; }
|
|
47
|
+
let r = null; try { r = await (await fetch('/api/principles' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
|
|
48
|
+
if (!r || !r.ok) { host.hidden = true; return; } // the block is an extra: a failed read leaves the Board as it was
|
|
49
|
+
const html = blockHtml(r);
|
|
50
|
+
host.hidden = !html; host.innerHTML = html;
|
|
51
|
+
host.onclick = async (e) => {
|
|
52
|
+
const b = e.target.closest('button[name="bdPrinKeep"], button[name="bdPrinDrop"]'); if (!b) return;
|
|
53
|
+
const act = b.name === 'bdPrinKeep' ? 'keep' : 'drop', id = b.value;
|
|
54
|
+
noteUse(b.name);
|
|
55
|
+
b.disabled = true;
|
|
56
|
+
const res = await pmPost('/api/principles', { ws, act, id }).catch(() => null);
|
|
57
|
+
if (!res || !res.ok) { b.disabled = false; if (say) say((res && res.error) || 'Not saved.'); return; }
|
|
58
|
+
if (say) say(act === 'keep' ? 'Principle kept.' : 'Principle dropped.', async () => { await pmPost('/api/principles', { ws, act: 'undo', id }).catch(() => null); mount(host, opts); });
|
|
59
|
+
mount(host, opts);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Draw the block again after a read of the Board. */
|
|
64
|
+
export const refresh = (host, opts) => mount(host, opts);
|
|
@@ -546,7 +546,7 @@ function scaled(rows, M, o) {
|
|
|
546
546
|
const ticks = W.ticks.map((k) => `<span style="left:${P(X(k.at))}" data-y="${k.y}" data-base="${esc(k.base)}"${k.plain ? ' data-plain' : ''}><b>${esc(k.label)}</b><small>${esc(k.sub)}</small></span>`).join('');
|
|
547
547
|
const tn = now > W.from && now < W.to ? X(now) : null;
|
|
548
548
|
const pill = tn != null ? `<span class="tg-tpill" style="left:${P(tn)}">Today</span>` : '';
|
|
549
|
-
const back = `<button type="button" class="tg-tback" data-today hidden aria-label="Back to today">${SV(
|
|
549
|
+
const back = `<button type="button" class="tg-tback" data-today hidden aria-label="Back to today">${SV('M19 12H5M11 6l-6 6 6 6')}<span>Today</span>${SV(CHR)}</button>`;
|
|
550
550
|
const attrs = `data-span="${sp}" data-from="${+W.from}" data-to="${+W.to}" data-ratio="${W.fixed ? 1 : ratio.toFixed(5)}" data-now="${+now}"${W.fixed ? ' data-fixed' : ''}`;
|
|
551
551
|
const style = `--tw:${Math.round(tpx * (W.fixed ? 1 : ratio))}px`;
|
|
552
552
|
// every undated initiative is a row that says "No dates" beside today, in every grouping and in no program too (batch 26 item 8, Wawan:
|
|
@@ -13,7 +13,7 @@ import { sugHtml } from './bd-stands.js';
|
|
|
13
13
|
|
|
14
14
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
15
15
|
const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
16
|
-
const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4
|
|
16
|
+
const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4', read: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7',
|
|
17
17
|
down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18' };
|
|
18
18
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
19
|
export const dayText = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
@@ -23,7 +23,7 @@ import * as DS from './bd-sprint-ds.js'; // This sprint from the system's part
|
|
|
23
23
|
|
|
24
24
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
25
25
|
const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
26
|
-
const I = { ok: 'M5 12.5l4.5 4.5L19 7', x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4L19 9l-4-4L4
|
|
26
|
+
const I = { ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4', read: 'M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7',
|
|
27
27
|
down: 'M7 10l5 5 5-5', chev: 'M10 7l5 5-5 5', lock: 'M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6z', jira: 'M12 3l9 9-9 9-9-9z M12 8l4 4-4 4-4-4z' };
|
|
28
28
|
const SPARK = '✦';
|
|
29
29
|
const OLD_MS = 36 * 3600000; // the Board's own line for an old Jira read (pm/premium-board.js jMood)
|
|
@@ -467,7 +467,7 @@ export function menuHtml(o = {}) {
|
|
|
467
467
|
const S = v.sorts, word = (k) => (SORT_KEYS.find(([x]) => x === k) || [k, (byK[k] || {}).n || k])[1];
|
|
468
468
|
const sortPills = `<button type="button" class="${S.length ? '' : 'on'}" aria-pressed="${!S.length}" data-wksortp="">PMOS order</button>`
|
|
469
469
|
+ sortKeys(o, S).map(([k, n]) => { const i = S.findIndex((x) => x.k === k); if (i < 0) return `<button type="button" aria-pressed="false" data-wksortp="${k}">${esc(n)}</button>`;
|
|
470
|
-
return `<span class="wk-sk"><button type="button" class="on" aria-pressed="true" data-wksortp="${k}" aria-label="${esc((i + 1) + ': ' + n + ', ' + (S[i].up ? 'first to last' : 'last to first') + '. Turn it round')}"><b>${i + 1}</b>${esc(n)}<span class="wk-sar${S[i].up ? '' : ' dn'}">${SV(I.sort, 11)}</span></button><button type="button" class="x" data-wksortx="${k}" aria-label="
|
|
470
|
+
return `<span class="wk-sk"><button type="button" class="on" aria-pressed="true" data-wksortp="${k}" aria-label="${esc((i + 1) + ': ' + n + ', ' + (S[i].up ? 'first to last' : 'last to first') + '. Turn it round')}"><b>${i + 1}</b>${esc(n)}<span class="wk-sar${S[i].up ? '' : ' dn'}">${SV(I.sort, 11)}</span></button><button type="button" class="x" data-wksortx="${k}" aria-label="Clear sorting by ${esc(n.toLowerCase())}">${SV(I.x, 11)}</button></span>`; }).join('');
|
|
471
471
|
const differs = JSON.stringify(v) !== JSON.stringify(u) || filterOn();
|
|
472
472
|
// a copy (shared-copy brief Part A 3): filter and sort, for this visit; nothing is kept and nothing reaches the publisher
|
|
473
473
|
if (RO || o.ro) return `<div class="wk-menu" role="dialog" aria-label="Filter and sort">`
|
|
@@ -53,7 +53,7 @@ export function monthGrid(at, o = {}) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const CAL = 'M7 3v3M17 3v3M4 8h16M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z';
|
|
56
|
-
const ARR = { prev: '
|
|
56
|
+
const ARR = { prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6' };
|
|
57
57
|
const svg = (d) => `<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
58
58
|
|
|
59
59
|
export function mountDay(el, o = {}) {
|
|
@@ -49,7 +49,7 @@ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
|
49
49
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
50
50
|
const svg = (d, w = 16) => `<svg class="pm-ic" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
51
51
|
export const ICON = {
|
|
52
|
-
yes: 'M5 12.5l4.5 4.5L19 7.5', no: 'M6 6l12 12M18 6L6 18', go: 'M9 6l6 6-6 6', back: '
|
|
52
|
+
yes: 'M5 12.5l4.5 4.5L19 7.5', no: 'M6 6l12 12M18 6L6 18', go: 'M9 6l6 6-6 6', back: 'M19 12H5M11 6l-6 6 6 6', plus: 'M12 5v14M5 12h14',
|
|
53
53
|
lock: 'M7 11V8a5 5 0 0 1 10 0v3M5.5 11h13v9h-13z', date: 'M7 5.5h10a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3v-8a3 3 0 0 1 3-3zM4 10h16M8.5 3.5v4M15.5 3.5v4',
|
|
54
54
|
done: 'M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17M8.5 12.2l2.4 2.4 4.6-5', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
|
|
55
55
|
};
|
|
@@ -35,7 +35,7 @@ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&':
|
|
|
35
35
|
const svg = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
36
36
|
const I = {
|
|
37
37
|
chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
|
|
38
|
-
hide: 'M4 5h16v14H4zM14.5 5v14M9 10l2 2-2 2', close: 'M6 6l12 12M18 6L6 18', down: 'M7 10l5 5 5-5', back: '
|
|
38
|
+
hide: 'M4 5h16v14H4zM14.5 5v14M9 10l2 2-2 2', close: 'M6 6l12 12M18 6L6 18', down: 'M7 10l5 5 5-5', back: 'M19 12H5M11 6l-6 6 6 6',
|
|
39
39
|
plus: 'M12 5v14M5 12h14', list: 'M5 7h14M5 12h14M5 17h14', find: 'M11 4.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 1 0 0-13M16 16l4 4', flag: 'M5 21V4h11l-2 4 2 4H5',
|
|
40
40
|
side: 'M3.5 5h17v14h-17zM12 5v14', more: 'M5 12h.01M12 12h.01M19 12h.01', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4',
|
|
41
41
|
};
|
|
@@ -43,7 +43,7 @@ const ICO = {
|
|
|
43
43
|
present: 'M3 4h18v12H3zM12 13V7M9 10l3-3 3 3M8 20h8M12 16v4', deck: 'M4 5h16v11H4zM12 16v4M8 20h8', doc: 'M7 3h7l5 5v13H7zM14 3v5h5',
|
|
44
44
|
image: 'M4 4.5h16v15H4zM9 10a1.6 1.6 0 1 0 0-.01M20 16l-5-5-8 8', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
|
|
45
45
|
search: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM20 20l-4-4', plus: 'M12 5v14M5 12h14', screen: 'M3 4h18v12H3zM8 20h8M12 16v4', x: 'M6 6l12 12M18 6L6 18',
|
|
46
|
-
prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6', up: 'M12 19V5M6 11l6-6 6 6', upload: 'M12 16V4M7 9l5-5 5
|
|
46
|
+
prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6', up: 'M12 19V5M6 11l6-6 6 6', upload: 'M12 16V4M7 9l5-5 5 5M5 20h14', eye: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z',
|
|
47
47
|
spark: 'M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8',
|
|
48
48
|
};
|
|
49
49
|
const ic = (k, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${ICO[k]}"/></svg>`;
|
|
@@ -90,7 +90,7 @@ export const smartHtml = (d) => dotsHtml(LETTERS.map(([, k]) => ({ name: k, agre
|
|
|
90
90
|
|
|
91
91
|
const P = (d, n = 18, w = 2) => `<svg width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
92
92
|
export const ICON = { go: 'M5 12h14M13 6l6 6-6 6', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', x: 'M6 6l12 12M18 6 6 18', ok: 'M5 12.5l4.5 4.5L19 7', plus: 'M12 5v14M5 12h14',
|
|
93
|
-
grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M6 9l6 6 6-6', undo: 'M9
|
|
93
|
+
grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M6 9l6 6 6-6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3' };
|
|
94
94
|
const icb = (attr, label, icon, pri) => `<button type="button" class="icb${pri ? ' pri' : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${P(icon, 18, icon === ICON.ok ? 2.4 : 2)}</button>`;
|
|
95
95
|
|
|
96
96
|
/** The method line over a question: "Method: Done criteria ⌄ it ends in a document". live: Change opens the menu of the other methods. */
|
|
@@ -49,7 +49,7 @@ const views = {
|
|
|
49
49
|
|
|
50
50
|
const SVG = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
51
51
|
const CHEV = 'M9 6l6 6-6 6', ARROW = 'M5 12h14M13 6l6 6-6 6', UP = 'M12 19V5M6 11l6-6 6 6', PLUS = 'M12 5v14M5 12h14', DOWN = 'M6 9l6 6 6-6';
|
|
52
|
-
const MIC = 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', SQ = '
|
|
52
|
+
const MIC = 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', SQ = 'M8 6h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z', XX = 'M6 6l12 12M18 6L6 18', OK = 'M5 12l5 5 9-10';
|
|
53
53
|
const PANE = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="3" y="4" width="18" height="16" rx="3"></rect><path d="M14 4v16"></path></svg>';
|
|
54
54
|
const INTERRUPT = /^\[Request interrupted by user/;
|
|
55
55
|
const POLL = 2000, IDLE_POLL = 9000;
|