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
@@ -0,0 +1,93 @@
1
+ /* The health tab: the checklist, the cycle line, the archive bar, the index
2
+ check. */
3
+
4
+ /* ── the lights (doctor's grades) ── */
5
+ .hc-dot{display:inline-block;width:10px;height:10px;border-radius:50%;flex:none;background:var(--faint);opacity:.6}
6
+ .hc-green{background:var(--teal);opacity:1;box-shadow:0 0 8px rgba(0,191,165,.6)}
7
+ .hc-amber{background:var(--amber);opacity:1;box-shadow:0 0 8px rgba(255,215,64,.45)}
8
+ .hc-red{background:var(--red);opacity:1;box-shadow:0 0 8px rgba(255,82,82,.55)}
9
+ .hc-grey,.hc-off{background:var(--faint);opacity:.55}
10
+
11
+ /* ── the checklist ── */
12
+ .hc{padding:0}
13
+ .hc-sum{display:flex;align-items:center;gap:12px;padding:16px 18px;border-bottom:1px solid var(--border)}
14
+ .hc-sum .hc-dot{width:14px;height:14px}
15
+ .hc-verdict{font-size:20px;font-weight:600;color:var(--ink)}
16
+ .hc-sub{font-size:13px;color:var(--dim);margin-left:auto}
17
+ .hc-list{display:flex;flex-direction:column}
18
+ .hc-row{display:grid;grid-template-columns:10px minmax(150px,220px) 1fr;gap:14px;align-items:center;width:100%;
19
+ min-height:44px;padding:8px 18px;background:none;border:none;border-bottom:1px solid var(--border);
20
+ color:var(--ink);font:inherit;font-size:13.5px;text-align:left;cursor:pointer}
21
+ .hc-row:hover,.hc-row[aria-expanded="true"]{background:var(--hover)}
22
+ .hc-name{font-weight:500}
23
+ .hc-line{color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
24
+ .hc-more{padding:10px 18px 14px 42px;border-bottom:1px solid var(--border);background:var(--deep);font-size:13px;line-height:1.6}
25
+ .hc-detail{color:var(--ink);word-break:break-word}
26
+ .hc-fix{margin-top:6px;color:var(--ink)}
27
+ .hc-fix b{color:var(--amber);font-weight:500}
28
+ .hc-key{margin-top:6px;font-family:var(--mono);font-size:11px;color:var(--faint)}
29
+ .hc-fold{list-style:none;margin:0;padding:0}
30
+ .hc-fold li{display:grid;grid-template-columns:10px minmax(140px,200px) 1fr;gap:12px;align-items:baseline;padding:4px 0}
31
+ .hc-fold .hc-dot{width:8px;height:8px}
32
+ .hc-fold .hc-detail{color:var(--dim);word-break:break-word}
33
+ .hc-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 18px;font-size:12px;color:var(--dim)}
34
+ .hc-again{min-height:32px}
35
+ .hc-problem{padding:12px 18px;font-size:13px;color:var(--amber)}
36
+
37
+ /* ── the last cycle ── */
38
+ .hcy{display:flex;align-items:center;gap:18px;flex-wrap:wrap;margin-top:10px}
39
+ .hcy-line{font-size:15px;color:var(--ink)}
40
+ .hcy-dots{display:flex;gap:8px;align-items:center}
41
+ .hcy-dot{width:12px;height:12px;cursor:help}
42
+
43
+ /* ── where archived memories went ── */
44
+ .ha-total{font-size:14px;color:var(--dim);margin-bottom:10px}
45
+ .ha-total b{font-family:var(--mono);font-size:20px;color:var(--ink);font-weight:700;margin-right:4px}
46
+ .ha-bar{display:flex;height:28px;border-radius:var(--radius);overflow:hidden;gap:2px;background:var(--deep)}
47
+ .ha-seg{border:none;padding:0;min-width:6px;cursor:pointer;opacity:.85}
48
+ .ha-seg:hover,.ha-seg.on{opacity:1;box-shadow:inset 0 0 0 2px rgba(255,255,255,.55)}
49
+ .ha-legend{display:flex;flex-wrap:wrap;gap:4px 18px;margin-top:12px}
50
+ .ha-key{display:inline-flex;align-items:center;gap:7px;background:none;border:none;border-radius:3px;padding:4px 6px;
51
+ margin-left:-6px;color:var(--ink);font:inherit;font-size:13.5px;cursor:pointer;min-height:32px}
52
+ .ha-key b{font-family:var(--mono);font-weight:700}
53
+ .ha-key:hover,.ha-key.on{background:var(--hover)}
54
+ .ha-zero{color:var(--dim);cursor:default;font-size:13.5px}
55
+ .ha-zero:hover{background:none}
56
+ .ha-sw{display:inline-block;width:11px;height:11px;border-radius:2px;flex:none}
57
+ .ha-sw0{background:transparent;border:1px solid var(--faint)}
58
+ .ha-none{font-size:15px;color:var(--ink)}
59
+ .ha-none+.ha-legend{margin-top:8px}
60
+ .ha-none+.ha-legend .ha-zero{margin-right:4px}
61
+ .ha-list:not(:empty){margin-top:12px;border-top:1px solid var(--border);padding-top:10px;max-height:320px;overflow-y:auto}
62
+ .ha-listhead{display:flex;align-items:center;gap:8px;font-weight:600;font-size:13.5px;margin-bottom:6px}
63
+ .ha-item{display:block;width:100%;text-align:left;background:none;border:none;border-bottom:1px solid var(--border);
64
+ color:var(--ink);font:inherit;font-size:13px;padding:7px 4px;cursor:pointer}
65
+ .ha-item:hover{background:var(--hover);color:var(--cyan)}
66
+ .ha-still{cursor:default}
67
+ .ha-still:hover{background:none;color:var(--ink)}
68
+ .ha-note{display:block;color:var(--dim);font-size:12px;margin-top:2px}
69
+ .ha-more{font-size:12px;color:var(--dim);padding:6px 4px}
70
+
71
+ /* ── the index check ── */
72
+ .hv{margin-top:18px}
73
+ .hv-head{display:flex;align-items:center;justify-content:space-between;gap:16px}
74
+ .hv-title{font-size:15px;font-weight:600}
75
+ .hv-sub{font-size:13px;color:var(--dim);margin-top:2px}
76
+ .hv-btn{font-size:13px;padding:8px 16px;min-height:40px;white-space:nowrap}
77
+ .hv-res{display:flex;align-items:center;gap:10px;margin-top:12px;font-size:14px}
78
+ .hv-facts{font-size:13px;color:var(--dim);margin:4px 0 0 20px}
79
+ .hv-full{margin-top:10px;font-size:12.5px;color:var(--dim)}
80
+ .hv-full summary{cursor:pointer}
81
+ .hv-full summary:hover{color:var(--cyan)}
82
+
83
+ @media (max-width:700px){
84
+ .hc-row{grid-template-columns:10px 1fr;gap:4px 12px;padding:10px 14px}
85
+ .hc-row .hc-line{grid-column:2;white-space:normal}
86
+ .hc-sum{flex-wrap:wrap;padding:14px}
87
+ .hc-sub{margin-left:0;width:100%}
88
+ .hc-more{padding:10px 14px}
89
+ .hc-fold li{grid-template-columns:8px 1fr}
90
+ .hc-fold li .hc-detail{grid-column:2}
91
+ .hv-head{flex-direction:column;align-items:stretch}
92
+ .hv-btn,.hc-again,.ha-key{min-height:44px}
93
+ }
@@ -0,0 +1,41 @@
1
+ /* The health tab: "is it working?" first — doctor's checks as a checklist
2
+ with lights — then the last sleep cycle as one line, where archived
3
+ memories went as one picture, and a button that checks the search index.
4
+ The developer panels that used to live here (band symmetry, what fired,
5
+ every durable record, the heatmap, what I cannot see) are on the flow tab,
6
+ under the diagram. `/api/health` for the cycle and the archive; doctor and
7
+ verify through the actions seam (both reads). */
8
+ import { api, fail } from "../../shared/api.js";
9
+ import * as archive from "./sections/archive.js";
10
+ import * as checks from "./sections/checks.js";
11
+ import * as cycle from "./sections/cycle.js";
12
+ import * as verify from "./sections/verify.js";
13
+
14
+ const markup = `
15
+ ${checks.markup}
16
+ ${cycle.markup}
17
+ ${archive.markup}
18
+ ${verify.markup}
19
+ `;
20
+
21
+ let checked = false;
22
+
23
+ async function paint() {
24
+ let d;
25
+ try { d = await api("/api/health"); } catch (e) { return fail("The health page", e); }
26
+ cycle.paint(d);
27
+ archive.paint(d);
28
+ }
29
+
30
+ async function render() {
31
+ // Doctor runs once, when the tab is first opened; "Check again" re-runs it.
32
+ if (!checked) { checked = true; void checks.run(); }
33
+ await paint();
34
+ }
35
+
36
+ export default {
37
+ name: "health",
38
+ mount(section) { section.innerHTML = markup; verify.mount(); },
39
+ render,
40
+ refresh: paint,
41
+ };
@@ -0,0 +1,84 @@
1
+ /* Where archived memories went — one stacked bar, in plain words, with the
2
+ counts. Was two panels ("ways out" and "the removal record"). Click a
3
+ segment (or its line in the legend) to list those memories; click one to
4
+ open its card. Nothing archived is ever deleted: an archived memory keeps
5
+ its id and its history. */
6
+ import { $, esc } from "../../../shared/dom.js";
7
+
8
+ export const markup = `
9
+ <h2>Where archived memories went <small>— counted since the store began; nothing leaves silently</small></h2>
10
+ <div class="card pad ha" id="h-archive"></div>`;
11
+
12
+ /** A colour per reason; an unknown reason is grey. Non-text, so any hue the
13
+ * ground can carry. */
14
+ const COLOUR = {
15
+ "handoff-cleared": "#5d7389",
16
+ "handoff-duplicate": "#3f5063",
17
+ "revised-by-pressure": "#b388ff",
18
+ "replaced-by-declaration": "#8f6ae0",
19
+ supersede: "#7057b8",
20
+ "episode-regrown": "#00e5ff",
21
+ "faded-by-decay": "#4a90a4",
22
+ pruned: "#00bfa5",
23
+ merged: "#1f8f84",
24
+ "removed-by-owner": "#ffd740",
25
+ };
26
+ const colourOf = (r) => COLOUR[r.reason] || "#6b7480";
27
+
28
+ let current = null;
29
+ let data = null;
30
+
31
+ function list(r) {
32
+ if (!r) return "";
33
+ const openable = r.reason !== "removed-by-owner";
34
+ const items = r.items.map((m) =>
35
+ openable
36
+ ? '<button type="button" class="ha-item" onclick="openMemory(\'' + esc(m.id) + '\')">' + esc(m.label) +
37
+ (m.note ? '<span class="ha-note">' + esc(m.note) + "</span>" : "") + "</button>"
38
+ : '<div class="ha-item ha-still">' + esc(m.label) +
39
+ (m.note ? '<span class="ha-note">' + esc(m.note) + "</span>" : "") + "</div>"
40
+ ).join("");
41
+ const more = r.count > r.items.length ? '<div class="ha-more">and ' + (r.count - r.items.length) + " more</div>" : "";
42
+ return '<div class="ha-listhead"><span class="ha-sw" style="background:' + colourOf(r) + '"></span>' +
43
+ esc(r.phrase) + " · " + r.count + "</div>" + items + more;
44
+ }
45
+
46
+ function select(reason) {
47
+ current = current === reason ? null : reason;
48
+ const r = current === null ? null : data.archive.reasons.find((x) => x.reason === current);
49
+ $("ha-list").innerHTML = list(r);
50
+ document.querySelectorAll("#h-archive [data-reason]").forEach((el) => {
51
+ el.classList.toggle("on", el.dataset.reason === current);
52
+ if (el.tagName === "BUTTON") el.setAttribute("aria-pressed", el.dataset.reason === current ? "true" : "false");
53
+ });
54
+ }
55
+
56
+ export function paint(d) {
57
+ data = d;
58
+ const a = d.archive;
59
+ const box = $("h-archive");
60
+ if (a.total === 0) {
61
+ box.innerHTML = '<div class="ha-none">Nothing archived yet — every memory is still live.</div>' +
62
+ '<div class="ha-legend">' + a.reasons.map((r) =>
63
+ '<span class="ha-zero">' + esc(r.phrase) + ": 0</span>").join("") + "</div>";
64
+ return;
65
+ }
66
+ const shown = a.reasons.filter((r) => r.count > 0);
67
+ const bar = shown.map((r) =>
68
+ '<button type="button" class="ha-seg" data-reason="' + esc(r.reason) + '" style="flex:' + r.count +
69
+ ";background:" + colourOf(r) + '" title="' + esc(r.phrase + ": " + r.count) + '" aria-label="' +
70
+ esc(r.phrase + ": " + r.count) + '"></button>').join("");
71
+ const legend = a.reasons.map((r) =>
72
+ r.count === 0
73
+ ? '<span class="ha-key ha-zero"><span class="ha-sw ha-sw0"></span>' + esc(r.phrase) + ": 0</span>"
74
+ : '<button type="button" class="ha-key" data-reason="' + esc(r.reason) + '" aria-pressed="false">' +
75
+ '<span class="ha-sw" style="background:' + colourOf(r) + '"></span>' + esc(r.phrase) + ': <b>' + r.count + "</b></button>"
76
+ ).join("");
77
+ box.innerHTML =
78
+ '<div class="ha-total"><b>' + a.total + "</b> archived, and every one is still here with its history</div>" +
79
+ '<div class="ha-bar">' + bar + "</div>" +
80
+ '<div class="ha-legend">' + legend + "</div>" +
81
+ '<div class="ha-list" id="ha-list"></div>';
82
+ box.querySelectorAll("[data-reason]").forEach((el) => { el.onclick = () => select(el.dataset.reason); });
83
+ if (current !== null) { const keep = current; current = null; if (shown.some((r) => r.reason === keep)) select(keep); }
84
+ }
@@ -0,0 +1,172 @@
1
+ /* "Is everything working?" — `counterparts doctor`, as a checklist with lights.
2
+
3
+ The reading is the console's own: the page runs `doctor --json` through the
4
+ actions seam (a READ — it writes nothing) and draws its findings, so this
5
+ list and the terminal cannot disagree about what "healthy" means. It runs
6
+ once when the tab first opens; "Check again" runs it again. */
7
+ import { act } from "../../../shared/actions.js";
8
+ import { $, esc } from "../../../shared/dom.js";
9
+
10
+ export const markup = `
11
+ <h2>Is everything working? <small>— the same checks as <code>counterparts doctor</code></small></h2>
12
+ <div class="card hc" id="h-checks">
13
+ <div class="hc-sum"><span class="hc-dot hc-grey"></span><span>Checking…</span></div>
14
+ </div>`;
15
+
16
+ /**
17
+ * Plain names for doctor's lines, by the finding's stable `key`. A key not
18
+ * listed keeps doctor's own title, so a check added next month still shows.
19
+ */
20
+ const NAMES = {
21
+ store: "Your memory",
22
+ host: "Connected to Claude Code",
23
+ embedder: "Recall by meaning",
24
+ "crash-write-up": "Session write-ups",
25
+ snapshot: "Snapshots",
26
+ "self-page": "Self page",
27
+ config: "Settings file",
28
+ checkout: "Code version",
29
+ "store-open": "Memory opens",
30
+ spawn: "Background worker",
31
+ clock: "Clock",
32
+ sweep: "Crash sweep",
33
+ sleep: "Sleep",
34
+ backfill: "Meaning index backfill",
35
+ credit: "Recall credit",
36
+ authorship: "Writing its own memories",
37
+ journal: "Database journal",
38
+ vectors: "Meaning vectors",
39
+ retention: "Raw transcripts",
40
+ "page-writer": "Self-page writer",
41
+ "journal-copy": "Journal copy",
42
+ fired: "Mechanisms",
43
+ stance: "Mode",
44
+ budget: "Time budget",
45
+ };
46
+
47
+ /**
48
+ * THE LINES THAT KEEP A ROW OF THEIR OWN however green they are — the
49
+ * terminal's own allowlist (`cli/report.ts#HEADLINE`, read there and restated
50
+ * here because a browser module cannot import it). Every other GREEN line
51
+ * folds into one "Behind the scenes" row that opens to list them; anything
52
+ * amber or red always gets its own row.
53
+ */
54
+ const HEADLINE = ["store", "host", "embedder", "crash-write-up", "snapshot", "self-page"];
55
+
56
+ let state = { running: false };
57
+
58
+ /** A light for one grade. `off` is an optional feature nobody turned on;
59
+ * `unasked` is a check this page could not make (no configuration named). */
60
+ function dot(grade) {
61
+ return '<span class="hc-dot hc-' + grade + '" role="img" aria-label="' +
62
+ ({ green: "fine", amber: "look at this", red: "broken", grey: "not checked", off: "off" }[grade] || grade) + '"></span>';
63
+ }
64
+
65
+ /** Doctor leads many details with the store's path; the row reads without it. */
66
+ function plain(detail) {
67
+ return String(detail || "").replace(/^\/\S+ — /, "").replace(/^\/\S+ /, "");
68
+ }
69
+
70
+ function gradeOf(f) {
71
+ if (f.key === "config" && f.data && f.data.reason === "not-read") return "grey";
72
+ if (f.optional) return "off";
73
+ return f.severity;
74
+ }
75
+
76
+ function row(i, f, grade, name, line) {
77
+ return '<button type="button" class="hc-row" aria-expanded="false" data-i="' + i + '">' + dot(grade) +
78
+ '<span class="hc-name">' + esc(name) + '</span><span class="hc-line">' + esc(line) + "</span></button>" +
79
+ '<div class="hc-more" id="hc-more-' + i + '" hidden></div>';
80
+ }
81
+
82
+ function more(f) {
83
+ return '<div class="hc-detail">' + esc(f.detail) + "</div>" +
84
+ (f.fix ? '<div class="hc-fix"><b>What to do:</b> ' + esc(f.fix) + "</div>" : "") +
85
+ '<div class="hc-key">doctor · ' + esc(f.key) + "</div>";
86
+ }
87
+
88
+ function paintFindings(report, when) {
89
+ const box = $("h-checks");
90
+ const rows = [];
91
+ const details = [];
92
+ const folded = [];
93
+ let look = 0;
94
+ let unasked = 0;
95
+ for (const f of report.findings) {
96
+ const grade = gradeOf(f);
97
+ if (grade === "red" || grade === "amber") look += 1;
98
+ if (grade === "grey") unasked += 1;
99
+ if (grade === "green" && !HEADLINE.includes(f.key)) { folded.push(f); continue; }
100
+ const name = NAMES[f.key] || f.title;
101
+ const line = grade === "grey"
102
+ ? "not checked — this dashboard was opened on a store, not through its settings file"
103
+ : plain(f.detail);
104
+ details.push(f);
105
+ rows.push({ grade, name, line, f, order: HEADLINE.indexOf(f.key) });
106
+ }
107
+ // Worst first, then the headline order the terminal reads in.
108
+ const rank = { red: 0, amber: 1, grey: 2, off: 3, green: 4 };
109
+ rows.sort((a, b) => (rank[a.grade] - rank[b.grade]) || ((a.order < 0 ? 99 : a.order) - (b.order < 0 ? 99 : b.order)));
110
+ const html = rows.map((r, i) => row(i, r.f, r.grade, r.name, r.line));
111
+ const moreHtml = rows.map((r) => more(r.f));
112
+ if (folded.length > 0) {
113
+ const i = rows.length;
114
+ html.push(row(i, null, "green", "Behind the scenes",
115
+ folded.length + " background checks, all fine"));
116
+ moreHtml.push('<ul class="hc-fold">' + folded.map((f) =>
117
+ "<li>" + dot("green") + '<span class="hc-name">' + esc(NAMES[f.key] || f.title) + "</span>" +
118
+ '<span class="hc-detail">' + esc(plain(f.detail)) + "</span></li>").join("") + "</ul>");
119
+ }
120
+ const head = look === 0
121
+ ? dot("green") + '<span class="hc-verdict">All good</span>'
122
+ : dot(report.red > 0 ? "red" : "amber") +
123
+ '<span class="hc-verdict">' + look + (look === 1 ? " thing" : " things") + " to look at</span>";
124
+ const tail = [];
125
+ tail.push(report.findings.length + " checks");
126
+ if (unasked > 0) tail.push(unasked + " not checked");
127
+ box.innerHTML =
128
+ '<div class="hc-sum">' + head + '<span class="hc-sub">' + esc(tail.join(" · ")) + "</span></div>" +
129
+ '<div class="hc-list">' + html.join("") + "</div>" +
130
+ '<div class="hc-foot"><span>Checked ' + esc(when) + '</span>' +
131
+ '<button type="button" class="act-btn hc-again" id="hc-again">Check again</button></div>';
132
+ box.querySelectorAll(".hc-row").forEach((b) => {
133
+ b.onclick = () => {
134
+ const i = Number(b.dataset.i);
135
+ const panel = $("hc-more-" + i);
136
+ const open = panel.hidden;
137
+ if (open && !panel.innerHTML) panel.innerHTML = moreHtml[i];
138
+ panel.hidden = !open;
139
+ b.setAttribute("aria-expanded", open ? "true" : "false");
140
+ };
141
+ });
142
+ $("hc-again").onclick = run;
143
+ }
144
+
145
+ function paintProblem(message) {
146
+ $("h-checks").innerHTML =
147
+ '<div class="hc-sum">' + dot("grey") + '<span class="hc-verdict">Could not check</span></div>' +
148
+ '<div class="hc-problem">' + esc(message) + "</div>" +
149
+ '<div class="hc-foot"><span></span><button type="button" class="act-btn hc-again" id="hc-again">Try again</button></div>';
150
+ $("hc-again").onclick = run;
151
+ }
152
+
153
+ /** Run `doctor --json` through the seam and draw what it said. */
154
+ export async function run() {
155
+ if (state.running) return;
156
+ state.running = true;
157
+ const again = document.getElementById("hc-again");
158
+ if (again) { again.disabled = true; again.textContent = "Checking…"; }
159
+ try {
160
+ const r = await act("doctor", {});
161
+ if (r.error && !r.out) return paintProblem(r.error);
162
+ let report = null;
163
+ try { report = JSON.parse((r.out || []).join("\n")); } catch (e) { report = null; }
164
+ if (!report || !Array.isArray(report.findings)) {
165
+ return paintProblem((r.err && r.err.length ? r.err.join(" ") : r.error) || "doctor gave no reading.");
166
+ }
167
+ const now = new Date();
168
+ paintFindings(report, now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
169
+ } finally {
170
+ state.running = false;
171
+ }
172
+ }
@@ -0,0 +1,37 @@
1
+ /* The last sleep cycle, as one line with a dot per step. */
2
+ import { $, esc } from "../../../shared/dom.js";
3
+
4
+ export const markup = `
5
+ <div class="card pad hcy" id="h-cycle"></div>`;
6
+
7
+ function sameLocalDay(ms) {
8
+ const a = new Date(ms);
9
+ const b = new Date();
10
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
11
+ }
12
+
13
+ function when(c) {
14
+ if (c.at !== null && sameLocalDay(c.at)) return "today";
15
+ if (c.at !== null) {
16
+ const d = new Date(c.at);
17
+ return "on " + d.toLocaleDateString([], { month: "short", day: "numeric" }) + " (lived day " + c.day + ")";
18
+ }
19
+ return "on lived day " + c.day;
20
+ }
21
+
22
+ const WORD = { ran: "finished in the last cycle", behind: "behind — last finished on lived day ", never: "has never run", torn: "its marker is unreadable" };
23
+
24
+ export function paint(d) {
25
+ const c = d.cycle;
26
+ const dots = c.phases.map((p) => {
27
+ const tone = p.state === "ran" ? "green" : p.state === "never" && c.day === null ? "grey" : "amber";
28
+ const said = p.state === "behind" ? WORD.behind + p.day : WORD[p.state];
29
+ const title = p.phase + " — " + p.gloss + " (" + said + ")";
30
+ return '<span class="hcy-dot hc-dot hc-' + tone + '" title="' + esc(title) + '" role="img" aria-label="' + esc(title) + '"></span>';
31
+ }).join("");
32
+ let line;
33
+ if (c.day === null) line = "Sleep hasn't run yet — it runs after a session ends";
34
+ else if (c.ran === c.total) line = "Sleep last ran " + when(c) + ": all " + c.total + " steps";
35
+ else line = "Sleep last ran " + when(c) + ": " + c.ran + " of " + c.total + " steps finished";
36
+ $("h-cycle").innerHTML = '<span class="hcy-line">' + esc(line) + '</span><span class="hcy-dots">' + dots + "</span>";
37
+ }
@@ -0,0 +1,54 @@
1
+ /* "Check the index" — `counterparts verify`, through the actions seam. A read:
2
+ it compares the search index with the memories and changes nothing (the
3
+ repairing flags are the terminal's). */
4
+ import { act, resultHtml } from "../../../shared/actions.js";
5
+ import { $, esc } from "../../../shared/dom.js";
6
+
7
+ export const markup = `
8
+ <div class="card pad hv" id="h-verify">
9
+ <div class="hv-head">
10
+ <div><div class="hv-title">The search index</div>
11
+ <div class="hv-sub" id="hv-sub">Compares what recall searches with what is actually stored. Changes nothing.</div></div>
12
+ <button type="button" class="act-btn hv-btn" id="hv-go">Check the index</button>
13
+ </div>
14
+ <div id="hv-out"></div>
15
+ </div>`;
16
+
17
+ /** The console's lines, read for the three facts a person wants. */
18
+ function summarise(out) {
19
+ const text = out.join("\n");
20
+ const live = /live rows:\s*(\d+)/.exec(text);
21
+ const indexed = /indexed documents:\s*(\d+)/.exec(text);
22
+ const stale = /indexed but not live[^:]*:\s*(\d+)/.exec(text);
23
+ const verdict = out.length ? out[out.length - 1].trim() : "";
24
+ const facts = [];
25
+ if (live) facts.push(live[1] + " live memories");
26
+ if (indexed) facts.push(indexed[1] + " in the index");
27
+ if (stale && Number(stale[1]) > 0) facts.push(stale[1] + " indexed but no longer live");
28
+ return { verdict, facts };
29
+ }
30
+
31
+ export function mount() {
32
+ $("hv-go").onclick = async () => {
33
+ const btn = $("hv-go");
34
+ btn.disabled = true;
35
+ btn.textContent = "Checking…";
36
+ $("hv-out").innerHTML = "";
37
+ const r = await act("verify", {});
38
+ btn.disabled = false;
39
+ btn.textContent = "Check again";
40
+ if (r.error || !r.out) {
41
+ $("hv-out").innerHTML = '<div class="hv-res">' + '<span class="hc-dot hc-amber"></span><span>' +
42
+ esc(r.error || "verify gave no reading.") + "</span></div>";
43
+ return;
44
+ }
45
+ const s = summarise(r.out);
46
+ const ok = r.ok === true;
47
+ $("hv-out").innerHTML =
48
+ '<div class="hv-res"><span class="hc-dot hc-' + (ok ? "green" : "amber") + '"></span><span>' +
49
+ esc(ok ? (s.verdict || "The index matches the memories.") : "The index needs a look: " + (s.verdict || "see the full report")) +
50
+ "</span></div>" +
51
+ (s.facts.length ? '<div class="hv-facts">' + esc(s.facts.join(" · ")) + "</div>" : "") +
52
+ '<details class="hv-full"><summary>The full report</summary>' + resultHtml(r) + "</details>";
53
+ };
54
+ }