counterparts 0.3.8 → 0.3.10

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 (93) hide show
  1. package/CHANGELOG.md +254 -0
  2. package/docs/module-map.md +14 -5
  3. package/package.json +3 -1
  4. package/src/adapters/claude-code/CONTRACT.md +40 -13
  5. package/src/adapters/claude-code/INTERFACE-GAPS.md +12 -13
  6. package/src/adapters/claude-code/NOTES.md +31 -0
  7. package/src/adapters/claude-code/bin/hook.ts +2 -2
  8. package/src/adapters/claude-code/bin/runner.ts +3 -3
  9. package/src/adapters/claude-code/doctor.ts +185 -3
  10. package/src/adapters/claude-code/embed-client.ts +1 -1
  11. package/src/adapters/claude-code/hooks.ts +112 -1376
  12. package/src/adapters/claude-code/index.ts +5 -5
  13. package/src/adapters/claude-code/night-run.ts +8 -6
  14. package/src/adapters/cli/CONTRACT.md +19 -1
  15. package/src/adapters/cli/commands.ts +103 -7
  16. package/src/adapters/cli/coverage.ts +16 -2
  17. package/src/adapters/cli/desktop.ts +181 -0
  18. package/src/adapters/cli/export.ts +4 -2
  19. package/src/adapters/cli/help.ts +8 -0
  20. package/src/adapters/cli/install.ts +16 -10
  21. package/src/adapters/cli/report.ts +2 -0
  22. package/src/adapters/cli/uninstall.ts +1 -1
  23. package/src/adapters/{claude-code/config.ts → config.ts} +26 -4
  24. package/src/adapters/dashboard/registries.ts +4 -4
  25. package/src/adapters/dashboard/web/README.md +2 -2
  26. package/src/adapters/dashboard/web/actions.ts +4 -0
  27. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +4 -3
  28. package/src/adapters/dashboard/web/narrate.ts +8 -5
  29. package/src/adapters/dashboard/web/pages/memories/fold.js +6 -1
  30. package/src/adapters/dashboard/web/pages/memories/sections/list.js +1 -1
  31. package/src/adapters/dashboard/web/shared/memory-marks.js +13 -7
  32. package/src/adapters/dashboard/web/shared/widgets/feel-radar.js +2 -2
  33. package/src/adapters/dashboard/web/views/archive-words.ts +36 -22
  34. package/src/adapters/dashboard/web/views/core-road.ts +2 -1
  35. package/src/adapters/dashboard/web/views/memories.ts +3 -3
  36. package/src/adapters/dashboard/web/views/mind.ts +1 -1
  37. package/src/adapters/expansions.ts +4 -3
  38. package/src/adapters/feelings-line.ts +9 -5
  39. package/src/adapters/fired.ts +6 -6
  40. package/src/adapters/hosts.ts +185 -0
  41. package/src/adapters/lifecycle.ts +1616 -0
  42. package/src/adapters/mcp/CONTRACT.md +86 -9
  43. package/src/adapters/mcp/INTERFACE-GAPS.md +17 -10
  44. package/src/adapters/mcp/NOTES.md +109 -11
  45. package/src/adapters/mcp/bin/serve.ts +86 -3
  46. package/src/adapters/mcp/deliberate.ts +405 -7
  47. package/src/adapters/mcp/index.ts +21 -2
  48. package/src/adapters/mcp/server.ts +754 -80
  49. package/src/adapters/mcp/tools.ts +148 -23
  50. package/src/adapters/mcp/write-up.ts +78 -14
  51. package/src/adapters/scopes.ts +9 -1
  52. package/src/adapters/sessions.ts +300 -12
  53. package/src/adapters/snapshots.ts +1 -1
  54. package/src/adapters/{claude-code/spawn.ts → spawn.ts} +13 -3
  55. package/src/core/associate/pending.ts +1 -1
  56. package/src/core/counterpart.ts +235 -38
  57. package/src/core/coverage/CONTRACT.md +2 -1
  58. package/src/core/coverage/NOTES.md +11 -0
  59. package/src/core/coverage/index.ts +146 -4
  60. package/src/core/dream/index.ts +13 -6
  61. package/src/core/dream/reflect.ts +10 -4
  62. package/src/core/feelings-wheel.ts +395 -239
  63. package/src/core/handoff/CONTRACT.md +123 -28
  64. package/src/core/handoff/NOTES.md +145 -1
  65. package/src/core/handoff/index.ts +590 -115
  66. package/src/core/handoff/last-here.ts +230 -0
  67. package/src/core/leaving.ts +77 -0
  68. package/src/core/physics/CONTRACT.md +20 -2
  69. package/src/core/physics/NOTES.md +25 -0
  70. package/src/core/physics/index.ts +43 -11
  71. package/src/core/recall/CONTRACT.md +82 -4
  72. package/src/core/recall/NOTES.md +222 -1
  73. package/src/core/recall/activate.ts +251 -18
  74. package/src/core/recall/feeling-ask.ts +258 -0
  75. package/src/core/recall/gate.ts +15 -3
  76. package/src/core/recall/index.ts +75 -2
  77. package/src/core/recall/mood.ts +52 -24
  78. package/src/core/recall/recency-ask.ts +164 -0
  79. package/src/core/recall/tunables.ts +36 -2
  80. package/src/core/self/NOTES.md +10 -0
  81. package/src/core/self/episodes.ts +5 -2
  82. package/src/core/self/index.ts +23 -1
  83. package/src/core/sleep/consolidate.ts +56 -12
  84. package/src/core/sleep/cycle.ts +8 -0
  85. package/src/core/sleep/index.ts +1 -0
  86. package/src/core/sleep/types.ts +10 -0
  87. package/src/core/store/CONTRACT.md +12 -7
  88. package/src/core/store/NOTES.md +88 -0
  89. package/src/core/store/cache.ts +1 -1
  90. package/src/core/store/feelings.ts +120 -43
  91. package/src/core/store/index.ts +51 -2
  92. package/src/core/store/operational.ts +152 -3
  93. package/src/core/types.ts +17 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,259 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.10 — 2026-09-30
4
+
5
+ Feelings now sit on a new wheel of seven cores — happy, warm, calm, curious, sad,
6
+ uneasy, angry — and every feeling already recorded is re-filed onto it. A feeling
7
+ written under a core is kept under that core, and every word carries default numbers,
8
+ so a note can name just the word. Several sessions working in one directory each keep
9
+ their own handoff now, and the wake says who left each one. A new session's wake has a
10
+ "Last here" line naming the latest chapter written in this directory, and asking "what
11
+ do you remember from our most recent session?" leads with that session. Every recall
12
+ result says which session it came from. **The store's format changes, v10 → v11, and a
13
+ pre-migration copy is taken.**
14
+
15
+ **The format change, and why every session must be closed.** The first Counterparts
16
+ process to open the store for writing after installing copies it (as every upgrade since
17
+ 0.3.1 has) and upgrades it. Usually that is a Claude Code hook, even the next prompt in a
18
+ session left open. With only Claude Desktop, it is Desktop's memory server as it starts,
19
+ or, if Desktop was left running, the background worker its next chat starts. The upgrade
20
+ adds three
21
+ columns to `feelings` (`valence`, and `core_v10` / `emotion_v10`) and re-files every
22
+ recorded feeling onto the seven cores. A re-filed row keeps its old core and word beside
23
+ it, and nothing else in the store changes. Until the upgrade, `counterparts doctor` and
24
+ the dashboard can't read the store (a v10 store is older than they read) and say so.
25
+ **Close every Claude Code session before installing, and if you have connected Claude
26
+ Desktop, quit it.** A v11 store can't be opened by 0.3.9: anything of 0.3.9's that opens
27
+ it afterwards refuses at once (`SCHEMA_AHEAD`), and its hooks stand down. A memory server
28
+ that was already running keeps 0.3.9's code with the store already open. Its tools
29
+ re-read the format on every call and refuse ("Counterparts was updated and this server
30
+ is still running the old version, so this tool did nothing."), ending with `/mcp` →
31
+ Reconnect in Claude Code and "Quit and reopen Claude Desktop" in Desktop. The hooks are
32
+ fresh processes at every event, so they run the new code at once. To go back to 0.3.9
33
+ you reinstall it and put back the copy the upgrade took; anything remembered since is
34
+ lost.
35
+
36
+ The feelings wheel, v2 (#301).
37
+
38
+ - **Seven cores: happy, warm, calm, curious, sad, uneasy, angry**, in 37 groups,
39
+ 180 words in all (a group's name is a word too). Every word from the first wheel, its additions and aliases, and
40
+ every word a counterpart has recorded in its own words has a home. Recognition is a
41
+ group under curious (also warm). Guilt sits under uneasy, disgust is a word under
42
+ angry, and hopeful is under happy.
43
+ - **Every word carries default numbers**: a valence (−1 to +1) and an intensity (0 to
44
+ 1). On `note` and `session_end`, `core` and `strength` may be left out: a feeling with
45
+ no core takes its word's home core, and a feeling with no strength takes the word's
46
+ intensity, capped at 0.55. A `valence` may be given to override the word's. A strength
47
+ you give is never changed.
48
+ - **The writer's core is kept.** A word named under a core it doesn't sit under is
49
+ stored under the core the writer chose, with nothing reported as moved. (0.3.9 moved
50
+ it to the word's home and said so.) A first-wheel core name (`fear`, `anger`,
51
+ `surprise`, `disgust`) sent by a session or dream still running is filed the way the
52
+ upgrade files it, and comes back as a `core` repair.
53
+ - **The upgrade re-files every feeling.** fear → uneasy; anger and disgust → angry; sad
54
+ stays sad, except guilty, remorseful and ashamed → uneasy. Rows under happy and
55
+ surprise, and `other` words under them, go by the word: to its home core, unless the
56
+ word can also be written under the old core (bittersweet under happy stays happy). A
57
+ word off the wheel stays happy under happy and goes to curious under surprise. Each
58
+ re-filed row keeps its old pair. It runs once. Doctor prints what moved ("Upgrade to
59
+ v11: feelings use seven cores now … N of M recorded feelings re-filed (…), each keeping
60
+ its old core beside it").
61
+ - **What a feeling does, by its valence.** How high a feeling holds a memory is
62
+ unchanged. How fast that hold softens now depends on valence: a negative feeling's hold
63
+ softens fastest (angry about 16 days), a positive one's slowest (happy and warm about
64
+ 26). Mood matching compares valence instead of core, and a low mood meeting a low
65
+ feeling counts a quarter as much, so a low mood can't feed itself.
66
+ - **Recognition reaches the core's fast lane.** An unmarked memory carrying the
67
+ counterpart's own recognition feeling (at least 0.6, felt in a session) counts as about
68
+ itself for the fast lane only; a mark still wins, and the slow lane still needs one.
69
+ Doctor counts it ("Recognition").
70
+ - **Readers.** The dashboard's radar, chips and dots show the seven cores in seven
71
+ colours, warm pink and angry red ("dislike" for "disgust" is gone; disgust is a word
72
+ under angry). In recall, a
73
+ stamp also answers to its group's word, so "when was I afraid" still reaches scared.
74
+ The dream and reflection prompts name the seven cores.
75
+
76
+ Handoffs, one per session (#295).
77
+
78
+ - **Each session in a directory keeps its own live handoff.** Writing again revises your
79
+ own; another session's write makes a new one beside it. Until now the last session to
80
+ end wrote over the others.
81
+ - **The wake shows every live handoff here, newest first, and who wrote each** (the
82
+ session's short id and model, "this session" for your own). With several, a count line,
83
+ up to three one-line entries, the older ones by id, and how to retire one.
84
+ - **Retiring.** `handoff: ""` retires only your own. `session_end` takes
85
+ `retireHandoff: [ids]` to retire any handoff in this directory, whoever wrote it. A
86
+ `handoff` write returns `others`, the other sessions' live handoffs here, so finished
87
+ ones can go in the same call.
88
+ - **Claude Desktop:** a `session_end` with no session named can't leave or retire a
89
+ handoff (`session-unnamed`); the rest of the call goes through.
90
+
91
+ Continuity (#300, #302).
92
+
93
+ - **"Last here" on the wake.** In a directory where a session wrote a chapter within the
94
+ fortnight, the wake says which session it was, its model, when it ran and the
95
+ chapter's title and first sentence. It is read from what is already stored, so chapters
96
+ written before this release show at once. A finished session needs no handoff for it.
97
+ - **The handoff pointer says how far the work since is written up**: "written up to
98
+ 17:50 (chapter), 3 pieces after" instead of "not yet written up" when a chapter or a
99
+ memory covers part of it.
100
+ - **A question about time leads with this directory's last session.** "What do you
101
+ remember from our most recent session?", "where did we leave off", "this evening" and
102
+ the like bring that session's latest chapter first, then the memories it wrote, newest
103
+ first, each marked `recent`. The rest of the answer is ranked as before.
104
+ - **Every recall result says where it came from**: `from: "session a1b2c3d4, ~/garden,
105
+ 09-30 17:41"`, or "this session". Older rows say less (nothing is backfilled).
106
+ - **A note from before the session was known (#305).** In Claude Code the memory server
107
+ learns which session it serves only at the first `chapter` or `session_end`; a `note`
108
+ before that is filed under no session. Such a note now reads "a session that hadn't
109
+ been identified yet" with its directory and time, never "this session". A question
110
+ about time still brings a finished session's earlier notes back with it when they were
111
+ written here, while that session was at work, and no other session was working here at
112
+ the same moment.
113
+
114
+ Tests only (#303): child processes in the suite get the test's time zone, and two
115
+ fixtures moved, so the suite passes at every hour in any zone. No product change.
116
+
117
+ Not proven here.
118
+
119
+ - Nothing ran on a real store. The re-filing of your own recorded feelings, the writer's
120
+ core on real notes, the softening and mood by valence, and the recognition lane were
121
+ checked on a seeded store and in tests only.
122
+ - The upgrade from Claude Desktop's memory server (a Desktop-only user) was checked over
123
+ stdio with a client that calls itself `claude-ai`, not against the real app.
124
+ - "Last here", the recency lead and handoffs from several sessions were checked with
125
+ driven sessions in one throwaway directory, not across a real day's parallel sessions.
126
+
127
+ ## 0.3.9 — 2026-09-30
128
+
129
+ Counterparts now reaches Claude Desktop's chat: one command connects it, a chat wakes
130
+ with the same memory a Claude Code session does, and each call says which chat it
131
+ belongs to. Underneath, the host-neutral part of a session moved out of the Claude Code
132
+ adapter so a second host could use it; Claude Code behaves as it did, apart from two
133
+ small, deliberate changes. Recall can now answer a question about how something felt,
134
+ and a journal chapter and the memory made from it come back as one. **The store's format
135
+ does not change** (it stays v10), so nothing is copied or upgraded. The hooks run the
136
+ new code at once; a session left open keeps 0.3.8's memory server until it is restarted
137
+ or `/mcp` → Reconnect.
138
+
139
+ Claude Desktop chat.
140
+
141
+ - **`counterparts install --host claude-desktop`** connects Desktop's chat. Quit Claude
142
+ Desktop first: it rewrites its own config file while it runs, and can write over the
143
+ change. The command makes (or keeps) the store and configuration exactly as the
144
+ scripted install does, then merges one `counterparts` entry into Desktop's
145
+ `claude_desktop_config.json`, found under the home directory it was given. The file is
146
+ backed up first, every other server and setting in it is left exactly as it was, and
147
+ a second run changes nothing ("already connected"). The file is written back as
148
+ 2-space JSON, the way Desktop writes it. If it replaces an entry that named a different
149
+ store, it names that store: the memory there is still there. Plain `install` is
150
+ unchanged and doesn't touch Desktop.
151
+ - **The `wake` tool** is Desktop's session start, and only Desktop is offered it. It
152
+ starts a new session (host `claude-desktop`, in the `claude-desktop:` place) and
153
+ returns what a Claude Code session start would: the wake, the clock, today's plain
154
+ reminders, the day's dream line when it is an ask, the update and doctor notices, and
155
+ the write-up pointer, sized for a tool result. It also starts the turn-end worker, as
156
+ the hook does. It doesn't ask the first-launch question and doesn't start the headless
157
+ nightly run. Desktop also lists one prompt, **"Start with Counterparts"**, which asks
158
+ the chat to call `wake` first and keep the session id it gets.
159
+ - **Each call binds to a session, and says when it guessed.** One server serves every
160
+ Desktop chat, and Desktop sends no chat id, so every Desktop tool takes an optional
161
+ `session`. A call that names a live Desktop session is filed under it. A call that
162
+ names none binds to the most recent live Desktop session and says so (`boundTo`,
163
+ `boundBy: "most-recent"`, and one line). A tool that needs a session (`session_end`,
164
+ `chapter`, `dream`, `reflect`) refuses a named id that is unknown or has gone quiet
165
+ (`session-unknown`, `session-not-live`), and never swaps in another; with no live
166
+ session at all it refuses and names `wake`. The other tools (`note`, `recall`,
167
+ `status`, `scope`, `self_page`) run unbound in those cases, as they always could. Only a call that names its session keeps that session alive
168
+ and counts toward its write-up ask; a guessed call moves nothing, because it may belong
169
+ to another chat.
170
+ - **The write-up ask.** After 3 named calls and 20 minutes since the later of the wake,
171
+ the last `session_end` or `chapter`, and the last ask, the next named result carries a
172
+ write-up ask. `session_end` can be called again in the same chat; later calls add to
173
+ what the first one wrote.
174
+ - **Desktop's own place.** `claude-desktop:` is a place, not a folder: `counterparts scope
175
+ claude-desktop: --on` and the other mode flags work on it, the off and paused refusals
176
+ are worded for Desktop, and observer is read on every call, so a change takes effect
177
+ at once. Desktop never takes on the observer setting of the folder the server was
178
+ started in.
179
+ - **Doctor has a Claude Desktop line.** It is quiet when Desktop has no entry, green with
180
+ the last wake and last session when it has one, and amber only when the entry names
181
+ another store.
182
+ - **`counterparts coverage` shows Desktop sessions as unmeasured**: "Claude Desktop: N
183
+ sessions that day — unmeasured: Desktop chat keeps no transcript, so what they did not
184
+ write up cannot be counted (not lost; what was written through the tools is kept)."
185
+ - **A Desktop session may write up a chat that went quiet, only when its launcher grants
186
+ it.** A session's record can carry `mayWriteUp`, the ended sessions it may write up.
187
+ Only a launcher writes it (`sessions.ts#grantWriteUps`); no tool can, and a
188
+ `mayWriteUp` argument is ignored. The subject must be listed, ended, and owed, and its
189
+ memories are filed where it was lived. Nothing in this release grants it yet.
190
+ - **How the server tells the hosts apart.** The client's name at `initialize` decides:
191
+ `claude-ai` (chat) or `local-agent-mode-*` (Cowork) makes it Desktop's. A process whose
192
+ environment carries Claude Code's markers (`CLAUDE_PROJECT_DIR`, `CLAUDECODE`,
193
+ `CLAUDE_CODE_ENTRYPOINT`) was started by Claude Code and stays Claude Code's whatever
194
+ its client says. Any other client gets the handshake, the nine tools and the refusals
195
+ it always got: `wake` is an unknown tool there.
196
+
197
+ Claude Code: two deliberate changes.
198
+
199
+ - **`status` explains `owner: false`.** When the server isn't the owner's,
200
+ `status.stance.ownerMeans` says in one phrase what that means: "owner: false is the
201
+ ordinary setting — confidential memories are left out of this server's answers;
202
+ nothing is wrong."
203
+ - **No scope question in Desktop's scratch folders.** The first-launch scope question is
204
+ skipped in a Code-tab "No folder" workspace
205
+ (`…/Library/Application Support/Claude/scratch-workspaces/…`).
206
+
207
+ The host seam (#292; no change in behaviour).
208
+
209
+ - **The host-neutral part of a session has its own module.** `src/adapters/lifecycle.ts`
210
+ (`HostLifecycle`, `Lifecycle`) holds what any host does at a session's start, turn
211
+ boundary and end: the registry record, the wake, recall and its record, capture, the
212
+ ask pacer, the write-up ask, the worker. The Claude Code adapter extends it, and each
213
+ hook runs the same steps in the same order. `src/adapters/hosts.ts` holds the wording
214
+ that differs by host; Claude Code's strings are byte-identical.
215
+ - `config.ts` and `spawn.ts` moved from `src/adapters/claude-code/` to `src/adapters/`.
216
+ The `./claude-code` export still re-exports everything that moved.
217
+ - **Registry records carry `host`.** A record written before this reads as `claude-code`.
218
+ - **New package exports**: `counterparts/lifecycle` and `counterparts/hosts`.
219
+
220
+ Recall and chapters.
221
+
222
+ - **Recall by feeling, for a deliberate question.** Asked "what have I felt most
223
+ strongly" or "what moved me", the `recall` tool (and `counterparts ask`) answers from
224
+ the feelings recorded on memories, strongest first. Stamps rank the answer only when
225
+ the question is really about a feeling: a feel-word (`feel`, `felt`, `feeling`,
226
+ `emotion`, `mood`), or a feeling word used about a person. Everyday phrasings don't
227
+ trigger it: "the happy path", "moved the parser", "I feel like…", "I moved it to src",
228
+ "is my build open" still work as ordinary words. "I" is whoever asks: the counterpart
229
+ in `recall`, you in `counterparts ask`. "afraid" is now an alias of scared. The
230
+ per-turn recall never opens this path.
231
+ - **A journal chapter and the memory made from it are one result**, and that memory now
232
+ keeps the chapter's title (the next time its chapter grows; nothing is backfilled).
233
+ The chapter is the row shown; credit reaches the copy only when recall showed the
234
+ chapter this session.
235
+ - **`status` counts `replaced` apart from `exited`.** `symmetry.exited` now means only
236
+ what left for good (let go, removed); a revision, a merge, a correction, or a journal
237
+ copy rebuilt when its chapter grew is counted under the new `symmetry.replaced`. A
238
+ store whose chapters keep growing used to read as losing its self-kind memories, so
239
+ **any note comparing `exited` across days sees a step on the day this is installed.**
240
+ - **The dashboard's Ask shows a chapter as its journal entry** (it used to show the
241
+ memory, with a "from chapter …" link), and the questions it rewrites into the
242
+ counterpart's voice ask as the counterpart (`--voiced`): there "I" means the
243
+ counterpart. An exact ask and a typed `counterparts ask` keep you as "I".
244
+
245
+ Not proven here.
246
+
247
+ - Desktop has never run against a real Claude Desktop app. The client names, the
248
+ prompt, the per-call binding and the write-up ask were checked over stdio with a
249
+ client that calls itself `claude-ai`.
250
+ - The Desktop Code tab's environment and client name were never measured live. A Code
251
+ tab session is expected to carry Claude Code's markers and stay Claude Code's.
252
+ - A process that Claude Code did not launch, started in a folder set to observer, opens
253
+ the store writable before `initialize` tells it which host it serves.
254
+ - A Desktop-only user on automatic dreaming gets no dream line: the wake leaves the
255
+ headless run for a Claude Code session to start.
256
+
3
257
  ## 0.3.8 — 2026-09-30
4
258
 
5
259
  When two memories disagree, Claude can now say how: the fact changed, the old one was
@@ -28,7 +28,8 @@ 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
+ | *(`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.** |
32
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`. |
33
34
 
34
35
  **Third open question (check-in): the `remember`/`encode` boundary.** With the
@@ -39,13 +40,21 @@ input — does `encode` shrink to gates-and-tagging inside `remember`'s pipeline
39
40
 
40
41
  | adapter | job |
41
42
  |---|---|
42
- | `claude-code/` | Hooks: wake injection at session start, end-of-session remember, crash detection. The launch adapter. |
43
- | `mcp/` | Deliberate tools: note, recall, status — plus the Stop ask's two return channels, `session_end` (memories) and `chapter` (the episode's own journal, **added 2026-09-04**, because the ask named a door no adapter had built) — and `dream`, the dreamer's phases (**added 2026-09-26**), and `reflect`, the waking self's (**added 2026-09-27**). |
44
- | `cli/` | `counterparts` command: status, install, owner operations (delete, export, backup). |
43
+ | `claude-code/` | Hooks: Claude Code's five events driving the host lifecycle (`lifecycle.ts`, below) — its payload translation, JSON envelope and the room it measures, transcript reader and wake-arrival check, the Stop ask's words, the first-launch question, the update and doctor notices, the dream line, and the headless nightly run (`night-run.ts`, `claude -p`, **2026-09-29**). The launch adapter. |
44
+ | `mcp/` | Deliberate tools, nine: note, recall, status — plus the Stop ask's two return channels, `session_end` (memories, and the next-session write-up's door) and `chapter` (the episode's own journal, **added 2026-09-04**, because the ask named a door no adapter had built) — `scope` (this directory's setting, **2026-09-15**), `self_page` (the page the wake opens with, **2026-09-18**), `dream`, the dreamer's phases (**added 2026-09-26**), and `reflect`, the waking self's (**added 2026-09-27**). A result's words about the host come from `hosts.ts`. For a Claude Desktop client (by its name at `initialize`, **2026-09-30**) a tenth, `wake` — Desktop's session start, since it has no hooks — plus per-call binding to the most recent live Desktop session, the write-up ask on a tool result, and a "Start with Counterparts" prompt; a Claude Code client sees none of it. |
45
+ | `cli/` | `counterparts` command — the full list is `COMMANDS` in `cli/commands.ts`: status, install, connect / disconnect (the host's two files), `install --host claude-desktop` (Desktop's config entry, **2026-09-30**), uninstall, start-fresh, init, owner operations (note, ask, export, backup, remove, verify, repairs, rebrief), the readings (doctor, mechanisms, log, coverage, version, help), scope, self-page, dream, core, settle, and dashboard. |
45
46
  | `dashboard/` | The owner's window (constitution line 16): brain-view, revision stories, band/protected lists. Observer-mode by construction; minimal version ships DURING the parallel run. **Added 2026-08-25 (owner elevation).** |
46
- | `sessions.ts` | Not an adapter — a leaf both may import: the live-session registry a host's hooks write (`<dataDir>/sessions/`) and its tools read, so a tool launched without a session can bind to one that is real, live and in its project. Adapters stay leaves; this is the sibling they share instead of importing each other. **Added 2026-09-04**, because this host's MCP servers are launched from a static config and cannot be told which session they serve. |
47
+ | `sessions.ts` | Not an adapter — a leaf both may import: the live-session registry a host's hooks write (`<dataDir>/sessions/`) and its tools read, so a tool launched without a session can bind to one that is real, live and in its project. Adapters stay leaves; this is the sibling they share instead of importing each other. **Added 2026-09-04**, because this host's MCP servers are launched from a static config and cannot be told which session they serve. Since **2026-09-30** Claude Desktop's MCP server writes its own records here (its `wake`), refreshed per call, and a runner's record can list the ended sessions a launcher granted it to write up (`mayWriteUp`). |
47
48
  | `expansions.ts` | The same shape, for the other direction: the handle-resolution log the MCP `recall` tool writes (`<dataDir>/sessions/expansions.jsonl` — a per-store SALTED hash of the handle (G58), the id it reached or `null` for a refusal, a timestamp, the project) and the boundary's credit pass reads, so an expansion by TITLE credits the memory it actually reached, and a refusal shadows it. **Added 2026-09-15** (LAUNCH-STATUS G50): `recall/reference.ts` credits literal `mem_…` addresses and resolves nothing, so until this the most deliberate act a session had — naming a memory and reading it — earned no credit at all. |
48
49
  | `scopes.ts` | The third shared leaf: the per-directory scope registry (`scopes.json` BESIDE the config, never inside the store, because the hook decides `off` before anything opens) — `on` / `observer` / `off` / `paused`, longest prefix wins, absent-or-unreadable meaning `unset` meaning on. Written by the `counterparts scope` console and the MCP `scope` tool, read by every hook. **Added 2026-09-15** (PR #92, G19): the hooks are registered globally, so until this the only way to say *not here* was a second config file and two environment variables. |
50
+ | `lifecycle.ts` | The host seam (**2026-09-30**): `HostLifecycle`, the interface a host adapter drives, and `Lifecycle`, its one implementation — what a session is to this memory whatever the host: the wake's composition and the registry's expectation of it, plain reminders, recall for a turn, the boundary (capture, the retroactive-capture seal, credit, the orphan tail), the ask's pacing (not its words), the next-session write-up pointer, every registry write, and the worker spawn with its counters. `claude-code/`'s `ClaudeCodeAdapter` extends it. Imports no adapter. |
51
+ | `hosts.ts` | Which host a session lives in (`claude-code` is the default, and what a registry record with no `host` reads as) and the few sentences that depend on it — how to reconnect after an update, what switching the scope does — plus Claude Desktop's: the host name, its pseudo-scope `claude-desktop:` (a name, never resolved as a path), which MCP clients are Desktop, and the Code tab's scratch workspaces. **Added 2026-09-30.** |
52
+ | `config.ts` | The host configuration's shape and reader (`AdapterConfig`, `loadConfig`, `TUNABLES`, capabilities) — read by the hooks, the worker, the console and the MCP server. Moved out of `claude-code/` on **2026-09-30**. |
53
+ | `config-path.ts` | Where every entry point looks for that configuration: `--config`, else `COUNTERPARTS_CONFIG`, else `~/.counterparts/claude-code.json`; a named configuration that cannot be honoured refuses rather than falling back. |
54
+ | `spawn.ts` | The detached worker's plan and start (`planSpawn`, `spawnDetached`): watchdog checked against the staleness window, environment pinned last. Moved out of `claude-code/` on **2026-09-30** so any host's adapter can start the same worker. |
55
+ | `fired.ts` | Which mechanisms have fired and which have gone quiet, read only from the store's rows — `counterparts mechanisms`, the dashboard's panel. Each entry names the module that does the work. |
56
+ | `snapshots.ts` | The daily rotating snapshot and its rotation — the one place this package deletes a copy of the memory, and only what it can prove is a snapshot. |
57
+ | `stance-env.ts` | `COUNTERPARTS_OBSERVER` / `COUNTERPARTS_OWNER`, read the way the explicit-dir guard is, each failing toward less power. |
49
58
  | `log/` | A shared leaf with its own CONTRACT: the process log — one line per allowlisted event (failures, stand-downs, turn ends, write-ups, the night, the wake) from the hook, the worker, the nightly run and the MCP server, to `<dataDir>/sessions/log/<date>.log`, ids and codes only, kept 7 days. Read by `counterparts log` and one doctor line. **Added 2026-09-30**: none of the four processes wired its `onEvent`, so ~270 event names died with their process. |
50
59
 
51
60
  ## Tools (`tools/`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
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": {
@@ -39,6 +39,8 @@
39
39
  "./dashboard": "./src/adapters/dashboard/index.ts",
40
40
  "./sessions": "./src/adapters/sessions.ts",
41
41
  "./scopes": "./src/adapters/scopes.ts",
42
+ "./lifecycle": "./src/adapters/lifecycle.ts",
43
+ "./hosts": "./src/adapters/hosts.ts",
42
44
  "./package.json": "./package.json"
43
45
  },
44
46
  "files": [
@@ -10,6 +10,24 @@ same composer, minus the prospective lane and minus anything protected or confid
10
10
  and this adapter's interpret client put that prompt on the wire until 2026-09-24 (see
11
11
  §1a: the sweep no longer interprets here).
12
12
 
13
+ **Where the parts live (2026-09-30, the host seam).** What a session is to this memory
14
+ whatever the host — the wake's composition and the registry's expectation of it, plain
15
+ reminders, recall for a turn and its row, the boundary (capture, the retroactive-capture
16
+ seal, credit, the orphan tail), the ask's *pacing*, the next-session write-up pointer,
17
+ every registry write, and the worker spawn with its counters — is the shared leaf
18
+ `adapters/lifecycle.ts`: the `HostLifecycle` interface and its one implementation,
19
+ `Lifecycle`. `ClaudeCodeAdapter` **extends** it, so each hook body calls those methods
20
+ where it called its own, in the same order, with the same rows. What stays here is this
21
+ host's: the five event names and their dispatch (`hooks.ts`), the payload translation, the
22
+ JSON envelope and the room it measures (`bin/hook.ts`, `envelope.ts`), the transcript
23
+ reader and the wake-arrival check against it (`transcript.ts`), the Stop ask's words
24
+ (`stopAsk`, `STOP_HUMAN_LINE`), the first-launch question, the parallel run's primacy, the
25
+ update and doctor notices, the dream line and the headless nightly run. The configuration
26
+ (`AdapterConfig`, `loadConfig`) and the worker spawn (`planSpawn`, `spawnDetached`) moved to
27
+ the shared leaves `adapters/config.ts` and `adapters/spawn.ts` the same day; `index.ts`
28
+ still re-exports them. Every registry record the lifecycle writes carries `host:
29
+ "claude-code"` (`sessions.ts#hostOf` reads an absent one the same way).
30
+
13
31
  ## 1a. Keyless (owner, 2026-09-24)
14
32
 
15
33
  The package reads no API key and calls no model API of its own. Removed that day: the
@@ -112,16 +130,19 @@ credential — belongs here, discovered at runtime, never assumed by the core.
112
130
  v1's own assignment file and lets the delivering hooks speak only when that file names the
113
131
  slot v2 occupies; it **fails toward mute** where v1 fails toward inject, so the joint
114
132
  failure state is v1-only rather than two voices or none. Absent flag ⇒ v2 delivers, which
115
- is the ordinary build. The flag, the resolver, and the two durable events are **retired at
116
- PROMOTE** — they are scaffolding for a comparison, not a feature.
133
+ is the ordinary build. The flag, the resolver, and the two durable events were meant to be
134
+ **retired at PROMOTE** — they are scaffolding for a comparison, not a feature. The parallel
135
+ run ended on 2026-09-21 and nothing retired them: they are **still wired**
136
+ (`hooks.ts#deliveryVerdict`, config `parallel`), and inert on every install that does not
137
+ set the flag. Removing them is a separate change.
117
138
  - **The 9,000-byte wake budget is not a constant here or anywhere.** The adapter
118
139
  **discovers or asserts** its host's injection ceiling and reports it as a capability;
119
140
  the core composes to whatever it is told (scar §2.18). v1's number was 90% of one host's
120
141
  cliff, encoded as though it were physiology.
121
- - **Multi-file API-key rotation and per-key cursor bookkeeping are dropped**; credentials
122
- come from one configured source the package owns, not from an inherited shell
123
- environment (scar §2.18: "nothing in the core depends on a tool, file, or environment the
124
- host may not provide"). Settled by the scar.
142
+ - **Multi-file API-key rotation and per-key cursor bookkeeping are dropped** — and since
143
+ 2026-09-24 there are no keys at all (§1a), so there is nothing to rotate and no credential
144
+ source to configure. (Until then credentials came from one configured source the package
145
+ owned, never an inherited shell environment — scar §2.18.)
125
146
  - **Model-seat pins are dropped.** **PROPOSED** — owner call at check-in. Constitution
126
147
  line 2 says which seat runs which job is a design choice, never doctrine, and the model
127
148
  lineup will have moved. What is **kept** is the bake-off *method* (earned-mechanism #20:
@@ -193,9 +214,12 @@ row, saying which source answered, existed until the keys were removed — §1a.
193
214
  checkable values**, never assumed; exceeding one is an event, not silent degradation
194
215
  (scar §2.18).
195
216
  5. **[M] The spawner pins the child's environment last**, so no caller can leak a run into
196
- the wrong store (scar §2.13).
197
- 6. **[M] A long call proves it survives this host's ceilings, once, in this host** —
198
- adapter-level evidence, per scar E3's rescope.
217
+ the wrong store (scar §2.13). (`adapters/spawn.ts` since 2026-09-30, shared so another
218
+ host's adapter can start the same worker.)
219
+ 6. ~~**[M] A long call proves it survives this host's ceilings, once, in this host**~~ —
220
+ **moot since 2026-09-24 (§1a).** The package makes no model call of its own, so there is
221
+ no long call to prove; the headless nightly run is `claude -p` — the host's own call,
222
+ under its own watchdog (`night-run.ts`), not one this adapter streams.
199
223
  7. **[M] Under observer, the boundary appends no span, resolves no references, spawns no
200
224
  worker, and asks for no episode** — and logs that it stood down (scar E7, §2.4).
201
225
  8. **[M] The read cursor is per-session and advances only after a successful append**, and
@@ -422,7 +446,10 @@ row, saying which source answered, existed until the keys were removed — §1a.
422
446
  smuggled past the limit. `SessionRecord.askedScope` is what makes "once" true
423
447
  across a resume or a compaction. The WORDING is advisory; that an unset directory
424
448
  raises the question exactly once and that any recorded mode ends it are the
425
- mechanized parts.
449
+ mechanized parts. Not asked at all in a Claude Desktop Code-tab "No folder"
450
+ scratch workspace (`hosts.ts#isDesktopScratchWorkspace`, 2026-09-30): Desktop
451
+ deletes that directory with the session, and an answer recorded for it would
452
+ outlive the folder it names (event `adapter.scope.ask.skipped`, `scratch-workspace`).
426
453
 
427
454
  22. **[M] TURNING A DIRECTORY BACK ON NEVER REACHES BACK.** A session that lived
428
455
  under `off` or `paused` left no session record and no span cursor, because the
@@ -803,9 +830,9 @@ charter).
803
830
 
804
831
  ## 7. Open questions
805
832
 
806
- 1. **Does the host offer an in-the-moment jot channel at all?** The owner's decision allows
807
- jots "where the host allows"; whether this host does, and at what cost to the turn, is
808
- unmeasured.
833
+ 1. ~~**Does the host offer an in-the-moment jot channel at all?**~~ **ANSWERED.** Not
834
+ through a hook: the jot channel is the MCP adapter's `note` tool (`mcp/CONTRACT.md`),
835
+ which the model calls mid-session; no hook calls `submitJot`.
809
836
  2. **What is the honest bound on the orphanable tail** — the stretch after the last
810
837
  session-ending event nobody can ask about — in this host specifically? v1 bounded it by
811
838
  its re-ask threshold and logged it, which is the right shape; the number is host-local.
@@ -99,9 +99,11 @@ entrance and prove the gate battery covers each (encode's caller-side half)."
99
99
  | `sweepFallback` → apply | `bridge.gateSweepChunk()` (CHUNK level) | `counterpart.ts` `applySweep()` |
100
100
 
101
101
  **Not yet covered, and named so it is not mistaken for covered:** anything an
102
- adapter other than this one adds. `mcp/`, `cli/` and `dashboard/` do not exist
103
- yet; when they do, the table above is the thing to extend, and the totality test
104
- in `test/claude-code.test.ts` is the shape to copy.
102
+ adapter other than this one adds. `mcp/`, `cli/` and `dashboard/` exist now, and
103
+ reach the core through the same `Counterpart` entrances above (the MCP tools
104
+ through `submitSessionEnd`, `submitJot` and `appendEpisode`); an entrance one of
105
+ them adds is the thing to extend this table with, and the totality test in
106
+ `test/claude-code.test.ts` is the shape to copy.
105
107
 
106
108
  ## 5. `kind` defaults in two places (SEAMS queued item 9, still open)
107
109
 
@@ -177,11 +179,9 @@ into the wrapper.
177
179
 
178
180
  ## Host-side gaps — this adapter's own open questions (CONTRACT §7)
179
181
 
180
- 1. **Is there a jot channel in this host?** `Counterpart.captureJot` and
181
- `submitJot` exist and are tested; no hook calls them, because the host offers
182
- no in-the-moment deposit surface this adapter can see. The MCP adapter is the
183
- likely home (`mcp/CONTRACT.md`: note, recall, status). Cost to the turn:
184
- unmeasured.
182
+ 1. **Is there a jot channel in this host? — CLOSED.** Yes, and not through a
183
+ hook: the MCP adapter's `note` tool is the jot channel (`mcp/CONTRACT.md`),
184
+ which the model calls mid-session. No hook calls `submitJot`.
185
185
  2. **The orphanable tail is measured, not bounded by anything host-specific.**
186
186
  `noteOrphanTail` runs on `session-end` and `pre-compact`, and its bound is
187
187
  `self/`'s re-ask thresholds — a memory number, not a host one. The host-local
@@ -195,11 +195,10 @@ into the wrapper.
195
195
  primary path in fact: it ran after every Stop, and on 2026-09-04 one evening's
196
196
  sweeps billed 13 chunks and minted 61 memories beside 34 authored ones.
197
197
  `pre-compact` is still wired and still captures; it is not by itself a crash.
198
- 4. **Long-call survival is asserted, not proven in this host (CONTRACT §5 G6).**
199
- The call streams (scar E3) and `socketLifetimeMs` is a reported capability
200
- with no reporter. The proof G6 asks for — one long call surviving this host's
201
- ceilings, in this host — needs a live run with a real credential, which no
202
- test here is entitled to make.
198
+ 4. **Long-call survival — MOOT since 2026-09-24 (keyless, CONTRACT §1a).** The
199
+ package makes no model call of its own, so there is no long call to prove and
200
+ no credential to prove it with (CONTRACT §5 G6 is struck).
201
+ `socketLifetimeMs` is still a reported capability with no reporter.
203
202
  5. **`executionCeilingMs` has no consumer.** It is reported and checkable; no
204
203
  code compares against it yet, because every foreground path is an appender and
205
204
  the heavy work is already detached. When something in the foreground can grow,
@@ -1849,3 +1849,34 @@ Working defaults, held lightly.
1849
1849
  `start` that runs the worker first).
1850
1850
  - **Delivery.** The delivery check compares each session's wake with the sentinel recorded
1851
1851
  at ITS start, so a session that woke before a rebuild still reads `delivered` (tested).
1852
+
1853
+ ## 2026-09-30 — the host seam (PR A of the host groundwork)
1854
+
1855
+ - **What moved.** The host-neutral half of `ClaudeCodeAdapter` is `adapters/lifecycle.ts`:
1856
+ the `HostLifecycle` interface and its implementation `Lifecycle` — `composeWake` (the
1857
+ wake plus the registry's sentinel), `plainFor` / `claimPlain` / `nowLine`, `recallTurn`
1858
+ (recall plus the `recall.delivered` row), `captureBoundary` (capture, the seal, credit,
1859
+ the `adapter.boundary` row), `noteTail`, `paceAsk` (the pacer and the `adapter.ask` row;
1860
+ the words stay here in `stopAsk`), `deliverWriteUpAsk`, `noteSession`, `spawnWorker` and
1861
+ its counters. `config.ts` and `spawn.ts` became the shared leaves `adapters/config.ts`
1862
+ and `adapters/spawn.ts`. The bodies moved verbatim; only their `this.` receiver changed.
1863
+ - **Extends, not holds.** `ClaudeCodeAdapter extends Lifecycle`. Two tests reach into the
1864
+ adapter by name (`envelope-budget.test.ts` stubs `a.dreamLines`, `write-up.test.ts`
1865
+ binds `a.deliverWriteUpAsk`); a held lifecycle would have made both stubs inert, and a
1866
+ refactor that has to change a test to pass is not a proof of no change.
1867
+ - **What stayed.** The re-fired Stop is refused in `askAtStop` before the pacer is asked
1868
+ (it was the first line of the old `askAtStop`'s try; same effect). The first-launch
1869
+ question, the wake-arrival check, the dream line and the headless nightly run, the
1870
+ update and doctor notices, primacy and every envelope measurement are still here —
1871
+ they are Claude Code's, or not yet needed by a second host.
1872
+ - **On disk.** Every registry record the lifecycle writes now carries `host:
1873
+ "claude-code"`; a record without one reads the same (`sessions.ts#hostOf`). That is the
1874
+ only on-disk change. A neutral config name (`counterparts.json`, read first when present)
1875
+ was built and taken back out before merge: the default path's identity checks
1876
+ (`throwawayDefaultRefusal`, `isNamed`, the console's `=== defaultConfigPath` tests)
1877
+ assume one fixed default, and a default that depends on which files exist let a named
1878
+ config slip past them. Nothing needs the new name yet; the config stays `claude-code.json`.
1879
+ - **Left for the Desktop work (PR B).** The worker script (`bin/runner.ts`) and the
1880
+ nightly run's planner still live here; a host that starts either from the MCP server
1881
+ needs their paths, not an import. `deliverWriteUpAsk`'s default limit is still this
1882
+ host's `HOST_OUTPUT_CHARS`; a tool result has no such cap and should pass its own.
@@ -38,8 +38,8 @@ import { canonicalScope, isEntrypoint, readSession } from "../../sessions.js";
38
38
  import { openLog } from "../../log/index.js";
39
39
  import type { LogEvent, ProcessLog } from "../../log/index.js";
40
40
  import { resolveZone, todayIn } from "../../../core/time.js";
41
- import { TUNABLES, loadConfig, withEmbedderDefault } from "../config.js";
42
- import type { AdapterConfig } from "../config.js";
41
+ import { TUNABLES, loadConfig, withEmbedderDefault } from "../../config.js";
42
+ import type { AdapterConfig } from "../../config.js";
43
43
  import { HOOKS, openAdapter } from "../index.js";
44
44
  import { STOP_HUMAN_LINE, plainLine, withoutDream, withoutDreamNote, withoutPlain } from "../hooks.js";
45
45
  import type { PlainReminder } from "../../../core/counterpart.js";
@@ -90,11 +90,11 @@ import {
90
90
  } from "../../config-path.js";
91
91
  import type { ConfigChoice } from "../../config-path.js";
92
92
 
93
- import { loadConfig, withEmbedderDefault } from "../config.js";
94
- import type { AdapterConfig } from "../config.js";
93
+ import { loadConfig, withEmbedderDefault } from "../../config.js";
94
+ import type { AdapterConfig } from "../../config.js";
95
95
  import { openEmbedder } from "../index.js";
96
96
  import type { LiveEmbedder } from "../embed-client.js";
97
- import { DATA_DIR_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV } from "../spawn.js";
97
+ import { DATA_DIR_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV } from "../../spawn.js";
98
98
  import { backfillVectors, laggedSemantic } from "../vectors.js";
99
99
  import type { BackfillReport, LagReport } from "../vectors.js";
100
100
  import { runSnapshot } from "../../snapshots.js";