create-pmos 0.851.0 → 0.852.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 +79 -105
- package/payload/AGENTS.md +63 -0
- 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 +78 -22
- package/workspace/guide/cli.md +20 -0
- package/workspace/guide/initiatives-and-next-steps.md +11 -0
- package/workspace/guide/programs.md +1 -0
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/knowledge-cli.js +6 -0
- package/workspace/lib/on-item-routes.js +68 -0
- package/workspace/lib/on-item.js +272 -0
- package/workspace/lib/one-person-knows.js +403 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-capture.js +1 -1
- package/workspace/lib/routes-one-person-knows.js +40 -0
- package/workspace/lib/routes-screen-map.js +47 -0
- package/workspace/lib/routes-stage-signoffs.js +4 -1
- package/workspace/lib/screen-map.js +381 -0
- package/workspace/lib/signoffs.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-prog-panel.js +25 -1
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-pop-work.js +5 -2
- package/workspace/public/pm/home-app.js +5 -0
- package/workspace/public/pm/on-item.js +155 -0
- package/workspace/public/pm/one-person-knows.js +66 -0
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/screen-map.css +23 -0
- package/workspace/public/pm/screen-map.js +187 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/kit-agents-verbs.json +9 -0
- package/workspace/test-lists/one-person-knows.json +9 -0
- package/workspace/test-lists/screen-map.json +9 -0
- package/workspace/test-lists/surface-on-item.json +9 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* screen-map.js — the live map of a product's screens (initiative screen-map, job #1895, idea A318; board BatchPlanDS panel 8).
|
|
3
|
+
*
|
|
4
|
+
* screensOf(files) → [{ id, file, route, name, kind }] PURE: the screens among the paths, files = [{ path, text }]
|
|
5
|
+
* flowsOf(screens, files, extra) → [{ from, to }] PURE: the links between them (extra: a screen's loaded scripts)
|
|
6
|
+
* marksOf(screens, flows) → { [id]: { marks: [{ kind, why }], steps } } PURE: dup, dead end, deep (more than 4 steps)
|
|
7
|
+
* read(root, { ref }) → { ok, ref, commit, updated, screens, flows, counts } | { ok: false, error }
|
|
8
|
+
* note(root, { screen, text, actor, stateDir }) → { ok, id, file, screen } | { ok: false, status, error }
|
|
9
|
+
* run(argv, o) → `pmos screens [show|note]`
|
|
10
|
+
*
|
|
11
|
+
* ANY PRODUCT. A screen is an HTML page (its name from <title>, else the file name) or a file route: Next.js `pages/` and
|
|
12
|
+
* `app/**\/page.*`, SvelteKit `+page.svelte`, Nuxt `pages/*.vue`. A flow is a link in a screen's file (href, to=, location,
|
|
13
|
+
* router.push, navigate, goto, redirect, window.open), or in a local script an HTML page loads, joined to the screen its route names.
|
|
14
|
+
*
|
|
15
|
+
* MERGED CODE ONLY. read() takes the files from the default branch (origin/HEAD, else origin/main, main, master, HEAD) with
|
|
16
|
+
* `git ls-tree` and `git cat-file --batch`, never the working tree, so the map follows each merge and shows the date of the commit it
|
|
17
|
+
* read. It is kept in memory by commit, so a read with no new merge costs one `git rev-parse`.
|
|
18
|
+
*
|
|
19
|
+
* WRITES NOTHING to the product's files. note() writes one capture through lib/capture.js (the folder Today's capture card and triage
|
|
20
|
+
* read), naming the screen and its file; PMOS files it as work from there. No model, no network, nothing sent. Log lines carry [screen-map].
|
|
21
|
+
*/
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
const { execFileSync } = require('child_process');
|
|
25
|
+
|
|
26
|
+
const TAG = '[screen-map]';
|
|
27
|
+
const DEEP = 4; // a screen more than this many steps from the start is marked deep
|
|
28
|
+
const MAX_SCREENS = 300;
|
|
29
|
+
const MAX_BYTES = 400 * 1024;
|
|
30
|
+
|
|
31
|
+
/* ── which paths are screens ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
32
|
+
const SKIP_DIR = /(^|\/)(node_modules|\.git|\.github|vendor|vendors|dist|build|out|coverage|\.next|\.nuxt|\.output|\.svelte-kit|storybook-static|\.?storybook|components|design-system|styleguide|docs|test|tests|__tests__|e2e|spec|specs|fixtures|__fixtures__|mocks|__mocks__|planning|prototype|prototypes|examples?)(\/|$)/i;
|
|
33
|
+
const SKIP_FILE = /\.(test|spec|stories|story)\.[a-z]+$/i;
|
|
34
|
+
const WEB_ROOT = /^(?:.*\/)?(public|static|www|site|web|src|client|frontend|html)\//;
|
|
35
|
+
|
|
36
|
+
const humanize = (s) => {
|
|
37
|
+
const t = String(s || '').replace(/\.[a-z0-9]+$/i, '').replace(/[-_.]+/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2').trim();
|
|
38
|
+
return t ? t[0].toUpperCase() + t.slice(1) : '';
|
|
39
|
+
};
|
|
40
|
+
const titleOf = (text) => {
|
|
41
|
+
const m = /<title[^>]*>([^<]*)<\/title>/i.exec(String(text || ''));
|
|
42
|
+
if (!m) return '';
|
|
43
|
+
const t = m[1].replace(/&/g, '&').replace(/'|'/g, "'").replace(/"/g, '"').replace(/\s+/g, ' ').trim();
|
|
44
|
+
return (t.split(/\s+[|·—–]\s+/).find((x) => x.trim()) || '').trim();
|
|
45
|
+
};
|
|
46
|
+
/** The route a file serves, or null when it is not a screen. */
|
|
47
|
+
function routeOf(p) {
|
|
48
|
+
if (SKIP_DIR.test(p) || SKIP_FILE.test(p)) return null;
|
|
49
|
+
let m;
|
|
50
|
+
if (/\.html?$/i.test(p)) {
|
|
51
|
+
const rel = p.replace(WEB_ROOT, '');
|
|
52
|
+
const r = '/' + rel;
|
|
53
|
+
return { kind: 'html', route: normRoute(r) };
|
|
54
|
+
}
|
|
55
|
+
if ((m = /(?:^|\/)routes\/(.*?)\+page\.svelte$/.exec(p))) return { kind: 'svelte', route: normRoute('/' + stripGroups(m[1])) };
|
|
56
|
+
if ((m = /(?:^|\/)app\/(.*?)page\.(?:jsx?|tsx?|mdx)$/.exec(p)) && (m[1] === '' || m[1].endsWith('/'))) return { kind: 'next-app', route: normRoute('/' + stripGroups(m[1])) };
|
|
57
|
+
if ((m = /(?:^|\/)pages\/(.+)\.(?:jsx?|tsx?|mdx|vue)$/.exec(p))) {
|
|
58
|
+
const rest = m[1];
|
|
59
|
+
if (/(^|\/)_/.test(rest) || /^api(\/|$)/.test(rest)) return null;
|
|
60
|
+
return { kind: /\.vue$/.test(p) ? 'nuxt' : 'next-pages', route: normRoute('/' + rest) };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const stripGroups = (s) => String(s).split('/').filter((x) => x && !/^\(.*\)$/.test(x) && !x.startsWith('@')).join('/');
|
|
65
|
+
/** One spelling per route: no query or hash, no .html, no /index, no trailing slash (except the root). */
|
|
66
|
+
function normRoute(r) {
|
|
67
|
+
let s = String(r || '').split(/[?#]/)[0];
|
|
68
|
+
s = s.replace(/\/{2,}/g, '/').replace(/\.html?$/i, '').replace(/(^|\/)index$/i, '$1');
|
|
69
|
+
if (!s.startsWith('/')) s = '/' + s;
|
|
70
|
+
if (s.length > 1) s = s.replace(/\/+$/, '');
|
|
71
|
+
return s || '/';
|
|
72
|
+
}
|
|
73
|
+
function nameOfRoute(route) {
|
|
74
|
+
const seg = route.split('/').filter(Boolean);
|
|
75
|
+
if (!seg.length) return 'Home';
|
|
76
|
+
const last = seg[seg.length - 1];
|
|
77
|
+
if (/^\[.*\]$|^:/.test(last) || /^_?_?slug$/i.test(last)) return seg.length > 1 ? humanize(seg[seg.length - 2]).replace(/s$/, '') + ' detail' : 'Detail';
|
|
78
|
+
return humanize(last);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** PURE. The screens among the files, at most MAX_SCREENS, in path order. A title shared by several pages names none of them. */
|
|
82
|
+
function screensOf(files) {
|
|
83
|
+
const found = [];
|
|
84
|
+
for (const f of files || []) {
|
|
85
|
+
const r = routeOf(f.path);
|
|
86
|
+
if (!r) continue;
|
|
87
|
+
found.push({ id: f.path, file: f.path, route: r.route, kind: r.kind, title: r.kind === 'html' ? titleOf(f.text) : '' });
|
|
88
|
+
if (found.length >= MAX_SCREENS) break;
|
|
89
|
+
}
|
|
90
|
+
const seen = new Map();
|
|
91
|
+
for (const s of found) if (s.title) seen.set(s.title, (seen.get(s.title) || 0) + 1);
|
|
92
|
+
return found.map((s) => {
|
|
93
|
+
const own = s.title && seen.get(s.title) === 1 ? s.title : '';
|
|
94
|
+
const name = own || (s.kind === 'html' ? (s.route === '/' ? 'Home' : humanize(path.basename(s.file).replace(/^index\.html?$/i, path.basename(path.dirname(s.file))))) : nameOfRoute(s.route));
|
|
95
|
+
return { id: s.id, file: s.file, route: s.route, name: name || s.file, kind: s.kind };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ── the flows between them ───────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
100
|
+
const LINK_RES = [
|
|
101
|
+
/\b(?:href|to)\s*=\s*\{?\s*(["'`])([^"'`\n]+)\1/g,
|
|
102
|
+
/\b(?:window\.)?location(?:\.href)?\s*=\s*(["'`])([^"'`\n]+)\1/g,
|
|
103
|
+
/\b(?:location\.(?:assign|replace)|window\.open|router\.(?:push|replace)|history\.push|navigate|navigateTo|goto|redirect)\s*\(\s*\{?\s*(?:pathname\s*:\s*)?(["'`])([^"'`\n]+)\1/g,
|
|
104
|
+
];
|
|
105
|
+
const EXTERNAL = /^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i;
|
|
106
|
+
/** The links in a text, as written (template parts become one segment). */
|
|
107
|
+
function linksIn(text) {
|
|
108
|
+
const out = [];
|
|
109
|
+
const t = String(text || '');
|
|
110
|
+
for (const re of LINK_RES) { re.lastIndex = 0; let m; while ((m = re.exec(t))) out.push(m[2].replace(/\$\{[^}]*\}/g, 'x').trim()); }
|
|
111
|
+
return out.filter((l) => l && !EXTERNAL.test(l) && !/^\{|^\$|\.(css|js|mjs|json|png|jpe?g|svg|gif|webp|ico|pdf|zip|woff2?)([?#]|$)/i.test(l));
|
|
112
|
+
}
|
|
113
|
+
/** A link, resolved against the route of the screen it is in. */
|
|
114
|
+
function resolve(link, fromRoute, kind) {
|
|
115
|
+
const l = link.split(/[?#]/)[0];
|
|
116
|
+
if (!l) return null;
|
|
117
|
+
if (l.startsWith('/')) return normRoute(l);
|
|
118
|
+
// a relative link: an HTML page resolves against its folder; a file route against itself as a folder's index
|
|
119
|
+
const base = kind === 'html' ? fromRoute.replace(/[^/]*$/, '') : fromRoute.replace(/\/?$/, '/');
|
|
120
|
+
const parts = (base + l).split('/');
|
|
121
|
+
const st = [];
|
|
122
|
+
for (const p of parts) { if (p === '..') st.pop(); else if (p !== '.' && p !== '') st.push(p); }
|
|
123
|
+
return normRoute('/' + st.join('/'));
|
|
124
|
+
}
|
|
125
|
+
/** A matcher for each screen's route: the exact spelling, then a dynamic one ([id], [...slug], :id) as a pattern. */
|
|
126
|
+
function matcherOf(screens) {
|
|
127
|
+
const exact = new Map();
|
|
128
|
+
const dyn = [];
|
|
129
|
+
for (const s of screens) {
|
|
130
|
+
// an HTML page also answers to its route under its web root's folder name dropped or kept (public/a.html is /a)
|
|
131
|
+
exact.set(s.route, s.id);
|
|
132
|
+
if (s.kind === 'html') exact.set(normRoute('/' + s.file), exact.get(normRoute('/' + s.file)) || s.id);
|
|
133
|
+
if (/\[|\/:/.test(s.route)) {
|
|
134
|
+
const re = new RegExp('^' + s.route.split('/').map((x) => (/^\[\.\.\..*\]$/.test(x) ? '.+' : /^\[.*\]$|^:/.test(x) ? '[^/]+' : x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))).join('/') + '$');
|
|
135
|
+
dyn.push([re, s.id]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return (route) => exact.get(route) || (dyn.find(([re]) => re.test(route)) || [])[1] || null;
|
|
139
|
+
}
|
|
140
|
+
/** PURE. files: [{ path, text }]; extra: { [screen id]: [text of each local script it loads] }. */
|
|
141
|
+
function flowsOf(screens, files, extra = {}) {
|
|
142
|
+
const text = new Map((files || []).map((f) => [f.path, f.text]));
|
|
143
|
+
const find = matcherOf(screens);
|
|
144
|
+
const seen = new Set();
|
|
145
|
+
const out = [];
|
|
146
|
+
for (const s of screens) {
|
|
147
|
+
const texts = [text.get(s.file) || ''].concat(extra[s.id] || []);
|
|
148
|
+
for (const t of texts) for (const l of linksIn(t)) {
|
|
149
|
+
const to = find(resolve(l, s.route, s.kind) || '');
|
|
150
|
+
if (!to || to === s.id) continue;
|
|
151
|
+
const k = s.id + '\u0000' + to;
|
|
152
|
+
if (seen.has(k)) continue;
|
|
153
|
+
seen.add(k); out.push({ from: s.id, to });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
/** The local scripts an HTML page loads, as repository paths. */
|
|
159
|
+
function scriptsOf(screen, text) {
|
|
160
|
+
if (screen.kind !== 'html') return [];
|
|
161
|
+
const out = [];
|
|
162
|
+
const re = /<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi;
|
|
163
|
+
let m;
|
|
164
|
+
const dir = path.posix.dirname(screen.file);
|
|
165
|
+
const webRoot = (WEB_ROOT.exec(screen.file) || [''])[0];
|
|
166
|
+
while ((m = re.exec(String(text || '')))) {
|
|
167
|
+
const src = m[1].split(/[?#]/)[0];
|
|
168
|
+
if (EXTERNAL.test(src)) continue;
|
|
169
|
+
out.push(src.startsWith('/') ? path.posix.normalize(webRoot + src.slice(1)) : path.posix.normalize(path.posix.join(dir, src)));
|
|
170
|
+
}
|
|
171
|
+
return out.slice(0, 8);
|
|
172
|
+
}
|
|
173
|
+
const SCRIPT = /\.(m?js|jsx|tsx?|vue|svelte)$/;
|
|
174
|
+
/** The relative modules a script imports (static `import … from './x'`, `import('./x')`, `require('./x')`), as repository paths. */
|
|
175
|
+
function importsOf(file, text, have) {
|
|
176
|
+
const out = [];
|
|
177
|
+
const re = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|^\s*import\s+)(["'])(\.{1,2}\/[^"'\n]+)\1/gm;
|
|
178
|
+
let m;
|
|
179
|
+
const dir = path.posix.dirname(file);
|
|
180
|
+
while ((m = re.exec(String(text || '')))) {
|
|
181
|
+
const p = path.posix.normalize(path.posix.join(dir, m[2]));
|
|
182
|
+
const hit = [p, p + '.js', p + '.ts', p + '.tsx', p + '.jsx', p + '/index.js', p + '/index.ts', p + '/index.tsx'].find((x) => have.has(x) && SCRIPT.test(x));
|
|
183
|
+
if (hit) out.push(hit);
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
const DEPTH = 2; // how many import steps from a screen its links are read
|
|
188
|
+
const PER_SCREEN = 60; // at most this many scripts read for one screen
|
|
189
|
+
|
|
190
|
+
/* ── the marks ────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
191
|
+
const dupKey = (name) => String(name || '').toLowerCase().replace(/[()[\]_.\-:/]+/g, ' ')
|
|
192
|
+
.split(/\s+/).filter((w) => w && !/^(old|new|copy|backup|bak|legacy|v\d+|\d+)$/.test(w)).join(' ');
|
|
193
|
+
const sameText = (t) => String(t || '').replace(/\s+/g, ' ').trim();
|
|
194
|
+
/** PURE. Each screen's marks and its steps from the start. Unmarked screens carry an empty list. */
|
|
195
|
+
function marksOf(screens, flows, files = []) {
|
|
196
|
+
const by = new Map(screens.map((s) => [s.id, { marks: [], steps: null }]));
|
|
197
|
+
const name = new Map(screens.map((s) => [s.id, s.name]));
|
|
198
|
+
// duplicates: the same name once old/new/copy/a version is taken off, or the same content
|
|
199
|
+
const groups = new Map();
|
|
200
|
+
const add = (k, id) => { if (!k) return; if (!groups.has(k)) groups.set(k, new Set()); groups.get(k).add(id); };
|
|
201
|
+
const text = new Map(files.map((f) => [f.path, f.text]));
|
|
202
|
+
for (const s of screens) {
|
|
203
|
+
add('n:' + dupKey(s.name), s.id);
|
|
204
|
+
const t = sameText(text.get(s.file));
|
|
205
|
+
if (t.length > 40) add('t:' + t, s.id);
|
|
206
|
+
}
|
|
207
|
+
const twins = new Map();
|
|
208
|
+
for (const g of groups.values()) if (g.size > 1) for (const id of g) { if (!twins.has(id)) twins.set(id, new Set()); for (const o of g) if (o !== id) twins.get(id).add(o); }
|
|
209
|
+
for (const [id, o] of twins) {
|
|
210
|
+
const L = [...new Set([...o].map((x) => name.get(x)))];
|
|
211
|
+
by.get(id).marks.push({ kind: 'dup', why: 'Looks like ' + L.slice(0, 3).join(', ') + (L.length > 3 ? ` and ${L.length - 3} more` : '') });
|
|
212
|
+
}
|
|
213
|
+
// dead ends: no flow on to another screen. Only when the links were read for at least half the screens: a product whose links PMOS
|
|
214
|
+
// cannot read (a router it does not know) would mark every screen, and a mark on every screen says nothing
|
|
215
|
+
const out = new Map(); const inn = new Map();
|
|
216
|
+
for (const f of flows) { (out.get(f.from) || out.set(f.from, []).get(f.from)).push(f.to); inn.set(f.to, (inn.get(f.to) || 0) + 1); }
|
|
217
|
+
if (screens.length > 1 && out.size * 2 >= screens.length) for (const s of screens) if (!(out.get(s.id) || []).length) by.get(s.id).marks.push({ kind: 'dead', why: 'No way on from this screen' });
|
|
218
|
+
// steps from the start: the root route, else the screens nothing leads to, else the first
|
|
219
|
+
let starts = screens.filter((s) => s.route === '/');
|
|
220
|
+
if (!starts.length) starts = screens.filter((s) => !inn.get(s.id));
|
|
221
|
+
if (!starts.length && screens.length) starts = [screens[0]];
|
|
222
|
+
const first = new Map();
|
|
223
|
+
const q = [];
|
|
224
|
+
for (const s of starts) { by.get(s.id).steps = 0; first.set(s.id, s.name); q.push(s.id); }
|
|
225
|
+
while (q.length) {
|
|
226
|
+
const id = q.shift();
|
|
227
|
+
for (const to of out.get(id) || []) { const b = by.get(to); if (b && b.steps === null) { b.steps = by.get(id).steps + 1; first.set(to, first.get(id)); q.push(to); } }
|
|
228
|
+
}
|
|
229
|
+
for (const s of screens) {
|
|
230
|
+
const b = by.get(s.id);
|
|
231
|
+
if (b.steps !== null && b.steps > DEEP) b.marks.push({ kind: 'deep', why: `${b.steps} steps from ${first.get(s.id)}` });
|
|
232
|
+
}
|
|
233
|
+
return Object.fromEntries(by);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* ── reading the merged code ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
237
|
+
const git = (root, args, input) => execFileSync('git', args, { cwd: root, input, maxBuffer: 256 * 1024 * 1024, stdio: ['pipe', 'pipe', 'ignore'] });
|
|
238
|
+
function defaultRef(root) {
|
|
239
|
+
try { const r = git(root, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD']).toString().trim(); if (r) return r; } catch { /* no remote HEAD */ }
|
|
240
|
+
for (const b of ['origin/main', 'origin/master', 'main', 'master']) { try { git(root, ['rev-parse', '--verify', '--quiet', b + '^{commit}']); return b; } catch { /* next */ } }
|
|
241
|
+
return 'HEAD';
|
|
242
|
+
}
|
|
243
|
+
/** The blobs of `paths` at `commit`, as text; a missing or large one is ''. */
|
|
244
|
+
function blobs(root, commit, paths) {
|
|
245
|
+
const out = new Map();
|
|
246
|
+
if (!paths.length) return out;
|
|
247
|
+
const buf = git(root, ['cat-file', '--batch'], paths.map((p) => `${commit}:${p}`).join('\n') + '\n');
|
|
248
|
+
let i = 0;
|
|
249
|
+
for (const p of paths) {
|
|
250
|
+
const nl = buf.indexOf(10, i);
|
|
251
|
+
if (nl < 0) break;
|
|
252
|
+
const head = buf.slice(i, nl).toString();
|
|
253
|
+
i = nl + 1;
|
|
254
|
+
const m = /^[0-9a-f]+ (\w+) (\d+)$/.exec(head);
|
|
255
|
+
if (!m) { out.set(p, ''); continue; }
|
|
256
|
+
const size = Number(m[2]);
|
|
257
|
+
out.set(p, m[1] === 'blob' && size <= MAX_BYTES ? buf.slice(i, i + size).toString('utf8') : '');
|
|
258
|
+
i += size + 1;
|
|
259
|
+
}
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
const CACHE = new Map(); // root → { commit, map }
|
|
263
|
+
function read(root, { ref } = {}) {
|
|
264
|
+
let r = ref, commit;
|
|
265
|
+
try {
|
|
266
|
+
r = r || defaultRef(root);
|
|
267
|
+
commit = git(root, ['rev-parse', '--verify', r + '^{commit}']).toString().trim();
|
|
268
|
+
} catch { return { ok: false, error: 'This folder is not a git repository with a commit yet.' }; }
|
|
269
|
+
const hit = CACHE.get(root);
|
|
270
|
+
if (hit && hit.commit === commit) return hit.map;
|
|
271
|
+
const updated = git(root, ['log', '-1', '--format=%cI', commit]).toString().trim();
|
|
272
|
+
const all = git(root, ['ls-tree', '-r', '-z', '--name-only', commit]).toString().split('\0').filter(Boolean);
|
|
273
|
+
const cand = all.filter((p) => routeOf(p));
|
|
274
|
+
const text = blobs(root, commit, cand.slice(0, MAX_SCREENS * 2));
|
|
275
|
+
const files = cand.map((p) => ({ path: p, text: text.get(p) || '' }));
|
|
276
|
+
const screens = screensOf(files);
|
|
277
|
+
// the scripts each screen runs: the ones an HTML page loads, then their relative imports, DEPTH steps; each blob read once
|
|
278
|
+
const have = new Set(all);
|
|
279
|
+
const src = new Map(text);
|
|
280
|
+
const reach = new Map(screens.map((s) => [s.id, new Set()]));
|
|
281
|
+
let front = new Map(screens.map((s) => [s.id, s.kind === 'html' ? scriptsOf(s, text.get(s.file)).filter((p) => have.has(p)) : importsOf(s.file, text.get(s.file), have)]));
|
|
282
|
+
for (let d = 0; d < DEPTH + 1; d++) {
|
|
283
|
+
const need = [...new Set([].concat(...front.values()))].filter((p) => !src.has(p));
|
|
284
|
+
for (const [p, t] of blobs(root, commit, need)) src.set(p, t);
|
|
285
|
+
const next = new Map();
|
|
286
|
+
for (const [id, L] of front) {
|
|
287
|
+
const R = reach.get(id), add = [];
|
|
288
|
+
for (const p of L) if (!R.has(p) && R.size < PER_SCREEN) { R.add(p); add.push(p); }
|
|
289
|
+
if (d < DEPTH) next.set(id, [].concat(...add.map((p) => importsOf(p, src.get(p), have))));
|
|
290
|
+
}
|
|
291
|
+
front = next;
|
|
292
|
+
}
|
|
293
|
+
const extra = Object.fromEntries([...reach].map(([id, R]) => [id, [...R].map((p) => src.get(p) || '')]));
|
|
294
|
+
const flows = flowsOf(screens, files, extra);
|
|
295
|
+
const marks = marksOf(screens, flows, files);
|
|
296
|
+
const S = screens.map((s) => ({ id: s.id, name: s.name, file: s.file, route: s.route, marks: marks[s.id].marks, steps: marks[s.id].steps }));
|
|
297
|
+
const counts = { screens: S.length, flows: flows.length, dup: 0, dead: 0, deep: 0 };
|
|
298
|
+
for (const s of S) for (const m of s.marks) counts[m.kind]++;
|
|
299
|
+
const map = { ok: true, ref: r, commit, updated, screens: S, flows, counts };
|
|
300
|
+
CACHE.set(root, { commit, map });
|
|
301
|
+
console.log(`${TAG} read ${r}@${commit.slice(0, 7)} screens=${S.length} flows=${flows.length} dup=${counts.dup} dead=${counts.dead} deep=${counts.deep}`);
|
|
302
|
+
return map;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* ── a note on a screen: a capture that names it ──────────────────────────────────────────────────────────────────────────── */
|
|
306
|
+
/** The folder Today's capture card and triage read (routes-capture.js's rule by hand): pmos/state in a kit, else planning. */
|
|
307
|
+
function captureDir(root) {
|
|
308
|
+
const kit = !fs.existsSync(path.join(root, 'planning', 'initiatives')) && fs.existsSync(path.join(root, 'pmos', 'state', 'initiatives'));
|
|
309
|
+
return kit ? path.join(root, 'pmos', 'state') : path.join(root, 'planning');
|
|
310
|
+
}
|
|
311
|
+
function findScreen(map, key) {
|
|
312
|
+
const k = String(key || '').trim();
|
|
313
|
+
if (!k) return { error: 'Name the screen: its file or its name.' };
|
|
314
|
+
const exact = map.screens.find((s) => s.id === k || s.file === k);
|
|
315
|
+
if (exact) return { screen: exact };
|
|
316
|
+
const named = map.screens.filter((s) => s.name.toLowerCase() === k.toLowerCase() || s.route === k);
|
|
317
|
+
if (named.length === 1) return { screen: named[0] };
|
|
318
|
+
if (named.length > 1) return { error: `${named.length} screens are named ${k}. Name its file: ${named.map((s) => s.file).join(', ')}.` };
|
|
319
|
+
return { error: `The map has no screen ${k}.` };
|
|
320
|
+
}
|
|
321
|
+
const noteText = (s, text) => `Screen ${s.name} (${s.file}): ${String(text).trim()}`;
|
|
322
|
+
function note(root, { screen, text, actor, stateDir, map } = {}) {
|
|
323
|
+
if (typeof text !== 'string' || !text.trim()) return { ok: false, status: 400, error: 'Type the note first.' };
|
|
324
|
+
const M = map || read(root);
|
|
325
|
+
if (!M.ok) return { ok: false, status: 409, error: M.error };
|
|
326
|
+
const f = findScreen(M, screen);
|
|
327
|
+
if (f.error) return { ok: false, status: 404, error: f.error };
|
|
328
|
+
const r = require('./capture.js').write(stateDir || captureDir(root), { text: noteText(f.screen, text), actor });
|
|
329
|
+
if (!r.ok) return r;
|
|
330
|
+
console.log(`${TAG} note ${r.id} screen=${f.screen.file}`);
|
|
331
|
+
return { ok: true, id: r.id, file: r.file, screen: { id: f.screen.id, name: f.screen.name, file: f.screen.file } };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* ── pmos screens ─────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
335
|
+
const COMMANDS = { screens: ['show', 'note'] };
|
|
336
|
+
const USAGE = [
|
|
337
|
+
'usage: pmos screens [show|note] — the map of the product\'s screens, from its merged code',
|
|
338
|
+
' pmos screens show every screen, its route, its marks and where it leads (writes nothing)',
|
|
339
|
+
' pmos screens note <screen> "<text>" a note on a screen (its file or its name), kept as a capture PMOS files as work',
|
|
340
|
+
' every command: [--json] [--root <dir>]',
|
|
341
|
+
'Marks: duplicate, dead end (no way on), deep (more than 4 steps from the start). Nothing is sent.',
|
|
342
|
+
];
|
|
343
|
+
const WORD = { dup: 'duplicate', dead: 'dead end', deep: 'deep' };
|
|
344
|
+
function repoOf(cwd) {
|
|
345
|
+
let d = path.resolve(cwd);
|
|
346
|
+
for (;;) { if (fs.existsSync(path.join(d, '.git'))) return d; const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
|
|
347
|
+
}
|
|
348
|
+
function run(argv, o = {}) {
|
|
349
|
+
const say = o.say || ((s) => console.log(s));
|
|
350
|
+
const args = argv[0] === 'screens' ? argv.slice(1) : argv.slice();
|
|
351
|
+
const pos = [], flags = {};
|
|
352
|
+
for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root') flags.root = args[++i]; else if (a === '--json') flags.json = true; else if (a === '--help' || a === '-h') flags.help = true; else pos.push(a); }
|
|
353
|
+
const cmd = pos[0] || 'show';
|
|
354
|
+
if (flags.help || cmd === 'help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
355
|
+
if (!COMMANDS.screens.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos screens`); USAGE.forEach((l) => say(l)); return 2; }
|
|
356
|
+
const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
|
|
357
|
+
const M = read(root);
|
|
358
|
+
if (!M.ok) { say(`✗ ${M.error}`); return 1; }
|
|
359
|
+
if (cmd === 'note') {
|
|
360
|
+
if (pos.length < 3) { say('✗ pmos screens note needs a screen and the note.'); USAGE.forEach((l) => say(l)); return 2; }
|
|
361
|
+
const actor = o.actor || require('./actor.js').fromCli({ isTTY: !!process.stdin.isTTY, env: process.env });
|
|
362
|
+
const r = note(root, { screen: pos[1], text: pos.slice(2).join(' '), actor, stateDir: o.stateDir, map: M });
|
|
363
|
+
if (flags.json) { say(JSON.stringify(r)); return r.ok ? 0 : 1; }
|
|
364
|
+
if (!r.ok) { say(`✗ ${r.error}`); return 1; }
|
|
365
|
+
say(`✓ Kept as ${r.id}: a note on ${r.screen.name}. PMOS files it as work; Today shows it.`);
|
|
366
|
+
return 0;
|
|
367
|
+
}
|
|
368
|
+
if (flags.json) { say(JSON.stringify(M)); return 0; }
|
|
369
|
+
if (!M.screens.length) { say(`No screen found in ${M.ref}.`); return 0; }
|
|
370
|
+
const name = new Map(M.screens.map((s) => [s.id, s.name]));
|
|
371
|
+
const to = new Map();
|
|
372
|
+
for (const f of M.flows) (to.get(f.from) || to.set(f.from, []).get(f.from)).push(name.get(f.to));
|
|
373
|
+
say(`${M.screens.length} screens in ${M.ref}, updated ${M.updated.slice(0, 10)}.`);
|
|
374
|
+
for (const s of M.screens) {
|
|
375
|
+
const marks = s.marks.map((m) => `${WORD[m.kind]}: ${m.why}`).join('; ');
|
|
376
|
+
say(`- ${s.name} (${s.route}, ${s.file})${(to.get(s.id) || []).length ? ' → ' + to.get(s.id).join(', ') : ''}${marks ? ' · ' + marks : ''}`);
|
|
377
|
+
}
|
|
378
|
+
return 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
module.exports = { TAG, DEEP, COMMANDS, USAGE, routeOf, normRoute, screensOf, flowsOf, linksIn, marksOf, read, note, captureDir, findScreen, run };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* drop(file, id, { why }, now) → { ok, signoff } | { ok: false, error }
|
|
13
13
|
* evidence(file, id, { ref, quote, doc }, now) → { ok, signoff } | { ok: false, error } where the yes is written: a file or a
|
|
14
14
|
* Jira key, the line copied from it, and the document it agrees to (optional)
|
|
15
|
+
* clearEvidence(file, id, now) → { ok, signoff } | { ok: false, error } no source again (the Undo of a pick)
|
|
15
16
|
* reopen(file, id, now) → { ok, signoff } | { ok: false, error } the Undo of an answer
|
|
16
17
|
* list(file, { ini, open }) → [signoff] the ledger folded, oldest ask first
|
|
17
18
|
* partsOf(list, now) → [{ ini, id, text }] PURE: the open sign-offs to ask about today
|
|
@@ -102,6 +103,8 @@ function evidence(file, id, { ref, quote, doc } = {}, now = Date.now()) {
|
|
|
102
103
|
if (!r || !q) return { ok: false, error: 'evidence needs ref (a file path or a Jira key) and quote (a line copied word for word)' };
|
|
103
104
|
return act(file, id, 'evidence', { ref: r, quote: q, doc: one(doc, 300) || null }, now);
|
|
104
105
|
}
|
|
106
|
+
/** The Undo of a source picked on the initiative (lib/on-item.js): the sign-off has no source again. */
|
|
107
|
+
function clearEvidence(file, id, now = Date.now()) { return act(file, id, 'evidence', { ref: null, quote: null, doc: null }, now); }
|
|
105
108
|
/** The Undo of an answer: the sign-off is open again. */
|
|
106
109
|
function reopen(file, id, now = Date.now()) {
|
|
107
110
|
const s = fold(readLines(file)).find((x) => x.id === id);
|
|
@@ -129,4 +132,4 @@ function partsOf(signoffs, now = Date.now()) {
|
|
|
129
132
|
return out;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
module.exports = { ask, answer, drop, evidence, reopen, list, partsOf, fileOf, fold, WAIT_DAYS, STAGE_SOURCE };
|
|
135
|
+
module.exports = { ask, answer, drop, evidence, clearEvidence, reopen, list, partsOf, fileOf, fold, WAIT_DAYS, STAGE_SOURCE };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.852.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.852.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* page load: its KRs' names (GET /api/boards/anchors, the OKR files), whether each KR is met (GET /api/insights-premium, the goals Insights
|
|
29
29
|
* shows) and its PMOS tasks (GET /api/boards/items). A part whose read failed is left out, never guessed. Every fold is kept in this browser. */
|
|
30
30
|
import { pmPost } from './http.js';
|
|
31
|
+
import { noteUse } from './use-log.js';
|
|
32
|
+
import { undoToast } from './hi-pop.js';
|
|
31
33
|
import { esc, store } from './premium-shell.js';
|
|
32
34
|
import { programState, liveRows, milestoneTrack, milestoneGroups, goalsByPeriod, shortDay, toJira, milestoneStep } from './program-model.js';
|
|
33
35
|
import { STEPS } from './premium-initiative-head.js';
|
|
@@ -182,11 +184,25 @@ function goalsHtml(st) {
|
|
|
182
184
|
/** The readiness dots of a milestone: one per initiative it waits on, filled when that one is past its own ◆ stage (D99). */
|
|
183
185
|
const rdHtml = (m) => (m.n ? `<span class="pp-rd" role="img" aria-label="${m.ready} of ${m.n} ${plural(m.n, 'initiative', 'initiatives')} ready">${Array.from({ length: m.n }, (_, j) => `<i${j < m.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : '');
|
|
184
186
|
const waitsLine = (m) => (m.check ? 'A program check, no initiative to wait on' : 'Waits on ' + m.titles.join(' and '));
|
|
187
|
+
/* a program with no milestones and no suggestion: PMOS offers its first ones, drafted from the initiatives' dates (surface-on-item,
|
|
188
|
+
* LINE.md Rule 12: no "pmos program draft" to type). GET /api/on-item/program-drafts once per program; ✓ files them as the suggestions above
|
|
189
|
+
* with Keep and Decline (POST, with Undo); ✕ hides the line on this computer. Zero is silence. */
|
|
190
|
+
const LDR = new Map(); // program id → n | null while reading
|
|
191
|
+
const LDR_NO = 'pp-ldraft-no';
|
|
192
|
+
const ldrNo = () => { try { return new Set(JSON.parse(localStorage.getItem(LDR_NO) || '[]')); } catch { return new Set(); } };
|
|
193
|
+
function lineDraftHtml(p) {
|
|
194
|
+
if (!LDR.has(p.id)) { LDR.set(p.id, null); getJson('/api/on-item/program-drafts?program=' + encodeURIComponent(p.id)).then((r) => { LDR.set(p.id, r && r.ok ? r.n || 0 : 0); if (cur && cur.id === p.id && r && r.n) draw(true); }); }
|
|
195
|
+
const n = LDR.get(p.id);
|
|
196
|
+
if (!n || ldrNo().has(p.id)) return '';
|
|
197
|
+
return `<div class="pm-said pp-ldraft" role="group" aria-label="PMOS can draft the first milestones"><span class="pm-star" aria-hidden="true">✦</span><p>PMOS can draft ${n} first ${plural(n, 'milestone', 'milestones')} from the initiatives' dates.</p>`
|
|
198
|
+
+ `<span class="pp-ldb"><button type="button" class="pm-btn primary" data-pp="ldraft" aria-label="Yes, draft them" title="Yes, draft them">${SV('M5 12.5l4.5 4.5L19 7.5', 15)}</button>`
|
|
199
|
+
+ `<button type="button" class="pm-btn" data-pp="ldrop" aria-label="No" title="No">${SV(I.x, 15)}</button></span></div>`;
|
|
200
|
+
}
|
|
185
201
|
function trackHtml(st, p) {
|
|
186
202
|
// no milestone yet: Claude's first suggestions when it has some (canvas XmsgB), else one dashed way into the charter, at Milestones (MsEmpty)
|
|
187
203
|
const S = MSG.openOf(p);
|
|
188
204
|
if (!st.milestones.length && S.length) return `<div class="pp-sec"><p class="lbl">Program milestones</p>${MSG.firstHtml(p, S)}</div>`;
|
|
189
|
-
if (!st.milestones.length) return `<div class="pp-sec"><p class="lbl">Program milestones</p
|
|
205
|
+
if (!st.milestones.length) return `<div class="pp-sec"><p class="lbl">Program milestones</p>${RO ? '' : lineDraftHtml(p)}<button type="button" class="pp-first" data-pp="first"><span class="gd" aria-hidden="true"></span>Add the first milestone</button></div>`;
|
|
190
206
|
const T = milestoneTrack(st, 3), n = Math.max(1, T.shown.length);
|
|
191
207
|
const lastDone = T.shown.map((m) => m.done).lastIndexOf(true);
|
|
192
208
|
// the filled line runs to halfway between the last done milestone in view and the next one; with none in view, to the done cluster
|
|
@@ -581,6 +597,14 @@ async function press(b) {
|
|
|
581
597
|
else if (a === 'add') { adding = true; draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); }
|
|
582
598
|
else if (a === 'charter') openCharter(p);
|
|
583
599
|
else if (a === 'edit' || a === 'first') openCharter(p, 'milestones');
|
|
600
|
+
else if (a === 'ldrop') { const no = ldrNo(); no.add(p.id); try { localStorage.setItem(LDR_NO, JSON.stringify([...no])); } catch { /* a private window */ } draw(true); }
|
|
601
|
+
else if (a === 'ldraft') {
|
|
602
|
+
b.disabled = true;
|
|
603
|
+
const r = await pmPost('/api/on-item/program-drafts', { program: p.id });
|
|
604
|
+
if (!r || !r.ok) { b.disabled = false; O.say((r && r.error) || 'PMOS could not draft them. The server did not say why.'); return; }
|
|
605
|
+
noteUse('programLineDraft'); LDR.delete(p.id); await O.reload(); draw();
|
|
606
|
+
undoToast('PMOS drafted the first milestones. Keep or decline each one.', async () => { const u = await pmPost('/api/on-item/program-drafts', { program: p.id, undo: true }); LDR.delete(p.id); await O.reload(); draw(); return u || { ok: false }; });
|
|
607
|
+
}
|
|
584
608
|
else if (a === 'done') {
|
|
585
609
|
const r = await pmPost('/api/programs/task-done', { ws: b.dataset.ws || p.home || board().ws || null, program: p.id, key: b.dataset.key, done: b.dataset.done === '1' });
|
|
586
610
|
if (!r || !r.ok) { O.say((r && r.error) || 'Not marked. The server did not say why.'); return; }
|
|
@@ -1627,6 +1627,9 @@ html.ro body.wk-on .bd-hd { display: none; } /* find and tune moved to the top
|
|
|
1627
1627
|
.bd-bc .t .bd-sg { margin-right: 6px; }
|
|
1628
1628
|
.bd-bc .s.ln { color: var(--cz-ink2); }
|
|
1629
1629
|
.bd-lrow .s.ln { color: var(--cz-ink2); white-space: normal; }
|
|
1630
|
+
/* one-person-knows (job 1899, A391): the row whose person has leave coming shows its ✦ at once, on the well tone (board BatchPeopleDS panel 12) */
|
|
1631
|
+
.pm-ds .pm-li.know-due{background:var(--well)}
|
|
1632
|
+
.pm-ds .pm-li.know-due .acts{display:flex}
|
|
1630
1633
|
/* Segments under the principles (pm/segments.js, idea A327): the health bar's width is run-time geometry (--bd-seg-h); the alert colour only on the row the line names */
|
|
1631
1634
|
.bd-seg-head { flex: 1; }
|
|
1632
1635
|
.bd-seg-sub { display: block; }
|
|
@@ -45,6 +45,7 @@ import * as TLY from './three-layouts.js'; // three layouts for a new screen,
|
|
|
45
45
|
import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
|
|
46
46
|
import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
|
|
47
47
|
import * as ID from './ini-detail.js'; // the page in two columns: four numbers, Details with the Jira epics, a milestone's stage (job #2013, TbInitiative)
|
|
48
|
+
import * as OI from './on-item.js'; // sign-offs, the numbers and the press release show on the item with no typed ask (job #1986, Rule 12)
|
|
48
49
|
import * as MST from './meeting-stance.js'; // before the meeting: the two questions for a contested decision, and where each stands (meeting-stance, A333)
|
|
49
50
|
import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
|
|
50
51
|
|
|
@@ -509,7 +510,9 @@ function dsHtml(r, v, o, W, S, C, mode) {
|
|
|
509
510
|
const smap = STMAP.blockHtml({ id, ws: o.ws || '', title: W.title || '', tasks: stagesOf(r, v, { ...o, today: W.today, subAll: true }).filter((x) => x.kind === 'task').length });
|
|
510
511
|
// two columns (job #2013, TbInitiative on Exploring 3 page "balanced"): the four numbers, the Stages and the breakdown on the left; the
|
|
511
512
|
// Overview without its facts part, Details (with the Jira epics) and People on the right
|
|
512
|
-
|
|
513
|
+
// what PMOS can do here now (surface-on-item, LINE.md Rule 12): the ✦ lines under the Overview, the Sign-offs block under Details
|
|
514
|
+
const oi = OI.sideFor(id, o.ws, (v.stage && v.stage.name) || '', () => { if (artRedraw) artRedraw(); });
|
|
515
|
+
const side = PD.overviewHtml({ ...W, facts: [] }, r, { oid: id, dropped: dropped(), open: ovOpen() }) + oi.lines + ID.detailsHtml(r, v, W, { rows: st, program: o.program }) + oi.block + ppl;
|
|
513
516
|
return ID.pageHtml({ stats: ID.statsHtml(v, st, W.today), main: `${PD.stagesHtml(st, W)}${lay}${smap}${crit}${BVD.html(id, o.ws)}${wbs}`, side });
|
|
514
517
|
}
|
|
515
518
|
|
|
@@ -934,7 +937,7 @@ export function wire(body, h0, x0) {
|
|
|
934
937
|
wireGrip(body);
|
|
935
938
|
STMAP.wire(body, { redraw: () => { if (body.querySelector('.pw')) redraw(); } }); // the story map's presses and drag (A419)
|
|
936
939
|
// the People block's presses (stakeholder-map), before the popup's own handler below
|
|
937
|
-
body.addEventListener('click', (e) => { const say = (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); }; if (!SMAP.press(e, body, { say })) MST.press(e, body, { say }); });
|
|
940
|
+
body.addEventListener('click', (e) => { const say = (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); }; if (!SMAP.press(e, body, { say }) && !OI.press(e, body, { say })) MST.press(e, body, { say }); });
|
|
938
941
|
// a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
|
|
939
942
|
wireSwipe(body, { on: phone, act: (row, way) => { const b = row.querySelector(way === 'right' ? '[data-sw-yes]' : '[data-sw-no]'); if (b) b.click(); } });
|
|
940
943
|
body.addEventListener('submit', (e) => {
|
|
@@ -80,6 +80,7 @@ import * as IM from './impact.js';
|
|
|
80
80
|
import { mountPull } from './cozy-pull.js'; // pull to refresh on Your day, Adler peeking up (batch 17 item 4-B, AdP2) // Your impact (batch 16 item 7): Adler's sprout on the greeting, the week in the Viewer, the Friday chapter
|
|
81
81
|
import * as DB from './dash-view.js'; // the page model's parts on the product page: the reports, the proposals (batch 17 item 1)
|
|
82
82
|
import * as PV from './prog-page.js'; // the product page is the one program and product page (batch 21 item 2, canvas RdProgL–RdProgP)
|
|
83
|
+
import * as SCR from './screen-map.js'; // the product page's Screens tab: the live map of its screens (screen-map, job #1895, A318)
|
|
83
84
|
import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
|
|
84
85
|
import * as SWN from './cozy-status-when.js'; // a stage move asks when it really happened (round 3 follow-up of point 18)
|
|
85
86
|
import * as CC from './change-cues.js'; // idea A313: a short cue on a row that is done, before the list draws again
|
|
@@ -1347,6 +1348,8 @@ function productPageHtml(x, ws, vid, name, g) {
|
|
|
1347
1348
|
{ id: 'initiatives', label: 'Initiatives', n: inis.length, html: () => (inis.length ? iniCards : '<p class="pv-none">Nothing is open. A new initiative shows here.</p>') },
|
|
1348
1349
|
{ id: 'reports', label: 'Reports', n: reps.length, sig: reps.some((r) => r.state === 'drafted') ? 'ready' : '', html: () => `<div class="db" data-level="product">${d ? DB.trustHtml(d) : ''}${R}</div><section class="pv-card" aria-label="More reports">${extra}</section>` },
|
|
1349
1350
|
];
|
|
1351
|
+
// Screens (board BatchPlanDS panel 8): only for a product whose merged code has a screen; zero is silence, so no tab and no empty map
|
|
1352
|
+
if (x.screens && (x.screens.screens || []).length) tabs.push({ id: 'screens', label: 'Screens', n: x.screens.screens.length, html: () => '<div id="smHost"></div>' });
|
|
1350
1353
|
// "The story so far" (board AwE): the product's Narrative under the top line, a source on every line; the top line says it is the weekly update
|
|
1351
1354
|
const story = x.story ? ST.storyHtml(x.story, { sources: true }) : '';
|
|
1352
1355
|
// the Intent card (board AwI): the PM's what we want, limits and what we will not do, with Claude's ✦ proposals to add or decline
|
|
@@ -1361,6 +1364,7 @@ function productDash(b, ws, vid, name, g) {
|
|
|
1361
1364
|
const paint = () => {
|
|
1362
1365
|
const c = VW.current(); if (!b.isConnected || !c || c.id !== vid) return;
|
|
1363
1366
|
b.innerHTML = productPageHtml(x, ws, vid, name, g);
|
|
1367
|
+
SCR.mount(b.querySelector('#smHost'), { ws, map: x.screens, say: toast }); // the Screens tab, when it is the open one
|
|
1364
1368
|
if (!(x.d && (x.d.goals || []).some((y) => !y.budget))) fillGoals(b, ws); // no goal in the page model yet: the goals line of /api/goal-status
|
|
1365
1369
|
};
|
|
1366
1370
|
PV.wirePage(b, { redraw: paint });
|
|
@@ -1383,6 +1387,7 @@ function productDash(b, ws, vid, name, g) {
|
|
|
1383
1387
|
paint();
|
|
1384
1388
|
DB.readDash(ws, 'product', 'read').then((d) => { if (d) { x.d = d; paint(); } });
|
|
1385
1389
|
DB.readKr(ws).then((k) => { x.kr = k; if (DB.krOf(k).length) paint(); });
|
|
1390
|
+
SCR.readMap(ws).then((m) => { if (m && (!x.screens || x.screens.commit !== m.commit)) { x.screens = m; paint(); } });
|
|
1386
1391
|
ST.readStory(ws).then((st) => { STORY.set(ws || '', st); if (JSON.stringify(st) !== JSON.stringify(x.story || null)) { x.story = st; paint(); } });
|
|
1387
1392
|
if (!(x.intent && x.intent.edit)) IT.readIntent(ws).then((v) => { if (x.intent && x.intent.edit) return; if (JSON.stringify(v) !== JSON.stringify(x.intent || null)) { x.intent = v; paint(); } });
|
|
1388
1393
|
}
|