counterparts 0.3.1 → 0.3.2

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 (179) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/docs/module-map.md +2 -0
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/NOTES.md +32 -0
  5. package/src/adapters/claude-code/bin/hook.ts +15 -2
  6. package/src/adapters/claude-code/bin/runner.ts +3 -1
  7. package/src/adapters/claude-code/config.ts +23 -0
  8. package/src/adapters/claude-code/doctor.ts +39 -20
  9. package/src/adapters/claude-code/hooks.ts +32 -12
  10. package/src/adapters/claude-code/index.ts +1 -0
  11. package/src/adapters/cli/commands.ts +178 -59
  12. package/src/adapters/cli/export.ts +27 -3
  13. package/src/adapters/cli/help.ts +22 -8
  14. package/src/adapters/cli/install.ts +3 -5
  15. package/src/adapters/cli/mechanisms.ts +295 -0
  16. package/src/adapters/cli/repair-dates.ts +3 -1
  17. package/src/adapters/dashboard/CONTRACT.md +13 -9
  18. package/src/adapters/dashboard/NOTES.md +3 -2
  19. package/src/adapters/dashboard/activity.ts +2 -1
  20. package/src/adapters/dashboard/bin/dashboard.ts +18 -3
  21. package/src/adapters/dashboard/upgrade.ts +23 -0
  22. package/src/adapters/dashboard/web/README.md +153 -0
  23. package/src/adapters/dashboard/web/actions.ts +631 -0
  24. package/src/adapters/dashboard/web/app.html +40 -1703
  25. package/src/adapters/dashboard/web/app.js +55 -0
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
  27. package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
  29. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
  30. package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
  31. package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
  32. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
  33. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
  34. package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
  35. package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
  36. package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
  37. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
  38. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
  39. package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
  40. package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
  41. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
  42. package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
  43. package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
  44. package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
  45. package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
  46. package/src/adapters/dashboard/web/narrate.ts +10 -10
  47. package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
  48. package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
  49. package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
  50. package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
  51. package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
  52. package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
  53. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
  54. package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
  55. package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
  56. package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
  57. package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
  58. package/src/adapters/dashboard/web/pages/health/health.css +93 -0
  59. package/src/adapters/dashboard/web/pages/health/index.js +41 -0
  60. package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
  61. package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
  62. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
  63. package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
  64. package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
  65. package/src/adapters/dashboard/web/pages/home/home.css +134 -0
  66. package/src/adapters/dashboard/web/pages/home/index.js +84 -0
  67. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
  68. package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
  69. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
  70. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
  71. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
  72. package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
  73. package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
  74. package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
  75. package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
  76. package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
  77. package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
  78. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
  79. package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
  80. package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
  81. package/src/adapters/dashboard/web/pages/self/index.js +43 -0
  82. package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
  83. package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
  84. package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
  85. package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
  86. package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
  87. package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
  88. package/src/adapters/dashboard/web/pages/self/self.css +182 -0
  89. package/src/adapters/dashboard/web/server.ts +305 -28
  90. package/src/adapters/dashboard/web/shared/absence.js +14 -0
  91. package/src/adapters/dashboard/web/shared/actions.js +48 -0
  92. package/src/adapters/dashboard/web/shared/api.js +17 -0
  93. package/src/adapters/dashboard/web/shared/base.css +34 -0
  94. package/src/adapters/dashboard/web/shared/canvas.js +68 -0
  95. package/src/adapters/dashboard/web/shared/colors.js +6 -0
  96. package/src/adapters/dashboard/web/shared/dom.js +4 -0
  97. package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
  98. package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
  99. package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
  100. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
  101. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
  102. package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
  103. package/src/adapters/dashboard/web/shared/format.js +31 -0
  104. package/src/adapters/dashboard/web/shared/layout.css +32 -0
  105. package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
  106. package/src/adapters/dashboard/web/shared/modal.css +24 -0
  107. package/src/adapters/dashboard/web/shared/modal.js +22 -0
  108. package/src/adapters/dashboard/web/shared/state.js +12 -0
  109. package/src/adapters/dashboard/web/shared/tip.css +4 -0
  110. package/src/adapters/dashboard/web/shared/tip.js +12 -0
  111. package/src/adapters/dashboard/web/shared/tokens.css +50 -0
  112. package/src/adapters/dashboard/web/shared/type.css +52 -0
  113. package/src/adapters/dashboard/web/shared/utilities.css +5 -0
  114. package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
  115. package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
  116. package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
  117. package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
  118. package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
  119. package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
  120. package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
  121. package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
  122. package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
  123. package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
  124. package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
  125. package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
  126. package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
  127. package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
  128. package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
  129. package/src/adapters/dashboard/web/shell/pages.js +15 -0
  130. package/src/adapters/dashboard/web/shell/pulse.js +86 -0
  131. package/src/adapters/dashboard/web/shell/tabs.js +49 -0
  132. package/src/adapters/dashboard/web/static.ts +76 -0
  133. package/src/adapters/dashboard/web/views/activity.ts +80 -0
  134. package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
  135. package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
  136. package/src/adapters/dashboard/web/views/health.ts +328 -0
  137. package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
  138. package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
  139. package/src/adapters/dashboard/web/views/memories.ts +342 -0
  140. package/src/adapters/dashboard/web/views/memory.ts +210 -0
  141. package/src/adapters/dashboard/web/views/meta.ts +64 -0
  142. package/src/adapters/dashboard/web/views/mind.ts +729 -0
  143. package/src/adapters/dashboard/web/views/overview.ts +282 -0
  144. package/src/adapters/dashboard/web/views/pulse.ts +19 -0
  145. package/src/adapters/dashboard/web/views/rows.ts +207 -0
  146. package/src/adapters/dashboard/web/views/search.ts +62 -0
  147. package/src/adapters/dashboard/web/views/shared.ts +161 -0
  148. package/src/adapters/dashboard/web/views.ts +34 -1724
  149. package/src/adapters/fired.ts +28 -17
  150. package/src/adapters/mcp/NOTES.md +43 -0
  151. package/src/adapters/mcp/bin/serve.ts +5 -1
  152. package/src/adapters/mcp/index.ts +3 -0
  153. package/src/adapters/mcp/server.ts +163 -6
  154. package/src/adapters/mcp/tools.ts +42 -0
  155. package/src/adapters/mcp/write-up.ts +1 -1
  156. package/src/core/counterpart.ts +30 -1
  157. package/src/core/feelings-wheel.ts +218 -0
  158. package/src/core/mint.ts +14 -2
  159. package/src/core/prospective/INTERFACE-GAPS.md +10 -0
  160. package/src/core/prospective/windows.ts +10 -48
  161. package/src/core/self/NOTES.md +17 -0
  162. package/src/core/self/calendar.ts +7 -78
  163. package/src/core/self/episodes.ts +7 -8
  164. package/src/core/self/index.ts +32 -11
  165. package/src/core/self/writer.ts +22 -22
  166. package/src/core/sleep/cycle.ts +8 -2
  167. package/src/core/store/CONTRACT.md +26 -7
  168. package/src/core/store/NOTES.md +142 -0
  169. package/src/core/store/errors.ts +15 -0
  170. package/src/core/store/feelings.ts +182 -0
  171. package/src/core/store/index.ts +297 -45
  172. package/src/core/store/operational.ts +133 -11
  173. package/src/core/store/owner-op-seam.ts +13 -3
  174. package/src/core/store/pre-migration.ts +3 -1
  175. package/src/core/store/prose.ts +8 -1
  176. package/src/core/store/render.ts +3 -0
  177. package/src/core/time.ts +374 -0
  178. package/src/core/types.ts +13 -0
  179. package/src/adapters/dashboard/web/brain.html +0 -463
@@ -255,8 +255,12 @@ function collectMarkdown(store: Store, opts: ExportOptions): { bundle: Bundle; c
255
255
  counts.notRendered.push(id);
256
256
  continue;
257
257
  }
258
- const text = render(id, doc);
259
- if (text === null) continue;
258
+ const rendered = render(id, doc);
259
+ if (rendered === null) continue;
260
+ // THE MEMORY'S FEELINGS TRAVEL WITH IT (schema v7, review N7): a short
261
+ // section after the body, one line each, so the readable copy says what the
262
+ // database does. The database export carries the table whole.
263
+ const text = rendered + feelingsSection(store, id);
260
264
  put(pathFor(store, row, doc), text);
261
265
  counts.rows += 1;
262
266
  if (row.type === "episode") counts.journal += 1;
@@ -293,6 +297,25 @@ function collectMarkdown(store: Store, opts: ExportOptions): { bundle: Bundle; c
293
297
  }
294
298
 
295
299
  /** Where one row's markdown goes in the tree. Ids only; never a title. */
300
+ /** `\n## Feelings\n\n- owner · fear · worried · 0.6 — carried by …`, or "" when none. */
301
+ function feelingsSection(store: Store, id: string): string {
302
+ let rows;
303
+ try {
304
+ rows = store.feelingsFor(id);
305
+ } catch {
306
+ return "";
307
+ }
308
+ if (rows.length === 0) return "";
309
+ const index = new Map(rows.map((r, i) => [r.id, i + 1]));
310
+ const lines = rows.map((r, i) => {
311
+ const word = r.emotion === "other" ? `other: ${r.other_word ?? ""}` : r.emotion;
312
+ const under = r.beneath_id === null ? "" : ` · over #${String(index.get(r.beneath_id) ?? "?")}`;
313
+ const by = r.carried_by.length === 0 ? "" : ` — carried by: ${r.carried_by.replace(/\r?\n/g, " ")}`;
314
+ return `${String(i + 1)}. ${r.whose} · ${r.core} · ${word} · ${String(r.strength)}${under}${by}`;
315
+ });
316
+ return `\n\n## Feelings\n\n${lines.join("\n")}\n`;
317
+ }
318
+
296
319
  function pathFor(store: Store, row: MemoryRow, doc: ProseDoc): string {
297
320
  if (row.type === "episode") return journalRelativePath(doc);
298
321
  if (row.type === "schema") {
@@ -710,7 +733,8 @@ function markdownReadme(census: MarkdownCensus, opts: ExportOptions): string {
710
733
  "## What is here",
711
734
  "",
712
735
  "- `memories/<kind>/<id>.md` — one file per memory, grouped by kind. The file name is",
713
- " the memory's id; the title, dates and everything else are in the frontmatter.",
736
+ " the memory's id; the title, dates and everything else are in the frontmatter, and",
737
+ " any feelings recorded on it are a `## Feelings` list after the words.",
714
738
  census.archived === 0
715
739
  ? " None of them is archived: every memory here is a live one."
716
740
  : ` ${String(census.archived)} of them ${census.archived === 1 ? "is" : "are"} ARCHIVED — faded, superseded or merged.` +
@@ -129,7 +129,7 @@ export const SHORT: Record<string, string | readonly string[]> = {
129
129
  // build's. Finding #18 is exactly this list read by somebody who had just
130
130
  // installed the package.
131
131
  note: "Remember something on purpose, right now",
132
- fired: "Which parts of memory have actually run, and which never have",
132
+ mechanisms: "Which parts of memory are working, one line each",
133
133
  init: "Make a second, separate memory store — a scratch one",
134
134
  "start-fresh": "Set this memory aside and start blank; --undo brings it back",
135
135
  verify: "Count the search index against what is actually stored",
@@ -139,9 +139,10 @@ export const SHORT: Record<string, string | readonly string[]> = {
139
139
  "repair-dates": "One-off repair: give imported memories their real dates",
140
140
  "repair-merged-beliefs": "One-off repair: put back beliefs a cleanup pass filed away",
141
141
  "probe-oq4": "A measurement: which footnotes were opened again later",
142
- // ── the three that are on no page, and `UNLISTED` says why ──
142
+ // ── the ones that are on no page, and `UNLISTED` says why ──
143
143
  help: "What it does, and every flag it takes",
144
144
  recall: "Ask memory a question",
145
+ fired: "Which parts of memory are working, one line each",
145
146
  version: "The version of Counterparts you have",
146
147
  };
147
148
 
@@ -174,7 +175,7 @@ export const GROUPS: readonly HelpGroup[] = [
174
175
  */
175
176
  export const ADVANCED: readonly string[] = [
176
177
  "note",
177
- "fired",
178
+ "mechanisms",
178
179
  "init",
179
180
  "start-fresh",
180
181
  "verify",
@@ -202,6 +203,9 @@ export const UNLISTED: Record<string, string> = {
202
203
  // the right one for what the machinery does. `ask` is the word a PERSON
203
204
  // reaches for, so that is the one on the map; both dispatch, forever.
204
205
  recall: "the unlisted spelling of `ask` — it still dispatches, and always will",
206
+ // Renamed 2026-09-25: the owner found the old name's page a wall of text, and
207
+ // `mechanisms` is the word the site uses. Scripts that say `fired` keep working.
208
+ fired: "the older name of `mechanisms` — it still dispatches, the same command",
205
209
  // `counterparts --version` is what a person types; `counterparts version` is
206
210
  // the same answer for anybody who types the verb. Neither belongs on a map of
207
211
  // things to do with a memory.
@@ -342,10 +346,18 @@ export const COMMAND_DETAIL: Record<string, readonly string[]> = {
342
346
  "recall CONTRACT §7. The footnote header is the one string the probe varies",
343
347
  "(recall/render.ts).",
344
348
  ],
349
+ mechanisms: [
350
+ "One line per memory mechanism: ● working this week, ◐ built but not firing,",
351
+ "○ not built yet, each with the count behind it; then the plumbing in one",
352
+ "line, naming only what is failing. `counterparts fired` is its older name.",
353
+ "",
354
+ "--all prints the full report, SILENT FIRST: when each part last fired, how",
355
+ "many times in the last 7 days, what it turned away, and — for the ones",
356
+ "nothing durable records — which row would fix that.",
357
+ ],
345
358
  fired: [
346
- "One line each, SILENT FIRST: when it last fired, how many times in the last",
347
- "7 days, what it turned away, and — for the ones nothing durable records —",
348
- "which row would fix that.",
359
+ "`counterparts mechanisms` is the same command, and it is the listed",
360
+ "spelling; this one stays so scripts that call it keep working.",
349
361
  ],
350
362
  "self-page": [
351
363
  "With no flags it prints the page, its size, its version and the date it was",
@@ -371,8 +383,10 @@ export const COMMAND_DETAIL: Record<string, readonly string[]> = {
371
383
  dashboard: [
372
384
  "It reads the store your CONFIGURATION names — the one the hooks and the",
373
385
  "memory tools open — so it needs no --dir. The page is served on 127.0.0.1",
374
- "and nowhere else, in observer mode: it strengthens nothing, deposits",
375
- "nothing, and writes no file of its own.",
386
+ "and nowhere else. Looking is observer mode: it strengthens nothing and",
387
+ "deposits nothing. What you do there on purpose — a note, a removal, a",
388
+ "backup, an export, a scope, a rebrief, a verify, an ask — runs through",
389
+ "these same commands, and a removal asks you to type the id back.",
376
390
  ],
377
391
  help: [
378
392
  "With no command it prints the short map — the same page `counterparts",
@@ -43,6 +43,7 @@ import {
43
43
  statSync,
44
44
  writeFileSync,
45
45
  } from "node:fs";
46
+ import { isDay } from "../../core/time.js";
46
47
  import { homedir, tmpdir } from "node:os";
47
48
  import { basename, dirname, join, resolve } from "node:path";
48
49
  import { fileURLToPath } from "node:url";
@@ -769,11 +770,8 @@ export function parkedNameParts(
769
770
  const m = new RegExp(`^${escaped}\\.parked-(\\d{4}-\\d{2}-\\d{2})(?:-(\\d+))?$`).exec(name);
770
771
  if (m === null) return null;
771
772
  const date = m[1] ?? "";
772
- // `Date.parse` of a bare ISO date is UTC midnight, and `toISOString` gives
773
- // the same ten characters back — for a real day, and not for 2099-13-45,
774
- // which either fails to parse or comes back as some other day.
775
- const parsed = new Date(`${date}T00:00:00.000Z`);
776
- if (Number.isNaN(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== date) return null;
773
+ // A real day, and not 2099-13-45 (`time.ts#isDay`).
774
+ if (!isDay(date)) return null;
777
775
  if (m[2] === undefined) return { date, ordinal: 1 };
778
776
  const ordinal = Number(m[2]);
779
777
  if (!Number.isInteger(ordinal) || ordinal < 2) return null;
@@ -0,0 +1,295 @@
1
+ /**
2
+ * `mechanisms` — the short answer to "is my memory working?", one line per
3
+ * memory mechanism the site names.
4
+ *
5
+ * **Why it exists** (2026-09-25). The owner ran `counterparts fired` and got 57
6
+ * rows mixing the eleven mechanisms with plumbing, sorted by state, in code
7
+ * words — and rows like "NEVER: a copy of the store could not be made" read as
8
+ * alarms when they are good news. This view is the page a regular user reads;
9
+ * `--all` still prints the full `fired` report, unchanged, for the diagnosis.
10
+ *
11
+ * **It reads nothing of its own.** Every count comes off the rows `fired.ts`
12
+ * already computed. The table below only says which of those rows are the
13
+ * evidence for which mechanism, and how to say the count in plain words.
14
+ *
15
+ * **Deliberately light.** The grouping and the words are this console's own,
16
+ * for now. The site and the dashboard have their own lists and are all still
17
+ * moving, so nothing here is shared with them or tested against them — the
18
+ * only coupling is to `MECHANISMS`, whose ids this table names.
19
+ *
20
+ * The truth per mechanism is `docs/research/mechanism-audit-2026-09-24.md`.
21
+ */
22
+ import type { FiredReport, FiredRow } from "../fired.js";
23
+
24
+ /** The three lights. */
25
+ export const LIGHT = {
26
+ working: "●",
27
+ idle: "◐",
28
+ notBuilt: "○",
29
+ } as const;
30
+ export type Light = (typeof LIGHT)[keyof typeof LIGHT];
31
+
32
+ export type Group = "Encoding" | "Storage" | "Retrieval" | "Transformation";
33
+
34
+ /** The evidence rows, by `MECHANISMS` id, as the view reads them. */
35
+ type Rows = (id: string) => FiredRow | undefined;
36
+
37
+ export interface MemoryMechanism {
38
+ readonly name: string;
39
+ readonly group: Group;
40
+ /** `MECHANISMS` ids that are this mechanism's evidence. */
41
+ readonly evidence: readonly string[];
42
+ /** The light and one plain line, from the evidence rows. */
43
+ readonly read: (rows: Rows) => { light: Light; says: string };
44
+ }
45
+
46
+ /** Rows landed in the window, summed over the named ids. */
47
+ function week(rows: Rows, ...ids: string[]): number {
48
+ let n = 0;
49
+ for (const id of ids) n += rows(id)?.firedInWindow ?? 0;
50
+ return n;
51
+ }
52
+
53
+ function plural(n: number, one: string, many = `${one}s`): string {
54
+ return `${String(n)} ${n === 1 ? one : many}`;
55
+ }
56
+
57
+ const NOT_BUILT = (why: string) => (): { light: Light; says: string } => ({
58
+ light: LIGHT.notBuilt,
59
+ says: `not built yet: ${why}`,
60
+ });
61
+
62
+ /**
63
+ * THE ELEVEN, in the site's four groups and its order. `evidence` lists every
64
+ * id a `read` looks at, so the test can check each one still exists.
65
+ */
66
+ export const MEMORY_MECHANISMS: readonly MemoryMechanism[] = [
67
+ // ── Encoding ──
68
+ {
69
+ name: "Salience",
70
+ group: "Encoding",
71
+ evidence: ["deposit", "chunk-gate"],
72
+ read: (rows) => {
73
+ const n = week(rows, "deposit", "chunk-gate");
74
+ return n > 0
75
+ ? { light: LIGHT.working, says: `${plural(n, "memory", "memories")} written and scored` }
76
+ : { light: LIGHT.idle, says: "built, not firing yet: no memories written this week" };
77
+ },
78
+ },
79
+ {
80
+ name: "Emotion",
81
+ group: "Encoding",
82
+ evidence: ["emotion"],
83
+ // The audit's verdict: a feeling is recorded as a label and carries no
84
+ // weight, and the classifier ships off. Idle whatever the counts say.
85
+ read: (rows) => ({
86
+ light: LIGHT.idle,
87
+ says:
88
+ rows("emotion")?.state === "disabled"
89
+ ? "built, held back: the feeling classifier is off, so feelings carry no weight yet"
90
+ : "built, not firing yet: feelings are recorded but carry no weight yet",
91
+ }),
92
+ },
93
+ // ── Storage ──
94
+ {
95
+ name: "Forgetting",
96
+ group: "Storage",
97
+ evidence: ["decay", "prune", "fade", "sleep-cycle"],
98
+ read: (rows) => {
99
+ // `memory.pruned` and `band.transition` are one row per memory; the fade
100
+ // is one row per night that faded a card.
101
+ const letGo = week(rows, "prune");
102
+ const dropped = week(rows, "decay");
103
+ const faded = week(rows, "fade");
104
+ const cycles = week(rows, "sleep-cycle");
105
+ const parts: string[] = [];
106
+ if (letGo > 0) parts.push(`${plural(letGo, "memory", "memories")} let go at the floor`);
107
+ if (dropped > 0) parts.push(`${plural(dropped, "memory", "memories")} faded a band`);
108
+ if (faded > 0) parts.push("unused names faded");
109
+ if (parts.length > 0) {
110
+ if (letGo === 0) parts.push("nothing at the floor yet");
111
+ return { light: LIGHT.working, says: parts.join("; ") };
112
+ }
113
+ if (cycles > 0) {
114
+ return {
115
+ light: LIGHT.working,
116
+ says: `decay ran in ${plural(cycles, "sleep cycle")}; nothing at the floor yet`,
117
+ };
118
+ }
119
+ return { light: LIGHT.idle, says: "built, not firing yet: no sleep cycle ran this week" };
120
+ },
121
+ },
122
+ {
123
+ name: "Interference",
124
+ group: "Storage",
125
+ evidence: [],
126
+ read: NOT_BUILT("only exact duplicates are merged"),
127
+ },
128
+ // ── Retrieval ──
129
+ {
130
+ name: "Retrieval",
131
+ group: "Retrieval",
132
+ evidence: ["recall-decision", "credit"],
133
+ read: (rows) => {
134
+ const turns = week(rows, "recall-decision");
135
+ // `recall.credit` is one row per session end, not per memory — so it is
136
+ // said as a fact, never as a count of memories.
137
+ const credited = week(rows, "credit") > 0;
138
+ if (turns === 0) {
139
+ return { light: LIGHT.idle, says: "built, not firing yet: no turns checked this week" };
140
+ }
141
+ return {
142
+ light: LIGHT.working,
143
+ says: credited
144
+ ? `${plural(turns, "turn")} checked; memories used were strengthened`
145
+ : `${plural(turns, "turn")} checked; nothing used yet, so nothing strengthened`,
146
+ };
147
+ },
148
+ },
149
+ {
150
+ name: "Association",
151
+ group: "Retrieval",
152
+ evidence: ["association-saved", "association"],
153
+ read: (rows) => {
154
+ const saved = week(rows, "association-saved");
155
+ const held = rows("association")?.total ?? 0;
156
+ if (saved > 0) {
157
+ return {
158
+ light: LIGHT.working,
159
+ says: `links saved after ${plural(saved, "session")}; ${plural(held, "link")} held`,
160
+ };
161
+ }
162
+ return {
163
+ light: LIGHT.idle,
164
+ says:
165
+ held > 0
166
+ ? `built, not firing yet: no new links this week (${plural(held, "link")} held)`
167
+ : "built, not firing yet: no links formed",
168
+ };
169
+ },
170
+ },
171
+ {
172
+ name: "Prospective",
173
+ group: "Retrieval",
174
+ evidence: ["prospective-armed", "prospective-fired"],
175
+ // Nothing in live use can put a date on a memory yet (audit: DRAFT_FIELDS),
176
+ // and nothing spends a fire. A store that holds dated intentions anyway has
177
+ // the half that is built; one that holds none has nothing of it.
178
+ read: (rows) => {
179
+ const armed = rows("prospective-armed")?.total ?? 0;
180
+ return armed > 0
181
+ ? {
182
+ light: LIGHT.idle,
183
+ says: `built, not firing yet: ${plural(armed, "dated reminder")} held, and nothing brings one back yet`,
184
+ }
185
+ : { light: LIGHT.notBuilt, says: "not built yet: nothing can put a date on a memory" };
186
+ },
187
+ },
188
+ // ── Transformation ──
189
+ {
190
+ name: "Consolidation",
191
+ group: "Transformation",
192
+ evidence: ["sleep-cycle", "promotion", "dedup"],
193
+ read: (rows) => {
194
+ const cycles = week(rows, "sleep-cycle");
195
+ if (cycles === 0) {
196
+ return { light: LIGHT.idle, says: "built, not firing yet: no sleep cycle ran this week" };
197
+ }
198
+ const promoted = week(rows, "promotion");
199
+ const merged = week(rows, "dedup");
200
+ const extra: string[] = [];
201
+ if (promoted > 0) extra.push(`${plural(promoted, "memory", "memories")} became core`);
202
+ if (merged > 0) extra.push(`${plural(merged, "duplicate")} merged`);
203
+ return {
204
+ light: LIGHT.working,
205
+ says: `${plural(cycles, "sleep cycle")} ran${extra.length > 0 ? `; ${extra.join(", ")}` : ""}`,
206
+ };
207
+ },
208
+ },
209
+ {
210
+ name: "Reconsolidation",
211
+ group: "Transformation",
212
+ evidence: ["revision", "accommodation"],
213
+ read: (rows) => {
214
+ const pressed = week(rows, "revision");
215
+ const replaced = week(rows, "accommodation");
216
+ if (pressed + replaced > 0) {
217
+ const parts: string[] = [];
218
+ if (replaced > 0) parts.push(`${plural(replaced, "memory", "memories")} corrected, old version kept`);
219
+ if (pressed > 0) parts.push(`${plural(pressed, "belief")} challenged`);
220
+ return { light: LIGHT.working, says: parts.join("; ") };
221
+ }
222
+ return { light: LIGHT.idle, says: "built, not firing yet: nothing corrected this week" };
223
+ },
224
+ },
225
+ {
226
+ name: "Schemas",
227
+ group: "Transformation",
228
+ // Entity cards are built; beliefs about them have no live producer.
229
+ evidence: ["entity-birth"],
230
+ read: NOT_BUILT("nothing forms beliefs about people and projects yet"),
231
+ },
232
+ {
233
+ name: "Gist",
234
+ group: "Transformation",
235
+ evidence: ["gist"],
236
+ read: NOT_BUILT("many episodes are not yet distilled into one lasting memory"),
237
+ },
238
+ ];
239
+
240
+ /**
241
+ * THE PLUMBING ROWS WHOSE FIRING MEANS SOMETHING FAILED, with the words to say
242
+ * it in. Every other plumbing row — a failure that never happened, an owner
243
+ * action never taken, a part blind by design — is not a problem, and the one
244
+ * line never makes it read like one.
245
+ */
246
+ const TROUBLE: Readonly<Record<string, string>> = {
247
+ "worker-trouble": "the background worker failed or was refused",
248
+ "snapshot-trouble": "a copy of the store could not be made",
249
+ };
250
+
251
+ /** Every `MECHANISMS` id the eleven account for; the rest are plumbing. */
252
+ export function mechanismIds(): Set<string> {
253
+ return new Set(MEMORY_MECHANISMS.flatMap((m) => m.evidence));
254
+ }
255
+
256
+ /** The plumbing line: how many parts ran this week, and only what failed. */
257
+ export function plumbingLine(report: FiredReport): string {
258
+ const mine = mechanismIds();
259
+ const plumbing = report.rows.filter((r) => !mine.has(r.id));
260
+ const running = plumbing.filter((r) => r.state === "firing" && TROUBLE[r.id] === undefined).length;
261
+ const failing: string[] = [];
262
+ for (const r of plumbing) {
263
+ const words = TROUBLE[r.id];
264
+ // No count: some of these rows are latched one per reason per day, so a
265
+ // number here would read as attempts and understate them.
266
+ if (words !== undefined && r.firedInWindow > 0) failing.push(words);
267
+ }
268
+ const head = `Plumbing: ${plural(running, "part")} running`;
269
+ return failing.length === 0
270
+ ? `${head}, none failing.`
271
+ : `${head}; failing this week: ${failing.join("; ")}.`;
272
+ }
273
+
274
+ /** The whole short view, as plain lines: one per mechanism in the site's four
275
+ * groups and order, then the plumbing in one line. */
276
+ export function mechanismsLines(report: FiredReport): string[] {
277
+ const byId = new Map(report.rows.map((r) => [r.id, r]));
278
+ const rows: Rows = (id) => byId.get(id);
279
+ const width = Math.max(...MEMORY_MECHANISMS.map((m) => m.name.length)) + 2;
280
+ const lines = [`Memory mechanisms — last 7 days (${report.from} to ${report.today}, UTC)`, ""];
281
+ if (report.young) {
282
+ lines.push("This memory is new, so most of these have had nothing to do yet.", "");
283
+ }
284
+ for (const m of MEMORY_MECHANISMS) {
285
+ const { light, says } = m.read(rows);
286
+ lines.push(`${light} ${m.name.padEnd(width)}${says}`);
287
+ }
288
+ lines.push(
289
+ "",
290
+ `${LIGHT.working} working this week ${LIGHT.idle} built, not firing ${LIGHT.notBuilt} not built yet`,
291
+ plumbingLine(report),
292
+ "Every detail: counterparts mechanisms --all",
293
+ );
294
+ return lines;
295
+ }
@@ -60,6 +60,7 @@
60
60
  * keeps its history. The owner runs `--apply`; nothing here runs it for him.
61
61
  */
62
62
  import { Store, storeExists } from "../../core/store/index.js";
63
+ import { utcDate } from "../../core/time.js";
63
64
 
64
65
  /** No memory in either lineage predates this. A parse below it is a coincidence. */
65
66
  export const PLAUSIBLE_FLOOR = "2015-01-01";
@@ -132,8 +133,9 @@ const ISO_MONTH = /(?<!\d)(\d{4})-(\d{2})(?![\d-])/;
132
133
 
133
134
  const TIER_ORDER: Record<Confidence, number> = { low: 0, medium: 1, high: 2 };
134
135
 
136
+ /** UTC on purpose: this repairs PRE-v7 rows, whose `learned_on` was UTC. */
135
137
  function dateOfMs(ms: number): string {
136
- return new Date(ms).toISOString().slice(0, 10);
138
+ return utcDate(ms);
137
139
  }
138
140
 
139
141
  /** A real calendar day inside the window the store could plausibly have lived. */
@@ -3,8 +3,9 @@
3
3
  ## 1. Purpose
4
4
 
5
5
  The owner's window: what was remembered, what faded, what changed and why — visually, at a
6
- glance. The direct instrument of constitution line 16, and the owner's tool for judging
7
- Counterparts against v1 during the parallel run.
6
+ glance. The direct instrument of constitution line 16. Since 2026-09-25 it is also meant to
7
+ be the owner's main command center: most people will use the terminal once, to install,
8
+ and manage their memory here by clicking (the owner's own preference too).
8
9
 
9
10
  ## 2. Brain analog
10
11
 
@@ -42,13 +43,16 @@ Legibility is the product's answer to the trust question a brain never has to fa
42
43
  ## 5. Contract
43
44
 
44
45
  **Inputs** — the canonical stores (read-only), the event log, the registry of kinds/bands,
45
- the written self page and its versions (2026-09-18; shown as a list with bodies, newest
46
- first — there is no precedent here for a text diff between two revisions, and a page is
47
- prose a person reads rather than a field that changed).
48
- **Outputs** — rendered views only. **Guarantees:** **[M]** the dashboard runs in observer
49
- mode by construction (`docs/observer-mode.md`): it strengthens nothing, deposits nothing,
50
- resolves no references, and a test asserts its process holds no write handle to any
51
- canonical store. **[M]** Render-time id resolution everywhere; no memory body text is
46
+ the written self page and its versions (2026-09-18; since 2026-09-25 shown as a timeline,
47
+ each version with what changed from the one before it).
48
+ **Outputs** — rendered views, and the owner's management actions. **Guarantees:** **[M]**
49
+ LOOKING is observer mode by construction (`docs/observer-mode.md`): every view strengthens
50
+ nothing, deposits nothing, resolves no references, and a test asserts the adapter's own
51
+ code holds no write handle to any canonical store. **[A]** MANAGING is the owner's own act
52
+ and is not artificially limited: an action the CLI offers (note, remove, backup, export,
53
+ scope, rebrief, …) may be offered here, run through the CLI's own door — the same code and
54
+ the same checks — never through the observer source; a destructive one asks the owner to
55
+ confirm. For now `install`, `uninstall` and `start-fresh` stay terminal-only. A known limit, not solved here: the page and its action token are served to anything that can reach the loopback port, so on a machine shared with other OS users another local user could manage this memory, not only read it. **[M]** Render-time id resolution everywhere; no memory body text is
52
56
  persisted into dashboard state. **[M]** Totality: every registered axis appears or is
53
57
  marked absent. **[A]** Views stay readable by a non-engineer — the owner is the acceptance
54
58
  test.
@@ -76,8 +76,9 @@ write now fails `tsc` until someone has decided which part of the machine it
76
76
  belongs to.
77
77
 
78
78
  **One exception was opened, narrowly.** `web/server.ts` is the only file in this
79
- directory that may import `node:fs` — `readFileSync`, for two static HTML pages
80
- that ship beside it — and `node:http`. The directory-wide ban mechanizes "there
79
+ directory that may import `node:fs` — `readFileSync`, for the static files
80
+ that ship beside it (two HTML pages, and since the 2026-09-25 module split the
81
+ page's own `.js`/`.css` under `web/`, via `web/static.ts`) — and `node:http`. The directory-wide ban mechanizes "there
81
82
  is no dashboard state file because nothing here can open one"; a read-only
82
83
  import keeps that exactly, and the test pins the binding by name so it cannot
83
84
  widen into a write. It also joins the enumerated network-verb list in
@@ -17,6 +17,7 @@
17
17
  * keeping only the ones latched by a `dedupKey`. A feed that showed six rows
18
18
  * without saying that would be quietly claiming six things ever happened.
19
19
  */
20
+ import { localClock } from "../../core/time.js";
20
21
  import { PLAIN } from "./ansi.js";
21
22
  import type { Style } from "./ansi.js";
22
23
  import { NEVER, NONE, heading, indent, plural, stack, subheading, table, truncate } from "./layout.js";
@@ -64,7 +65,7 @@ export function renderActivity(src: DashboardSource, opts: ActivityOptions = {})
64
65
 
65
66
  const rows: string[][] = [];
66
67
  for (const row of shown) {
67
- const when = new Date(row.at).toISOString().replace("T", " ").slice(0, 19);
68
+ const when = localClock(row.at, store.zone());
68
69
  const subject = row.ref === null ? style.dim("—") : resolveRef(store, row.ref, 44).label;
69
70
  rows.push([`day ${row.day}`, style.dim(when), row.name, subject]);
70
71
  const detail = payloadLine(src, row.payload, style);
@@ -21,6 +21,7 @@ import { Dashboard, VIEWS, VIEW_BLURB, isViewName } from "../index.js";
21
21
  import type { ViewArgs, ViewName } from "../index.js";
22
22
  import { terminalWantsColour } from "../ansi.js";
23
23
  import { DATA_DIR_ENV, dataDir, describeGuardRefusal, isStoreError } from "../../../core/store/index.js";
24
+ import { UPGRADE_PENDING_SENTENCE, upgradePending } from "../upgrade.js";
24
25
  import type { StoreError } from "../../../core/store/index.js";
25
26
  import type { Band, Kind } from "../../../core/types.js";
26
27
 
@@ -124,6 +125,8 @@ export function helpText(): string {
124
125
  "The web view:",
125
126
  " serve --dir <path> [--port <n>] the local dashboard, on 127.0.0.1 only",
126
127
  ` (default port ${SERVE_DEFAULT_PORT}, or ${SERVE_PORT_ENV})`,
128
+ " serve ... --config <path> the configuration the page's scope and rebrief",
129
+ " actions name (absent: the page offers no scope)",
127
130
  " serve --default-store open the DEFAULT store instead. Without --dir",
128
131
  " or --default-store, 'serve' refuses: on a machine",
129
132
  " with an install the default is the owner's live",
@@ -131,7 +134,8 @@ export function helpText(): string {
131
134
  "",
132
135
  "A flag a subcommand does not take is refused before anything is opened.",
133
136
  "",
134
- "It reads in observer mode and writes nothing, ever.",
137
+ "Looking reads in observer mode and writes nothing. The web view's management",
138
+ "actions (note, remove, backup, …) run through the console's own commands.",
135
139
  ];
136
140
  return lines.join("\n");
137
141
  }
@@ -151,6 +155,9 @@ export interface ServeArgs {
151
155
  * `serve` has no confirmation to skip. The flag that puts a whole store on a
152
156
  * socket says which store. */
153
157
  readonly defaultStore: boolean;
158
+ /** `--config <path>`: the host configuration the page's `scope` and
159
+ * `rebrief` actions name. Absent, the page offers no `scope`. */
160
+ readonly config: string | undefined;
154
161
  }
155
162
 
156
163
  /**
@@ -172,7 +179,7 @@ export interface ServeArgs {
172
179
  const VIEW_FLAGS: readonly string[] = [
173
180
  "dir", "id", "limit", "band", "kind", "name", "archived", "width", "colour", "no-colour", "help", "h",
174
181
  ];
175
- const SERVE_FLAGS: readonly string[] = ["dir", "port", "default-store", "help", "h"];
182
+ const SERVE_FLAGS: readonly string[] = ["dir", "port", "default-store", "config", "help", "h"];
176
183
 
177
184
  export function unknownFlag(argv: readonly string[]): string | null {
178
185
  const serve = (argv[0] ?? "") === "serve";
@@ -200,6 +207,7 @@ export function parseServe(argv: readonly string[]): ServeArgs {
200
207
  dir: parsed.dir,
201
208
  ...(port === undefined ? { port: undefined } : { port }),
202
209
  defaultStore: argv.includes("--default-store") || argv.includes("--default-store=true"),
210
+ config: flagValue(argv, "config"),
203
211
  };
204
212
  }
205
213
 
@@ -285,11 +293,13 @@ export async function serve(argv: readonly string[]): Promise<number> {
285
293
  const running = await startDashboard({
286
294
  ...(dir === undefined ? {} : { dir }),
287
295
  ...(args.port === undefined ? {} : { port: args.port }),
296
+ ...(args.config === undefined ? {} : { config: resolve(args.config) }),
288
297
  });
289
298
  process.stdout.write(
290
299
  [
291
300
  `counterparts dashboard — ${running.url}`,
292
301
  `reading ${running.dir}`,
302
+ ...(running.upgradePending ? [UPGRADE_PENDING_SENTENCE] : []),
293
303
  // Named when it was not asked for. `--dir` is optional and the default
294
304
  // is somebody's real memory, so a `serve` typed without one should not
295
305
  // look the same as a `serve` aimed on purpose (constitution 16: the
@@ -300,7 +310,11 @@ export async function serve(argv: readonly string[]): Promise<number> {
300
310
  ...(dir === undefined
301
311
  ? [`(--default-store, so this is the DEFAULT store — ${DATA_DIR_ENV} or ~/.counterparts/store)`]
302
312
  : []),
303
- "observer mode: it strengthens nothing, deposits nothing, and writes no file of its own.",
313
+ "looking is observer mode: it strengthens nothing and deposits nothing. What you do on purpose",
314
+ "there (a note, a removal, a backup, …) runs through the console's own commands.",
315
+ ...(args.config === undefined
316
+ ? []
317
+ : [`configuration ${resolve(args.config)} (for scope and rebrief)`]),
304
318
  "ctrl-c to stop.",
305
319
  "",
306
320
  ].join("\n"),
@@ -351,6 +365,7 @@ export function describeStoreError(err: StoreError, dir: string, namedDir = fals
351
365
  // line that just named `--dir /somewhere`, creates the store in the DEFAULT
352
366
  // place instead — advice that works, somewhere else.
353
367
  case "STORE_UNINITIALIZED":
368
+ if (upgradePending(err)) return UPGRADE_PENDING_SENTENCE.replace("; then reload.", "; then run this again.");
354
369
  return `No store at ${dir}. Run 'counterparts init${namedDir ? ` --dir ${dir}` : ""}' to create one.`;
355
370
  // The exact error a stranger who put the adapter's config in the wrong place
356
371
  // will hit. The CLI's `init` already teaches the rule; this says the same
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A store waiting for its one-time schema upgrade, as the dashboard meets it.
3
+ * Its own small module so the terminal views can say the sentence without
4
+ * loading the web server.
5
+ */
6
+ import { SCHEMA_VERSION, isStoreError } from "../../core/store/index.js";
7
+
8
+ /**
9
+ * A store on an OLDER schema this build can upgrade (v6 up): an observer meets
10
+ * it as `STORE_UNINITIALIZED` with a `found` version, and it is waiting for the
11
+ * first Claude Code session to copy and upgrade it. The dashboard is an
12
+ * observer and never upgrades anything, so it says so and waits.
13
+ */
14
+ export function upgradePending(err: unknown): boolean {
15
+ if (!isStoreError(err, "STORE_UNINITIALIZED")) return false;
16
+ const found = Number.parseInt(String(err.detail["found"] ?? ""), 10);
17
+ return Number.isFinite(found) && found >= 6 && found < SCHEMA_VERSION;
18
+ }
19
+
20
+ /** The sentence a store waiting for its upgrade gets, on the page and in the terminal. */
21
+ export const UPGRADE_PENDING_SENTENCE =
22
+ "This memory needs a one-time upgrade. Open a Claude Code session and it will upgrade itself; then reload.";
23
+