create-pmos 0.707.0 → 0.709.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +27 -51
- 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 +26 -0
- package/workspace/guide/layout.md +1 -0
- package/workspace/guide/settings-and-switches.md +3 -2
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-use-log.js +33 -0
- package/workspace/lib/use-log.js +126 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-settings.js +21 -3
- package/workspace/public/pm/draft-keep.js +5 -2
- package/workspace/public/pm/use-log.js +62 -0
- package/workspace/test-lists/use-log.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.709.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.709.0",
|
|
38
|
+
"at": "2026-11-22T12:36:24.052Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1539,
|
|
43
|
+
"t": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
|
|
44
|
+
"s": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
|
|
45
|
+
"k": "new"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.708.0",
|
|
51
|
+
"at": "2026-11-22T11:26:56.196Z",
|
|
52
|
+
"f": 4,
|
|
53
|
+
"prs": [
|
|
54
|
+
{
|
|
55
|
+
"n": 1536,
|
|
56
|
+
"t": "Cleared chat text no longer comes back as a draft",
|
|
57
|
+
"s": "Cleared chat text no longer comes back as a draft",
|
|
58
|
+
"k": "fix"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
36
62
|
{
|
|
37
63
|
"v": "0.707.0",
|
|
38
64
|
"at": "2026-11-22T11:12:27.208Z",
|
|
@@ -410,56 +436,6 @@
|
|
|
410
436
|
"k": "fix"
|
|
411
437
|
}
|
|
412
438
|
]
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
"v": "0.666.0",
|
|
416
|
-
"at": "2026-11-22T04:26:58.946Z",
|
|
417
|
-
"f": 4,
|
|
418
|
-
"prs": [
|
|
419
|
-
{
|
|
420
|
-
"n": 1448,
|
|
421
|
-
"t": "Check launch readiness before go-live",
|
|
422
|
-
"s": "Check launch readiness before go-live",
|
|
423
|
-
"k": "new"
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
"n": 1452,
|
|
427
|
-
"t": "A task opened from a place is the full popup from design system blocks",
|
|
428
|
-
"s": "A task opened from a place is the full popup from design system blocks",
|
|
429
|
-
"k": "new"
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
"n": 1453,
|
|
433
|
-
"t": "Read the tracker daily for all products, never forecast from a stale state",
|
|
434
|
-
"s": "Read the tracker daily for all products, never forecast from a stale state",
|
|
435
|
-
"k": "new"
|
|
436
|
-
}
|
|
437
|
-
]
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
"v": "0.663.0",
|
|
441
|
-
"at": "2026-11-22T04:09:31.042Z",
|
|
442
|
-
"f": 4,
|
|
443
|
-
"prs": [
|
|
444
|
-
{
|
|
445
|
-
"n": 1449,
|
|
446
|
-
"t": "Rebuild the Intelligence page from Komorebi blocks",
|
|
447
|
-
"s": "Rebuild the Intelligence page from Komorebi blocks",
|
|
448
|
-
"k": "new"
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
"n": 1442,
|
|
452
|
-
"t": "Routine is built from the design system's blocks",
|
|
453
|
-
"s": "Routine is built from the design system's blocks",
|
|
454
|
-
"k": "new"
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
"n": 1446,
|
|
458
|
-
"t": "A design critic reads each design against every standing rule before the PM sees it",
|
|
459
|
-
"s": "A design critic reads each design against every standing rule before the PM sees it",
|
|
460
|
-
"k": "new"
|
|
461
|
-
}
|
|
462
|
-
]
|
|
463
439
|
}
|
|
464
440
|
]
|
|
465
441
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T12:36:20Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T12:36:20Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-22T12:36:20Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.709.0",
|
|
4
|
+
"at": "2026-11-22T12:36:24.052Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1539,
|
|
9
|
+
"t": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
|
|
10
|
+
"s": "A local use log of page opens and controls pressed, cleared in Settings (A466)",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.708.0",
|
|
17
|
+
"at": "2026-11-22T11:26:56.196Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1536,
|
|
22
|
+
"t": "Cleared chat text no longer comes back as a draft",
|
|
23
|
+
"s": "Cleared chat text no longer comes back as a draft",
|
|
24
|
+
"k": "fix"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.707.0",
|
|
4
30
|
"at": "2026-11-22T11:12:27.208Z",
|
|
@@ -123,6 +123,7 @@ Text you type in a PMOS box (a chat message, a Why, notes, a routine's instructi
|
|
|
123
123
|
- If a panel closes or the page reloads before you send, open the same box again: the text is back, and a short note at the bottom of the page says **Draft kept**. On a phone the note shows under the top bar.
|
|
124
124
|
- Press the Undo icon on that note to start empty instead.
|
|
125
125
|
- A message typed in one chat stays with that chat.
|
|
126
|
+
- Text you clear yourself, or that PMOS sends or saves, is not kept, so it never comes back.
|
|
126
127
|
- PMOS keeps nothing from password, key, token or search boxes. A kept draft goes after 14 days.
|
|
127
128
|
|
|
128
129
|
### A task opened from a place
|
|
@@ -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
|
|
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
|
|
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$/;
|
|
@@ -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.
|
|
3
|
+
"version": "0.709.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.709.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -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 });
|
|
@@ -75,6 +75,9 @@ export function createKeeper(opts) {
|
|
|
75
75
|
if (!key) return null;
|
|
76
76
|
const r = { el, key, base: el.value, last: el.value, pending: 0, restored: null };
|
|
77
77
|
let d = get(key);
|
|
78
|
+
// settle the boxes this one replaces first: one the page emptied or reset itself (a chat's Escape, a send) drops its draft before
|
|
79
|
+
// the redraw can take it for a panel that closed (premium-chat-attach B5: a "/" typed and cleared came back on the next redraw)
|
|
80
|
+
if (d) { tick(); d = get(key); }
|
|
78
81
|
// the same box drawn again right after a send or save (an Add that clears and redraws its list): the draft went with the press
|
|
79
82
|
for (const o of live) if (o.key === key && o.pending && now() - o.pending < PRESS_WINDOW && (!o.el.isConnected || o.el.value === '')) { drop(key); d = null; live.delete(o); }
|
|
80
83
|
if (d && el.value === d.v) r.base = d.base; // the page drew the box again with the draft in it
|
|
@@ -111,10 +114,10 @@ export function createKeeper(opts) {
|
|
|
111
114
|
const t = now();
|
|
112
115
|
for (const r of [...live]) {
|
|
113
116
|
const sent = r.pending && t - r.pending < PRESS_WINDOW;
|
|
114
|
-
if (!r.el.isConnected) { if (sent) drop(r.key); live.delete(r); continue; }
|
|
115
117
|
if (r.el.value !== r.last) { // the page changed the box itself: sent, saved or reset
|
|
116
|
-
drop(r.key); r.base = r.el.value; r.last = r.el.value;
|
|
118
|
+
drop(r.key); r.base = r.el.value; r.last = r.el.value; // (checked first: a box emptied and then taken away still counts)
|
|
117
119
|
} else if (sent && r.el.value === '') drop(r.key);
|
|
120
|
+
if (!r.el.isConnected) { if (sent) drop(r.key); live.delete(r); continue; }
|
|
118
121
|
if (r.pending && !sent) r.pending = 0;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
@@ -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
|
+
}
|