create-pmos 0.745.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.
Files changed (33) hide show
  1. package/package.json +33 -33
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-board-test.js +3 -2
  7. package/workspace/changelog.json +32 -0
  8. package/workspace/guide/home.md +9 -1
  9. package/workspace/guide/index.md +1 -0
  10. package/workspace/guide/tour.md +41 -0
  11. package/workspace/lib/doc-category.js +1 -0
  12. package/workspace/lib/route-modules.js +1 -0
  13. package/workspace/lib/routes-tour.js +18 -0
  14. package/workspace/lib/short-links.js +90 -0
  15. package/workspace/lib/tour.js +72 -0
  16. package/workspace/lib/vendor/workspace/lib/doc-category.js +1 -0
  17. package/workspace/package-lock.json +2 -2
  18. package/workspace/package.json +1 -1
  19. package/workspace/public/pm/bd-ini-panel.js +3 -1
  20. package/workspace/public/pm/cozy-nav.js +2 -0
  21. package/workspace/public/pm/cozy-task-pop.js +3 -0
  22. package/workspace/public/pm/cozy-viewer.js +11 -1
  23. package/workspace/public/pm/home-ini.js +3 -1
  24. package/workspace/public/pm/home-need.js +6 -2
  25. package/workspace/public/pm/home-task.js +2 -0
  26. package/workspace/public/pm/premium-board.js +14 -1
  27. package/workspace/public/pm/short-link.js +35 -0
  28. package/workspace/public/pm/tour.css +27 -0
  29. package/workspace/public/pm/tour.js +131 -0
  30. package/workspace/server.js +8 -0
  31. package/workspace/task-card-test.js +6 -0
  32. package/workspace/test-files.json +1 -1
  33. package/workspace/test-lists/short-links.json +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.745.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,38 @@
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
+ },
49
+ {
50
+ "v": "0.746.0",
51
+ "at": "2026-11-23T11:03:05.465Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1670,
56
+ "t": "Give PressRelease a doc-category row (red main)",
57
+ "s": "Give PressRelease a doc-category row (red main)",
58
+ "k": "fix"
59
+ },
60
+ {
61
+ "n": 1668,
62
+ "t": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
63
+ "s": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
64
+ "k": "new"
65
+ }
66
+ ]
67
+ },
36
68
  {
37
69
  "v": "0.745.0",
38
70
  "at": "2026-11-23T10:30:13.712Z",
@@ -592,38 +624,6 @@
592
624
  "k": "fix"
593
625
  }
594
626
  ]
595
- },
596
- {
597
- "v": "0.723.0",
598
- "at": "2026-11-23T01:56:36.110Z",
599
- "f": 4,
600
- "prs": [
601
- {
602
- "n": 1599,
603
- "t": "Pmos why coverage leaves out Closed, Cancelled and Killed records",
604
- "s": "Pmos why coverage leaves out Closed, Cancelled and Killed records",
605
- "k": "fix"
606
- },
607
- {
608
- "n": 1600,
609
- "t": "Pinned views' Unpin is the system's pm-btn (Checker V6, job #1558)",
610
- "s": "Pinned views' Unpin is the system's pm-btn (Checker V6, job #1558)",
611
- "k": "fix"
612
- }
613
- ]
614
- },
615
- {
616
- "v": "0.721.0",
617
- "at": "2026-11-23T00:30:20.134Z",
618
- "f": 4,
619
- "prs": [
620
- {
621
- "n": 1597,
622
- "t": "Search counts pages and actions on All only (job #1562 follow-up)",
623
- "s": "Search counts pages and actions on All only (job #1562 follow-up)",
624
- "k": "fix"
625
- }
626
- ]
627
627
  }
628
628
  ]
629
629
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@75b5a732
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-23T10:30:10Z"}
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-23T10:30:10Z"}
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-23T10:30:10Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-23T13:39:35Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -401,7 +401,7 @@ const IVREAD = () => {
401
401
  ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
402
402
  await A.ctx.close();
403
403
 
404
- /* B14 there is no Page/Popup switch. Re-pointed (batch 14 item 5): "Open in full" left ⋯ (the header's Open wide says it once); Copy link holds the initiative page's address */
404
+ /* B14 there is no Page/Popup switch. Re-pointed (batch 14 item 5): "Open in full" left ⋯ (the header's Open wide says it once); Copy link holds the initiative's short link (A428) */
405
405
  {
406
406
  const D = await open();
407
407
  await D.ctx.route('**/premium-initiative.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<title>x</title>' }));
@@ -416,7 +416,8 @@ const IVREAD = () => {
416
416
  await D.page.click('#czViewer [data-cz-vw="more"]'); await D.page.click('.cz-vw-menu [role="menuitem"]:has(> span:text-is("Copy"))'); await D.page.click('.hi-pop [role="menuitem"]:has(> span:text-is("Link"))');
417
417
  const cl = await until(() => D.page.evaluate(() => navigator.clipboard.readText().catch(() => '')));
418
418
  const u = new URL(cl || 'http://x/none');
419
- ok('B14 Copy › Link holds the initiative page with the initiative, the workspace and the board', u.pathname === '/premium-initiative.html' && u.searchParams.get('id') === 'self-serve-v2' && u.searchParams.get('ws') === 'w1' && u.searchParams.get('board') === 'w1', cl);
419
+ // the short link (bet A428, lib/short-links.js): /i/i/<id>?w=<product> opens the initiative on any device
420
+ ok('B14 Copy › Link holds the initiative\'s short link with its product', u.pathname === '/i/i/self-serve-v2' && u.searchParams.get('w') === 'w1', cl);
420
421
  ok('0 no page error on expand', D.errors.length === 0, D.errors.join(' | '));
421
422
  await D.ctx.close();
422
423
  }
@@ -1,4 +1,36 @@
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
+ },
15
+ {
16
+ "v": "0.746.0",
17
+ "at": "2026-11-23T11:03:05.465Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1670,
22
+ "t": "Give PressRelease a doc-category row (red main)",
23
+ "s": "Give PressRelease a doc-category row (red main)",
24
+ "k": "fix"
25
+ },
26
+ {
27
+ "n": 1668,
28
+ "t": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
29
+ "s": "A short link for every item, which opens it in its panel on a desktop and full screen on a phone (A428)",
30
+ "k": "new"
31
+ }
32
+ ]
33
+ },
2
34
  {
3
35
  "v": "0.745.0",
4
36
  "at": "2026-11-23T10:30:13.712Z",
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Home: your list, the chat, the Viewer, My work, documents and people"
4
4
  description: "Home's list, Mentions, Your day, the chat and the Viewer; My work; documents and their copies; People; and the suggested next prompt."
5
- timestamp: 2026-11-19
5
+ timestamp: 2026-11-23
6
6
  ---
7
7
 
8
8
  # Home
@@ -270,6 +270,14 @@ This section gives the order of **Your move** in Your day. `pmos today` prints t
270
270
 
271
271
  A session that waits on you has a blue dot in Home's list, under its initiative.
272
272
 
273
+ ## A short link for every item
274
+
275
+ Each initiative, task, milestone and Needs-you decision has one short link. To get it, open the item, press ⋯ and then **Copy link**. For an initiative, press ⋯, then **Copy**, then **Link**. Paste it in Slack, an email, a Jira comment or a report. The link looks like `<your PMOS address>/i/t/IDPF-12`: `i` is an initiative, `t` a task, `m` a milestone and `d` a decision.
276
+
277
+ When you open the link on a computer, the item opens in its own panel: an initiative or a task on the Board, and a decision on Today. On a phone the item covers the whole screen, and ← goes back. The link names the item, so it also opens on a teammate's PMOS when that PMOS has the same item. A link to an item that is gone opens the Viewer page with "Nothing is open".
278
+
279
+ PMOS counts the links you open and copy in the local use log on this computer (`node workspace/lib/short-links.js count`). Nothing is sent anywhere.
280
+
273
281
  ## PMOS's leads
274
282
 
275
283
  The premium Briefing page is now Home. Its leads still work, in popups and from a terminal.
@@ -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.
@@ -49,6 +49,7 @@ const TYPE_TO_CATEGORY = {
49
49
  Radar: 'report', Checklist: 'other', Calibration: 'report', Research: null, Design: 'spec-artifact',
50
50
  Prototype: 'other', Handover: 'report', Review: 'report',
51
51
  Decision: 'spec-artifact', Principle: 'knowledge', Debt: 'report', Discovery: 'report', Guide: 'knowledge',
52
+ PressRelease: 'spec-artifact',
52
53
  };
53
54
 
54
55
  /* A tenant repository is not bound to PMOS's registry, so a few spellings a PM would write for the same kinds are read too. */
@@ -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,90 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* short-links.js — a short link for every item (bet A428, initiative item-short-links; done test planning/done-tests/item-short-links.md).
4
+ *
5
+ * A link a PM pastes in Slack, an email, a Jira comment or a report opens that one item: in its panel on a desk, full screen on a phone (the
6
+ * Viewer does that by itself at 760 px or less). The link NAMES the item, so it opens on any PMOS that holds the item, on any product, and
7
+ * nothing is stored to make it:
8
+ * /i/<k>/<id>[?w=<product>] k: i initiative · t task · m milestone · d decision
9
+ *
10
+ * pathOf({ kind, id, ws? }) → '/i/t/IDPF-12?w=idpf' | null an unknown kind or a bad id: null
11
+ * parse(pathname, searchParams) → { kind, id, ws } | null
12
+ * targetOf({ kind, id, ws? }) → the page that opens it:
13
+ * initiative /premium-board.html?focus=<id> the Board opens its panel (premium-board.js focusOnce)
14
+ * task, milestone /premium-board.html?task=<id> the Board opens the task view, ← its initiative (taskOnce)
15
+ * decision /today.html?open=decision:<id> Today opens the Needs-you row (home-app.js ?open=)
16
+ * each with &ws=<product> when the link names one
17
+ * resolve(pathname, searchParams, { runtimeDir, ua, now }) → { status: 302, location }
18
+ * server.js answers /i/… with it. Each open adds one use line (control shortLinkOpen, the device from the browser) to the local use log
19
+ * (lib/use-log.js), the health number. A link that names nothing goes to /premium-viewer.html ("Nothing is open") and logs nothing.
20
+ * CLI: node lib/short-links.js count → [short-links] opens …, then the opens in the last 7 days on its last line (the health number)
21
+ *
22
+ * Nothing here sends anything. The page side (public/pm/short-link.js) makes the same links. */
23
+ const UL = require('./use-log.js');
24
+
25
+ const KINDS = Object.freeze({ initiative: 'i', task: 't', milestone: 'm', decision: 'd' });
26
+ const BY_LETTER = Object.freeze(Object.fromEntries(Object.entries(KINDS).map(([k, v]) => [v, k])));
27
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
28
+ const WS_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;
29
+ const NOTHING = '/premium-viewer.html';
30
+ const say = (s) => { try { console.log('[short-links] ' + s); } catch { /* no console */ } };
31
+
32
+ function pathOf(item) {
33
+ if (!item || !Object.prototype.hasOwnProperty.call(KINDS, item.kind)) return null;
34
+ const id = String(item.id == null ? '' : item.id);
35
+ if (!ID_RE.test(id)) return null;
36
+ const ws = item.ws && WS_RE.test(String(item.ws)) ? String(item.ws) : '';
37
+ return '/i/' + KINDS[item.kind] + '/' + id + (ws ? '?w=' + encodeURIComponent(ws) : '');
38
+ }
39
+
40
+ function parse(pathname, searchParams) {
41
+ const m = /^\/i\/([a-z])\/([^/]+)$/.exec(String(pathname || ''));
42
+ if (!m || !BY_LETTER[m[1]]) return null;
43
+ let id;
44
+ try { id = decodeURIComponent(m[2]); } catch { return null; }
45
+ if (!ID_RE.test(id)) return null;
46
+ const w = searchParams && typeof searchParams.get === 'function' ? searchParams.get('w') || '' : '';
47
+ return { kind: BY_LETTER[m[1]], id, ws: WS_RE.test(w) ? w : '' };
48
+ }
49
+
50
+ function targetOf(item) {
51
+ const q = new URLSearchParams();
52
+ let page;
53
+ if (item.kind === 'initiative') { page = '/premium-board.html'; q.set('focus', item.id); }
54
+ else if (item.kind === 'task' || item.kind === 'milestone') { page = '/premium-board.html'; q.set('task', item.id); }
55
+ else { page = '/today.html'; q.set('open', 'decision:' + item.id); }
56
+ if (item.ws) q.set('ws', item.ws);
57
+ return page + '?' + q.toString();
58
+ }
59
+
60
+ function deviceOf(ua) {
61
+ const s = String(ua || '');
62
+ if (/iPad|Tablet/i.test(s) || (/Android/i.test(s) && !/Mobile/i.test(s))) return 'tablet';
63
+ if (/Mobi|iPhone|Android/i.test(s)) return 'phone';
64
+ return 'desk';
65
+ }
66
+
67
+ function resolve(pathname, searchParams, { runtimeDir = null, ua = '', now = Date.now() } = {}) {
68
+ const item = parse(pathname, searchParams);
69
+ if (!item) { say('names nothing'); return { status: 302, location: NOTHING }; }
70
+ const device = deviceOf(ua);
71
+ if (runtimeDir) {
72
+ const r = UL.record(runtimeDir, [{ kind: 'use', page: '/short-link', control: 'shortLinkOpen', device }], now);
73
+ if (!r || !r.ok) say('open not logged: ' + ((r && r.error) || 'no reason'));
74
+ }
75
+ say(`open ${item.kind} on ${device}`); // never the id: the log stays free of item names
76
+ return { status: 302, location: targetOf(item) };
77
+ }
78
+
79
+ /** The opens in the last `days` days (the health number). */
80
+ const opens = (lines, days = 7, now = Date.now()) => UL.controlCount(lines, 'shortLinkOpen', days, now);
81
+
82
+ module.exports = { KINDS, ID_RE, pathOf, parse, targetOf, deviceOf, resolve, opens };
83
+
84
+ if (require.main === module) {
85
+ if (process.argv[2] !== 'count') { console.error('usage: node lib/short-links.js count (short-link opens in the last 7 days, on the last line)'); process.exit(2); }
86
+ const dir = require('./state-root.js').defaultRoot({ env: process.env });
87
+ const lines = UL.readLines(dir), n = opens(lines);
88
+ console.log('[short-links] opens in the last 7 days: ' + n + ' (copies: ' + UL.controlCount(lines, 'shortLinkCopy', 7) + ')');
89
+ console.log(String(n));
90
+ }
@@ -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 };
@@ -49,6 +49,7 @@ const TYPE_TO_CATEGORY = {
49
49
  Radar: 'report', Checklist: 'other', Calibration: 'report', Research: null, Design: 'spec-artifact',
50
50
  Prototype: 'other', Handover: 'report', Review: 'report',
51
51
  Decision: 'spec-artifact', Principle: 'knowledge', Debt: 'report', Discovery: 'report', Guide: 'knowledge',
52
+ PressRelease: 'spec-artifact',
52
53
  };
53
54
 
54
55
  /* A tenant repository is not bound to PMOS's registry, so a few spellings a PM would write for the same kinds are read too. */
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.745.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.745.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.745.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",
@@ -27,6 +27,7 @@ import * as VW from './cozy-viewer.js';
27
27
  import * as SV from './small-vw.js'; // the one stakeholder form, Home's too (batch 18 item 2-C)
28
28
  import { esc } from './premium-shell.js';
29
29
  import { copyText } from './cozy-xv.js';
30
+ import { linkPath } from './short-link.js'; // the initiative's short link (bet A428)
30
31
  import { iniView } from './ini-view-model.js';
31
32
  import { gateOf } from './premium-initiative-head.js'; // the gate chips (PRD, draft, reviewed), as Home's page reads them (UI grill U1)
32
33
  import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
@@ -130,7 +131,8 @@ function iniMore(r) {
130
131
  // split or merge, then the one Program picker (batch 11 items 2 and 14; batch 16 item 5c; pm/split-merge.js, pm/prog-move.js)
131
132
  sm: id && O.smItems && !r.ended ? O.smItems(r) : [],
132
133
  pm: id && O.moveItems ? O.moveItems(r) : [],
133
- link: id ? () => copyText(new URL(O.pageHref(r), location.href).href, 'Link copied.') : null,
134
+ // Copy › Link is the item's short link (bet A428, pm/short-link.js): it opens the initiative on any device; an id it cannot carry keeps the page link
135
+ link: id ? () => copyText(new URL(linkPath({ kind: 'initiative', id, ws: r.ws || ((O.M() || {}).board || {}).ws || '' }) || O.pageHref(r), location.href).href, 'Link copied.') : null,
134
136
  text: () => copyText(iniText(r.title, viewOf(r), (r.track && r.track.tickets) || []), 'Copied as text.'),
135
137
  record: id ? async () => { VW.drill(); (await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: r.title, ...where(r) }); } : null,
136
138
  del: id ? () => deleteIni(r) : null,
@@ -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
  }
@@ -18,6 +18,7 @@
18
18
  * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
19
  import { taskOf, mountCard, boardSaver, cardStyle, historyFor } from './task-card.js';
20
20
  import * as SWN from './cozy-status-when.js';
21
+ import { linkPath, copyLink } from './short-link.js'; // Copy link in ⋯ (bet A428)
21
22
  import * as VD from './vw-ds.js'; // viewer-ds-task (board ViewerDS): the full popup's Where it stands, Linked and Activity blocks
22
23
 
23
24
  const CSS = new URL('./cozy-task-pop.css', import.meta.url).href;
@@ -244,6 +245,7 @@ function moreMenu(btn) {
244
245
  if (m) { m.remove(); btn.setAttribute('aria-expanded', 'false'); return; }
245
246
  m = document.createElement('div'); m.className = 'ctp-menu'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'More for this task');
246
247
  m.innerHTML = `<button type="button" role="menuitem" data-k="kind">${SVG(s.t.milestone ? P.box : P.dia)}${s.t.milestone ? 'Make it a task' : 'Make it a milestone'}</button>`
248
+ + (linkPath({ kind: 'task', id: s.uid }) ? '<button type="button" role="menuitem" data-k="link">Copy link</button>' : '') // the short link (bet A428)
247
249
  + (s.t.status !== 'Archived' ? '<button type="button" role="menuitem" data-k="arch">Archive</button>' : '')
248
250
  + '<button type="button" role="menuitem" data-k="del" class="ctp-del">Delete</button>';
249
251
  btn.setAttribute('aria-expanded', 'true');
@@ -253,6 +255,7 @@ function moreMenu(btn) {
253
255
  const x = e.target.closest('[data-k]'); if (!x) return;
254
256
  e.stopPropagation(); m.remove(); btn.setAttribute('aria-expanded', 'false');
255
257
  if (x.dataset.k === 'kind') kindOf(!s.t.milestone);
258
+ else if (x.dataset.k === 'link') copyLink({ kind: s.t.milestone ? 'milestone' : 'task', id: s.uid, ws: s.ctx.ws || '' });
256
259
  else if (x.dataset.k === 'arch') s.card.setStatus('Archived');
257
260
  else if (x.dataset.k === 'del') delTask(s);
258
261
  });
@@ -127,6 +127,7 @@ const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file
127
127
  * the listeners, the rail's card. Only the first instance (#czViewer) writes the browser history; another keeps its own ← → trail.
128
128
  * Without cozy-panels.js (Board, Intelligence) the limit stays 1 and there is one Viewer, as before. */
129
129
  import { capture as capturePlace, restore as restorePlace } from './back-place.js'; // Back restores your place (A430)
130
+ import { linkOf, copyLink } from './short-link.js'; // a short link for every item (A428): Copy link in ⋯
130
131
  const G = { chat: null, subs: [], railKey: null, rail: false, lw: 0, tick: 0, limit: 1, beside: null, place: null, managed: null, popH: null, popNext: null, behindNext: null };
131
132
  const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], unplace: null, wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '', pop: false });
132
133
  let V = mk(0);
@@ -190,7 +191,7 @@ export function headHtml(it) {
190
191
  // in the popup the work side's header is the title and ⋯ only (board 20): its quiet icon presses go into ⋯; a solid primary stays
191
192
  const toMenu = (x) => (phone && x.menu) || (o.pop && !x.solid);
192
193
  const inMenu = (o.presses || []).some((x) => x && x.act && x.label && toMenu(x));
193
- const more = inMenu || typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
194
+ const more = inMenu || typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url || linkOf(o) ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
194
195
  const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
195
196
  const pressHtml = (x) => (x.solid
196
197
  ? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}${x.blue ? ' blue' : ''}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
@@ -426,6 +427,15 @@ function itemsOf(X, b) {
426
427
  const at = items.findIndex((x) => x && x.danger), tab = { label: X.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(X.cur.url, '_blank', 'noopener') };
427
428
  if (at < 0) items.push({ sep: true }, tab); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, tab);
428
429
  }
430
+ // Copy link (bet A428): an item that names itself (its own link: a task, a milestone, a decision) gets one short link that opens it,
431
+ // in its panel on a desk and full screen on a phone. It sits with the item's own address, before the red group.
432
+ const link = linkOf(X.cur.args);
433
+ if (link) {
434
+ const copy = { label: 'Copy link', on: () => { copyLink(link); } }, tabAt = X.cur.url ? items.findIndex((x) => x && x.on && /^Open in (a new tab|full)$/.test(x.label || '')) : -1;
435
+ const at = items.findIndex((x) => x && x.danger);
436
+ if (tabAt >= 0) items.splice(tabAt + 1, 0, copy);
437
+ else if (at < 0) items.push({ sep: true }, copy); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, copy);
438
+ }
429
439
  while (items.length && items[0].sep) items.shift();
430
440
  for (let i = items.length - 1; i > 0; i--) if (items[i].sep && items[i - 1].sep) items.splice(i, 1);
431
441
  return items;
@@ -31,6 +31,7 @@ import * as WF from './ini-wf.js';
31
31
  import { openPop, closePop, undoToast, popEl, ensureCss as ensurePopCss } from './hi-pop.js';
32
32
  import { iniMore, iniText, pageHref, stagePick, deleteSaid, DELETE_MS } from './ini-more.js'; // the one initiative ⋯ menu and stage picker, the same on the Board (batch 14 item 5, batch 16 item 5c)
33
33
  import * as SC from './home-stage-card.js';
34
+ import { linkPath } from './short-link.js'; // the initiative's short link (bet A428)
34
35
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
35
36
  import { ensureCss as ensureStepsCss } from './cozy-steps.js'; // stage card D: the card's last node and the move sheet's words // D99: the initiative's own workflow (Change picker, switch, Won't do, Archive)
36
37
  import * as DB from './dash-view.js'; // the ready-made Dashboard view (batch 17 item 1)
@@ -410,7 +411,8 @@ function pageMore(id) {
410
411
  sm: C.smItems && !row.ended ? C.smItems(id, openList) : [],
411
412
  pm: C.moveItems ? C.moveItems(id, openList) : [],
412
413
  board: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); },
413
- link: () => copy(new URL(pageHref(id, M.board.ws, M.board.id), location.href).href, 'Link copied.'),
414
+ // Copy › Link is the item's short link (bet A428, pm/short-link.js): it opens the initiative on any device; an id it cannot carry keeps the page link
415
+ link: () => copy(new URL(linkPath({ kind: 'initiative', id, ws: M.board.ws || '' }) || pageHref(id, M.board.ws, M.board.id), location.href).href, 'Link copied.'),
414
416
  text: () => copy(iniText(C.iniTitle(id), C.view ? C.view(id) : null, (row.track && row.track.tickets) || []), 'Copied as text.'),
415
417
  record: async () => (C.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }),
416
418
  del: M.board && M.board.id ? () => deleteIni(id, M) : null,
@@ -19,6 +19,10 @@
19
19
  * linkOf(r), toast(m), signIn(), rowGone(key) }
20
20
  * refresh() draws the open ask again when its phase changed (a run finished, the row left Home); called after each read. */
21
21
 
22
+ import { linkPath } from './short-link.js';
23
+ /** A decision's short link (bet A428, pm/short-link.js): the Viewer's ⋯ then shows Copy link for /i/d/<id>, which opens this row on any
24
+ * device. Other rows, and a decision whose id a short link cannot carry, keep the page link (h.linkOf). */
25
+ const shortOf = (r) => { const id = r && r.row && r.row.kind === 'decision' ? String(r.key || '').replace(/^decision:/, '') : ''; return id && linkPath({ kind: 'decision', id }) ? { kind: 'decision', id, ws: (r.row && r.row.ws) || r.ws || '' } : null; };
22
26
  const STEP_WORD = { spec: 'the spec', prototype: 'the prototype', contract: 'the agreed done-criteria', anchor: 'the goal it moves', route: 'its lane', brief: 'the problem brief', prd: 'the PRD', rubric: 'the rubric' };
23
27
  const STEP_AT = { spec: 'the spec', prototype: 'the prototype', contract: 'the contract', anchor: 'the goal', route: 'routing' };
24
28
  export const LANE_WORD = { feature: 'New feature', discovery: 'Discovery', chore: 'Upkeep', incident: 'Incident', content: 'Content', prototype: 'Prototype' };
@@ -238,11 +242,11 @@ export function openNeed(r, h, o = {}) {
238
242
  const out = [];
239
243
  const rec = h.recordHref(r); if (rec) out.push({ label: 'Open the record', on: () => window.open(rec, '_blank', 'noopener') });
240
244
  const bd = h.boardHref(r); if (bd) out.push({ label: 'Open on the Board', on: () => window.open(bd, '_blank', 'noopener') });
241
- out.push({ label: 'Copy link', on: async () => { try { await navigator.clipboard.writeText(h.linkOf(r)); h.toast('The link is copied.'); } catch { h.toast('The link could not be copied.'); } } });
245
+ if (!shortOf(r)) out.push({ label: 'Copy link', on: async () => { try { await navigator.clipboard.writeText(h.linkOf(r)); h.toast('The link is copied.'); } catch { h.toast('The link could not be copied.'); } } });
242
246
  return out;
243
247
  };
244
248
  const body = h.VW.open({ id: 'need:' + r.key, kind: ({ decision: 'Decision', blocked: 'Blocked', waited: 'Waiting', source: 'Source' }[r.row.kind] || 'Needs you'), title: m0.title, sub: m0.sub, icon: m0.icon,
245
- presses: pressesOf(m0, r, h), more, onPress: (act, b) => pressHead(act, b), render: draw });
249
+ link: shortOf(r), presses: pressesOf(m0, r, h), more, onPress: (act, b) => pressHead(act, b), render: draw });
246
250
  NV.sig = sigOf(m0);
247
251
  if (body) {
248
252
  body.oninput = (e) => { if (e.target.id === 'nvWhy') { NV.st.why = e.target.value; const b = body.querySelector('[data-nv-rec]'); if (b) b.disabled = !canRecord(); } };
@@ -28,6 +28,8 @@ export function openTask(task, h) {
28
28
  const del = deleteEntry({ ws, board, t, post: (p, b) => h.pmPost(p, b), toast, done: () => { if (h.VW.close) h.VW.close(); if (h.onChange) h.onChange(); } });
29
29
  const body = h.VW.open({
30
30
  id, kind: 'Task', title: t.title, icon: 'task', check: checkOf(t),
31
+ // a short link (bet A428): ⋯ Copy link gives /i/t/<uid> (or /i/m/ for a milestone), which opens this task on any device
32
+ link: { kind: t.milestone ? 'milestone' : 'task', id: raw.uid, ws: ws || '' },
31
33
  rename: t.jira ? null : h.rename ? h.rename(raw) : null,
32
34
  more: () => {
33
35
  return [{ label: 'Talk it through in chat', on: () => h.askInChat(raw) }, ...(del ? [{ sep: true }, del] : [])]; // Delete: batch 7 item 5
@@ -1408,6 +1408,19 @@ function focusOnce() {
1408
1408
  const b = $$('#ibBody [data-key]').find((x) => x.dataset.key === r.key);
1409
1409
  openIni(r, b || null, 'track');
1410
1410
  }
1411
+ /** ?task=<id> (a short link, lib/short-links.js; bet A428): open that task or milestone once, on the first read that has it. A PMOS task opens in
1412
+ * the task view with ← to its initiative; a Jira ticket in its ticket view. The Viewer covers the screen on a phone by itself. */
1413
+ let taskDone = false;
1414
+ function taskOnce() {
1415
+ if (taskDone) return;
1416
+ const id = new URLSearchParams(location.search).get('task'); if (!id) { taskDone = true; return; }
1417
+ const rows = (M.rows || []).filter((x) => x.track);
1418
+ if (!rows.length) return; // the first read is still on its way
1419
+ taskDone = true;
1420
+ for (const r of rows) { const k = (r.tasks || []).find((x) => x.uid === id); if (k) { openTask(r, k); return; } }
1421
+ for (const r of rows) { const k = ((r.track && r.track.tickets) || []).find((x) => x.key === id); if (k) { BI.openTicket(r, k, null); return; } }
1422
+ say('That task is not on this Board. It may have moved to another product or been deleted.');
1423
+ }
1411
1424
  /* The address follows the initiative or program open in the Viewer (?focus=, ?program=), so Back from another page comes back to it
1412
1425
  * (batch 14 item 7). The Viewer writes it once the history has settled on the entry the Board shows. */
1413
1426
  VW.onChange((d) => {
@@ -1478,7 +1491,7 @@ async function load() {
1478
1491
  LE.loaded({ since, stale: !!r.stale }); // a change still saving stays on the new read; open views (the big Work breakdown) follow it
1479
1492
  STRAT.refresh($('#cStrat'), { ws: M.board.ws || null, board: M.board.id || null, single: !ALL, say });
1480
1493
  PRIN.refresh($('#cPrin'), { ws: M.board.ws || null, single: !ALL, say });
1481
- focusOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
1494
+ focusOnce(); taskOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
1482
1495
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
1483
1496
  else { loadTrail(); loadGrill(); }
1484
1497
  }
@@ -0,0 +1,35 @@
1
+ /* pm/short-link.js — the page side of a short link for every item (bet A428, initiative item-short-links). The server side and the rules are
2
+ * lib/short-links.js; this module makes the same links.
3
+ *
4
+ * linkPath({ kind, id, ws? }) → '/i/t/IDPF-12?w=idpf' | null kind: initiative | task | milestone | decision
5
+ * linkOf(o) → { kind, id, ws } | null what a Viewer item names: its own o.link (a task, a milestone, a decision)
6
+ * An initiative's link is Copy › Link in the one initiative ⋯ (pm/ini-more.js), built by bd-ini-panel.js and home-ini.js with linkPath.
7
+ * copyLink(link) → copies the full address (this PMOS's origin + the path) and says so in the page's toast; logs shortLinkCopy
8
+ *
9
+ * Opening the link: in its panel on a desk, full screen on a phone (the Viewer does that at 760 px or less). Nothing here sends anything:
10
+ * the copy is the person's own press. */
11
+ const KINDS = { initiative: 'i', task: 't', milestone: 'm', decision: 'd' };
12
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
13
+ const WS_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;
14
+
15
+ export function linkPath(item) {
16
+ if (!item || !Object.prototype.hasOwnProperty.call(KINDS, item.kind)) return null;
17
+ const id = String(item.id == null ? '' : item.id);
18
+ if (!ID_RE.test(id)) return null;
19
+ const ws = item.ws && WS_RE.test(String(item.ws)) ? String(item.ws) : '';
20
+ return '/i/' + KINDS[item.kind] + '/' + id + (ws ? '?w=' + encodeURIComponent(ws) : '');
21
+ }
22
+
23
+ export function linkOf(o) {
24
+ if (!o || !o.link || !linkPath(o.link)) return null;
25
+ return { kind: o.link.kind, id: String(o.link.id), ws: o.link.ws || '' };
26
+ }
27
+
28
+ export async function copyLink(link) {
29
+ const p = linkPath(link); if (!p) return false;
30
+ const url = location.origin + p;
31
+ try { import('./use-log.js').then((U) => { if (U && typeof U.noteUse === 'function') U.noteUse('shortLinkCopy'); }).catch(() => {}); } catch { /* the log is optional */ }
32
+ const { copyText } = await import('./cozy-xv.js');
33
+ await copyText(url, 'Link copied. It opens this ' + (link.kind === 'decision' ? 'decision' : link.kind) + ' on any device.');
34
+ return true;
35
+ }
@@ -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
+ }
@@ -7396,6 +7396,14 @@ async function handleRequest(req, res) {
7396
7396
  }, (e) => { res.writeHead(500); res.end(String(e && e.message)); });
7397
7397
  });
7398
7398
  }
7399
+ // A short link for every item (bet A428, lib/short-links.js): /i/<k>/<id> goes to the page that opens it, in its panel on a desk and full
7400
+ // screen on a phone. Each open is one shortLinkOpen line in the local use log.
7401
+ if (p.startsWith('/i/')) {
7402
+ const r = require('./lib/short-links.js').resolve(p, url.searchParams, { runtimeDir: STATE, ua: req.headers['user-agent'] });
7403
+ // (Location starts with the literal '/i/' so run-tests.js --changed reads this block as a redirect of /i/ and runs only the suites that name it)
7404
+ res.writeHead(302, { Location: '/i/' === p ? '/premium-viewer.html' : r.location, 'Cache-Control': 'no-store' });
7405
+ return res.end();
7406
+ }
7399
7407
  // claude-onboarding-build: first run is a conversation in Home now. The old Welcome pages (/welcome and the three-step /premium-welcome.html)
7400
7408
  // open Home's project setup; their old query (?ws=, ?step=) has nothing left to say there.
7401
7409
  if (p === '/welcome' || p === '/welcome.html' || p === '/premium-welcome' || p === '/premium-welcome.html') {
@@ -237,6 +237,12 @@ async function pure() {
237
237
  ok('D4 a day typed in Due ("5 Nov") and Enter sets the due day and closes the picker', await until(() => last(A, '/api/boards/tasks/edit').body.due === '2026-11-05') && await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)), JSON.stringify(last(A, '/api/boards/tasks/edit')));
238
238
  await p.click(C + ' [data-tkc="dates"]');
239
239
  await until(() => p.evaluate((c) => !!document.querySelector(c + ' .tkc-dp'), C));
240
+ // the week and month keys: Home and End go to the week's Monday and Sunday, Page Down and Page Up move a month
241
+ await p.focus(C + ' .tkc-dp .rp-g [tabindex="0"]');
242
+ const fd = () => p.evaluate(() => (document.activeElement || {}).dataset && document.activeElement.dataset.rpDay);
243
+ const wk = [await fd()];
244
+ for (const k of ['Home', 'End', 'PageDown', 'PageUp']) { await p.keyboard.press(k); wk.push(await fd()); }
245
+ ok('D4 the keys: Home and End go to the week ends, Page Down and Page Up move a month and redraw it', wk.join() === '2026-10-23,2026-10-19,2026-10-25,2026-11-25,2026-10-25', JSON.stringify(wk));
240
246
  await p.mouse.click(5, 5);
241
247
  ok('D4 a press outside closes the picker', await until(() => p.evaluate((c) => !document.querySelector(c + ' .tkc-dp'), C)));
242
248
  // owner
@@ -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",
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "A short link for every item (initiative item-short-links, bet A428, done test S1-S7): /i/<k>/<id> opens the item in its panel on a desktop and full screen on a phone; Copy link in the Viewer's ⋯. Pure checks and source reads. No browser, no network.",
3
+ "modules": [
4
+ "short-links.test.js"
5
+ ],
6
+ "seconds": {
7
+ "short-links.test.js": 5
8
+ }
9
+ }