create-pmos 0.746.0 → 0.747.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.746.0",
3
+ "version": "0.747.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,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.747.0",
38
+ "at": "2026-11-23T13:39:39.287Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1676,
43
+ "t": "A guided tour, press Next to walk through a workspace",
44
+ "s": "A guided tour, press Next to walk through a workspace",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.746.0",
38
51
  "at": "2026-11-23T11:03:05.465Z",
@@ -611,25 +624,6 @@
611
624
  "k": "fix"
612
625
  }
613
626
  ]
614
- },
615
- {
616
- "v": "0.723.0",
617
- "at": "2026-11-23T01:56:36.110Z",
618
- "f": 4,
619
- "prs": [
620
- {
621
- "n": 1599,
622
- "t": "Pmos why coverage leaves out Closed, Cancelled and Killed records",
623
- "s": "Pmos why coverage leaves out Closed, Cancelled and Killed records",
624
- "k": "fix"
625
- },
626
- {
627
- "n": 1600,
628
- "t": "Pinned views' Unpin is the system's pm-btn (Checker V6, job #1558)",
629
- "s": "Pinned views' Unpin is the system's pm-btn (Checker V6, job #1558)",
630
- "k": "fix"
631
- }
632
- ]
633
627
  }
634
628
  ]
635
629
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@9e1bb9bf
1
+ kernel-source: pmos@05278b1b
2
2
  assembled: 2026-11-23
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-23T11:03:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T13:39:35Z"}
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-23T11:03:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T13:39:35Z"}
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-23T11:03:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T13:39:35Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.747.0",
4
+ "at": "2026-11-23T13:39:39.287Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1676,
9
+ "t": "A guided tour, press Next to walk through a workspace",
10
+ "s": "A guided tour, press Next to walk through a workspace",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.746.0",
4
17
  "at": "2026-11-23T11:03:05.465Z",
@@ -42,6 +42,7 @@ PMOS has three places: **Home**, **Board** and **Intelligence**. The round menu
42
42
 
43
43
  - [What PMOS does behind the scenes](agent-capabilities.md): every job PMOS runs by itself, when it runs, what it reads, where you see it, how to stop it, and what it fixes by itself; the three classes of change (D106), what is applied at once with Undo, what waits for you, and how a job goes back to propose; long-running goals; the team of role agents; the idle lab; and the PM-only acts, how each is checked and recorded, and how an agent's act is logged under its name (D98).
44
44
  - [Layout and first run](layout.md): the three places, the menu button, the Viewer and its trail, docking panels, the keys and the phone; the first run; why a new PMOS starts quiet and what opens each place; the PMOS app and the login item; and Adler, PMOS's face, with Settings › General › Adler.
45
+ - [A guided tour](tour.md): press Next to walk through a workspace, put a step's words in the chat box, and write a workspace's own tour in pmos/tour.json.
45
46
  - [Run PMOS in the cloud](cloud.md): move PMOS from the Mac to an always-on server with one paste, the one sign-in that is yours, what runs on the server, `pmos-cloud`, and how to go back to the Mac.
46
47
  - [Settings, switches and data freshness](settings-and-switches.md): what each section of Settings holds, every `PMOS_` environment variable with its default and the Settings entry that does the same, and when each source is read again and how old it is.
47
48
 
@@ -0,0 +1,41 @@
1
+ ---
2
+ type: Guide
3
+ title: "A guided tour: press Next to walk through a workspace"
4
+ description: "How a workspace's tour works, how to start, move through and end it, and how to write pmos/tour.json."
5
+ timestamp: 2026-11-23
6
+ ---
7
+
8
+ # A guided tour
9
+
10
+ A workspace can hold a guided tour. Use it to show PMOS to other people, or to learn a sample workspace step by step. The Lendly demo workspace has one.
11
+
12
+ ## Start, move and end
13
+
14
+ 1. When a workspace has a tour, a small **Tour** control shows at the bottom right of every page. Press it to start.
15
+ 2. A card shows the step: its number, its title and a few lines on why it matters.
16
+ 3. Press **Next** (or →) to go on. When the next step names a page, PMOS opens that page and the card follows. Press ← (or the Back arrow) to go one step back.
17
+ 4. Some steps put words in the chat box. The card shows the words. Read them and press send in the chat when you are ready. The tour never sends a message by itself and never runs a command.
18
+ 5. Press **Finish** on the last step, or × on the card, to end the tour. The Tour control shows again, so you can start again.
19
+
20
+ × on the Tour control hides it. To show it again, add `?tour=start` to the address of any page, for example `/today.html?tour=start`. The tour then starts at step 1.
21
+
22
+ The card works on a phone: it spans the width of the screen, above the bottom bar.
23
+
24
+ ## Write a tour
25
+
26
+ A tour is the file `pmos/tour.json` in the workspace's folder:
27
+
28
+ ```json
29
+ {
30
+ "title": "Lendly tour",
31
+ "steps": [
32
+ { "title": "Today", "text": "What needs you today, in one place.", "open": "/today.html" },
33
+ { "title": "Capture an idea", "text": "PMOS writes the PRD draft.", "open": "/premium-board.html", "chat": "Capture this idea: a waitlist for borrowed books." }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ - `title` and `text`: what the card says. A title has at most 80 characters, and the text at most 600.
39
+ - `open` (optional): the page to open, as a path on this PMOS, for example `/premium-goals.html` or `/premium-board.html?focus=<initiative id>`. PMOS adds the workspace to the address. A full web address is ignored.
40
+ - `chat` (optional): words to put in the chat box, at most 600 characters.
41
+ - A tour has at most 40 steps. PMOS reads the file again each time a page opens, so a change shows at the next Next.
@@ -81,6 +81,7 @@ const MODULES = Object.freeze([
81
81
  'routes-inbox', // premium-agent-inbox: the bell's agent results and the PM's seen marks (page press only)
82
82
  'routes-search', // premium-uncovered-features (E1): Search across the repository and every worktree (read-only)
83
83
  'routes-news', // premium-uncovered-features (E2): New for you, the FYI items, and their seen marks (page press only)
84
+ 'routes-tour', // workspace-tour: the guided tours of the registered workspaces, from each pmos/tour.json (read-only)
84
85
  'routes-slash', // testing fixes: the chat box's / menu, every command Claude Code takes plus the workspace's and the PM's own (read-only)
85
86
  'routes-phone-day', // phone companion: the agent's finished drafts, the evening recap and tomorrow at a glance (read-only)
86
87
  'routes-records', // console3 E1a: ideas, hypotheses, decisions, KR metrics, bets (GET list; page-press add/edit/reading)
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+ /* routes-tour.js — GET /api/tour: the guided tours of the registered workspaces (initiative workspace-tour, lib/tour.js).
3
+ *
4
+ * GET /api/tour → { ok: true, tours: [{ ws, name, title, steps }] } a workspace with no pmos/tour.json lists nothing
5
+ *
6
+ * Read-only: it reads each workspace's tour file and writes nothing. public/pm/tour.js draws the Tour control and the step card. */
7
+ const Tour = require('./tour.js');
8
+
9
+ module.exports = {
10
+ prefixes: ['/api/tour'],
11
+ handle: async (req, res, url, ctx) => {
12
+ if (url.pathname !== '/api/tour') return false;
13
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
14
+ const rows = typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : [];
15
+ ctx.json(res, { ok: true, tours: Tour.list(rows) });
16
+ return true;
17
+ },
18
+ };
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+ /* tour.js — a workspace's guided tour (initiative workspace-tour; done test planning/done-tests/workspace-tour.md).
3
+ *
4
+ * A workspace can hold a tour in `pmos/tour.json`: ordered steps a presenter walks with Next, or a new person follows the first time.
5
+ * Each step has a title and a short explanation, and can name a page to open and words to put in the chat box:
6
+ *
7
+ * { "title": "Lendly tour", "steps": [
8
+ * { "title": "Today", "text": "What needs you today …", "open": "/today.html" },
9
+ * { "title": "Ask PMOS for an idea", "text": "…", "open": "/premium-board.html", "chat": "Capture this idea: …" } ] }
10
+ *
11
+ * clean(raw) → { ok: true, title, steps } | { ok: false, error } checks and caps one parsed file
12
+ * read(root) → the same for the file in `root`, or null when the workspace has no tour
13
+ * list(workspaces) → [{ ws, name, title, steps }] the tours of the registered workspaces ([{ id, root, label|name }])
14
+ *
15
+ * A TOUR ONLY SHOWS AND SAYS. A step's `open` must be a path on this server (one leading `/`, no scheme, no `//`); any other value is
16
+ * dropped and the step keeps its words. A step's `chat` words go into the chat box for the person to read and send (public/pm/tour.js
17
+ * through page-chat.js ask): a tour never sends a message and never runs a command. Pure of the network; fs only.
18
+ */
19
+ const fs = require('fs');
20
+ const path = require('path');
21
+
22
+ const FILE = path.join('pmos', 'tour.json');
23
+ const MAX_STEPS = 40;
24
+ const MAX_TITLE = 80;
25
+ const MAX_TEXT = 600;
26
+ const MAX_OPEN = 300;
27
+
28
+ const str = (v, n) => (typeof v === 'string' ? v.replace(/\r\n?/g, '\n').trim().slice(0, n) : '');
29
+ /** A path on this server, or '' (a full URL, `//host`, `javascript:` and the like are dropped). */
30
+ function pageOf(v) {
31
+ const s = str(v, MAX_OPEN);
32
+ if (!s || s[0] !== '/' || s[1] === '/' || s[1] === '\\' || /[\s<>"'`]/.test(s) || /^\/[^?#]*:/.test(s)) return '';
33
+ return s;
34
+ }
35
+
36
+ function clean(raw) {
37
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return { ok: false, error: 'a tour is a JSON object with a "steps" list' };
38
+ if (!Array.isArray(raw.steps)) return { ok: false, error: 'the tour has no "steps" list' };
39
+ const steps = [];
40
+ for (const s of raw.steps.slice(0, MAX_STEPS)) {
41
+ if (!s || typeof s !== 'object') continue;
42
+ const title = str(s.title, MAX_TITLE), text = str(s.text, MAX_TEXT);
43
+ if (!title && !text) continue;
44
+ const step = { title: title || 'Step ' + (steps.length + 1), text };
45
+ const open = pageOf(s.open); if (open) step.open = open;
46
+ const chat = str(s.chat, MAX_TEXT); if (chat) step.chat = chat;
47
+ steps.push(step);
48
+ }
49
+ if (!steps.length) return { ok: false, error: 'the tour has no step with a title or words' };
50
+ return { ok: true, title: str(raw.title, MAX_TITLE) || 'Tour', steps };
51
+ }
52
+
53
+ function read(root) {
54
+ if (!root) return null;
55
+ let text;
56
+ try { text = fs.readFileSync(path.join(root, FILE), 'utf8'); } catch { return null; }
57
+ let raw;
58
+ try { raw = JSON.parse(text); } catch { return { ok: false, error: FILE + ' is not JSON' }; }
59
+ return clean(raw);
60
+ }
61
+
62
+ function list(workspaces) {
63
+ const out = [];
64
+ for (const w of workspaces || []) {
65
+ if (!w || !w.id || !w.root) continue;
66
+ const t = read(w.root);
67
+ if (t && t.ok) out.push({ ws: w.id, name: w.label || w.name || w.id, title: t.title, steps: t.steps });
68
+ }
69
+ return out;
70
+ }
71
+
72
+ module.exports = { clean, read, list, pageOf, FILE, MAX_STEPS, MAX_TITLE, MAX_TEXT };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.746.0",
3
+ "version": "0.747.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.746.0",
9
+ "version": "0.747.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.746.0",
3
+ "version": "0.747.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",
@@ -358,5 +358,7 @@ export function mountNav(here, doc = document, opts = {}) {
358
358
  if (typeof matchMedia === 'function') { const mq = matchMedia(DESK); const f = () => { if (!N.rail) set(false); draw(); }; if (mq.addEventListener) mq.addEventListener('change', f); }
359
359
  if (typeof matchMedia === 'function') { const mp = matchMedia(PHONE_Q); const f = () => { if (!N.rail) set(false); }; if (mp.addEventListener) mp.addEventListener('change', f); }
360
360
  window.addEventListener('pm:sources', (e) => { const d = e.detail; if (d && d.ok) { N.stale = bannerOf(d.sources); draw(); } });
361
+ // a workspace's guided tour (initiative workspace-tour): the Tour control or the step card, only when a workspace holds pmos/tour.json
362
+ if (typeof document !== 'undefined' && doc === document) import('./tour.js').then((m) => m.boot()).catch(() => {});
361
363
  return w;
362
364
  }
@@ -0,0 +1,27 @@
1
+ /* tour.css — the guided tour's control and step card (public/pm/tour.js, initiative workspace-tour). Tokens only. */
2
+ .tr-card,.tr-go{position:fixed;z-index:2147483000;font-family:inherit;color:var(--cz-ink, var(--foreground))}
3
+ .tr-card{left:50%;bottom:var(--space-24,24px);transform:translateX(-50%);width:min(440px,calc(100vw - 32px));background:var(--card);
4
+ border:1px solid var(--cz-hair, var(--border));border-radius:8px;box-shadow:var(--cz-lift, var(--lift));padding:var(--space-16,16px) var(--space-16,16px) var(--space-12,12px)}
5
+ .tr-top{display:flex;align-items:center;gap:var(--space-8,8px);font-size:var(--fs-meta);color:var(--cz-ink3, var(--muted-foreground))}
6
+ .tr-top span{flex:1}
7
+ .tr-bar{display:block;width:100%;height:3px;margin:var(--space-8,8px) 0 var(--space-12,12px);border:0;border-radius:0;background:var(--cz-well, var(--muted));accent-color:var(--cz-blue, var(--primary));appearance:none}
8
+ .tr-bar::-webkit-progress-bar{background:var(--cz-well, var(--muted))}
9
+ .tr-bar::-webkit-progress-value{background:var(--cz-blue, var(--primary))}
10
+ .tr-bar::-moz-progress-bar{background:var(--cz-blue, var(--primary))}
11
+ .tr-card h2{margin:0 0 var(--space-8,8px);font-size:var(--fs-section);font-weight:var(--fw-strong)}
12
+ .tr-card p{margin:0 0 var(--space-8,8px);font-size:var(--fs-body);color:var(--cz-ink, var(--foreground));white-space:pre-line}
13
+ .tr-chat{margin:0 0 var(--space-8,8px);padding:var(--space-8,8px) var(--space-12,12px);border-radius:8px;background:var(--cz-well, var(--muted));font-size:var(--fs-meta);color:var(--cz-ink, var(--foreground))}
14
+ .tr-chat b{display:block;font-weight:var(--fw-strong);color:var(--cz-ink3, var(--muted-foreground));font-size:var(--fs-badge)}
15
+ .tr-row{display:flex;align-items:center;justify-content:flex-end;gap:var(--space-8,8px);margin-top:var(--space-12,12px)}
16
+ .tr-card button,.tr-go button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:36px;min-width:36px;border-radius:6px;
17
+ border:1px solid var(--cz-hair, var(--border));background:transparent;color:inherit;font:inherit;font-size:var(--fs-body);cursor:pointer;padding:0 var(--space-12,12px)}
18
+ .tr-card .tr-x{border:0;min-height:28px;min-width:28px;padding:0}
19
+ .tr-card .tr-next{background:var(--cz-blue, var(--primary));color:var(--cz-onsolid, var(--primary-foreground));border-color:transparent;padding:0 var(--space-16,16px)}
20
+ .tr-card button:disabled{opacity:.4;cursor:default}
21
+ .tr-card button:focus-visible,.tr-go button:focus-visible{outline:2px solid color-mix(in oklab, var(--ring, var(--cz-blue)) 50%, var(--cz-ink, var(--foreground)));outline-offset:2px}
22
+ .tr-go{right:var(--space-16,16px);bottom:var(--space-16,16px);display:flex;gap:4px;background:var(--card);border:1px solid var(--cz-hair, var(--border));border-radius:8px;box-shadow:var(--cz-float, var(--raise));padding:4px}
23
+ .tr-go button{border:0}
24
+ .tr-go .tr-x{min-width:28px;padding:0;color:var(--cz-ink3, var(--muted-foreground))}
25
+ @media (pointer: coarse){.tr-card button,.tr-go button{min-height:44px;min-width:44px}}
26
+ @media (max-width:760px){.tr-card,.tr-go{bottom:calc(76px + env(safe-area-inset-bottom,0px))}}
27
+ @media print{.tr-card,.tr-go{display:none}}
@@ -0,0 +1,131 @@
1
+ /* pm/tour.js — a workspace's guided tour (initiative workspace-tour; lib/tour.js, GET /api/tour).
2
+ *
3
+ * A workspace that holds pmos/tour.json shows a small Tour control at the foot of every page that has the menu (cozy-nav.js mountNav
4
+ * loads this file). Start opens the first step. Each step is one card: "Step 3 of 14", its title, a few lines of context, and Back and
5
+ * Next. Next opens the step's page when it names one (the workspace is added to the address), and the card follows on that page.
6
+ * A step with chat words puts them in the chat box (page-chat.js ask): the presenter reads them and sends them. A tour never sends a
7
+ * message and never runs a command.
8
+ *
9
+ * boot() draws the control or the card for this page; nothing at all when no workspace has a tour
10
+ * ?tour=start in any page address starts the first tour again (after × hid the control)
11
+ *
12
+ * State is one localStorage key, 'pmos.tour': { ws, i, chatAt } while a tour runs, { hidden: [ws] } after × on the control. On a phone
13
+ * the card spans the width, above the bottom bar. Keys: → Next, ← Back, while the focus is not in a text box. */
14
+ import { pmGet } from './http.js';
15
+
16
+ const KEY = 'pmos.tour';
17
+ const NEXT = 'M5 12h14M13 6l6 6-6 6';
18
+ const BACK = 'M19 12H5M11 6l-6 6 6 6';
19
+ const PLAY = 'M8 5v14l11-7z';
20
+ const CLOSE = 'M6 6l12 12M18 6L6 18';
21
+ const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
22
+ const svg = (d) => `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
23
+ const load = () => { try { return JSON.parse(localStorage.getItem(KEY) || 'null') || {}; } catch { return {}; } };
24
+ const save = (v) => { try { localStorage.setItem(KEY, JSON.stringify(v)); } catch { /* private window: the tour still runs on this page */ } };
25
+
26
+ const CSS = new URL('./tour.css', import.meta.url).href;
27
+
28
+ /** A page address split by hand into its path, its query and its hash (no URL base is needed). */
29
+ function split(h) {
30
+ const m = /^([^?#]*)(\?[^#]*)?(#.*)?$/.exec(String(h || '')) || [];
31
+ return { path: m[1] || '', q: new URLSearchParams((m[2] || '').slice(1)), hash: m[3] || '' };
32
+ }
33
+ /** The step's address with the tour's workspace added, unless the address names one. */
34
+ export function hrefOf(step, ws) {
35
+ if (!step || !step.open) return '';
36
+ const u = split(step.open);
37
+ if (ws && !u.q.has('ws')) u.q.set('ws', ws);
38
+ const q = u.q.toString();
39
+ return u.path + (q ? '?' + q : '') + u.hash;
40
+ }
41
+ /** True when the page at `loc` ({ pathname, search }) is the step's page: the same path, and every parameter the step names. */
42
+ export function isAt(href, loc) {
43
+ if (!href) return true;
44
+ const u = split(href), here = new URLSearchParams(loc.search || '');
45
+ if (u.path !== loc.pathname) return false;
46
+ for (const [k, v] of u.q) if (here.get(k) !== v) return false;
47
+ return true;
48
+ }
49
+
50
+ let T = null; // { tours, tour, el, go }
51
+
52
+ function sheet() {
53
+ if (document.getElementById('tr-css')) return;
54
+ const l = document.createElement('link'); l.id = 'tr-css'; l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
55
+ }
56
+ function clear() { for (const k of ['el', 'go']) { if (T && T[k]) { T[k].remove(); T[k] = null; } } }
57
+
58
+ function drawGo(tour) {
59
+ clear();
60
+ const go = document.createElement('div');
61
+ go.className = 'tr-go'; go.setAttribute('role', 'group'); go.setAttribute('aria-label', tour.title);
62
+ go.innerHTML = `<button type="button" class="tr-start" title="Start the tour: ${esc(tour.title)}" aria-label="Start the tour: ${esc(tour.title)}">${svg(PLAY)}<span>Tour</span></button>`
63
+ + `<button type="button" class="tr-x" title="Hide the tour" aria-label="Hide the tour">${svg(CLOSE)}</button>`;
64
+ go.querySelector('.tr-start').onclick = () => to(tour, 0);
65
+ go.querySelector('.tr-x').onclick = () => { const s = load(); save({ hidden: [...new Set([...(s.hidden || []), tour.ws])] }); clear(); };
66
+ document.body.appendChild(go); T.go = go;
67
+ }
68
+
69
+ function drawCard(tour, i) {
70
+ clear();
71
+ const st = tour.steps[i], n = tour.steps.length, last = i === n - 1;
72
+ const el = document.createElement('section');
73
+ el.className = 'tr-card'; el.setAttribute('role', 'dialog'); el.setAttribute('aria-modal', 'false'); el.setAttribute('aria-labelledby', 'tr-h');
74
+ el.innerHTML = `<div class="tr-top"><span>${esc(tour.title)} · Step ${i + 1} of ${n}</span>`
75
+ + `<button type="button" class="tr-x" title="End the tour" aria-label="End the tour">${svg(CLOSE)}</button></div>`
76
+ + `<progress class="tr-bar" max="${n}" value="${i + 1}" aria-hidden="true"></progress>`
77
+ + `<h2 id="tr-h">${esc(st.title)}</h2>` + (st.text ? `<p>${esc(st.text)}</p>` : '')
78
+ + (st.chat ? `<div class="tr-chat"><b>In the chat box, ready to send</b>${esc(st.chat)}</div>` : '')
79
+ + `<div class="tr-row"><button type="button" class="tr-back" title="Back" aria-label="Back"${i === 0 ? ' disabled' : ''}>${svg(BACK)}</button>`
80
+ + `<button type="button" class="tr-next">${last ? 'Finish' : 'Next'}${last ? '' : svg(NEXT)}</button></div>`;
81
+ el.querySelector('.tr-x').onclick = end;
82
+ el.querySelector('.tr-back').onclick = () => to(tour, i - 1);
83
+ el.querySelector('.tr-next').onclick = () => (last ? end() : to(tour, i + 1));
84
+ document.body.appendChild(el); T.el = el;
85
+ el.querySelector('.tr-next').focus({ preventScroll: true });
86
+ const s = load();
87
+ if (st.chat && s.chatAt !== i) { // the step's words go in the chat box once per arrival, for the presenter to send
88
+ save({ ...s, chatAt: i });
89
+ import('./page-chat.js').then((m) => m.ask(st.chat, { ws: tour.ws })).catch(() => {});
90
+ }
91
+ }
92
+
93
+ function to(tour, i) {
94
+ if (i < 0 || i >= tour.steps.length) return;
95
+ const s = load();
96
+ save({ ws: tour.ws, i, chatAt: s.ws === tour.ws && s.i === i ? s.chatAt : -1 });
97
+ const href = hrefOf(tour.steps[i], tour.ws);
98
+ if (href && !isAt(href, location)) { location.assign(href); return; }
99
+ drawCard(tour, i);
100
+ }
101
+ function end() { const s = load(); save({ hidden: s.hidden || [] }); clear(); if (T && T.tour) drawGo(T.tour); }
102
+
103
+ function keys(e) {
104
+ if (!T || !T.el || e.altKey || e.ctrlKey || e.metaKey) return;
105
+ const t = e.target, tag = t && t.tagName;
106
+ if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || (t && t.isContentEditable)) return;
107
+ if (e.key === 'ArrowRight') { e.preventDefault(); T.el.querySelector('.tr-next').click(); }
108
+ else if (e.key === 'ArrowLeft') { const b = T.el.querySelector('.tr-back'); if (!b.disabled) { e.preventDefault(); b.click(); } }
109
+ }
110
+
111
+ export async function boot() {
112
+ if (typeof document === 'undefined' || T) return;
113
+ T = { tours: [], tour: null, el: null, go: null };
114
+ const r = await pmGet('/api/tour');
115
+ const tours = r && r.ok && Array.isArray(r.tours) ? r.tours : [];
116
+ if (!tours.length) return;
117
+ T.tours = tours;
118
+ const p = new URLSearchParams(location.search), s = load();
119
+ const pick = (ws) => tours.find((t) => t.ws === ws) || null;
120
+ sheet();
121
+ document.addEventListener('keydown', keys);
122
+ if (p.get('tour') === 'start') {
123
+ const tour = pick(p.get('ws')) || tours[0];
124
+ T.tour = tour; save({ hidden: (s.hidden || []).filter((w) => w !== tour.ws) }); return to(tour, 0);
125
+ }
126
+ const running = s.ws ? pick(s.ws) : null;
127
+ if (running && Number.isInteger(s.i) && s.i >= 0 && s.i < running.steps.length) { T.tour = running; return drawCard(running, s.i); }
128
+ const tour = pick(p.get('ws')) || tours.find((t) => !(s.hidden || []).includes(t.ws));
129
+ if (!tour || (s.hidden || []).includes(tour.ws)) return;
130
+ T.tour = tour; drawGo(tour);
131
+ }
@@ -7,7 +7,7 @@
7
7
  "unit": [
8
8
  "test.js"
9
9
  ],
10
- "modules": [
10
+ "modules": ["tour.test.js",
11
11
  "find-browser.test.js",
12
12
  "units.test.js",
13
13
  "program-worktree.test.js",