counterparts 0.3.9 → 0.3.11

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 (115) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/README.md +9 -3
  3. package/docs/QUICKSTART.md +3 -2
  4. package/docs/module-map.md +1 -1
  5. package/package.json +9 -7
  6. package/src/adapters/claude-code/CONTRACT.md +44 -2
  7. package/src/adapters/claude-code/NOTES.md +17 -0
  8. package/src/adapters/claude-code/bin/hook.mjs +8 -0
  9. package/src/adapters/claude-code/bin/hook.ts +29 -4
  10. package/src/adapters/claude-code/bin/nightly.ts +1 -0
  11. package/src/adapters/claude-code/doctor.ts +164 -6
  12. package/src/adapters/claude-code/hooks.ts +144 -11
  13. package/src/adapters/claude-code/night-catch-up.ts +543 -0
  14. package/src/adapters/claude-code/night-run.ts +53 -8
  15. package/src/adapters/claude-code/standdown.ts +10 -1
  16. package/src/adapters/cli/bin/counterparts.mjs +8 -0
  17. package/src/adapters/cli/commands.ts +21 -6
  18. package/src/adapters/cli/desktop.ts +25 -3
  19. package/src/adapters/cli/export.ts +4 -2
  20. package/src/adapters/cli/install.ts +51 -2
  21. package/src/adapters/cli/wire.ts +12 -49
  22. package/src/adapters/config.ts +17 -0
  23. package/src/adapters/dashboard/NOTES.md +36 -0
  24. package/src/adapters/dashboard/bin/dashboard.mjs +8 -0
  25. package/src/adapters/dashboard/bin/dashboard.ts +10 -4
  26. package/src/adapters/dashboard/registries.ts +10 -4
  27. package/src/adapters/dashboard/upgrade.ts +15 -3
  28. package/src/adapters/dashboard/web/README.md +2 -2
  29. package/src/adapters/dashboard/web/flow.ts +1 -0
  30. package/src/adapters/dashboard/web/lanes.ts +1 -0
  31. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +4 -3
  32. package/src/adapters/dashboard/web/narrate.ts +36 -7
  33. package/src/adapters/dashboard/web/pages/health/sections/archive.js +22 -10
  34. package/src/adapters/dashboard/web/pages/health/sections/checks.js +37 -2
  35. package/src/adapters/dashboard/web/pages/health/sections/wake.js +41 -4
  36. package/src/adapters/dashboard/web/pages/memories/index.js +1 -1
  37. package/src/adapters/dashboard/web/pages/memories/sections/list.js +1 -1
  38. package/src/adapters/dashboard/web/pages/self/sections/dreams.js +4 -2
  39. package/src/adapters/dashboard/web/pages/self/sections/settling.js +6 -1
  40. package/src/adapters/dashboard/web/pages/self/self.css +1 -0
  41. package/src/adapters/dashboard/web/server.ts +8 -8
  42. package/src/adapters/dashboard/web/shared/memory-marks.js +13 -7
  43. package/src/adapters/dashboard/web/shared/widgets/feel-radar.js +2 -2
  44. package/src/adapters/dashboard/web/views/core-road.ts +2 -1
  45. package/src/adapters/dashboard/web/views/dreams.ts +20 -1
  46. package/src/adapters/dashboard/web/views/health.ts +164 -25
  47. package/src/adapters/dashboard/web/views/memories.ts +3 -3
  48. package/src/adapters/dashboard/web/views/mind.ts +1 -1
  49. package/src/adapters/feelings-line.ts +9 -5
  50. package/src/adapters/fired.ts +4 -1
  51. package/src/adapters/hosts.ts +43 -1
  52. package/src/adapters/launch.mjs +30 -0
  53. package/src/adapters/lifecycle.ts +65 -9
  54. package/src/adapters/log/index.ts +5 -0
  55. package/src/adapters/mcp/CONTRACT.md +76 -16
  56. package/src/adapters/mcp/NOTES.md +107 -1
  57. package/src/adapters/mcp/bin/serve.mjs +8 -0
  58. package/src/adapters/mcp/bin/serve.ts +2 -1
  59. package/src/adapters/mcp/deliberate.ts +441 -22
  60. package/src/adapters/mcp/index.ts +2 -0
  61. package/src/adapters/mcp/server.ts +386 -45
  62. package/src/adapters/mcp/tools.ts +87 -20
  63. package/src/adapters/mcp/write-up.ts +131 -30
  64. package/src/adapters/node-hooks.mjs +108 -0
  65. package/src/adapters/runtime.ts +126 -0
  66. package/src/adapters/sessions.ts +287 -30
  67. package/src/core/briefing.ts +8 -2
  68. package/src/core/counterpart.ts +581 -44
  69. package/src/core/coverage/CONTRACT.md +2 -1
  70. package/src/core/coverage/INTERFACE-GAPS.md +11 -9
  71. package/src/core/coverage/NOTES.md +11 -0
  72. package/src/core/coverage/index.ts +146 -4
  73. package/src/core/dream/CONTRACT.md +6 -1
  74. package/src/core/dream/index.ts +118 -12
  75. package/src/core/dream/reflect.ts +17 -6
  76. package/src/core/feelings-wheel.ts +395 -241
  77. package/src/core/handoff/CONTRACT.md +156 -28
  78. package/src/core/handoff/NOTES.md +194 -1
  79. package/src/core/handoff/index.ts +701 -115
  80. package/src/core/handoff/last-here.ts +446 -0
  81. package/src/core/mint.ts +20 -1
  82. package/src/core/physics/CONTRACT.md +20 -2
  83. package/src/core/physics/NOTES.md +25 -0
  84. package/src/core/physics/index.ts +43 -11
  85. package/src/core/recall/CONTRACT.md +66 -11
  86. package/src/core/recall/NOTES.md +234 -3
  87. package/src/core/recall/activate.ts +91 -16
  88. package/src/core/recall/feeling-ask.ts +375 -17
  89. package/src/core/recall/index.ts +1 -0
  90. package/src/core/recall/mood.ts +52 -24
  91. package/src/core/recall/recency-ask.ts +164 -0
  92. package/src/core/recall/tunables.ts +20 -2
  93. package/src/core/remember/proposals.ts +13 -1
  94. package/src/core/self/CONTRACT.md +36 -4
  95. package/src/core/self/INTERFACE-GAPS.md +5 -0
  96. package/src/core/self/NOTES.md +122 -0
  97. package/src/core/self/briefing.ts +76 -11
  98. package/src/core/self/covered.ts +104 -0
  99. package/src/core/self/episodes.ts +15 -2
  100. package/src/core/self/identity.ts +57 -1
  101. package/src/core/self/index.ts +175 -6
  102. package/src/core/self/tunables.ts +20 -3
  103. package/src/core/self/work.ts +209 -0
  104. package/src/core/self/writer.ts +27 -2
  105. package/src/core/sleep/consolidate.ts +56 -12
  106. package/src/core/sleep/index.ts +1 -0
  107. package/src/core/sleep/types.ts +10 -0
  108. package/src/core/store/CONTRACT.md +12 -7
  109. package/src/core/store/NOTES.md +112 -0
  110. package/src/core/store/db.ts +29 -6
  111. package/src/core/store/feelings.ts +120 -43
  112. package/src/core/store/index.ts +102 -2
  113. package/src/core/store/operational.ts +152 -3
  114. package/src/core/types.ts +38 -0
  115. package/tools/install-loop/run.sh +94 -90
package/CHANGELOG.md CHANGED
@@ -1,5 +1,312 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.11 — 2026-10-01
4
+
5
+ The nightly run now writes up the sessions that ended before they were written up, in
6
+ any directory, before it writes the page, and the wake gets a dated "Yesterday" line.
7
+ The wake splits work from personal: "Work here" lists the work done in the directory the
8
+ session opens in, and Nearby keeps what is personal, so a session in one project no
9
+ longer wakes to another project's plumbing. Counterparts runs under Node 22.15 or newer,
10
+ and on Linux. Claude Desktop's Code tab files its memories under its own session again,
11
+ asking by feeling finds more of what was felt, and the wake says when a handoff may be
12
+ out of date. **The store's format does not change** (still v11): nothing is upgraded and
13
+ no pre-migration copy is taken, and 0.3.10 can open a store 0.3.11 has used.
14
+
15
+ The morning catch-up and the "Yesterday" line (#308).
16
+
17
+ - **The nightly run writes up what was left unwritten, in any directory, before it
18
+ writes the page.** Until now a conversation that ended before it was written up waited
19
+ for the next session opened in the same directory, and a project nobody reopened within
20
+ two days of use simply let it lapse. Now, when the day's first prompt starts the
21
+ nightly run (dreaming `auto`), a short `claude -p` of its own goes first: it is allowed
22
+ one tool (`session_end`), and it writes up at most 4 sessions or about 96 KB of their
23
+ words a night, oldest first. What it leaves stays owed, for another night or a session
24
+ in its directory. It costs one more `claude -p` start on a night with something owed,
25
+ and nothing on a night without. That run can only write up: it can't write memories
26
+ of its own, notes, chapters or handoffs. A run that stops early (a usage limit, say)
27
+ is recorded as partial, and one whose process was killed has its permission ended at
28
+ the next run.
29
+ - **A written-up memory belongs to the conversation it came from.** It carries that
30
+ session and its directory, is marked as written up second-hand (and by whom), and its
31
+ "happened" date is the day the conversation was lived. Its "learned" date stays the day
32
+ it was written. The page writer reads it on the day it happened, not the day it was
33
+ written. This is true of the in-session catch-up too.
34
+ - **The writer now sees both sides.** The part handed over carries the session's own
35
+ replies, labelled `[its reply]` and each cut at about 1.5 KB, beside what was said to
36
+ it. A part may hold a little less of what was said than before.
37
+ - **Two writers never write the same stretch.** Whoever fetches a stretch holds it until
38
+ it comes back (at most two hours). The session-start pointer passes over one the
39
+ nightly run holds, and a session that tries to fetch one gets "the nightly run is
40
+ writing that session up now".
41
+ - **A conversation that crashed without an end can be written up from another
42
+ directory.** "Ended" is now read the same way the rest of the write-up rule reads it:
43
+ nothing captured since the date changed. A refusal always says why.
44
+ - **The wake has a "Yesterday" line**: yesterday's chapter titles with their ids, with
45
+ the date in the line ("Yesterday, 09-30: …"), so a wake composed late at night still
46
+ reads right in the morning. It takes its room from the wake's existing budget.
47
+ - **`counterparts doctor`** says what the nightly run's catch-up did (written up, left
48
+ owed) on the Nightly run and Write-ups lines, and counts yesterday's Claude Desktop
49
+ chats as unmeasured rather than lost. `counterparts log` shows an
50
+ `adapter.night.writeup` line for it.
51
+
52
+ The wake: work here, and what is personal (#313).
53
+
54
+ - The wake's craft lane is now the work done in the directory the session opens in: "Work
55
+ here, if it helps:" lists that directory's newest few work memories (marked `work`, or
56
+ unmarked skills and facts written there), each a title, a short excerpt and its id.
57
+ Nearby keeps what is personal, so a session in one project no longer wakes to another
58
+ project's plumbing.
59
+ - The chapter tool takes `about` (me, us, owner, work or world), and the chapter's memory
60
+ copy keeps it. A chapter marked me, us or owner reaches the wake in other directories;
61
+ one marked work stays in its own.
62
+ - `note` and `session_end` entries take `unresolved: true` for an open question or a
63
+ promise still pending; the wake shows those under "Still open:" (at most five). A later
64
+ write that `updates` one with `unresolved: false`, or with `how: "changed"` and the
65
+ answer, closes it.
66
+ - The end-of-session ask (and Desktop's write-up ask) now says to close anything dated or
67
+ open that got done in the session, so a finished follow-up stops coming back.
68
+ - The day's lines (the dream line, the night run's report, plain reminders, the update
69
+ notice) go only to a session someone can see: the terminal or Desktop's Code tab, not
70
+ `claude -p` or the SDK. A headless session can still start the nightly run, and the next
71
+ session you are in says so. The assistant now says the day's dream line itself, once, in
72
+ its first reply; the terminal line is extra.
73
+
74
+ Node and Linux (#312).
75
+
76
+ - **Runs under Node 22.15 or newer, and on Linux.** `npm install -g counterparts` works
77
+ without bun. The setup wires Claude Code to whichever runtime ran it (`bun run …` under
78
+ bun, `node --import …/node-hooks.mjs …` under Node), and `counterparts doctor` has a
79
+ Runtime line naming it and saying whether it is still there. The four commands now
80
+ start under bun when bun is on PATH, else Node. On Linux, `install --host
81
+ claude-desktop` says Claude Desktop is not available there instead of writing a config.
82
+ Tested on Node 22 and 24, macOS and Linux (Debian, arm64); no daily user on Node yet.
83
+
84
+ Continuity, round 2 (#311).
85
+
86
+ - A handoff that may be out of date says so at the wake: "written 09-30 18:45 by session
87
+ a1b2c3d4, before 0.3.10 was installed" when an older release wrote it, or "a newer chapter
88
+ here since" when another session wrote a chapter in that directory after it. The end-of-
89
+ session ask now says any session may retire a handoff here whose work is done.
90
+ - Recalled by its id, a handoff says who wrote it and when, not "an earlier session" and the
91
+ date its row was first made.
92
+ - "Last here" shows the first sentence of the chapter the episode's title was written with
93
+ (and "2 chapters" when there are more), not a later chapter's under the first one's title.
94
+ A question about time in recall does the same (for "yesterday" or "this morning", the first
95
+ chapter written then), and says how many chapters there are.
96
+ - A note written before the memory server knows its session is filed under the session its
97
+ host opened in that directory, when that match is exact. An older such note, written
98
+ inside exactly one session's stretch, says "session a1b2c3d4 (placed by when it was
99
+ written)".
100
+ - Nearby leaves out what the self page already says, a memory a later one has settled
101
+ (changed or corrected), and a memory already under Arriving; and it no longer ends with a
102
+ "(331 more nearby; recall ids…)" line.
103
+ - A chapter about me written in another directory reaches the wake elsewhere, as one line,
104
+ when its memory is marked about me, us or the owner, the directory it came from is on, and
105
+ it is not confidential. A confidential chapter is named in "Last here" to the owner only.
106
+ - A "Last here" line dropped for room now leaves a record, and the dashboard's Health wake
107
+ bar goes amber for it.
108
+ - recall says why `considered` can be above `consideredCap` (links between memories and a
109
+ feeling the question named have their own bounds).
110
+ - With only Claude Desktop, an older store waiting for its upgrade says to open Desktop or
111
+ start a new chat in it, not to quit and reopen it.
112
+
113
+ Claude Desktop's Code tab (#309).
114
+
115
+ - Claude Desktop's Code tab files its memories under its own session again. There, the
116
+ counterparts tools the assistant sees turned out to be Claude Desktop's memory server, not
117
+ the session's own (both are named `counterparts`, and Desktop's wins), so a Code-tab
118
+ session's notes, chapters and write-ups were filed under the most recent Desktop chat, or
119
+ refused. Now the Code tab's wake gives the assistant one line with its session id, and a
120
+ call that passes that id is filed exactly as Claude Code would file it: in that session's
121
+ folder, under that session, with no Desktop write-up reminder added. Only a session Claude
122
+ Code's hooks recorded, and that is still running, is taken this way, and only for that one
123
+ call, so it can't spill into a Desktop chat's next call. A Code-tab call that passes no id
124
+ still lands under the most recent Desktop chat; its result now says which chat, and tells a
125
+ Claude Code session to pass its own id. The `wake` tool's description no longer says it is
126
+ never offered in Claude Code, and doctor's Claude Desktop line says the Code tab's tools
127
+ come from Desktop's server. Terminal sessions are unchanged. Each prompt now also marks
128
+ its session as still running, so a Code-tab session left idle for hours is recognised
129
+ again at its next prompt, and a call whose session id wasn't accepted says why.
130
+
131
+ Recall by feeling, round 2 (#310).
132
+
133
+ - Asking recall by feeling finds more of what was felt. Any feeling word reaches its family on
134
+ the wheel: "when was I afraid", with nothing recorded as afraid, answers with the strongest
135
+ uneasy moments, and a moment recorded as afraid still comes first. Everyday words off the
136
+ wheel ("shame", "dread", "relief"), forms like "happiest" or "sadness", and phrases like
137
+ "caught out" are understood, and so is your name in the possessive ("Mike's feelings"). Asking for the most, the
138
+ strongest, or "ever" ranks by how strongly something was felt at the time, not by how fresh
139
+ it is. Memories that only talk about feelings (notes on the wheel itself, say) no longer
140
+ crowd out the moments that were actually felt.
141
+
142
+ Dashboard Health (#306).
143
+
144
+ - A full wake is the normal state, so the Health wake bar is green for it ("The wake is
145
+ full — normal: …"). It turns amber only when being full cost something (the self page
146
+ cut or left out, a handoff a session start had no room for, the page writer held back
147
+ for room), and the line names the cost.
148
+ - The archive list shows one line per memory: a chapter's copies are one item that says
149
+ how many times, and opens the newest.
150
+ - The folded rows under "all fine" use the same plain words as the main rows ("… —
151
+ harmless; nothing to do") and no longer say "You may remove".
152
+ - The last sleep shown is the last one that did something, not a check that found
153
+ nothing to do. The map's `?` describes the three named rings.
154
+ - The Lookups row is "Looked up in dreams and reflections", in doctor's words. A dream's
155
+ start says how many memories wait for the next night and how many aged out, and a merge
156
+ the dream saw less than whole says so ("seen only as a line").
157
+
158
+ Small fixes (#307).
159
+
160
+ - The wake's "Arriving:" lines say when each thing is due, not only when it was learned:
161
+ `2026-09-27 (due 2026-10-03) · …`.
162
+ - When the console or the dashboard meets a store still waiting for its upgrade, it says who
163
+ will upgrade it in your hosts' words: with only Claude Desktop it no longer tells you to
164
+ wait for a Claude Code session.
165
+ - Whoever rewrites the self page (the page writer, or the nightly reflection) is asked to name
166
+ the model when a claim is about one model, to write dates rather than "tonight" or
167
+ "today" (the page is read on later days), and not to add a revised-on line of its own.
168
+ - Wake labels: the line under the header no longer also starts "Counterparts memory", and it
169
+ says only the listed memories open with a date (the page is dated on its own line); a
170
+ memory whose words already start with its date shows that date once; and the closing
171
+ comment says `page=1` beside `identity=0` when the wake carries the page.
172
+ - The install loop (`tools/install-loop`, in the package) reads what it captured with a
173
+ here-string, so a long output can no longer fail a check that had matched.
174
+
175
+ Not proven here.
176
+
177
+ - No one uses Counterparts on Node daily yet. Linux was tested on arm64 Debian, in a
178
+ container. Dreaming and the nightly run under Node go through the same wiring, but
179
+ were not run, since that needs a real `claude`. Windows was not attempted.
180
+ - The night catch-up was checked in tests and in a throwaway home with a stand-in
181
+ `claude` that drives the memory server as the real one's single tool would, never with
182
+ a real `claude -p` or on a real store.
183
+ - The Code tab's sessions were measured read-only on a real Desktop, and the serving was
184
+ checked in tests, not on a day's real use.
185
+
186
+ ## 0.3.10 — 2026-09-30
187
+
188
+ Feelings now sit on a new wheel of seven cores — happy, warm, calm, curious, sad,
189
+ uneasy, angry — and every feeling already recorded is re-filed onto it. A feeling
190
+ written under a core is kept under that core, and every word carries default numbers,
191
+ so a note can name just the word. Several sessions working in one directory each keep
192
+ their own handoff now, and the wake says who left each one. A new session's wake has a
193
+ "Last here" line naming the latest chapter written in this directory, and asking "what
194
+ do you remember from our most recent session?" leads with that session. Every recall
195
+ result says which session it came from. **The store's format changes, v10 → v11, and a
196
+ pre-migration copy is taken.**
197
+
198
+ **The format change, and why every session must be closed.** The first Counterparts
199
+ process to open the store for writing after installing copies it (as every upgrade since
200
+ 0.3.1 has) and upgrades it. Usually that is a Claude Code hook, even the next prompt in a
201
+ session left open. With only Claude Desktop, it is Desktop's memory server as it starts,
202
+ or, if Desktop was left running, the background worker its next chat starts. The upgrade
203
+ adds three
204
+ columns to `feelings` (`valence`, and `core_v10` / `emotion_v10`) and re-files every
205
+ recorded feeling onto the seven cores. A re-filed row keeps its old core and word beside
206
+ it, and nothing else in the store changes. Until the upgrade, `counterparts doctor` and
207
+ the dashboard can't read the store (a v10 store is older than they read) and say so.
208
+ **Close every Claude Code session before installing, and if you have connected Claude
209
+ Desktop, quit it.** A v11 store can't be opened by 0.3.9: anything of 0.3.9's that opens
210
+ it afterwards refuses at once (`SCHEMA_AHEAD`), and its hooks stand down. A memory server
211
+ that was already running keeps 0.3.9's code with the store already open. Its tools
212
+ re-read the format on every call and refuse ("Counterparts was updated and this server
213
+ is still running the old version, so this tool did nothing."), ending with `/mcp` →
214
+ Reconnect in Claude Code and "Quit and reopen Claude Desktop" in Desktop. The hooks are
215
+ fresh processes at every event, so they run the new code at once. To go back to 0.3.9
216
+ you reinstall it and put back the copy the upgrade took; anything remembered since is
217
+ lost.
218
+
219
+ The feelings wheel, v2 (#301).
220
+
221
+ - **Seven cores: happy, warm, calm, curious, sad, uneasy, angry**, in 37 groups,
222
+ 180 words in all (a group's name is a word too). Every word from the first wheel, its additions and aliases, and
223
+ every word a counterpart has recorded in its own words has a home. Recognition is a
224
+ group under curious (also warm). Guilt sits under uneasy, disgust is a word under
225
+ angry, and hopeful is under happy.
226
+ - **Every word carries default numbers**: a valence (−1 to +1) and an intensity (0 to
227
+ 1). On `note` and `session_end`, `core` and `strength` may be left out: a feeling with
228
+ no core takes its word's home core, and a feeling with no strength takes the word's
229
+ intensity, capped at 0.55. A `valence` may be given to override the word's. A strength
230
+ you give is never changed.
231
+ - **The writer's core is kept.** A word named under a core it doesn't sit under is
232
+ stored under the core the writer chose, with nothing reported as moved. (0.3.9 moved
233
+ it to the word's home and said so.) A first-wheel core name (`fear`, `anger`,
234
+ `surprise`, `disgust`) sent by a session or dream still running is filed the way the
235
+ upgrade files it, and comes back as a `core` repair.
236
+ - **The upgrade re-files every feeling.** fear → uneasy; anger and disgust → angry; sad
237
+ stays sad, except guilty, remorseful and ashamed → uneasy. Rows under happy and
238
+ surprise, and `other` words under them, go by the word: to its home core, unless the
239
+ word can also be written under the old core (bittersweet under happy stays happy). A
240
+ word off the wheel stays happy under happy and goes to curious under surprise. Each
241
+ re-filed row keeps its old pair. It runs once. Doctor prints what moved ("Upgrade to
242
+ v11: feelings use seven cores now … N of M recorded feelings re-filed (…), each keeping
243
+ its old core beside it").
244
+ - **What a feeling does, by its valence.** How high a feeling holds a memory is
245
+ unchanged. How fast that hold softens now depends on valence: a negative feeling's hold
246
+ softens fastest (angry about 16 days), a positive one's slowest (happy and warm about
247
+ 26). Mood matching compares valence instead of core, and a low mood meeting a low
248
+ feeling counts a quarter as much, so a low mood can't feed itself.
249
+ - **Recognition reaches the core's fast lane.** An unmarked memory carrying the
250
+ counterpart's own recognition feeling (at least 0.6, felt in a session) counts as about
251
+ itself for the fast lane only; a mark still wins, and the slow lane still needs one.
252
+ Doctor counts it ("Recognition").
253
+ - **Readers.** The dashboard's radar, chips and dots show the seven cores in seven
254
+ colours, warm pink and angry red ("dislike" for "disgust" is gone; disgust is a word
255
+ under angry). In recall, a
256
+ stamp also answers to its group's word, so "when was I afraid" still reaches scared.
257
+ The dream and reflection prompts name the seven cores.
258
+
259
+ Handoffs, one per session (#295).
260
+
261
+ - **Each session in a directory keeps its own live handoff.** Writing again revises your
262
+ own; another session's write makes a new one beside it. Until now the last session to
263
+ end wrote over the others.
264
+ - **The wake shows every live handoff here, newest first, and who wrote each** (the
265
+ session's short id and model, "this session" for your own). With several, a count line,
266
+ up to three one-line entries, the older ones by id, and how to retire one.
267
+ - **Retiring.** `handoff: ""` retires only your own. `session_end` takes
268
+ `retireHandoff: [ids]` to retire any handoff in this directory, whoever wrote it. A
269
+ `handoff` write returns `others`, the other sessions' live handoffs here, so finished
270
+ ones can go in the same call.
271
+ - **Claude Desktop:** a `session_end` with no session named can't leave or retire a
272
+ handoff (`session-unnamed`); the rest of the call goes through.
273
+
274
+ Continuity (#300, #302).
275
+
276
+ - **"Last here" on the wake.** In a directory where a session wrote a chapter within the
277
+ fortnight, the wake says which session it was, its model, when it ran and the
278
+ chapter's title and first sentence. It is read from what is already stored, so chapters
279
+ written before this release show at once. A finished session needs no handoff for it.
280
+ - **The handoff pointer says how far the work since is written up**: "written up to
281
+ 17:50 (chapter), 3 pieces after" instead of "not yet written up" when a chapter or a
282
+ memory covers part of it.
283
+ - **A question about time leads with this directory's last session.** "What do you
284
+ remember from our most recent session?", "where did we leave off", "this evening" and
285
+ the like bring that session's latest chapter first, then the memories it wrote, newest
286
+ first, each marked `recent`. The rest of the answer is ranked as before.
287
+ - **Every recall result says where it came from**: `from: "session a1b2c3d4, ~/garden,
288
+ 09-30 17:41"`, or "this session". Older rows say less (nothing is backfilled).
289
+ - **A note from before the session was known (#305).** In Claude Code the memory server
290
+ learns which session it serves only at the first `chapter` or `session_end`; a `note`
291
+ before that is filed under no session. Such a note now reads "a session that hadn't
292
+ been identified yet" with its directory and time, never "this session". A question
293
+ about time still brings a finished session's earlier notes back with it when they were
294
+ written here, while that session was at work, and no other session was working here at
295
+ the same moment.
296
+
297
+ Tests only (#303): child processes in the suite get the test's time zone, and two
298
+ fixtures moved, so the suite passes at every hour in any zone. No product change.
299
+
300
+ Not proven here.
301
+
302
+ - Nothing ran on a real store. The re-filing of your own recorded feelings, the writer's
303
+ core on real notes, the softening and mood by valence, and the recognition lane were
304
+ checked on a seeded store and in tests only.
305
+ - The upgrade from Claude Desktop's memory server (a Desktop-only user) was checked over
306
+ stdio with a client that calls itself `claude-ai`, not against the real app.
307
+ - "Last here", the recency lead and handoffs from several sessions were checked with
308
+ driven sessions in one throwaway directory, not across a real day's parallel sessions.
309
+
3
310
  ## 0.3.9 — 2026-09-30
4
311
 
5
312
  Counterparts now reaches Claude Desktop's chat: one command connects it, a chat wakes
package/README.md CHANGED
@@ -10,7 +10,8 @@ its memories itself, and they fade and grow the way yours do. It runs today with
10
10
 
11
11
  ## Install
12
12
 
13
- You need [bun](https://bun.sh) 1.3 or newer (`npm install` won't work; it needs bun).
13
+ You need [bun](https://bun.sh) 1.3 or newer, or [Node](https://nodejs.org) 22.15 or newer.
14
+ macOS and Linux.
14
15
 
15
16
  ```
16
17
  curl -fsSL https://bun.sh/install | bash # if you don't have bun
@@ -18,6 +19,9 @@ bun add -g counterparts
18
19
  counterparts
19
20
  ```
20
21
 
22
+ With Node instead: `npm install -g counterparts`, then `counterparts`. Whichever runtime
23
+ runs the setup is the one Claude Code's hooks and memory tools are wired to.
24
+
21
25
  `counterparts` walks you through setup: your name and connecting Claude Code. No API
22
26
  keys. Then restart Claude Code and check it:
23
27
 
@@ -106,8 +110,10 @@ More: [`docs/ELI5.md`](docs/ELI5.md) (the whole system in plain words) and
106
110
 
107
111
  ## Status
108
112
 
109
- Early. It's been the author's daily memory since September 2026. It runs on bun only;
110
- Node is untested. Expect rough edges, and please
113
+ Early. It's been the author's daily memory since September 2026, on bun and macOS; Node
114
+ (22.15+) and Linux pass a smoke test and an install run but have no daily user yet.
115
+ Claude Desktop has no Linux build, so on Linux it is Claude Code only. Expect rough
116
+ edges, and please
111
117
  [open an issue](https://github.com/mlapeter/counterparts/issues) when you hit one.
112
118
 
113
119
  There are no API keys, and nothing leaves your machine except through Claude Code
@@ -2,8 +2,9 @@
2
2
 
3
3
  ## Install
4
4
 
5
- You need [bun](https://bun.sh) 1.3 or newer. Counterparts runs on bun only; Node is
6
- untested.
5
+ You need [bun](https://bun.sh) 1.3 or newer, or [Node](https://nodejs.org) 22.15 or newer,
6
+ on macOS or Linux. With Node, install with `npm install -g counterparts` instead of the
7
+ `bun add` line below; the rest is the same.
7
8
 
8
9
  ```
9
10
  curl -fsSL https://bun.sh/install | bash # if you don't have bun
@@ -28,7 +28,7 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
28
28
  | `fit/` | working memory's pointers | Fitting what a mechanism has into the room it has: a line for everything, the whole text for the most important, ids and a named lookup for the rest, a count of what waits. Plus `lineOf`, `derivedFrom`, parts, and the lookup ledger that measures whether receivers use the lookup. First users: the dream and the reflection. **Added 2026-09-28 (build B).** |
29
29
  | *(`contradictions.ts`)* | reconsolidation + interference | Two memories that disagree: flagged (a dream, today), noticed at write time (the nearest few live memories come back with a stored one), and SETTLED — `changed` (both true at their time: one strength cut, labelled earlier), `corrected` (archived, readable by id), or `open` (both kept, shown together) — by a new memory's `updates` + `how`, a `note` settle, a dream or reflection with a plain reason, or the owner's `counterparts settle`. Every settle is on a trail (who, how, why, when) and can be undone. A file beside `revision.ts`, whose ordinary-memory arm it is; its tables are the store's (schema v10), its labels recall's (`recall/standing.ts`). **Added 2026-09-29.** |
30
30
  | *(`time.ts`)* | — (a clock, not a memory) | The one module that converts: a moment (UTC ms from `store.now()`) to a person's local date or clock line, "today" in a zone, and calendar dates as said (day, month, year, range). A file, not a module; a test keeps hand-built dates out of `src/`. **Added 2026-09-25 (`docs/time.md`).** |
31
- | *(`feelings-wheel.ts`)* | — (a vocabulary) | The feelings wheel as a typed list: six cores, the middle and outer rings, valence, and the key scheme (`<core>.<word>` only for a word printed under two cores). Read by `store/` to validate the `feelings` table. **Added 2026-09-25.** |
31
+ | *(`feelings-wheel.ts`)* | — (a vocabulary) | The feelings wheel as a typed list: seven cores (happy, warm, calm, curious, sad, uneasy, angry), the groups and their words, default valence and intensity on every entry, blends, aliases, and the rule that re-filed the first wheel's feelings (v11). Read by `store/` to validate the `feelings` table. **Added 2026-09-25; v2 2026-09-30.** |
32
32
  | *(`leaving.ts`)* | — (a table) | What counts as having left: every `archived_reason` the code writes, filed `replaced` (a live row carries it — a revision, a merge, a rebuilt journal copy), `let-go` or `removed`. The `status` census and the dashboard's archive words both read it, so they agree. **Added 2026-09-30.** |
33
33
  | *(observer)* | — (instrument stance) | **RESOLVED (owner, 2026-08-25): a MODE, not a module** — one predicate threaded through the core API, checked at the store seam. Spec moved to `docs/observer-mode.md`. |
34
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -20,13 +20,14 @@
20
20
  ],
21
21
  "type": "module",
22
22
  "engines": {
23
- "bun": ">=1.3.0"
23
+ "bun": ">=1.3.0",
24
+ "node": ">=22.15.0"
24
25
  },
25
26
  "bin": {
26
- "counterparts": "./src/adapters/cli/bin/counterparts.ts",
27
- "counterparts-hook": "./src/adapters/claude-code/bin/hook.ts",
28
- "counterparts-mcp": "./src/adapters/mcp/bin/serve.ts",
29
- "counterparts-dashboard": "./src/adapters/dashboard/bin/dashboard.ts"
27
+ "counterparts": "./src/adapters/cli/bin/counterparts.mjs",
28
+ "counterparts-hook": "./src/adapters/claude-code/bin/hook.mjs",
29
+ "counterparts-mcp": "./src/adapters/mcp/bin/serve.mjs",
30
+ "counterparts-dashboard": "./src/adapters/dashboard/bin/dashboard.mjs"
30
31
  },
31
32
  "main": "./src/core/counterpart.ts",
32
33
  "types": "./src/core/counterpart.ts",
@@ -64,6 +65,7 @@
64
65
  },
65
66
  "scripts": {
66
67
  "test": "bun test",
67
- "typecheck": "tsc --noEmit"
68
+ "typecheck": "tsc --noEmit",
69
+ "test:node": "node --import ./src/adapters/node-hooks.mjs --test test/node-smoke.ts"
68
70
  }
69
71
  }
@@ -254,8 +254,10 @@ row, saying which source answered, existed until the keys were removed — §1a.
254
254
  later hook process needs: which configuration was read, whether the first-launch
255
255
  question went out, the wake's sentinel and whether its arrival has been checked, the
256
256
  model that last answered — which the `chapter` tool records per chapter), Stop
257
- refreshes the clock — creating the record when it is missing — and SessionEnd closes
258
- it. The writes
257
+ refreshes the clock — creating the record when it is missing — UserPromptSubmit
258
+ refreshes it too but never creates one (2026-10-01: so a session idle past the TTL
259
+ is live again before its model's first call; a missing record stays the off→on
260
+ signal), and SessionEnd closes it. The writes
259
261
  are atomic (temp + rename), tiny, and silent on failure, because a hook may not fail
260
262
  the host (G2) and SessionEnd's hooks share 1.5 s between them. It exists because this
261
263
  host launches its MCP servers from a static configuration and cannot tell them which
@@ -610,6 +612,21 @@ line is claimed once a day across sessions (`dream_asks`), and again only for a
610
612
  behind (a dream begun and quiet for 30 minutes, or — `auto` — a launch no dream followed),
611
613
  at most twice a day.
612
614
 
615
+ **[M] Only a session someone can see claims the day's told lines (2026-10-01, lane 8, a
616
+ working default).** `hooks.ts#isInteractive`: the host's own `CLAUDE_CODE_SESSION_ATTENDED`
617
+ (`1` / `0`) decides when it is set; otherwise a session whose `entrypoint` is one of
618
+ `sessions.ts#NON_INTERACTIVE_ENTRYPOINTS` (`sdk-cli` is `claude -p`; the SDKs; `mcp`; the
619
+ GitHub action) claims none of them — the dream line, a night run's hand-back, a carried
620
+ share, a raised contradiction, plain reminders (at SessionStart and at a prompt), the update
621
+ notice. An unknown or absent value is a person's. It may still START the day's headless run
622
+ (`startUnwatched`); the line it would have been told is held (`Dreams#holdTold`) and the next
623
+ interactive prompt says it while the run is still going, claimed at delivery (`claimHeld`,
624
+ an event latch per run) — once the run has ended its hand-back tells what it did instead. An
625
+ `ask` is left unclaimed for the next interactive session. Every day's line now tells the
626
+ model to say it ONCE, in its first reply, as one plain sentence (`dream/#sayOnce`); the
627
+ terminal line is the extra. Measured that morning: the day's first prompt came from an SDK
628
+ session with no terminal, which started the run (fine) and claimed the line nobody saw.
629
+
613
630
  **[M] The writer moved out of the wake and into the run (2026-09-28).** The SessionStart ask
614
631
  that handed the first session of a day the day just gone (S2's session mode, 2026-09-20) is
615
632
  RETIRED, and with it its deferral (`no-room`), its contest with the first-launch question
@@ -687,6 +704,27 @@ child's own host-minted session is QUIET (`HookInput.nightRun`, from
687
704
  lines, plain reminders, Stop ask, write-up pointer or first-launch question. It still wakes
688
705
  with the ordinary wake.
689
706
 
707
+ **[M] The morning catch-up runs first (2026-10-01, wake build 3 — held lightly).** A `night`
708
+ run (never a reflection-alone one) writes up owed stretches, in ANY directory, before it
709
+ composes its launch prompt (`night-catch-up.ts#runCatchUp`): every session that owes a
710
+ write-up a person's conversation left (`sessions.ts#pointable`), oldest stretch first,
711
+ bounded by `NIGHT_WRITE_UP_SESSIONS` (4) and `NIGHT_WRITE_UP_BYTES` (96 KB, whole parts;
712
+ the first part always). Its runner is a session id of its own, `writeup-<run>`: the
713
+ launcher writes the grant on the runner's record (`grantWriteUps`) and claims every subject
714
+ (`WriteUpProgress.claim`, with `upTo` the last part allowed tonight) before a SECOND
715
+ `claude -p` starts, pinned to that runner, locked down like the first but with
716
+ `--allowedTools` exactly `mcp__counterparts__session_end`, `NIGHT_WRITE_UP_MAX_TURNS` (40)
717
+ and its own watchdog `NIGHT_WRITE_UP_MS` (10 minutes). When it ends, whatever became of it,
718
+ the claims are let go, the grant withdrawn and the runner's record ended; one durable row
719
+ (`adapter.night.writeup`: granted, written, parts, left owed, over the bound, busy elsewhere,
720
+ state) and a process-log line record it, and doctor's Nightly run and Write-ups lines read
721
+ it. Nothing owed: no child, no row. The run's row carries the catch-up's time on its
722
+ watchdog, so a run still going is not read as lost. A clean exit that stopped short of
723
+ its allowance — some granted session neither written up nor brought to its `upTo` part —
724
+ is recorded `partial`, not `done` (a usage limit exits 0 too; its output is not read); a
725
+ bounded night that did every part it was allowed is `done`. A runner record a killed process left open is ended at the
726
+ next run's start (`endStaleRunners`).
727
+
690
728
  **[M] The person sees it, and a run that cannot do its job falls back to asking.** The prompt
691
729
  hook's `systemMessage` carries "dreaming in the background (a few minutes). Say "no dreams"
692
730
  to turn it off." when the envelope has room (the model's line never claims it was shown).
@@ -718,6 +756,10 @@ did not get.
718
756
  longer the reported injection budget) → plain reminders due today (they wait for the
719
757
  first prompt, unclaimed) → the wake, which is never cut at delivery: it was composed to
720
758
  its own budget at the boundary, trimming hints → craft → threads → horizon → identity.
759
+ The clock line rides with the wake — and, in Desktop's Code tab only (entrypoint
760
+ `claude-desktop`, 2026-10-01), one line under it naming the session id to pass as
761
+ `session`, because there the counterparts tools are Desktop's server
762
+ (`hooks.ts#codeTabSessionLine`; mcp CONTRACT G21). A terminal session's wake is unchanged.
721
763
  A reminder reaches the person only in the JSON form, so when one is due and it fits
722
764
  beside the wake in that form, the two asks are measured against THAT form (escaped,
723
765
  under 9,500) and it is they that give way (review of #285, S2). A wake too full for the
@@ -1880,3 +1880,20 @@ Working defaults, held lightly.
1880
1880
  nightly run's planner still live here; a host that starts either from the MCP server
1881
1881
  needs their paths, not an import. `deliverWriteUpAsk`'s default limit is still this
1882
1882
  host's `HOST_OUTPUT_CHARS`; a tool result has no such cap and should pass its own.
1883
+
1884
+ ## 2026-10-01 — the day's lines reach a session someone can see (lane 8, build 4)
1885
+
1886
+ An SDK session (`claude -p`, `entrypoint: sdk-cli`, ~/general) sent the day's first prompt at
1887
+ 09:00: it started the nightly run and claimed the once-a-day line, which nobody saw. Now
1888
+ `isInteractive` gates every told line (dream line, hand-back, carried share, raised
1889
+ contradiction, plain reminders, update notice). A headless session still starts the run
1890
+ (`startUnwatched`) and holds its line (`Dreams#holdTold`); the next interactive prompt says it
1891
+ if the run is still going, claimed at delivery (`claimHeld`, `deliverTurn`'s `held` branch,
1892
+ stripped from the model's context when the claim is lost). The model is told to say the line
1893
+ once in its first reply, one plain sentence. Not gated: the doctor notice (it returns at the
1894
+ next start) and the write-up pointer (a headless session can do a write-up).
1895
+
1896
+ Review of #313: Claude Code exports `CLAUDE_CODE_SESSION_ATTENDED` to the processes it
1897
+ starts. Measured in a terminal session's child: `1`, beside `CLAUDE_CODE_ENTRYPOINT=cli`. Not
1898
+ measured under `claude -p`. When the variable says `1` or `0` it decides `isInteractive`; the
1899
+ entrypoint list is the fallback when it is absent or unreadable (`bin/hook.ts#attendedOf`).
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ ':' //; if command -v bun >/dev/null 2>&1; then exec bun "$0" "$@"; elif command -v node >/dev/null 2>&1; then exec node "$0" "$@"; else echo "counterparts: needs Bun 1.3+ or Node 22.15+ on PATH" >&2; exit 127; fi
3
+ // A shell script and an ES module at once: the line above is a no-op string to
4
+ // JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node).
5
+ // See `adapters/launch.mjs`.
6
+ import { launch } from "../../launch.mjs";
7
+
8
+ await launch(new URL("./hook.ts", import.meta.url));
@@ -56,6 +56,7 @@ import {
56
56
  } from "../standdown.js";
57
57
  import type { SaysSoHook, StandDownFault } from "../standdown.js";
58
58
  import { readTranscript } from "../transcript.js";
59
+ import { scriptArgs } from "../../runtime.js";
59
60
 
60
61
  /**
61
62
  * The host's own spellings of the two events that carry a notice — one
@@ -403,6 +404,9 @@ export function toHookInput(
403
404
  ...(isEntrypoint((opts.env ?? process.env)["CLAUDE_CODE_ENTRYPOINT"])
404
405
  ? { entrypoint: (opts.env ?? process.env)["CLAUDE_CODE_ENTRYPOINT"] as string }
405
406
  : {}),
407
+ // IS SOMEONE THERE (2026-10-01, lane 8): the host's own word, when it
408
+ // gives one, ahead of the entrypoint list (`hooks.ts#isInteractive`).
409
+ ...attendedOf((opts.env ?? process.env)["CLAUDE_CODE_SESSION_ATTENDED"]),
406
410
  // THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
407
411
  // hook's rows, the wake preface, the prospective "today" and the date the
408
412
  // boundary hands the lived clock — which is why the lived clock can see a
@@ -716,8 +720,8 @@ async function runHook(
716
720
  const toLog = (e: LogEvent): void => log?.event(e);
717
721
  const adapter = openAdapter(config, {
718
722
  command: process.execPath,
719
- args: ["run", RUNNER_PATH],
720
- nightArgs: ["run", NIGHTLY_PATH],
723
+ args: scriptArgs(RUNNER_PATH),
724
+ nightArgs: scriptArgs(NIGHTLY_PATH),
721
725
  // WHICH FILE THIS RUN READ, carried into the adapter so it can be RECORDED:
722
726
  // a hook cannot print to the owner (its stdout is the model's context), so
723
727
  // the answer goes into the session registry record and the event ring
@@ -826,6 +830,15 @@ async function runHook(
826
830
  opened.end(outcome);
827
831
  }
828
832
 
833
+ /** `CLAUDE_CODE_SESSION_ATTENDED` as `HookInput.attended`: `1`/`true` and
834
+ * `0`/`false`; anything else says nothing. */
835
+ export function attendedOf(raw: string | undefined): { attended?: boolean } {
836
+ const v = (raw ?? "").trim().toLowerCase();
837
+ if (v === "1" || v === "true") return { attended: true };
838
+ if (v === "0" || v === "false") return { attended: false };
839
+ return {};
840
+ }
841
+
829
842
  /** The two adapter doors `deliverTurn` needs — structural, so a test can
830
843
  * hand it doors that throw. */
831
844
  export interface UpdateNoticeDoors {
@@ -843,6 +856,12 @@ export interface UpdateNoticeDoors {
843
856
  * line is not shown and waits for a later prompt.
844
857
  */
845
858
  claimDream?(input: HookInput, offer: DreamOffer): boolean;
859
+ /**
860
+ * Claim a HELD dream line — a run a session nobody watched started — this
861
+ * delivery is certainly about to show (`ClaudeCodeAdapter#claimHeld`,
862
+ * 2026-10-01). Absent: nothing can be claimed, so it waits.
863
+ */
864
+ claimHeld?(input: HookInput, run: string): boolean;
846
865
  /** Claim the one-time line about `auto` set back to `ask` (`ClaudeCodeAdapter#claimDreamNote`). */
847
866
  claimDreamNote?(input: HookInput): boolean;
848
867
  /**
@@ -936,7 +955,13 @@ export function deliverTurn(
936
955
  const probe = hostDelivery(name, r, payload, [...(ordered ?? []), told.notice]);
937
956
  let showDream = false;
938
957
  if (probe.dropped === null) {
939
- if (told.offer === null) showDream = true;
958
+ if (told.held !== undefined) {
959
+ try {
960
+ showDream = doors.claimHeld?.(input, told.held) ?? false;
961
+ } catch {
962
+ showDream = false;
963
+ }
964
+ } else if (told.offer === null) showDream = true;
940
965
  else {
941
966
  try {
942
967
  showDream = doors.claimDream?.(input, told.offer) ?? false;
@@ -949,7 +974,7 @@ export function deliverTurn(
949
974
  gaveWay(doors, input, "dream", 1);
950
975
  }
951
976
  if (showDream) ordered = [...(ordered ?? []), told.notice];
952
- else if (told.offer !== null) r = withoutDream(r);
977
+ else if (told.offer !== null || told.held !== undefined) r = withoutDream(r);
953
978
  }
954
979
  // THE ONE-TIME RESET LINE (owner decision A), under the same rule.
955
980
  const note = r.dreamNote;
@@ -59,6 +59,7 @@ async function main(): Promise<void> {
59
59
  scope: pinnedScope() ?? "",
60
60
  kind: readKind(process.env[NIGHT_KIND_ENV]),
61
61
  configPath: choice.path,
62
+ onEvent: log.event,
62
63
  });
63
64
  log.end(out.state, {
64
65
  run: out.run,