create-pmos 0.708.0 → 0.710.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.708.0",
3
+ "version": "0.710.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.710.0",
38
+ "at": "2026-11-22T13:35:34.451Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1542,
43
+ "t": "What-moved route answers label and rows; put-back task tested (Checker M2, M6)",
44
+ "s": "What-moved route answers label and rows; put-back task tested (Checker M2, M6)",
45
+ "k": "fix"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.709.0",
51
+ "at": "2026-11-22T12:36:24.052Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1539,
56
+ "t": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
57
+ "s": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.708.0",
38
64
  "at": "2026-11-22T11:26:56.196Z",
@@ -398,56 +424,6 @@
398
424
  "k": "new"
399
425
  }
400
426
  ]
401
- },
402
- {
403
- "v": "0.668.0",
404
- "at": "2026-11-22T04:47:26.459Z",
405
- "f": 4,
406
- "prs": [
407
- {
408
- "n": 1456,
409
- "t": "Library draws 40 rows a group and hides every Final badge",
410
- "s": "Library draws 40 rows a group and hides every Final badge",
411
- "k": "fix"
412
- },
413
- {
414
- "n": 1447,
415
- "t": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
416
- "s": "Dry-run each ticket before it is built, and outside sign-offs on the same question card",
417
- "k": "new"
418
- },
419
- {
420
- "n": 1459,
421
- "t": "The task popup loads komorebi.css from its own folder only (main red since #1452)",
422
- "s": "The task popup loads komorebi.css from its own folder only (main red since #1452)",
423
- "k": "fix"
424
- }
425
- ]
426
- },
427
- {
428
- "v": "0.666.0",
429
- "at": "2026-11-22T04:26:58.946Z",
430
- "f": 4,
431
- "prs": [
432
- {
433
- "n": 1448,
434
- "t": "Check launch readiness before go-live",
435
- "s": "Check launch readiness before go-live",
436
- "k": "new"
437
- },
438
- {
439
- "n": 1452,
440
- "t": "A task opened from a place is the full popup from design system blocks",
441
- "s": "A task opened from a place is the full popup from design system blocks",
442
- "k": "new"
443
- },
444
- {
445
- "n": 1453,
446
- "t": "Read the tracker daily for all products, never forecast from a stale state",
447
- "s": "Read the tracker daily for all products, never forecast from a stale state",
448
- "k": "new"
449
- }
450
- ]
451
427
  }
452
428
  ]
453
429
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@070bc60c
1
+ kernel-source: pmos@a24ad5a5
2
2
  assembled: 2026-11-22
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-22T11:26:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T13:35:31Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-22T11:26:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T13:35:31Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-22T11:26:52Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T13:35:31Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.710.0",
4
+ "at": "2026-11-22T13:35:34.451Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1542,
9
+ "t": "What-moved route answers label and rows; put-back task tested (Checker M2, M6)",
10
+ "s": "What-moved route answers label and rows; put-back task tested (Checker M2, M6)",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.709.0",
17
+ "at": "2026-11-22T12:36:24.052Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1539,
22
+ "t": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
23
+ "s": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.708.0",
4
30
  "at": "2026-11-22T11:26:56.196Z",
@@ -49,7 +49,7 @@ Home, the Board, Insights and the Viewer use one typeface, Plus Jakarta Sans, wi
49
49
  - **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
50
50
  - **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
51
51
  - **Done** lists what PMOS finished by itself in the last 14 days, one line each with Undo.
52
- - **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository.
52
+ - **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository, or `--week <Monday>` for an earlier week.
53
53
  - An outbox draft opens with who it is for and the words. **Copy** puts the words on the clipboard, so you send them from your own tool. ✕ discards it, with Undo. Nothing leaves PMOS by itself.
54
54
 
55
55
  ## Mentions
@@ -11,7 +11,7 @@ Press the round menu button at the bottom of any page, then the **Settings** ico
11
11
 
12
12
  | Section | What it holds |
13
13
  |---|---|
14
- | General | The theme (Light, Dark or Auto), the products Home, the Board and Intelligence read, **New work starts as** (Product, Project or Full SDLC: the kind a new initiative starts as when its name gives no hint; see [what each kind shows](initiatives-and-next-steps.md)), when Your day ends, the Your impact switch, and that agents write to Jira only after you press Commit. When a new PMOS is ready, a card here says so. Under **Extras**, **Adler ›** and **Jev and Laya ›** open their own settings (see below). |
14
+ | General | The theme (Light, Dark or Auto), the products Home, the Board and Intelligence read, **New work starts as** (Product, Project or Full SDLC: the kind a new initiative starts as when its name gives no hint; see [what each kind shows](initiatives-and-next-steps.md)), when Your day ends, the Your impact switch, and that agents write to Jira only after you press Commit. When a new PMOS is ready, a card here says so. Under **Extras**, **Adler ›**, **Jev and Laya ›** and **Use log ›** open their own settings (see below). |
15
15
  | How PMOS decides | One suggestion from PMOS when it sees a pattern in what you kept, each kind of change PMOS makes by itself, the calls that are **Always yours**, and PMOS's **Lessons**. |
16
16
  | Checks | When PMOS grills an initiative by itself and the monthly credit for its checks. |
17
17
  | Prototype rules | What every prototype version is checked for before you see it. |
@@ -70,10 +70,11 @@ When PMOS sees a pattern, one suggestion opens the section, with **Why**, **PMOS
70
70
 
71
71
  ## General › Extras: Adler, Jev and Laya
72
72
 
73
- At the bottom of **General**, **Extras** has two rows. Press the arrow on a row to open its settings; the back arrow returns to General.
73
+ At the bottom of **General**, **Extras** has three rows. Press the arrow on a row to open its settings; the back arrow returns to General.
74
74
 
75
75
  - **Adler ›**: how much of Adler you see (Full, Face only or Off), motion, celebrations, Quiet after, and Dress for the day. See [Adler, PMOS's face](layout.md).
76
76
  - **Jev and Laya ›**: the TypeSafe key for Jev, the local model Laya, and the switches for each repository: whether Jev may read it, sort documents, check claims and label notes.
77
+ - **Use log ›**: what PMOS notes on this computer about how you use it: the pages you open and the buttons you press, kept 30 days. A button is noted by its code name, never by its text or anything you typed. The log stays in the PMOS folder on this computer and is never sent. The panel shows the last 30 days (days, page opens, presses, and the pages and buttons you use most). Press **Clear** to empty it.
77
78
 
78
79
  ## Checks: when PMOS grills, and what it may spend
79
80
 
@@ -137,6 +137,7 @@ const MODULES = Object.freeze([
137
137
  'routes-moments', // onboarding B3 gradual exposure: the day's ✦ in Home's chat, the menu dots, a quiet place's one line (onboarding-progress record; page-press POST)
138
138
  'routes-spec-critic', // spec-critic: the sceptical reviewer's hardest questions on a document before it is shared (runtime spec-critic.jsonl)
139
139
  '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)
140
+ '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)
140
141
  ]);
141
142
  const PM_DIR = path.join(__dirname, '..', 'public', 'pm');
142
143
  const MODULE_NAME = /^[a-z0-9][a-z0-9-]*\.js$/;
@@ -8,7 +8,7 @@
8
8
  * POST /api/drift/drop { id } → { ok } ⋯ "Not right, drop it": it never comes back (PRD R5)
9
9
  * POST /api/drift/undo { id } → { ok } the drop taken back
10
10
  * POST /api/drift/looked { week } → { ok } the card was shown for that week
11
- * GET /api/drift/moves?ws=<id>[&week=YYYY-MM-DD] → { ok, ws, name, week, notRead, moves, total, unsourced } the weekly what-moved list of
11
+ * GET /api/drift/moves?ws=<id>[&week=YYYY-MM-DD] → { ok, ws, name, week, label, notRead, rows, total, unsourced } the weekly what-moved list of
12
12
  * one product (initiative weekly-what-moved, lib/week-moves.js): last week by default; read-only
13
13
  *
14
14
  * THE SWITCH. PMOS_DRIFT=off, or the shared guard's switch (lib/ai-guard.js off: PMOS_AI, the ai settings): every GET answers { ok, on: false }
@@ -53,7 +53,8 @@ async function handle(req, res, url, ctx) {
53
53
  try { const IR = require('./initiative-rows.js').rowsFor(w.root); rows = IR && IR.ok ? IR.rows : []; } catch { rows = []; }
54
54
  const f = require('./drift-facts.js').factsOf({ id: w.id, name: w.name || w.id, root: w.root }, { stateDir, rows });
55
55
  const r = WM.movesOf(f, W);
56
- return send({ status: 200, body: { ok: true, ws: w.id, name: w.name || w.id, week: W.week, notRead: f.notRead, moves: r.moves, total: r.total, unsourced: r.unsourced } });
56
+ const label = day && W.week !== WM.lastWeek(nowMs(ctx)).week ? 'The week of ' + W.week : 'Last week';
57
+ return send({ status: 200, body: { ok: true, ws: w.id, name: w.name || w.id, week: W.week, label, notRead: f.notRead, rows: r.moves, total: r.total, unsourced: r.unsourced } });
57
58
  } catch (e) {
58
59
  console.warn(WM.TAG + ' could not read the moves of ' + w.id + ': ' + ((e && e.message) || e));
59
60
  return send(bad(500, 'The moves could not be read.'));
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+ /* routes-use-log.js — the local use log over HTTP (bet A466). The ledger and its rules are lib/use-log.js; the file is <runtime>/use-log.jsonl
3
+ * on this computer. Nothing here sends anything.
4
+ *
5
+ * GET /api/use-log → { ok, keep, days, opens, uses, pages, controls } Settings › General › Use log
6
+ * POST /api/use-log { events } → { ok, wrote } the page side (public/pm/use-log.js), in batches
7
+ * POST /api/use-log/clear {} → { ok } Clear, in Settings
8
+ * `ws` is accepted and ignored: the log is per person, across products.
9
+ *
10
+ * WHO WRITES. The PM's own pages only: a POST that carries an agent session header is refused (403; an agent does not open pages), and
11
+ * pm-guard requirePagePress checks the page's Origin and launch nonce. */
12
+ const guard = require('./pm-guard.js');
13
+ const UL = require('./use-log.js');
14
+
15
+ async function handle(req, res, url, ctx) {
16
+ const send = (status, body) => { ctx.json(res, body, status); return true; };
17
+ const what = url.pathname.replace(/^\/api\/use-log\/?/, '');
18
+ if (what !== '' && what !== 'clear') return send(404, { ok: false, error: 'no such use-log route' });
19
+ const dir = ctx.runtimeDir || null;
20
+ if (what === '' && req.method === 'GET') return send(200, { ok: true, ...UL.summary(UL.readLines(dir)) });
21
+ if (req.method !== 'POST') return send(405, { ok: false, error: what ? 'POST only' : 'GET or POST' });
22
+ if (req.headers && req.headers['x-pmos-session']) return send(403, { ok: false, error: 'An agent session does not open pages or press buttons. Only your own use is recorded.' });
23
+ const rd = await ctx.readJson(req);
24
+ if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
25
+ const body = rd.body || {};
26
+ const g = guard.requirePagePress(req, body);
27
+ if (!g.ok) return send(g.status, { ok: false, error: g.error });
28
+ if (what === 'clear') { const r = UL.clear(dir); return r.ok ? send(200, { ok: true }) : send(500, r); }
29
+ const r = UL.record(dir, body.events);
30
+ return r.ok ? send(200, { ok: true, wrote: r.wrote }) : send(r.error.startsWith('This workspace') ? 409 : 400, { ok: false, error: r.error });
31
+ }
32
+
33
+ module.exports = { prefixes: ['/api/use-log'], handle };
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* use-log.js — the local use log (bet A466, initiative A466): which pages the user opens and which controls they press, so the ease-of-use
4
+ * ideas (A453, A454, A461, A463, A381, A144, A314) can count real use. THE ONE WRITER and THE ONE FOLD of <runtime>/use-log.jsonl.
5
+ * lib/routes-use-log.js does the HTTP; public/pm/use-log.js is the page side; Settings › General › Use log shows it and clears it.
6
+ *
7
+ * LOCAL ONLY. The file is in the runtime folder on this computer, outside every repository, so no commit, sync or teammate reads it, and
8
+ * nothing here sends anything. KEEP NOTHING PERSONAL: a line holds a page's file name, a control's id or data-attribute NAME, a device class
9
+ * and a time. Anything else (a value, visible text, a URL, an address) fails the patterns below and the event is dropped, not cut.
10
+ *
11
+ * THE LEDGER. One line per event, { at, kind, page, control?, device }:
12
+ * kind 'open' (the page was opened) | 'use' (a control was pressed)
13
+ * page the page's file name without .html: today, premium-board (PAGE_RE)
14
+ * control 'use' only: an element id or a data-attribute name: czFab, data-ev-sub (CONTROL_RE)
15
+ * device phone | tablet | desk
16
+ * Lines older than KEEP_DAYS are removed on the first write of each day (one `[use-log] pruned` server log line).
17
+ *
18
+ * ledgerFile(dir) · readLines(dir) · clean(ev, now) → line | null
19
+ * record(dir, events, now) → { ok, wrote } | { ok: false, error } at most MAX_BATCH events per call
20
+ * summary(lines, now) → { keep, days, opens, uses, pages: [{ page, n }], controls: [{ page, control, n }] } PURE, last KEEP_DAYS days
21
+ * clear(dir) → { ok }
22
+ * CLI: node lib/use-log.js count → the distinct days with a line in the last KEEP_DAYS days, on its last line (the health number) */
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+
26
+ const FILE = 'use-log.jsonl';
27
+ const KEEP_DAYS = 30;
28
+ const MAX_BATCH = 200;
29
+ const DAY = 864e5;
30
+ const KINDS = ['open', 'use'];
31
+ const DEVICES = ['phone', 'tablet', 'desk'];
32
+ const PAGE_RE = /^[a-z0-9][a-z0-9._-]{0,59}$/;
33
+ const CONTROL_RE = /^[A-Za-z][A-Za-z0-9_-]{0,79}$/;
34
+ const TOP = 10;
35
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
36
+ const say = (s) => { try { console.log('[use-log] ' + s); } catch { /* no console */ } };
37
+
38
+ function ledgerFile(dir) { return dir ? path.join(dir, FILE) : null; }
39
+
40
+ /** The page's file name from a path or a name: '/premium-board.html?ws=x' → 'premium-board', '/' → 'index'. */
41
+ function pageOf(v) {
42
+ let s = String(v == null ? '' : v).split(/[?#]/)[0];
43
+ s = s.slice(s.lastIndexOf('/') + 1).replace(/\.html?$/i, '').toLowerCase();
44
+ return s || (String(v || '').startsWith('/') ? 'index' : '');
45
+ }
46
+
47
+ /** One event as a line, or null when any part is not one of the safe shapes. `t` (ms) is kept when it falls in the last day and not ahead. */
48
+ function clean(ev, now = Date.now()) {
49
+ if (!isObj(ev) || !KINDS.includes(ev.kind) || !DEVICES.includes(ev.device)) return null;
50
+ const page = pageOf(ev.page);
51
+ if (!PAGE_RE.test(page)) return null;
52
+ const t = Number(ev.t), at = new Date(Number.isFinite(t) && t <= now && t > now - DAY ? t : now).toISOString();
53
+ if (ev.kind === 'open') return { at, kind: 'open', page, device: ev.device };
54
+ const control = String(ev.control == null ? '' : ev.control);
55
+ if (!CONTROL_RE.test(control)) return null;
56
+ return { at, kind: 'use', page, control, device: ev.device };
57
+ }
58
+
59
+ function readLines(dir) {
60
+ const f = ledgerFile(dir); if (!f) return [];
61
+ let text = '';
62
+ try { text = fs.readFileSync(f, 'utf8'); } catch { return []; }
63
+ const out = [];
64
+ for (const raw of text.split('\n')) {
65
+ if (!raw.trim()) continue;
66
+ try { const l = JSON.parse(raw); if (isObj(l) && typeof l.at === 'string' && KINDS.includes(l.kind) && PAGE_RE.test(String(l.page))) out.push(l); } catch { /* a torn line is skipped */ }
67
+ }
68
+ return out;
69
+ }
70
+
71
+ /** Remove lines older than KEEP_DAYS, once a day: only when the oldest line is past the cut. */
72
+ function prune(dir, now) {
73
+ const f = ledgerFile(dir), cut = now - KEEP_DAYS * DAY;
74
+ let first = '';
75
+ try { const fd = fs.openSync(f, 'r'); const b = Buffer.alloc(200); const n = fs.readSync(fd, b, 0, 200, 0); fs.closeSync(fd); first = b.toString('utf8', 0, n).split('\n')[0]; } catch { return 0; }
76
+ let at = NaN; try { at = Date.parse(JSON.parse(first).at); } catch { at = NaN; }
77
+ if (Number.isFinite(at) && at >= cut) return 0;
78
+ const all = readLines(dir), keep = all.filter((l) => Date.parse(l.at) >= cut);
79
+ const gone = all.length - keep.length;
80
+ fs.writeFileSync(f, keep.map((l) => JSON.stringify(l)).join('\n') + (keep.length ? '\n' : ''));
81
+ if (gone) say(`pruned ${gone} lines older than ${KEEP_DAYS} days`);
82
+ return gone;
83
+ }
84
+
85
+ function record(dir, events, now = Date.now()) {
86
+ if (!dir) return { ok: false, error: 'This workspace has no runtime folder, so use is not recorded.' };
87
+ if (!Array.isArray(events)) return { ok: false, error: 'events is a list' };
88
+ const lines = events.slice(0, MAX_BATCH).map((e) => clean(e, now)).filter(Boolean);
89
+ if (!lines.length) return { ok: true, wrote: 0 };
90
+ fs.mkdirSync(dir, { recursive: true });
91
+ prune(dir, now);
92
+ fs.appendFileSync(ledgerFile(dir), lines.map((l) => JSON.stringify(l)).join('\n') + '\n');
93
+ return { ok: true, wrote: lines.length };
94
+ }
95
+
96
+ function summary(lines, now = Date.now()) {
97
+ const cut = now - KEEP_DAYS * DAY, L = (lines || []).filter((l) => { const t = Date.parse(l && l.at); return t >= cut && t <= now + DAY; });
98
+ const days = new Set(), pages = new Map(), controls = new Map();
99
+ let opens = 0, uses = 0;
100
+ for (const l of L) {
101
+ days.add(l.at.slice(0, 10));
102
+ if (l.kind === 'open') { opens++; pages.set(l.page, (pages.get(l.page) || 0) + 1); }
103
+ else { uses++; const k = l.page + ' ' + l.control; controls.set(k, (controls.get(k) || 0) + 1); }
104
+ }
105
+ const top = (m) => [...m].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, TOP);
106
+ return { keep: KEEP_DAYS, days: days.size, opens, uses,
107
+ pages: top(pages).map(([page, n]) => ({ page, n })),
108
+ controls: top(controls).map(([k, n]) => { const [page, control] = k.split(' '); return { page, control, n }; }) };
109
+ }
110
+
111
+ function clear(dir) {
112
+ const f = ledgerFile(dir);
113
+ if (!f) return { ok: false, error: 'This workspace has no runtime folder.' };
114
+ try { fs.rmSync(f, { force: true }); } catch (e) { return { ok: false, error: 'could not clear the use log: ' + ((e && e.message) || e) }; }
115
+ say('cleared by the user');
116
+ return { ok: true };
117
+ }
118
+
119
+ module.exports = { FILE, KEEP_DAYS, MAX_BATCH, KINDS, DEVICES, PAGE_RE, CONTROL_RE, ledgerFile, pageOf, clean, readLines, record, summary, clear };
120
+
121
+ if (require.main === module) {
122
+ const cmd = process.argv[2];
123
+ if (cmd !== 'count') { console.error('usage: node lib/use-log.js count (the distinct days with a line in the last ' + KEEP_DAYS + ' days)'); process.exit(2); }
124
+ const dir = require('./state-root.js').defaultRoot({ env: process.env });
125
+ console.log(String(summary(readLines(dir)).days));
126
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.708.0",
3
+ "version": "0.710.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.708.0",
9
+ "version": "0.710.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.708.0",
3
+ "version": "0.710.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -43,6 +43,7 @@ import { fabLabel, bannerOf } from './cozy-evmodel.js';
43
43
  import { mountToastFaces, loadPrefs } from './cozy-adler.js';
44
44
  import './draft-keep.js'; // forms-keep-drafts: every text box on every page keeps a draft until sent, saved or cleared
45
45
  import { pmPost } from './http.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
46
+ import { startUseLog } from './use-log.js'; // bet A466: every page mounts the menu, so the menu starts the local use log (this computer only)
46
47
 
47
48
  /* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
48
49
  * Today is today.html (slice 5; Home before it), Work is the Board and Goals is premium-goals.html (slice 9; Intelligence before it); the keys stay the pages' own (home, board, insights). */
@@ -197,6 +198,7 @@ export function mountNav(here, doc = document, opts = {}) {
197
198
  + '<i class="ev-fd you" id="czFdYou" hidden></i><i class="ev-fd risk" id="czFdRisk" hidden></i>';
198
199
  doc.body.appendChild(w);
199
200
  mountToastFaces(doc); loadPrefs();
201
+ startUseLog(doc);
200
202
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
201
203
  const draw = () => {
202
204
  N.rail = railOn();
@@ -74,7 +74,7 @@ async function pmSend(method, path, body) {
74
74
  catch (e) { return { ok: false, error: 'could not reach the workspace server — ' + ((e && e.message) || String(e)) }; }
75
75
  }
76
76
  const SECTIONS = SD.SECTIONS;
77
- const SUBS = { adler: 'Adler', jl: 'Jev and Laya', workflows: 'Workflows' }; // General › Extras and Workspaces › Workflows: each opens as a sub-panel of its section (U4, U1)
77
+ const SUBS = { adler: 'Adler', jl: 'Jev and Laya', workflows: 'Workflows', uselog: 'Use log' }; // General › Extras and Workspaces › Workflows: each opens as a sub-panel of its section (U4, U1)
78
78
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
79
79
  const T = { lsOpen: false, el: null, sec: 'general', sub: '', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, info: false, fold: false, dir: null, q: '', cat: 'all', wait: null, dress: false, more: false, bday: false, dset: {}, wkOpen: new Set(), wkMore: new Set(), arc: false };
80
80
  const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
@@ -100,6 +100,7 @@ const seg = SD.seg, trow = SD.row, sw = SD.sw; // the system's Tabs, Settings
100
100
  function general() {
101
101
  if (T.sub === 'adler') return T.dress ? dressSec() : subHead('adler') + adlerSec();
102
102
  if (T.sub === 'jl') return subHead('jl') + JL.html();
103
+ if (T.sub === 'uselog') return subHead('uselog') + useLogSec();
103
104
  const theme = (() => { const t = store.get('pmos.c3.theme'); return t === 'light' || t === 'dark' ? t : 'auto'; })();
104
105
  const P = T.prods, on = P ? P.filter((x) => x.on) : null;
105
106
  // the product the pages read (workspace grill W4): the page's own ?ws= first, then the pick; "No product" only when none is registered
@@ -118,7 +119,23 @@ function general() {
118
119
  + upd
119
120
  + '<h4 class="pm-h-sm">Extras</h4>'
120
121
  + trow('Adler', 'How much of PMOS’s face shows, motion, celebrations, quiet hours and Dress for the day', subBtn('adler'))
121
- + trow('Jev and Laya', 'The TypeSafe key, Laya on this computer and the repositories it reads', subBtn('jl'));
122
+ + trow('Jev and Laya', 'The TypeSafe key, Laya on this computer and the repositories it reads', subBtn('jl'))
123
+ + trow('Use log', 'The pages you open and the buttons you press, kept 30 days. It stays on this computer and is never sent.', subBtn('uselog'));
124
+ }
125
+ /* General › Extras › Use log (bet A466): what lib/use-log.js keeps for the last 30 days (GET /api/use-log), and Clear (POST /api/use-log/clear) */
126
+ const UL_PAGE = { today: 'Today', premium: 'Home', 'premium-board': 'Work', 'premium-goals': 'Goals', 'premium-intelligence': 'Intelligence', 'premium-library': 'Library', 'premium-events': 'Events', 'premium-routine': 'Routine', 'premium-viewer': 'Viewer' };
127
+ const ulPage = (p) => UL_PAGE[p] || p;
128
+ async function loadUseLog() { const r = await pmGet('/api/use-log'); T.ul = r && r.ok ? r : { error: (r && r.error) || 'PMOS could not read the use log.' }; draw(); }
129
+ function useLogSec() {
130
+ const U = T.ul, about = '<p class="ev-mut">PMOS notes which pages you open and which buttons you press, so it can see what is easy to use and what nobody uses. It keeps 30 days, it stays on this computer, and it is never sent anywhere. It keeps no text you type and no names.</p>';
131
+ if (!U) return about + '<p class="ev-mut">Reading…</p>';
132
+ if (U.error) return about + `<p class="ev-mut">${esc(U.error)}</p>`;
133
+ if (!U.opens && !U.uses) return about + '<p class="ev-mut">Nothing yet.</p>';
134
+ const list = (rows) => `<ul class="ev-ul-list">${rows.join('')}</ul>`;
135
+ return about
136
+ + trow('Last 30 days', `${U.days} ${U.days === 1 ? 'day' : 'days'} · ${U.opens} page ${U.opens === 1 ? 'open' : 'opens'} · ${U.uses} ${U.uses === 1 ? 'press' : 'presses'}`, '<button type="button" class="ev-btn sm" data-ev-ulclear>Clear</button>')
137
+ + (U.pages.length ? '<h4 class="pm-h-sm">Pages you open most</h4>' + list(U.pages.map((x) => `<li>${esc(ulPage(x.page))} <span class="ev-mut">${x.n}</span></li>`)) : '')
138
+ + (U.controls.length ? '<h4 class="pm-h-sm">Buttons you press most</h4>' + list(U.controls.map((x) => `<li>${esc(x.control)} <span class="ev-mut">on ${esc(ulPage(x.page))} · ${x.n}</span></li>`)) : '');
122
139
  }
123
140
  /* Your role (initiative kind-scopes-lifecycle-stages): work.role, the kind a new initiative starts as when its name gives no cue */
124
141
  const roleVal = () => { const r = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'work.role') : null; return r && r.value ? r.value : 'product'; };
@@ -619,11 +636,12 @@ async function press(e) {
619
636
  if (await extClick(e, XT, draw, toast)) return;
620
637
  if (t.dataset.evWk) { const k = t.dataset.evWk; if (T.wkOpen.has(k)) T.wkOpen.delete(k); else T.wkOpen.add(k); draw(); return; }
621
638
  if ('evArc' in t.dataset) { T.arc = !T.arc; draw(); return; }
639
+ if ('evUlclear' in t.dataset) { const r = await pmPost('/api/use-log/clear', {}); if (r && r.ok) { T.ul = null; toast('Use log cleared.'); loadUseLog(); } else toast((r && r.error) || 'PMOS could not clear the use log.'); return; }
622
640
  if ('evInfo' in t.dataset) { T.info = !T.info; draw(); return; }
623
641
  if ('evFold' in t.dataset) { T.fold = !T.fold; draw(); return; }
624
642
  if (t.dataset.evMore) { T.wkMore.add(t.dataset.evMore); draw(); return; }
625
643
  if (t.dataset.evGo) { T.sec = t.dataset.evGo; T.sub = ''; draw(); return; }
626
- if (t.dataset.evSub !== undefined) { const k = t.dataset.evSub, was = T.sub; T.sub = k; T.dress = false; T.more = false; T.bday = false; T.msg = ''; draw(); const f = T.el.querySelector(k ? '[data-ev-sub=""]' : `[data-ev-sub="${was}"]`); if (f) f.focus(); return; }
644
+ if (t.dataset.evSub !== undefined) { const k = t.dataset.evSub, was = T.sub; T.sub = k; if (k === 'uselog') { T.ul = null; loadUseLog(); } T.dress = false; T.more = false; T.bday = false; T.msg = ''; draw(); const f = T.el.querySelector(k ? '[data-ev-sub=""]' : `[data-ev-sub="${was}"]`); if (f) f.focus(); return; }
627
645
  if (t.dataset.evSeg && t.dataset.evSeg.startsWith('claude.way:')) { await saveWay(t.dataset.evSeg.slice(11), t.dataset.v); return; }
628
646
  if (t.dataset.evSeg === 'work.role') {
629
647
  const r = await pmPost('/api/settings', { key: 'work.role', value: t.dataset.v });
@@ -13,7 +13,8 @@ const KEY = 'pmos.moves.looked';
13
13
  const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
14
  const ICON = 'M3 12h4l3-8 4 16 3-8h4';
15
15
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
16
- const ok = (l) => l && l.ok && Array.isArray(l.moves);
16
+ const rowsOf = (l) => (Array.isArray(l.rows) ? l.rows : Array.isArray(l.moves) ? l.moves : null); // GET /api/drift/moves answers rows
17
+ const ok = (l) => l && l.ok && !!rowsOf(l);
17
18
 
18
19
  export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
19
20
  export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
@@ -40,11 +41,11 @@ function moveHtml(m, esc) {
40
41
 
41
42
  /** The list, one section per product. */
42
43
  export function listHtml(lists, { esc = escDefault } = {}) {
43
- const L = (lists || []).filter(ok).filter((l) => l.moves.length);
44
+ const L = (lists || []).filter(ok).filter((l) => rowsOf(l).length);
44
45
  if (!L.length) return '<p class="yd-exp">Nothing moved in dates or scope last week.</p>';
45
46
  const many = L.length > 1;
46
47
  return L.map((l) => {
47
- const rows = l.moves.slice().sort((a, b) => (a.sourced === b.sourced ? 0 : a.sourced ? 1 : -1));
48
+ const rows = rowsOf(l).slice().sort((a, b) => (a.sourced === b.sourced ? 0 : a.sourced ? 1 : -1));
48
49
  const head = many ? `<h3>${esc(l.name || l.ws)}</h3>` : '';
49
50
  const sum = `<p class="yd-exp">${esc(plural(l.total, 'move', 'moves'))}${l.unsourced ? ', ' + esc(String(l.unsourced)) + ' with no source' : ''}.</p>`;
50
51
  return `<section class="mv-prod">${head}${sum}<ul class="mv-list">${rows.map((m) => moveHtml(m, esc)).join('')}</ul></section>`;
@@ -0,0 +1,62 @@
1
+ /* pm/use-log.js — the page side of the local use log (bet A466; the ledger is lib/use-log.js, the routes lib/routes-use-log.js).
2
+ *
3
+ * startUseLog(doc?) notes this page's open and every press of a button, link, switch or tab; called once by the menu
4
+ * (pm/cozy-nav.js mountNav), which every page mounts. A second call does nothing, and nor does a call in a browser
5
+ * a script drives (navigator.webdriver: a test or a crawler is not the user's own use).
6
+ * controlOf(el) PURE: the name a pressed element is logged under, or '' to log nothing
7
+ * deviceOf(width) PURE: phone (≤ 760 px), tablet (≤ 1100 px) or desk
8
+ *
9
+ * ON THIS COMPUTER ONLY. Events go to this workspace's own server (POST /api/use-log, a relative URL) in batches: every 15 s while there
10
+ * are some, and once more when the page hides (keepalive). Nothing goes anywhere else. NOTHING PERSONAL: a control is named by its id or
11
+ * by the NAME of its first data- attribute (data-ev-sub), never by a value, its text or its label; an element with neither is not logged. */
12
+ import { pmPost } from './http.js';
13
+
14
+ const FLUSH_MS = 15000;
15
+ const MAX_QUEUE = 200;
16
+ const ID_RE = /^[A-Za-z][A-Za-z0-9_-]{0,79}$/;
17
+ const PRESSABLE = 'button, a[href], [role="button"], [role="tab"], [role="switch"], [role="menuitem"], input[type="checkbox"], input[type="radio"], select, summary';
18
+ let started = false;
19
+ const Q = [];
20
+
21
+ export const deviceOf = (w) => (w <= 760 ? 'phone' : w <= 1100 ? 'tablet' : 'desk');
22
+
23
+ export function controlOf(el) {
24
+ if (!el || !el.getAttribute) return '';
25
+ const id = el.getAttribute('id') || '';
26
+ if (ID_RE.test(id)) return id;
27
+ for (const a of el.attributes || []) if (/^data-[a-z0-9-]{1,70}$/.test(a.name)) return a.name;
28
+ return '';
29
+ }
30
+
31
+ const botNow = () => { try { return !!(typeof navigator !== 'undefined' && navigator.webdriver); } catch { return false; } };
32
+ const pageNow = () => { try { return location.pathname; } catch { return ''; } };
33
+ const deviceNow = () => { try { return deviceOf(window.innerWidth || 1280); } catch { return 'desk'; } };
34
+
35
+ function flush(keepalive = false) {
36
+ if (!Q.length) return;
37
+ const events = Q.splice(0, Q.length);
38
+ Promise.resolve(pmPost('/api/use-log', { events }, { keepalive })).catch(() => null);
39
+ }
40
+
41
+ function note(ev) {
42
+ if (Q.length >= MAX_QUEUE) return;
43
+ Q.push({ ...ev, page: pageNow(), device: deviceNow(), t: Date.now() });
44
+ }
45
+
46
+ export function startUseLog(doc = typeof document !== 'undefined' ? document : null) {
47
+ if (started || !doc) return false;
48
+ if (botNow()) return false; // a browser driven by a script (a test, a crawler) is not the user's own use: nothing is noted
49
+ started = true;
50
+ note({ kind: 'open' });
51
+ // one listener on the window for every press on the page; it notes a press and is not itself a control
52
+ if (doc.defaultView) doc.defaultView.addEventListener('click', (e) => {
53
+ const el = e.target && e.target.closest ? e.target.closest(PRESSABLE) : null;
54
+ const control = controlOf(el);
55
+ if (control) note({ kind: 'use', control });
56
+ }, { capture: true, passive: true });
57
+ setInterval(() => flush(false), FLUSH_MS);
58
+ const hide = () => flush(true);
59
+ try { window.addEventListener('pagehide', hide); doc.addEventListener('visibilitychange', () => { if (doc.visibilityState === 'hidden') hide(); }); } catch { /* no window */ }
60
+ setTimeout(() => flush(false), 2000); // the open goes soon after load, so a page closed quickly still counts
61
+ return true;
62
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The local use log (bet A466, done test planning/done-tests/local-use-log.md C1-C7): page opens and controls pressed, kept 30 days in the runtime folder on this computer, never sent, cleared in Settings. Pure checks and the routes in process. No connector, model or network.",
3
+ "modules": [
4
+ "use-log.test.js"
5
+ ],
6
+ "seconds": {
7
+ "use-log.test.js": 3
8
+ }
9
+ }