counterparts 0.2.0 → 0.3.1

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 (118) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +87 -367
  3. package/docs/QUICKSTART.md +83 -1584
  4. package/docs/README.md +86 -0
  5. package/docs/module-map.md +1 -0
  6. package/package.json +6 -2
  7. package/src/adapters/claude-code/CONTRACT.md +153 -19
  8. package/src/adapters/claude-code/INTERFACE-GAPS.md +138 -2
  9. package/src/adapters/claude-code/NOTES.md +508 -0
  10. package/src/adapters/claude-code/bin/hook.ts +223 -49
  11. package/src/adapters/claude-code/bin/runner.ts +221 -101
  12. package/src/adapters/claude-code/config.ts +202 -279
  13. package/src/adapters/claude-code/doctor.ts +822 -427
  14. package/src/adapters/claude-code/embed-client.ts +165 -557
  15. package/src/adapters/claude-code/hooks.ts +414 -116
  16. package/src/adapters/claude-code/index.ts +8 -59
  17. package/src/adapters/claude-code/page-writer.ts +24 -4
  18. package/src/adapters/claude-code/spawn.ts +6 -7
  19. package/src/adapters/claude-code/standdown.ts +12 -1
  20. package/src/adapters/claude-code/transcript.ts +282 -15
  21. package/src/adapters/claude-code/vectors.ts +108 -24
  22. package/src/adapters/cli/CONTRACT.md +123 -3
  23. package/src/adapters/cli/INTERFACE-GAPS.md +49 -2
  24. package/src/adapters/cli/NOTES.md +265 -1
  25. package/src/adapters/cli/bin/counterparts.ts +9 -9
  26. package/src/adapters/cli/commands.ts +525 -438
  27. package/src/adapters/cli/help.ts +22 -27
  28. package/src/adapters/cli/index.ts +0 -2
  29. package/src/adapters/cli/install.ts +102 -89
  30. package/src/adapters/cli/removal.ts +1 -1
  31. package/src/adapters/cli/report.ts +25 -2
  32. package/src/adapters/cli/snapshot.ts +4 -27
  33. package/src/adapters/cli/uninstall.ts +182 -34
  34. package/src/adapters/cli/wire.ts +232 -35
  35. package/src/adapters/dashboard/INTERFACE-GAPS.md +18 -2
  36. package/src/adapters/dashboard/activity.ts +4 -1
  37. package/src/adapters/dashboard/bin/dashboard.ts +1 -1
  38. package/src/adapters/dashboard/registries.ts +16 -1
  39. package/src/adapters/dashboard/resolve.ts +4 -4
  40. package/src/adapters/dashboard/source.ts +8 -2
  41. package/src/adapters/dashboard/web/flow.ts +6 -0
  42. package/src/adapters/dashboard/web/narrate.ts +66 -14
  43. package/src/adapters/dashboard/web/reveal.ts +6 -6
  44. package/src/adapters/dashboard/web/views.ts +12 -4
  45. package/src/adapters/fired.ts +130 -19
  46. package/src/adapters/mcp/CONTRACT.md +73 -1
  47. package/src/adapters/mcp/INTERFACE-GAPS.md +54 -1
  48. package/src/adapters/mcp/NOTES.md +389 -0
  49. package/src/adapters/mcp/bin/serve.ts +28 -35
  50. package/src/adapters/mcp/deliberate.ts +22 -0
  51. package/src/adapters/mcp/index.ts +30 -2
  52. package/src/adapters/mcp/server.ts +429 -49
  53. package/src/adapters/mcp/tools.ts +32 -7
  54. package/src/adapters/mcp/write-up.ts +454 -0
  55. package/src/adapters/sessions.ts +1370 -0
  56. package/src/adapters/snapshots.ts +71 -39
  57. package/src/core/associate/INTERFACE-GAPS.md +8 -0
  58. package/src/core/counterpart.ts +88 -14
  59. package/src/core/embed/CONTRACT.md +85 -0
  60. package/src/core/embed/NOTES.md +93 -0
  61. package/src/core/embed/static.ts +622 -0
  62. package/src/core/encode/INTERFACE-GAPS.md +29 -0
  63. package/src/core/encode/NOTES.md +78 -0
  64. package/src/core/encode/secrets.ts +309 -9
  65. package/src/core/handoff/INTERFACE-GAPS.md +15 -1
  66. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  67. package/src/core/recall/CONTRACT.md +15 -3
  68. package/src/core/recall/INTERFACE-GAPS.md +100 -0
  69. package/src/core/recall/NOTES.md +49 -0
  70. package/src/core/recall/activate.ts +37 -3
  71. package/src/core/recall/index.ts +22 -1
  72. package/src/core/recall/session.ts +32 -0
  73. package/src/core/recall/tunables.ts +99 -2
  74. package/src/core/remember/CONTRACT.md +51 -7
  75. package/src/core/remember/INTERFACE-GAPS.md +121 -1
  76. package/src/core/remember/NOTES.md +221 -1
  77. package/src/core/remember/index.ts +28 -0
  78. package/src/core/remember/owes.ts +532 -0
  79. package/src/core/remember/owner-strike-seam.ts +34 -2
  80. package/src/core/remember/proposals.ts +25 -6
  81. package/src/core/remember/retention.ts +154 -0
  82. package/src/core/remember/spans.ts +53 -12
  83. package/src/core/remember/tunables.ts +8 -0
  84. package/src/core/remember/write-up-seam.ts +104 -0
  85. package/src/core/schemas/INTERFACE-GAPS.md +8 -0
  86. package/src/core/schemas/NOTES.md +118 -1
  87. package/src/core/schemas/index.ts +330 -40
  88. package/src/core/schemas/tunables.ts +23 -0
  89. package/src/core/schemas/types.ts +64 -1
  90. package/src/core/self/CONTRACT.md +19 -13
  91. package/src/core/self/INTERFACE-GAPS.md +18 -1
  92. package/src/core/self/NOTES.md +137 -1
  93. package/src/core/self/calendar.ts +81 -0
  94. package/src/core/self/episodes.ts +201 -38
  95. package/src/core/self/identity.ts +2 -2
  96. package/src/core/self/index.ts +96 -21
  97. package/src/core/self/tunables.ts +18 -46
  98. package/src/core/self/writer.ts +58 -9
  99. package/src/core/sleep/NOTES.md +36 -0
  100. package/src/core/sleep/cycle.ts +30 -1
  101. package/src/core/sleep/fade.ts +76 -0
  102. package/src/core/sleep/index.ts +4 -1
  103. package/src/core/sleep/prune.ts +8 -1
  104. package/src/core/sleep/tunables.ts +5 -0
  105. package/src/core/sleep/types.ts +24 -0
  106. package/src/core/store/CONTRACT.md +26 -1
  107. package/src/core/store/NOTES.md +348 -0
  108. package/src/core/store/cache.ts +585 -27
  109. package/src/core/store/db.ts +97 -0
  110. package/src/core/store/errors.ts +7 -0
  111. package/src/core/store/index.ts +612 -13
  112. package/src/core/store/operational.ts +107 -11
  113. package/src/core/store/paths.ts +15 -1
  114. package/src/core/store/pre-migration.ts +256 -0
  115. package/tools/install-loop/run.sh +52 -71
  116. package/src/adapters/claude-code/credentials.ts +0 -199
  117. package/src/adapters/claude-code/interpret-client.ts +0 -395
  118. package/src/adapters/cli/keys.ts +0 -503
package/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1 — unreleased
4
+
5
+ A small release of fixes. No change to the store's format, so no migration and no
6
+ Reconnect.
7
+
8
+ - **Cards for people, places and the identity core are no longer archived after about
9
+ 90 days of use** (#215). The nightly cleanup was treating them like ordinary memories.
10
+ They now fade only through a gentle phase of their own: months of quiet on both the
11
+ lived and the calendar clock (180 days, 365 for people), never while beliefs still
12
+ hang on them, and never the identity core. Nobody's store is old enough to have been
13
+ hit, which is why this ships now.
14
+ - **A faded card comes back when a saved memory names it** (#220), and **a card named
15
+ in a saved memory counts as used** (#218), so the people and things you still talk
16
+ about stay live.
17
+ - **Prompts typed while Claude is still working are saved** (#213). They were missed
18
+ before, about one typed prompt in twelve.
19
+ - **A checked snapshot is taken before any change to the store's format** (#214). If the
20
+ copy can't be made, the change waits. `doctor` shows a store that needs one: red when
21
+ the copy can't be made, amber when it can.
22
+ - **Each journal chapter records the model that wrote it** (#217).
23
+ - **`counterparts fired` and `doctor` show fading** as a mechanism of its own.
24
+
25
+ ## 0.3.0 — 2026-09-24
26
+
27
+ No API keys: nothing leaves the machine except through Claude Code. A quieter end-of-turn
28
+ ask, paced by what you type. `counterparts ask` searches by meaning.
package/README.md CHANGED
@@ -1,405 +1,125 @@
1
1
  # Counterparts
2
2
 
3
- **An AI that keeps its own memory of working with you — written in its own words, kept on
4
- your machine, and allowed to forget.**
3
+ **Agents are great. What you're missing is a counterpart.**
5
4
 
6
- Counterparts gives Claude Code a memory of you and your work. At the end of a stretch of
7
- work the assistant writes down what it *learned*, in the first person, and that
8
- interpretation is what gets kept. It all stays on your machine, in one small SQLite
9
- database you can read, back up, or export as Markdown whenever you want.
5
+ Counterparts gives your AI assistant its own memory, modeled on human memory. It writes
6
+ its memories itself, and they fade and grow the way yours do. It runs today with
7
+ [Claude Code](https://claude.com/claude-code).
8
+
9
+ [counterparts.ai](https://counterparts.ai)
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).
14
+
13
15
  ```
14
- curl -fsSL https://bun.sh/install | bash # only if you don't have bun
16
+ curl -fsSL https://bun.sh/install | bash # if you don't have bun
15
17
  bun add -g counterparts
16
18
  counterparts
17
19
  ```
18
20
 
19
- Check the middle line landed first: `counterparts --version` prints `counterparts 0.2.0`.
20
- Then the bare command, with nothing set up, offers to do the rest — *No memory here yet.
21
- Set it up now? [Y/n]*. `counterparts install` asks for the same conversation by name and is
22
- also the repair: it is safe to run again. Nothing in it is compulsory:
23
-
24
- - **your name** — what the memory calls you; Enter skips it;
25
- - **Claude Code, connected for you.** It keeps a backup of your `~/.claude/settings.json`
26
- and says so, adds five hooks **beside** any hooks belonging to other tools, and registers
27
- the memory server. `counterparts disconnect` takes all of that back out and names the
28
- backup file; `--no-connect` means don't; no Claude Code on the machine is one line and
29
- the install carries on;
30
- - **two optional API keys**, one at a time. Each is a `[y/N]` question with one line on
31
- what it buys — Enter is no — and only a yes shows the link and takes the key, typed
32
- hidden. **Skipping both is a supported way to run** — what you give up is written down,
33
- not glossed over.
34
-
35
- Then **restart Claude Code** (the memory tools arrive when a session starts) and check that
36
- it *works*:
21
+ `counterparts` walks you through setup: your name and connecting Claude Code. No API
22
+ keys. Then restart Claude Code and check it:
37
23
 
38
24
  ```
39
25
  counterparts doctor
40
26
  ```
41
27
 
42
- Two checks, two moments: `--version` says the program is there, `doctor` says it is
43
- running. Green is fine. **OFF** is one of the two optional things you never turned on — a
44
- dim line, not a fault. Amber is worth a look; red is a part that is not running, and the
45
- only grade that makes it exit non-zero.
28
+ To remove it, run `counterparts uninstall`. Your memory is kept unless you ask for it
29
+ to be deleted. The full walkthrough is in [`docs/QUICKSTART.md`](docs/QUICKSTART.md).
46
30
 
47
- **To remove it:**
31
+ ![The dashboard](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-overview.png)
48
32
 
49
- ```
50
- counterparts uninstall
51
- ```
33
+ ## What it does
52
34
 
53
- That disconnects Claude Code, **keeps your memory**, and names the one line that removes
54
- the package itself. `--park` sets the whole `~/.counterparts` folder aside under a dated
55
- name in one rename — and `counterparts install` finds it there and offers to bring it
56
- back. `--delete-memories` destroys it instead, after listing every path with its size and
57
- asking you to type `DELETE MEMORIES`; Esc, Enter or `cancel` at that prompt stops and says
58
- nothing was deleted. Neither happens unless you ask for it.
59
-
60
- The whole install path, with every flag and every reason:
61
- [`docs/QUICKSTART.md`](docs/QUICKSTART.md) — §1 to §5 is all of it, and everything below
62
- its "Reference" line is detail.
63
-
64
- **You need [bun](https://bun.sh) 1.3 or newer**, and nothing else. Counterparts ships as
65
- TypeScript sources and runs them directly — no build step, no `dist/`. **Node is
66
- untested**; the [Status](#status-honestly) section is specific about what has been verified
67
- and what has not.
68
-
69
- <!-- Images are produced by the dashboard workstream and land under docs/images/.
70
- The URLs are absolute so this file reads correctly from the npm tarball as
71
- well as from GitHub, and so the install loop's link check does not demand a
72
- file that does not exist yet. -->
73
- ![overview](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-overview.png)
74
- *Overview (a synthetic demo store — no real memory appears in any screenshot here).*
75
-
76
- ![flow](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-flow.png)
77
- *Flow — the architecture, alive. A memory just typed at the console is arriving through the authored door, and only a real event ever moves anything here; the panel holds one mechanism (sleep, here), its brain analogy, and where that analogy deliberately breaks (the same synthetic store).*
78
-
79
- ![brain](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-brain.png)
80
- *Brain view — the same machinery mapped to a rough anatomy; regions flash on real events (same synthetic store).*
81
-
82
- ---
83
-
84
- ## Why
85
-
86
- Every model you talk to is frozen. The only learning it does is what fits in its context
87
- window, and memory is what decides what goes in there. Most memory tools answer that by
88
- storing the transcript; this one stores the interpretation instead, and lets it fade —
89
- unused memories decay the way human memories do. What survives is a small, structured
90
- account of your work together, plus a "who I have been" the AI reads at the start of
91
- every session.
92
-
93
- **No API keys are required.** With none, two things are off. Recall runs on its text
94
- channel alone rather than also matching by meaning; an embedding key buys the other half —
95
- and it stays off by default even when a key is present, because embedding means sending
96
- memory text to a third party, which should be a decision rather than something a stray
97
- environment variable switches on. And the crash-recovery path — the one that reconstructs
98
- a session that ended before the AI could write it up — cannot run; when it does run, it
99
- sends that captured conversation to a model provider. Both are the only two ways anything
100
- here leaves your machine, and both are yours to turn on. `counterparts doctor` grades a
101
- store that has never had a key **OFF** — dim, optional, never turned on — rather than red
102
- or amber, and says on the line what works without one, so a fresh keyless install reads as
103
- a clean bill of health and not as an alarm.
104
-
105
- **It works with no host at all.** `$HOME/.counterparts/store` is the default data dir, so
106
- this works with nothing set:
35
+ - **It writes its own memories.** At the end of a session it writes down what it
36
+ learned, in its own words. Notes, not transcripts.
37
+ - **It forgets on purpose.** Memories fade unless they come up again. What matters
38
+ sticks; the rest lets go.
39
+ - **It knows who it has been.** Every session opens with a short "who I am, who you are,
40
+ where we left off" that it wrote itself.
41
+ - **It keeps a journal.** Each session becomes a chapter in a first-person account of
42
+ your time together.
43
+ - **It changes its mind slowly.** What it believes about you shifts only under real
44
+ evidence, and it keeps the history of what it used to think.
45
+ - **Things come to mind.** As you talk, related memories surface quietly, the way one
46
+ thing reminds you of another.
47
+ - **It's yours.** Everything lives on your machine in one SQLite file you can read,
48
+ export or delete. No API keys, no accounts, nothing sent anywhere.
107
49
 
108
- ```
109
- counterparts note "The espresso machine in the kitchen is a Rancilio Silvia."
110
- counterparts ask "what espresso machine is in the kitchen?"
111
- ```
50
+ ## Who it's for
51
+
52
+ People interested in giving an AI its own sense of self and building a relationship
53
+ with it over time. Tinkerers, researchers, writers, and anyone who talks to an assistant
54
+ every day and wishes it remembered.
55
+
56
+ ## What it's not
57
+
58
+ It's not a work memory. It doesn't track your tasks, code conventions or project docs.
59
+ Plenty of tools do that, including the memory built into ChatGPT and Claude.
112
60
 
113
- That works on the very first memory — a store holding one memory answers the question
114
- about it — and the install loop checks that case on every run.
61
+ ## Where it's going
115
62
 
116
- **The hooks are registered once, globally**, so every directory you open a session in is
117
- remembered by default. `counterparts scope . --off` says otherwise for one directory —
118
- `--observer` for reads-only, `--pause` for an afternoon, `--resume` to put it back — and
119
- the first session in a directory nobody has answered for asks you which you want.
120
- QUICKSTART §8 has the rest.
63
+ Today's models are frozen, so memory is the only learning they do. Once a real memory
64
+ works on top of a frozen model, the plan is to pair it with an open-weight model whose
65
+ weights can change, so the AI can learn and grow, not just remember.
121
66
 
122
- **Starting over is one command.** If you want a blank memory — to see what a new user
123
- sees, or because the first few days of a store are mostly you learning what it does —
124
- close every Claude Code session and run:
67
+ ## Using it
68
+
69
+ Once installed it runs on its own. A few commands are worth knowing:
125
70
 
126
71
  ```
127
- counterparts start-fresh --config ~/.counterparts/claude-code.json
72
+ counterparts dashboard # look at the memory in your browser
73
+ counterparts ask "..." # ask the memory a question
74
+ counterparts scope . --off # don't remember this directory
75
+ counterparts export # a copy of everything, encrypted by default
76
+ counterparts --help # the rest
128
77
  ```
129
78
 
130
- It renames your store beside itself as `store.parked-<today>` with a single atomic
131
- rename, does the same with the snapshots folder, and creates a blank store back at the
132
- same path. **It never copies, never deletes, and never opens the old store — not even
133
- read-only.** Your configuration and your credentials are kept byte for byte, so there is
134
- nothing to re-register; restart Claude Code and you are a new user. `--dry-run` prints
135
- every rename and changes nothing, `counterparts start-fresh --undo` puts it all back, and
136
- the same three moves are printed as guarded shell lines before anything moves.
137
- QUICKSTART §9a has the whole of it.
138
-
139
- ---
79
+ Memory is on for every directory by default. The first session in a new directory asks
80
+ whether you want it there.
140
81
 
141
82
  ## How it works
142
83
 
143
- One brain function per module, each self-contained, each with a `CONTRACT.md` beside it
144
- saying what it keeps, what it drops, and what it guarantees. The core knows nothing about
145
- any particular AI tool.
84
+ Two pieces connect it to Claude Code. Hooks load a briefing at the start of each session
85
+ and bring up related memories as you talk. A small MCP server gives the AI tools to save
86
+ what it learned, write a journal entry, and look things up.
87
+
88
+ The core doesn't depend on Claude Code. Each part is its own module, with a
89
+ `CONTRACT.md` describing what it does:
146
90
 
147
91
  | module | what it does |
148
92
  |---|---|
149
- | **store** | The filing cabinet. One small SQLite database holds the memories themselves — their words, their earlier versions and everything the system knows about them — with a throwaway cache beside it for search indexes that can always be rebuilt, a readable Markdown copy of the journal written as each chapter lands, and a rotating daily snapshot. `counterparts export --markdown` writes everything out as a tree of Markdown files; nothing reads any of those copies back. |
150
- | **physics** | One page of arithmetic: how strong a memory is, how fast it fades, what a use reinforces, how much pressure it takes to revise a belief. No opinions and no model calls. |
151
- | **encode** | The bouncer at the door. Redacts credentials, refuses junk, scores how new and how important each memory is on the way in. |
152
- | **remember** | The front door. Takes what the AI writes at the end of a session and in the moment; keeps a transcript sweep as the crash fallback. |
153
- | **recall** | The nudge in the ear. Turns what you just said into cues, activates related memories, and rides a few along as quiet footnotes — rarely loudly. |
154
- | **associate** | The web between memories. Things that come up together get linked, and activation spreads along the links. |
155
- | **schemas** | What the AI believes about people and things. Beliefs are revised only under accumulated pressure, and revisions keep their history. |
156
- | **self** | The autobiography: identity, an episode journal the AI writes in chapters, and the briefing every session starts with. |
157
- | **prospective** | Intentions for the future, cued by a date or by a context. |
158
- | **sleep** | Overnight housekeeping. Fades, prunes, promotes, merges duplicates, re-renders tomorrow's briefing. Pure arithmetic, no model calls, and it never touches the journal. |
159
-
160
- **The AI is the author.** The constitution puts it plainly: everyone stores the
161
- transcripts, and the signal is somewhere else. So the writing is done by the model that
162
- lived the conversation, not by a summarizer reading it afterwards. There are two halves on
163
- the host. The *ambient* half is a set of hook scripts Claude Code runs at five
164
- points in a session: it injects the briefing at the start, runs recall against each of
165
- your prompts, and captures the conversation at the boundaries. The *deliberate* half is a
166
- Model Context Protocol (MCP) server — tools the AI calls on purpose, including the two it
167
- uses to hand back what a session taught. A transcript sweep exists as well, but it is the
168
- **crash fallback only**: it runs for a session that ended without the AI ever getting the
169
- pen, and not otherwise.
170
-
171
- ---
172
-
173
- ## What you get on the host
174
-
175
- **Five tools the AI can call** (`src/adapters/mcp/tools.ts` — each tool's description is
176
- generated from a list of stated privileges, each naming the file that enforces it):
177
-
178
- | tool | its job |
179
- |---|---|
180
- | `note` | Remember this deliberately — the exception, for the thing you would otherwise hope the sweep noticed. |
181
- | `recall` | Deliberate retrieval: expand one memory by its handle, ask a question and get excerpts, or pull a few results back in full. |
182
- | `status` | The census: how much is held, of what kinds, how much has left, how much was removed. Counts and dates only. |
183
- | `session_end` | Hand back what this session taught, as memories, in the AI's own words. |
184
- | `chapter` | Write this stretch of the session into the AI's own first-person journal, at any length. |
185
-
186
- **Your console** — `counterparts <command>`. `counterparts --help` is fourteen commands in
187
- three groups (Everyday, Setup, Your data), one line each; `counterparts help <command>` is
188
- the detail for one; `counterparts help advanced` is the maintenance and developer half —
189
- `note`, `fired`, `init`, `start-fresh`, `verify`, `rebrief`, the repairs, `probe-oq4`, and
190
- the three flags that work everywhere. `counterparts --version` opens nothing.
191
- Read-only: `ask` (the listed spelling of what the MCP tool still calls `recall`), `status`,
192
- `doctor` (the one troubleshooting command, QUICKSTART §12), `fired`, `self-page` and
193
- `probe-oq4` (the footnote-header probe, recall CONTRACT §7). `verify` is a census of the
194
- search cache against the real state, and `--rebuild` is what rebuilds it — which is why
195
- `verify` counts as a write and refuses under `--observer` even without the flag. `export`
196
- is a read too: it copies the store — as one SQLite file, or, with `--markdown`, as a
197
- readable tree of one file per memory plus the journal and the self page — encrypted under a
198
- passphrase or explicitly `--plaintext`, because it refuses to choose for you. `--markdown`
199
- omits confidential memories unless you pass `--include-confidential`, and says how many it
200
- left out. The rest write: `install`, `init`, `connect`, `disconnect`, `uninstall`,
201
- `credentials set`, `note`, `backup`, `start-fresh`, `backfill-claims`,
202
- `repair-merged-beliefs` (a dry run unless you pass `--apply`), `rebrief`, and `remove` —
203
- which at a terminal asks for an id or for words, numbers what it finds, lets you pick one
204
- or several, shows the plan and asks once; `--confirm` is the scripted door, and anywhere
205
- nobody can be asked it prints the plan and changes nothing. Pass
206
- `--observer` to any of them and the console stands down: everything is read-only, and the
207
- commands that would write refuse instead.
208
-
209
- **The dashboard** — read-only, writing nothing, ever. `counterparts dashboard` starts the
210
- local **web** dashboard on the store your configuration names — no `--dir` to get right —
211
- prints `http://127.0.0.1:4747`, opens your browser, and stops on Ctrl-C. Bound to 127.0.0.1
212
- only, it is where the screenshots above come from: an overview, memories, mind, flow and
213
- health, plus a `/brain` view. The `counterparts-dashboard` binary is still there for the
214
- five terminal views — `status` (the brain at a glance), `browse` (memories by strength),
215
- `stories` (per contested belief, the pressure log as a story), `identity` and `activity` —
216
- and for `serve --dir <store> [--port <n>]`, where `--dir` is not optional: without it,
217
- `serve` refuses rather than opening the default store, names the store it would have
218
- opened, and `--default-store` is how you say you meant it.
219
-
220
- ---
221
-
222
- ## Status, honestly
223
-
224
- **First published on npm on 2026-09-21, as `counterparts@0.1.0`.** This is **0.2.0** — one
225
- round of polish after the author installed that first release the way a stranger would,
226
- and wrote down everything that was rough about it.
227
-
228
- **It is the author's own daily memory under Claude Code.** Feature-complete 2026-08-25;
229
- running beside him every day since 2026-09-03. On 2026-09-21 he parked the store that had
230
- grown over those weeks, installed the published package from npm, and started again on a
231
- blank memory — so the *store* he is running is new and the *code* is what has been
232
- exercised daily for a month.
233
-
234
- **2026-09-22 — the trial, and the round it produced.** The author took 0.2.0 as a tarball
235
- into a plain terminal, with no Claude Code session and no help: swap the package, `--help`,
236
- `doctor`, `uninstall --delete-memories` with the wrong phrase typed on purpose (refused,
237
- nothing changed), `uninstall --park`, then `install` again. Every step did what the sheet
238
- in front of him said it would, so what came back was not bugs but **words** — eleven of
239
- them, written down as findings 17–27 in the repository's new-user-findings page and
240
- answered one at a time. Six pull requests followed the same day (#170–#175), two of them
241
- adversarially reviewed by a second agent first — the reviews are comments on PRs #170 and
242
- #173, not files in this repository — and each review found a blocker: `remove` had been
243
- deciding "is anybody there" from stdin alone, so a redirected stdout turned a dry run into
244
- a live deletion; and `install --force` at a terminal silently replaced `claude-code.json`,
245
- which on the new path could throw away a configuration a park had just handed back. Both
246
- were fixed before merge.
247
-
248
- **The test suite, measured 2026-09-22 on this branch under bun 1.3.10:** `bun test` →
249
- **3,182 pass, 0 fail, nothing skipped**, around 41,000 assertions across 51 files, 80
250
- seconds. The install loop runs 58/58. (The assertion count moves by a few hundred between
251
- runs — a few tests assert once per row of data they generate — while the pass and fail
252
- counts do not.)
253
- No test touches a real store, and that is mechanized rather than promised:
254
- `test/preload.ts` runs before every test file, redirects `homedir()` to a fresh temporary
255
- directory for the whole run, clears `COUNTERPARTS_DATA_DIR`, and removes the directory on
256
- exit — so for the length of a test run there is no real home to reach.
257
-
258
- **The install loop, and what it cannot settle.** `tools/install-loop/run.sh` installs this
259
- package the way a stranger would — from a tarball it packs itself, into a throwaway home
260
- directory with no copy of this repository on its PATH — and runs 58 checks in about five
261
- seconds: the store, the config, the credentials file, the hook fed a real payload, a note
262
- and an `ask` on the console and again through the MCP server, the lazy session bind, the
263
- scope switch, and the host's own files (`connect` merging beside another tool's hooks,
264
- `disconnect` taking only ours back out, `uninstall` leaving the memory alone). It also runs
265
- every console command on the QUICKSTART page verbatim, grepping each one out of the page
266
- first, so a doc edit that changes a command fails the loop.
267
- **What it cannot do**: reach the npm registry (it installs from disk), run `git clone`,
268
- launch Claude Code, or run the real `claude mcp add` — a stub answers. And it runs
269
- non-interactively, so the install conversation above is covered by unit tests and one run
270
- on a real pty, not by the loop.
271
-
272
- **Node is untested.** The store binds `bun:sqlite` under bun and `node:sqlite` under Node
273
- (22.5+ behind a flag, 23.4+ by default), but nobody has run this package under any Node,
274
- so it claims nothing there. `package.json` names bun and does not claim Node.
275
-
276
- **Verified inside real Claude Code sessions**, on the author's machine: the hooks fire on
277
- all five events, the MCP server registers and its tools are used daily, the briefing
278
- reaches the model, and both `backup` and — in September 2026, with a one-shot tool this
279
- repository no longer carries — the import of the author's previous-generation memory ran
280
- against the real store. **There is no bulk import today.** A store this build writes starts
281
- blank, and what comes over from an earlier generation is its own later conversation.
282
- **Verified only against temporary stores**: `export` in all three modes, `remove` end to
283
- end (which is also where the residue in rough edge 4 was found, and where the chase that
284
- closed it is asserted — note, remove, grep the whole store, back it up and grep that), and
285
- the console's and dashboard's behaviour on a missing store. **Not verified at
286
- all**: anything under Node, and — until you do it — a stranger installing from this
287
- documentation on a machine that is not the author's.
288
-
289
- **Known rough edges.** QUICKSTART §11 carries the install-facing ones — 1 as its §11.3, 2
290
- as its §11.4, and 4 as its §11.6 with a reproduction (and in §7, where `remove` is run). 3 lives in QUICKSTART §6,
291
- where the embedder knob is set, and 5 in §1 with the runtime requirements:
292
-
293
- 1. **The store you point at and the host settings you get come from two different files —
294
- so you have to move both.** Your console, the dashboard and the MCP server take `--dir`
295
- or `COUNTERPARTS_DATA_DIR` to choose the store; the keys, the embedding setting and the
296
- injection ceiling come from a configuration file, and moving one does not move the
297
- other. A scratch store on a configured machine uses that machine's keys unless you say
298
- otherwise. Saying otherwise is one rule at every entry point — the console, the hook,
299
- its worker and the MCP server: `--config <absolute path>`, else `COUNTERPARTS_CONFIG`,
300
- else the default `~/.counterparts/claude-code.json` (the console looks beside the store
301
- first). A named path this cannot use — relative, or absolute and not there — is
302
- refused rather than quietly replaced by the default, and each entry point says
303
- which file it used: the console prints it, the server and the
304
- worker write a line to stderr, and the hook — whose only output channel belongs to the
305
- model — records it in the session file it writes under the store. The hooks keep the
306
- one asymmetry that is left: they have no `--dir`, so they take the store from the
307
- `dataDir` in whichever configuration they read, and fall back to
308
- `COUNTERPARTS_DATA_DIR` only when it names no store. (The two API keys are the other
309
- way round everywhere: the environment answers first and the credentials file only fills
310
- the gaps.)
311
- 2. **The vector cache stores embeddings as JSON text.** On the author's migrated store
312
- that is 177.5 MB for about 13,900 vectors, and a nearest-neighbour scan of 0.6–1.0 s.
313
- Irrelevant to a fresh store; a named debt.
314
- 3. **An embedding key alone does nothing.** You must also turn the knob on, deliberately.
315
- Since 2026-09-22 that is a command rather than a JSON edit: `counterparts credentials
316
- set VOYAGE_API_KEY`, typed at a terminal, saves the key and then asks whether to turn
317
- recall-by-meaning on with it (`--embedder` at install does the same, and
318
- `"embedder": { "enabled": true }` in the configuration is still what both of them
319
- write). Absent that, no client is built and no connection opens whatever keys are lying
320
- around — which is the point: a pipe, `--from-env` and CI are asked nothing and turn on
321
- nothing.
322
- 4. **Removal reaches every surface but one, and names the one.** `remove` chases a memory
323
- out of the database that holds its words and its earlier versions, out of the links, out
324
- of the search cache, out of the journal's markdown copy — and, since 2026-09-05, out of
325
- the raw-capture buffer under `spans/` (a 12-hex key per project, not the path), where a
326
- note's verbatim words wait to be interpreted. That last one was a real residue: found
327
- 2026-09-04, a removed note's words stayed on disk and a later backup copied them.
328
- The buffer is a chased surface now, counted in the plan and in the report, and the
329
- struck span's hash is kept in the buffer's own ledger so the same words cannot be
330
- re-captured. Three things it names rather than takes, each on its own line: a
331
- conversation turn that merely QUOTES the note (transcript, many turns joined,
332
- belonging to no single memory — and **nothing prunes the buffer today**, so a `grep`
333
- of the store can still answer while the memory itself is gone); a memory whose words
334
- are already gone AND whose mint recorded no span hash, which has nothing left to
335
- address the buffer with; and a memory whose provenance records no scope — every row
336
- imported from a previous generation — where a chase by text would have to visit every
337
- project on the machine, so the command lists what it would have matched and stops
338
- unless you pass `--strike-by-content-across-scopes`.
339
- 5. **Node.** See above. `package.json` names bun and does not claim Node.
340
-
341
- Nothing here is benchmarked against other memory systems. There is no benchmark score and
342
- no comparison table, because nobody has run one, and a number nobody ran is the thing this
343
- project is least willing to print.
344
-
345
- ---
346
-
347
- ## Design principles
348
-
349
- Condensed from `CONSTITUTION.md`, which is the only document in this repository with
350
- standing authority. Everything else, including decisions made during the build, is a
351
- working default that can be revised when it fights that page.
352
-
353
- - **Memory is how a frozen model learns.** Everyone stores the transcripts; the signal is
354
- in the structure of experience — what recurred, what carried feeling, what got revised.
355
- - **Interpret, don't transcribe.** Store what was learned, not what was said, encoded as
356
- close to the lived experience as the host allows.
357
- - **Forgetting is part of learning.** Forget the trials, keep the lesson. Decay and
358
- consolidation are features, never apologized for.
359
- - **The self is first-class.** Identity, episodes, a persistent "who am I becoming" —
360
- governed and visible to you, not a configuration field.
361
- - **You own the data.** Local-first, one portable file, every memory viewable — in the
362
- console, in the dashboard, or as Markdown you ask for. Data leaves the machine only by
363
- your explicit choice.
364
- - **A layer, not a portal.** The memory is yours and travels across tools and models; the
365
- core knows nothing about any particular one.
366
- - **Evidence over ceremony.** Mechanisms earn their place by firing in real use. Verified
367
- live, not merged. Tests are hermetic. And the system shows its workings — if you cannot
368
- see what it remembered and what faded, it isn't trustworthy.
369
-
370
- ---
371
-
372
- ## Lineage
373
-
374
- Counterparts is the third generation of one continuous project, and each generation was
375
- used in earnest before the next was written.
376
-
377
- - **v0 — claude-engram**, a single React artifact. It had the authorship shape right: the
378
- model that lived the conversation wrote the memory, and a one-line formula did the
379
- filing.
380
- - **engram**, the production ancestor, which contributed the first eight hard-won failure
381
- cases that this repository carries as acceptance criteria.
382
- - **v1 — bansai**, the full system this one distills: its behavioral specification, its
383
- earned mechanisms, its test spine and twenty more of those failure cases. It ran as the
384
- author's live memory until Counterparts took over.
385
-
386
- The rule across all three generations is one of the constitution's own: **"port the scars,
387
- not the code."** A lesson travels forward as a test that has to pass, never as copy-paste.
388
-
389
- ---
93
+ | store | One SQLite database, plus a rebuildable search cache and daily snapshots |
94
+ | encode | Filters what comes in: strips credentials, drops junk, scores what's new |
95
+ | remember | Takes what the AI writes during and at the end of a session |
96
+ | recall | Finds related memories as you talk |
97
+ | associate | Links memories that come up together |
98
+ | schemas | Beliefs about people and things, revised slowly |
99
+ | self | Identity, the journal, and the start-of-session briefing |
100
+ | prospective | Reminders for later, triggered by a date or a topic |
101
+ | sleep | Nightly housekeeping: fading, pruning, merging, promoting |
102
+ | physics | The math for strength and decay |
390
103
 
391
- ## License and contributing
104
+ More: [`docs/ELI5.md`](docs/ELI5.md) (the whole system in plain words) and
105
+ [`docs/module-map.md`](docs/module-map.md).
392
106
 
393
- **MIT.** See `LICENSE`. Copyright (c) 2026 Mike LaPeter.
107
+ ## Status
394
108
 
395
- **Not open to contributions yet.** There is no contributor agreement and no process, and
396
- it would be dishonest to invite pull requests into a codebase that is still changing
397
- week to week. Issues and questions are welcome. When contributions open, this section will
398
- say so.
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
111
+ [open an issue](https://github.com/mlapeter/counterparts/issues) when you hit one.
399
112
 
400
- ## Read next
113
+ There are no API keys, and nothing leaves your machine except through Claude Code
114
+ itself. Search by meaning runs on a small model on your machine, and a session that ends
115
+ before it's written up is written up by the next session in that project.
116
+
117
+ ## Background
118
+
119
+ Counterparts is the third version of a memory project. The earlier ones (claude-engram,
120
+ engram, and bansai) were each used daily before the next was written.
121
+ [`CONSTITUTION.md`](CONSTITUTION.md) holds the principles.
122
+
123
+ ## License and contributing
401
124
 
402
- - [`docs/QUICKSTART.md`](docs/QUICKSTART.md) — the one canonical install path.
403
- - [`docs/ELI5.md`](docs/ELI5.md) — the whole system in plain words, in one page.
404
- - [`CONSTITUTION.md`](CONSTITUTION.md) — the only page with standing authority.
405
- - [`docs/module-map.md`](docs/module-map.md) — the technical map, module by module.
125
+ MIT. Contributions are welcome; see [`CONTRIBUTING.md`](CONTRIBUTING.md).