counterparts 0.3.53 → 0.3.54

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 (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/docs/manual.md +2 -2
  3. package/package.json +1 -1
  4. package/src/adapters/dashboard/CONTRACT.md +8 -0
  5. package/src/adapters/dashboard/web/README.md +7 -2
  6. package/src/adapters/dashboard/web/app.html +4 -0
  7. package/src/adapters/dashboard/web/app.js +31 -2
  8. package/src/adapters/dashboard/web/mechanisms/picture.js +2 -2
  9. package/src/adapters/dashboard/web/pages/flow/sections/detail.js +3 -1
  10. package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +1 -1
  11. package/src/adapters/dashboard/web/pages/health/sections/archive.js +2 -1
  12. package/src/adapters/dashboard/web/pages/home/sections/hero.js +3 -0
  13. package/src/adapters/dashboard/web/pages/memories/sections/search.js +4 -1
  14. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +7 -3
  15. package/src/adapters/dashboard/web/pages/self/sections/dreams.js +2 -2
  16. package/src/adapters/dashboard/web/pages/self/sections/journal.js +2 -1
  17. package/src/adapters/dashboard/web/pages/self/sections/settling.js +4 -3
  18. package/src/adapters/dashboard/web/pages/self/sections/stories.js +3 -2
  19. package/src/adapters/dashboard/web/pages/self/sections/traits.js +2 -1
  20. package/src/adapters/dashboard/web/pages/self/sections/wake.js +2 -1
  21. package/src/adapters/dashboard/web/respond.ts +349 -0
  22. package/src/adapters/dashboard/web/server.ts +41 -209
  23. package/src/adapters/dashboard/web/shared/actions.js +4 -1
  24. package/src/adapters/dashboard/web/shared/api.js +17 -1
  25. package/src/adapters/dashboard/web/shared/dom.js +50 -1
  26. package/src/adapters/dashboard/web/shared/event-modal.js +3 -0
  27. package/src/adapters/dashboard/web/shared/host.js +48 -0
  28. package/src/adapters/dashboard/web/shared/memory-modal.js +17 -9
  29. package/src/adapters/dashboard/web/shared/modal.js +8 -3
  30. package/src/adapters/dashboard/web/shared/utilities.css +5 -0
  31. package/src/adapters/dashboard/web/shared/widgets/feed.js +1 -1
  32. package/src/adapters/dashboard/web/shell/pages.js +13 -1
  33. package/src/adapters/mcp/server-words.ts +1 -1
  34. package/src/adapters/update-check.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.54 — 2026-11-10
4
+
5
+ **Hosted gets your dashboard (read-only: home, memories, your page and dreams), and hosted sign-up can open by spots instead of invite codes (closed until we open it).** What you'll notice on hosted: the account page links "Open your dashboard", which shows Home, Memories and Self; Subjects, Flow and Health say they're not on hosted yet. The sign-in page reads "Email me a link", with an optional "Have an invite code?". For local users: the dashboard's buttons work as before (their click handling moved, nothing new). No store-format change (store v15, cache v7), no migration. Nothing to run after upgrading beyond the usual restart of the dashboard and every Claude Code session. Going back to 0.3.53 is a reinstall with no store restore: `counterparts disconnect`, 0.3.53's install, then `counterparts connect`.
6
+
7
+ - **Hosted: your dashboard, read-only.** The account page links "Open your dashboard" (`/dashboard/`): the local
8
+ dashboard's Home, Memories and Self pages (the days, the memories, the self page, the dreams), served from your
9
+ hosted memory and seen only by you. Nothing on it writes; the pages that read your computer (Subjects, Flow,
10
+ Health) say they're not on hosted yet. The local dashboard and hosted's now share one server-side answerer, and
11
+ every button's click handling moved from inline handlers to delegated listeners: the local dashboard looks and
12
+ works as before. Its pages retry a request that was told to slow down.
13
+ - **Hosted: sign up with just your email while the beta has spots left.** The operator sets how many accounts
14
+ hosted takes (`spots set N`); until it's full, a new address gets a sign-up link with no code. When it's full,
15
+ the sign-in page says so and links counterparts.ai's waiting list. Invite codes still work, and are now an
16
+ optional "Have an invite code?" field. Spots start at 0, so nothing opens until the operator says so.
17
+
3
18
  ## 0.3.53 — 2026-11-09
4
19
 
5
20
  **Your page names what it sets down and tells more than corrections; the morning wake reads cleaner; things waiting on you come up when they're relevant, not as a pile.** What you'll notice: the morning after a night's page write, the wake can say "Set down from my page last night: …"; the wake ends with a "Carried forward" line, gives overdue items as a count with the oldest date, and names the session id in its first line; and now and then a line "Waiting on <you>, ask when it fits: …" when something you owe an answer on comes up in the conversation or at the week's session start. The wake changes are in the shaped wake (on for a store created since 0.3.46, or after `counterparts wake-shape on`). `remember` takes `story: true`. No store-format change (store v15, cache v7), no migration. Nothing to run after upgrading beyond the usual restart of the dashboard and every Claude Code session. Going back to 0.3.52 is a reinstall with no store restore: `counterparts disconnect`, 0.3.52's install, then `counterparts connect`.
package/docs/manual.md CHANGED
@@ -111,8 +111,8 @@ If something seems off (no wake, no night), check before guessing: `status`, and
111
111
  [hosted] Counterparts Online is this memory on a server, used from claude.ai with the `wake` tool.
112
112
 
113
113
  - It's connected in claude.ai as a custom connector, from the setup page the person was given. In a new chat, the `wake` tool starts the conversation.
114
- - Sign-in is by an emailed link. The account page has the connected AIs, the time zone (the memory's day turns over at their midnight), "Download my memory", and delete.
115
- - There are no hooks: the `wake` tool starts each chat, and nothing asks for a write-up at the end. There are no terminal commands and no dashboard.
114
+ - Sign-up is by email while the beta has spots left; when it's full, the sign-in page links counterparts.ai's waiting list, and an invite code still signs up. Sign-in is by an emailed link. The account page has the connected AIs, the time zone (the memory's day turns over at their midnight), "Download my memory", and delete.
115
+ - There are no hooks: the `wake` tool starts each chat, and nothing asks for a write-up at the end. There are no terminal commands. The account page links a read-only dashboard (Home, Memories, Self); its other pages are local only.
116
116
  - One account is one memory, with no folders: the `scope` tool pauses it or turns it off.
117
117
  - Nights run in the day's first chat, after the `wake` and before the answer (see Nights and dreams), or from the person's own routine.
118
118
  - Limits in the beta: about 120 calls a minute and 1,500 an hour; a store of up to 1 GiB. Over a limit, the tool says so; nothing is lost.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.53",
3
+ "version": "0.3.54",
4
4
  "license": "MIT",
5
5
  "description": "Long-term memory for Claude Code, written by Claude itself. Local MCP server and hooks; remembers you across sessions.",
6
6
  "repository": {
@@ -64,6 +64,14 @@ persisted into dashboard state. **[M]** Totality: every registered axis appears
64
64
  marked absent. **[A]** Views stay readable by a non-engineer — the owner is the acceptance
65
65
  test.
66
66
 
67
+ **Two hosts, one page (HD2, 2026-11-10).** The local server and the hosted server
68
+ (`hosted/src/dashboard.ts`, at `/dashboard/` for the signed-in owner) serve the same page,
69
+ files and views through `web/respond.ts`, each with a `DashboardHost`. **[M]** Looking is
70
+ the same observer stance on both. **[M]** Managing is the local host's only: the shared half
71
+ never imports `web/actions.ts`, and the page hides every managing control where
72
+ `HOST.canAct` is false (`shared/host.js`). Panels about the local machine (doctor, the store's
73
+ folder path) are the local host's too. A part a host doesn't show says so in one line.
74
+
67
75
  **Which store it serves (2026-10-12).** Two stores on one machine (a throwaway trial store
68
76
  and the person's real one) can both try port 4747, so a reader must be able to tell whose
69
77
  dashboard answered. **[M]** `GET /api/whoami` returns `{ store, version }`: `store` is the
@@ -11,6 +11,7 @@ step, no dependencies. `server.ts` serves them as files (see "Serving" below).
11
11
  | file | what it is |
12
12
  |---|---|
13
13
  | `server.ts` | `node:http` on 127.0.0.1, the Host allowlist, `router()` (GET: `/`, `/brain` (now a redirect to `/#home`), the favicon (`favicon.svg`, a file beside it since 2026-10-14), `/api/*`, the static files), and the POST hand-off to `actions.ts`. A store waiting for its one-time upgrade (v6 met by v7, `../upgrade.ts`) gets one calm page instead, and is tried again on every request |
14
+ | `respond.ts` | the half both hosts serve (HD2, 2026-11-10): `staticReply` (the page, the favicon, the static files) and `viewReply` (every `/api` view) over an observer source, for a `DashboardHost` — `LOCAL_HOST` (`/`, every view, can act) or `HOSTED_HOST` (`/dashboard/`, the views in `HOSTED_VIEWS`, read-only, no machine panels, no brain). Root-absolute links in the page and CSS are rebased to the host's base at serve time; the page learns the host from `<meta name="counterparts-host">`. Never imports `actions.ts` and has no `node:fs` (the caller hands in `Files`). The hosted door is `hosted/src/dashboard.ts` |
14
15
  | `actions.ts` | managing: `POST /api/action/<name>` — the same-origin + per-launch-token guard, argument validation, and the console's own `run()` (loaded lazily; never handed the observer source). `ACTIONS` lists them: `ask`, `note`, `remove`, `backup`, `export`, `scope`, `rebrief`, `verify`, and `doctor` (a read: the health tab's checklist, `doctor --json`) |
15
16
  | `ask-voice.ts` | `toMyVoice(question, ownerName)`: Ask is the owner talking to me, so `ask` turns his question into my voice before it searches ("do you remember what I said" → "do I remember what Mike said"; his I → "you" when the store knows no name). Pure; the rules are in its header and `test/dashboard-ask-voice.test.ts`. The server reads the name (`sleep#ownerNames`) and hands `actions.ts` the string |
16
17
  | `static.ts` | `resolveStatic()`: which URL paths are static files and where they live (pure; no fs) |
@@ -43,7 +44,11 @@ shared/
43
44
  fonts/ Outfit (variable, latin) + Courier Prime 400/700 (latin) .woff2, with their OFL licences
44
45
  base.css layout.css utilities.css reset, header/nav, headings, the .cols grids, .foot/.tone-*/#err
45
46
  tip.css modal.css the tooltip and the overlay card
46
- dom.js $ esc
47
+ dom.js $ esc, and the delegated clicks: markup says `data-do="open-memory" data-id=…`
48
+ (never an inline onclick=), a module registers `onDo(name, fn)`, one listener
49
+ (`wireClicks`, from the modal's mount) runs it — so hosted's CSP needs no inline script
50
+ host.js HOST: which host serves the page (local | hosted) and what it shows — tabs, canAct,
51
+ machine, the pulse's pace; `NOT_HERE`, the one line a hidden part says instead
47
52
  format.js n2 n3 pct said livedSpan headline
48
53
  dates.js dateWords dateOr stampWords: every date the dashboard prints itself, one style
49
54
  ("Sep 30th", the year when it is not this one; "Wed, Sep 30th" for a title).
@@ -55,7 +60,7 @@ shared/
55
60
  actions.js act() (managing: the one POST, with the page's token) and resultHtml()
56
61
  canvas.js FACE (the canvas's face, Outfit) fit hitTest roundRect clip wrapText
57
62
  tip.js modal.js showTip/hideTip; openModal/closeModal/section
58
- memory-modal.js openMemory, copyId, removeMemory (window globals: rows use inline onclick)
63
+ memory-modal.js openMemory, copyId, removeMemory (data-do handlers; window globals kept for the harness)
59
64
  memory-marks.js .css a memory's kind icon/colour, feeling dots, strength meter, badges;
60
65
  feelingName (what the page CALLS a stored core: its own name
61
66
  since the wheel v2, 2026-09-30) and feelingWord (a
@@ -11,6 +11,10 @@
11
11
  <!-- The server turns this off when the brain picture's three.js is not
12
12
  installed (server.ts#BRAIN_LIBRARY); the home tab then draws without it. -->
13
13
  <meta name="counterparts-brain" content="on">
14
+ <!-- Which host serves this page (web/respond.ts#DashboardHost): "local" here,
15
+ "hosted" on app.counterparts.ai. shared/host.js reads it, and hides what
16
+ the host can't do (act) or has no business showing (the local machine). -->
17
+ <meta name="counterparts-host" content="local">
14
18
  <!--
15
19
  The shell. Styles, scripts and the two font faces are served beside this file
16
20
  (see README.md): no CDN, no network of any kind beyond this origin.
@@ -8,13 +8,23 @@
8
8
  ─────────────────────────────────────────────────────────────────────────── */
9
9
  import { api, fail } from "./shared/api.js";
10
10
  import { $ } from "./shared/dom.js";
11
+ import { HOST } from "./shared/host.js";
11
12
  import { mountModal } from "./shared/modal.js";
12
13
  import { live, tabs } from "./shared/state.js";
13
14
  import { PAGE, PAGES, TABS } from "./shell/pages.js";
14
15
  import { poll } from "./shell/pulse.js";
15
16
  import { mountNav, showTab } from "./shell/tabs.js";
16
17
 
18
+ // On hosted, one line under the header: who sees this page, and the way back.
19
+ if (HOST.name === "hosted") {
20
+ const note = document.createElement("p");
21
+ note.className = "host-note";
22
+ note.innerHTML = 'Only you see this page: it is read from your memory each time you open it. <a href="/account">Your account</a>';
23
+ $("err").before(note);
24
+ }
25
+
17
26
  // Each page writes its own markup into its section and wires its listeners.
27
+ // A tab this host doesn't show is a one-line stub (shell/pages.js).
18
28
  for (const page of PAGES) page.mount($("tab-" + page.name));
19
29
  mountNav();
20
30
  mountModal();
@@ -35,7 +45,22 @@ addEventListener("resize", () => {
35
45
  // home tab's headline, the store's path on the health tab).
36
46
  const meta = await api("/api/meta");
37
47
  live.fingerprint = { rows: meta.rows, day: meta.day };
38
- } catch (e) { fail("The header", e); }
48
+ } catch (e) {
49
+ // On hosted a store a look can't read (never connected yet, set to be
50
+ // deleted, being restored) says why in its one sentence, and nothing else
51
+ // is drawn or polled: every panel would only say the same thing again.
52
+ if (HOST.name === "hosted") {
53
+ const p = document.createElement("p");
54
+ p.className = "not-here";
55
+ p.textContent = e && e.message ? e.message : String(e);
56
+ for (const s of document.querySelectorAll("section.tab")) s.hidden = true;
57
+ $("nav").hidden = true;
58
+ $("err").before(p);
59
+ document.documentElement.dataset.loaded = "1";
60
+ return;
61
+ }
62
+ fail("The header", e);
63
+ }
39
64
  showTab(location.hash.slice(1) || "home", false);
40
65
  // Every tab is built once, up front: a screenshot of any of them should never
41
66
  // be waiting on a fetch, and the flow diagram needs its data before it can be
@@ -46,6 +71,10 @@ addEventListener("resize", () => {
46
71
  try { await document.fonts.ready; } catch { /* no FontFaceSet: the fallback face stands */ }
47
72
  const current = PAGE[tabs.current];
48
73
  if (current.redraw) current.redraw();
49
- setInterval(poll, 4000);
74
+ // The pulse: every 4 s locally; on hosted slower, and never while the tab is
75
+ // hidden (each poll opens the person's store on the server), with one look
76
+ // as soon as it is shown again (shared/host.js).
77
+ setInterval(() => { if (HOST.pulseWhenHidden || !document.hidden) void poll(); }, HOST.pulseMs);
78
+ if (!HOST.pulseWhenHidden) addEventListener("visibilitychange", () => { if (!document.hidden) void poll(); });
50
79
  document.documentElement.dataset.loaded = "1";
51
80
  })();
@@ -2,13 +2,13 @@
2
2
  markup, touches no DOM and fetches nothing, so a picture is a function of the
3
3
  `/api/mechanism` payload alone. A memory is always clickable (the page's
4
4
  `openMemory`). */
5
+ import { openMemoryAttrs } from "../shared/dom.js";
5
6
  import { esc } from "../shared/dom.js";
6
7
 
7
8
  /** A memory's words, clickable. `width` trims long ones for a tight row. */
8
9
  export function memLink(m, width) {
9
10
  const text = width && m.text.length > width ? m.text.slice(0, width - 1).trimEnd() + "…" : m.text;
10
- return '<span class="pic-mem" role="button" tabindex="0" title="' + esc(m.text) + '" onclick="openMemory(\'' +
11
- esc(m.id) + '\')" onkeydown="if(event.key===\'Enter\')openMemory(\'' + esc(m.id) + '\')">' + esc(text) + "</span>";
11
+ return '<span class="pic-mem" role="button" tabindex="0" title="' + esc(m.text) + '" ' + openMemoryAttrs(esc(m.id)) + '>' + esc(text) + "</span>";
12
12
  }
13
13
 
14
14
  /** A thin horizontal bar, `frac` of the way, with a mark at `mark` if given. */
@@ -1,6 +1,7 @@
1
1
  /* Selected mechanism — what a node does, its brain analogy, where that analogy
2
2
  deliberately breaks, and what it has actually been doing. */
3
3
  import { api, fail } from "../../../shared/api.js";
4
+ import { onDo } from "../../../shared/dom.js";
4
5
  import { $, esc } from "../../../shared/dom.js";
5
6
  import { flow } from "../state.js";
6
7
  import { drawFlow } from "./diagram.js";
@@ -41,5 +42,6 @@ function nodeEvent(ev) {
41
42
  "<span style='color:var(--faint)'>day " + ev.day + " · </span>" + esc(ev.text) + "</p>";
42
43
  }
43
44
 
44
- // The phone list's rows select through an inline `onclick` string.
45
+ // The phone list's rows select with `data-do="select-node"` (shared/dom.js).
46
+ onDo("select-node", (el) => selectNode(el.getAttribute("data-key") || ""));
45
47
  window.selectNode = selectNode;
@@ -238,7 +238,7 @@ function renderFlowList() {
238
238
  const col = ACCENT[n.accent] || COL.cyan;
239
239
  return (i === 0 ? "" : '<div class="fchain">↓</div>') +
240
240
  '<div class="fnode' + (n.silent ? " silent" : "") + (flow.selected === n.key ? " on" : "") +
241
- '" onclick="selectNode(\'' + n.key + '\')">' +
241
+ '" data-do="select-node" data-key="' + esc(n.key) + '">' +
242
242
  '<span><span class="nm" style="color:' + col + '">' + esc(n.label) + "</span>" +
243
243
  '<span class="sb">' + esc(n.sub) + "</span></span>" +
244
244
  '<span class="st">' + esc(n.state) + "</span></div>";
@@ -3,6 +3,7 @@
3
3
  segment (or its line in the legend) to list those memories; click one to
4
4
  open its card. Nothing archived is ever deleted: an archived memory keeps
5
5
  its id and its history. */
6
+ import { openMemoryAttrs } from "../../../shared/dom.js";
6
7
  import { $, esc } from "../../../shared/dom.js";
7
8
 
8
9
  export const markup = `
@@ -47,7 +48,7 @@ function list(r) {
47
48
  const items = r.items.map((m) => {
48
49
  const notes = [timesNote(m), m.note || ""].filter((x) => x !== "").map((x) => '<span class="ha-note">' + esc(x) + "</span>").join("");
49
50
  return openable
50
- ? '<button type="button" class="ha-item" onclick="openMemory(\'' + esc(m.id) + '\')">' + esc(m.label) + notes + "</button>"
51
+ ? '<button type="button" class="ha-item" ' + openMemoryAttrs(esc(m.id)) + '>' + esc(m.label) + notes + "</button>"
51
52
  : '<div class="ha-item ha-still">' + esc(m.label) + notes + "</div>";
52
53
  }).join("");
53
54
  const listed = typeof r.listed === "number" ? r.listed : r.items.length;
@@ -7,6 +7,7 @@
7
7
  `shared/doctor.js`'s reading, the same run the Health tab draws. */
8
8
  import { $, esc } from "../../../shared/dom.js";
9
9
  import { onDoctor, verdictOf } from "../../../shared/doctor.js";
10
+ import { HOST } from "../../../shared/host.js";
10
11
 
11
12
  export const markup = `
12
13
  <section class="home-top" aria-label="This memory, today">
@@ -19,6 +20,8 @@ function dot(grade) {
19
20
  }
20
21
 
21
22
  export function mount() {
23
+ // Doctor checks this machine (hooks, worker, install): only where there is one (shared/host.js).
24
+ if (!HOST.machine) { const el = $("home-health"); if (el) el.remove(); return; }
22
25
  onDoctor((r) => {
23
26
  const el = $("home-health");
24
27
  if (!el) return;
@@ -27,6 +27,7 @@ import { act, resultHtml } from "../../../shared/actions.js";
27
27
  import { api, fail } from "../../../shared/api.js";
28
28
  import { dateOr } from "../../../shared/dates.js";
29
29
  import { $, esc } from "../../../shared/dom.js";
30
+ import { HOST } from "../../../shared/host.js";
30
31
  import { withIdMarks } from "../../../shared/memory-marks.js";
31
32
  import { memRow, searchWords } from "../row.js";
32
33
  import { find, onFilter, setFilter } from "../state.js";
@@ -58,7 +59,9 @@ export const MODES = {
58
59
 
59
60
  /** The switch and the box's placeholder, as `find.mode` says. */
60
61
  function paintMode() {
61
- $("q-mode").innerHTML = Object.entries(MODES).map(([m, x]) =>
62
+ // Facts and by meaning ask the console (`act("ask")`): only where the page can act.
63
+ if (!HOST.canAct) find.mode = "word";
64
+ $("q-mode").innerHTML = Object.entries(MODES).filter(([m]) => HOST.canAct || m === "word").map(([m, x]) =>
62
65
  '<button type="button" class="fchip' + (find.mode === m ? " on" : "") + '" data-mode="' + m + '" aria-pressed="' +
63
66
  (find.mode === m) + '">' + x.label + "</button>").join("");
64
67
  $("q").placeholder = MODES[find.mode].placeholder;
@@ -4,11 +4,14 @@
4
4
  console's own command through `shared/actions.js` and says what it said.
5
5
  (Remove lives on the memory card, where the memory is.) */
6
6
  import { act, resultHtml } from "../../../shared/actions.js";
7
+ import { openMemoryAttrs } from "../../../shared/dom.js";
7
8
  import { $, esc } from "../../../shared/dom.js";
9
+ import { HOST } from "../../../shared/host.js";
8
10
  import { MY_NAME } from "../../../shared/voice.js";
9
11
  import { changed } from "../state.js";
10
12
 
11
- export const markup = `
13
+ // Every button here manages: only where the page can act (shared/host.js).
14
+ export const markup = !HOST.canAct ? "" : `
12
15
  <div class="tools">
13
16
  <button class="mbtn primary" id="note-open" type="button" aria-expanded="false">+ Add a memory</button>
14
17
  <button class="mbtn" id="backup-open" type="button">Back up…</button>
@@ -16,7 +19,7 @@ export const markup = `
16
19
  <button class="mbtn" id="delete-open" type="button">Delete data…</button>
17
20
  </div>`;
18
21
 
19
- export const notePanel = `
22
+ export const notePanel = !HOST.canAct ? "" : `
20
23
  <div class="card pad note-panel" id="note-panel" hidden>
21
24
  <div class="np-head">Remember this, on purpose</div>
22
25
  <textarea id="note-text" rows="3" spellcheck="true" placeholder="something for ${MY_NAME} to remember"></textarea>
@@ -29,6 +32,7 @@ export const notePanel = `
29
32
  </div>`;
30
33
 
31
34
  export function mount() {
35
+ if (!HOST.canAct) return;
32
36
  const panel = $("note-panel");
33
37
  const setOpen = (open) => {
34
38
  panel.hidden = !open;
@@ -49,7 +53,7 @@ export function mount() {
49
53
  const said = (r.out || []).find((l) => /^Remembered /.test(l));
50
54
  const id = said && (said.match(/\b(mem_[A-Za-z0-9_-]+)/) || [])[1];
51
55
  $("note-out").innerHTML = '<div class="act-out act-good">' + esc(said || "Remembered.") +
52
- (id ? ' <button class="linkbtn" type="button" onclick="openMemory(\'' + esc(id) + '\')">open it</button>' : "") +
56
+ (id ? ' <button class="linkbtn" type="button" ' + openMemoryAttrs(esc(id)) + '>open it</button>' : "") +
53
57
  "</div>";
54
58
  $("note-text").value = ""; $("note-title").value = "";
55
59
  changed();
@@ -4,6 +4,7 @@
4
4
  A change the owner undid is struck through. The journal is a dream, kept
5
5
  apart from the memories: nothing here is something that happened. */
6
6
  import { absenceLine } from "../../../shared/absence.js";
7
+ import { openMemoryAttrs } from "../../../shared/dom.js";
7
8
  import { $, esc } from "../../../shared/dom.js";
8
9
  import { said } from "../../../shared/format.js";
9
10
  import { renderMarkdown } from "../markdown.js";
@@ -22,8 +23,7 @@ const STATE = { begun: "dreaming", journaled: "woke", undone: "undone" };
22
23
 
23
24
  /** One memory a change touched; an original the dream had less than whole says how it saw it. */
24
25
  export function memoryRef(m) {
25
- return '<span class="dr-mem" role="button" tabindex="0" onclick="openMemory(\'' +
26
- esc(m.id) + '\')" onkeydown="if(event.key===\'Enter\')openMemory(\'' + esc(m.id) + '\')">' + said(m.text) + "</span>" +
26
+ return '<span class="dr-mem" role="button" tabindex="0" ' + openMemoryAttrs(esc(m.id)) + '>' + said(m.text) + "</span>" +
27
27
  (m.seen ? ' <span class="dr-seen">(' + esc(m.seen) + ")</span>" : "");
28
28
  }
29
29
 
@@ -4,6 +4,7 @@
4
4
  recorded), and picking a title opens its text in place. The whole entry
5
5
  still opens as a record. */
6
6
  import { absenceLine } from "../../../shared/absence.js";
7
+ import { openMemoryAttrs } from "../../../shared/dom.js";
7
8
  import { $, esc } from "../../../shared/dom.js";
8
9
  import { renderMarkdown } from "../markdown.js";
9
10
  import { chapterKey, ui } from "../state.js";
@@ -75,7 +76,7 @@ export function paint(d) {
75
76
  "</button>" +
76
77
  (open
77
78
  ? '<div class="jc-body">' + (c.text === null ? '<p class="foot">This chapter could not be read.</p>' : renderMarkdown(c.text)) +
78
- '<button type="button" class="act-btn jc-open" onclick="openMemory(\'' + c.id + '\')">open the whole entry</button></div>'
79
+ '<button type="button" class="act-btn jc-open" ' + openMemoryAttrs(esc(c.id)) + '>open the whole entry</button></div>'
79
80
  : "") +
80
81
  "</div>";
81
82
  }).join("");
@@ -4,6 +4,7 @@
4
4
  crossed lately (became core, sent back, nominated in a dream). Closeness to
5
5
  the core is measured by physics' own promotion rule (the view computes it;
6
6
  this only draws it). The explaining words sit behind `?`. */
7
+ import { openMemoryAttrs } from "../../../shared/dom.js";
7
8
  import { $, esc } from "../../../shared/dom.js";
8
9
  import { headline, n2, said } from "../../../shared/format.js";
9
10
  import { openModal } from "../../../shared/modal.js";
@@ -85,7 +86,7 @@ function history(h) {
85
86
  if (!h) return "";
86
87
  const LANE = { fast: "strongly felt, and came back", slow: "kept coming back over weeks" };
87
88
  const row = (r, tail) =>
88
- '<button type="button" class="st-row click" onclick="openMemory(\'' + esc(r.id) + '\')">' +
89
+ '<button type="button" class="st-row click" ' + openMemoryAttrs(esc(r.id)) + '>' +
89
90
  '<span class="st-text">' + said(headline(r.text)) + "</span>" +
90
91
  '<span class="st-hist-tail">' + esc(tail) + "</span></button>";
91
92
  const out = [];
@@ -112,7 +113,7 @@ function list(s, key) {
112
113
  if (key === "reconsidering") {
113
114
  // Still core; nothing leaves without a decision — mine, or yours.
114
115
  return s.reconsidering.map((r) =>
115
- '<button type="button" class="st-row click" onclick="openMemory(\'' + esc(r.id) + '\')">' +
116
+ '<button type="button" class="st-row click" ' + openMemoryAttrs(esc(r.id)) + '>' +
116
117
  '<span class="st-text">' + said(headline(r.text)) + "</span>" +
117
118
  '<span class="st-hist-tail">' + esc("since day " + r.day + " · " + r.why) + "</span></button>").join("") +
118
119
  '<p class="foot st-note">Still in the core. Nothing leaves it without a decision: keep one with <code>counterparts core --reaffirm &lt;id&gt; --reason "…"</code>, or send it back with <code>--demote</code>. I can decide too, awake or when I reflect.</p>';
@@ -141,7 +142,7 @@ function list(s, key) {
141
142
  }
142
143
 
143
144
  function row(r) {
144
- return '<button type="button" class="st-row click" onclick="openMemory(\'' + r.id + '\')">' +
145
+ return '<button type="button" class="st-row click" ' + openMemoryAttrs(esc(r.id)) + '>' +
145
146
  '<span class="st-text">' + said(r.text) + "</span></button>";
146
147
  }
147
148
 
@@ -1,6 +1,7 @@
1
1
  /* One revision story as a card: how a belief began, what it says now, and each
2
2
  credited challenge in the order it landed. The settling section opens it in
3
3
  the overlay. */
4
+ import { openMemoryAttrs } from "../../../shared/dom.js";
4
5
  import { esc } from "../../../shared/dom.js";
5
6
  import { n3, pct } from "../../../shared/format.js";
6
7
 
@@ -19,7 +20,7 @@ export function storyCard(s) {
19
20
  "<div class='verdict'>pressure " + n3(b.pressureAfter) + " against a bar of " + n3(b.bar) +
20
21
  " — " + esc(b.verdict) + "</div>" +
21
22
  (b.became
22
- ? "<div class='verdict became'" + (b.becameId ? " onclick=\"openMemory('" + b.becameId + "')\"" : "") +
23
+ ? "<div class='verdict became'" + (b.becameId ? " " + openMemoryAttrs(esc(b.becameId)) : "") +
23
24
  ">it became: " + esc(b.became) + "</div>"
24
25
  : "") +
25
26
  "</div>" +
@@ -31,7 +32,7 @@ export function storyCard(s) {
31
32
  const said = (label, text, full, id, style) =>
32
33
  '<div class="said"><span class="k">' + label + "</span>" +
33
34
  '<span class="stmt' + (id ? " click" : "") + '" title="' + esc(full) + '"' +
34
- (id ? " onclick=\"openMemory('" + id + "')\"" : "") + (style ? ' style="' + style + '"' : "") + ">" +
35
+ (id ? " " + openMemoryAttrs(esc(id)) : "") + (style ? ' style="' + style + '"' : "") + ">" +
35
36
  esc(text) + "</span></div>";
36
37
  return '<div class="story">' +
37
38
  '<div class="about">about ' + esc(s.about) + "</div>" +
@@ -9,6 +9,7 @@
9
9
  marker, never a centred one (the faint one still shows when the memories
10
10
  behind it a week ago have all left since). Tap a row for the memories behind it; each opens
11
11
  its card. What is open is kept in `state.js`, so a live refresh keeps it. */
12
+ import { openMemoryAttrs } from "../../../shared/dom.js";
12
13
  import { $, esc } from "../../../shared/dom.js";
13
14
  import { headline, said } from "../../../shared/format.js";
14
15
  import { ui } from "../state.js";
@@ -93,7 +94,7 @@ function row(a) {
93
94
  /** The memories behind one axis, the weightiest first; each opens its card. */
94
95
  function list(a) {
95
96
  const rows = a.rows.map((r) =>
96
- '<button type="button" class="st-row click tr-item" onclick="openMemory(\'' + esc(r.id) + '\')">' +
97
+ '<button type="button" class="st-row click tr-item" ' + openMemoryAttrs(esc(r.id)) + '>' +
97
98
  '<span class="st-text">' + said(headline(r.text)) +
98
99
  '<span class="tr-why">' + esc(r.carriedBy) + "</span></span>" +
99
100
  '<span class="tr-toward k-' + (r.toward === a.poles[1] ? "r" : "l") + '">' + esc(r.toward) + "</span></button>").join("");
@@ -6,6 +6,7 @@
6
6
  built (the console's `counterparts rebrief` is unchanged). */
7
7
  import { absenceLine } from "../../../shared/absence.js";
8
8
  import { dateWords } from "../../../shared/dates.js";
9
+ import { openMemoryAttrs } from "../../../shared/dom.js";
9
10
  import { $, esc } from "../../../shared/dom.js";
10
11
  import { headline, said } from "../../../shared/format.js";
11
12
  import { ui } from "../state.js";
@@ -40,7 +41,7 @@ export function pageAge(p) {
40
41
  export function memoryItem(m) {
41
42
  const name = m.title || headline(m.text);
42
43
  if (!m.id) return '<li class="wk-line-i" title="' + esc(m.text) + '">' + esc(name) + "</li>";
43
- return '<li><button type="button" class="wk-mem" onclick="openMemory(\'' + esc(m.id) + '\')" title="' +
44
+ return '<li><button type="button" class="wk-mem" ' + openMemoryAttrs(esc(m.id)) + ' title="' +
44
45
  esc(m.text) + '">' + said(name) + "</button></li>";
45
46
  }
46
47