counterparts 0.1.0

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 (195) hide show
  1. package/CONSTITUTION.md +68 -0
  2. package/LICENSE +21 -0
  3. package/README.md +348 -0
  4. package/docs/ELI5.md +84 -0
  5. package/docs/QUICKSTART.md +1258 -0
  6. package/docs/module-map.md +81 -0
  7. package/package.json +63 -0
  8. package/src/adapters/claude-code/CONTRACT.md +606 -0
  9. package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
  10. package/src/adapters/claude-code/NOTES.md +1055 -0
  11. package/src/adapters/claude-code/bin/hook.ts +820 -0
  12. package/src/adapters/claude-code/bin/runner.ts +522 -0
  13. package/src/adapters/claude-code/config.ts +778 -0
  14. package/src/adapters/claude-code/credentials.ts +199 -0
  15. package/src/adapters/claude-code/doctor.ts +2557 -0
  16. package/src/adapters/claude-code/embed-client.ts +617 -0
  17. package/src/adapters/claude-code/hooks.ts +2240 -0
  18. package/src/adapters/claude-code/index.ts +224 -0
  19. package/src/adapters/claude-code/interpret-client.ts +395 -0
  20. package/src/adapters/claude-code/page-writer.ts +462 -0
  21. package/src/adapters/claude-code/primacy.ts +162 -0
  22. package/src/adapters/claude-code/spawn.ts +241 -0
  23. package/src/adapters/claude-code/standdown.ts +536 -0
  24. package/src/adapters/claude-code/transcript.ts +661 -0
  25. package/src/adapters/claude-code/vectors.ts +415 -0
  26. package/src/adapters/cli/CONTRACT.md +255 -0
  27. package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
  28. package/src/adapters/cli/NOTES.md +936 -0
  29. package/src/adapters/cli/bin/counterparts.ts +74 -0
  30. package/src/adapters/cli/commands.ts +6095 -0
  31. package/src/adapters/cli/export.ts +766 -0
  32. package/src/adapters/cli/index.ts +103 -0
  33. package/src/adapters/cli/install.ts +670 -0
  34. package/src/adapters/cli/removal.ts +1186 -0
  35. package/src/adapters/cli/repair-dates.ts +659 -0
  36. package/src/adapters/cli/self-page.ts +229 -0
  37. package/src/adapters/cli/snapshot.ts +279 -0
  38. package/src/adapters/cli/start-fresh.ts +1228 -0
  39. package/src/adapters/config-path.ts +342 -0
  40. package/src/adapters/dashboard/CONTRACT.md +67 -0
  41. package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
  42. package/src/adapters/dashboard/NOTES.md +474 -0
  43. package/src/adapters/dashboard/activity.ts +121 -0
  44. package/src/adapters/dashboard/ansi.ts +82 -0
  45. package/src/adapters/dashboard/bin/dashboard.ts +479 -0
  46. package/src/adapters/dashboard/browse.ts +298 -0
  47. package/src/adapters/dashboard/identity.ts +182 -0
  48. package/src/adapters/dashboard/index.ts +183 -0
  49. package/src/adapters/dashboard/layout.ts +149 -0
  50. package/src/adapters/dashboard/registries.ts +291 -0
  51. package/src/adapters/dashboard/resolve.ts +206 -0
  52. package/src/adapters/dashboard/source.ts +48 -0
  53. package/src/adapters/dashboard/status.ts +327 -0
  54. package/src/adapters/dashboard/stories.ts +194 -0
  55. package/src/adapters/dashboard/web/app.html +1731 -0
  56. package/src/adapters/dashboard/web/brain.html +463 -0
  57. package/src/adapters/dashboard/web/fired.ts +31 -0
  58. package/src/adapters/dashboard/web/flow.ts +457 -0
  59. package/src/adapters/dashboard/web/narrate.ts +1042 -0
  60. package/src/adapters/dashboard/web/reveal.ts +135 -0
  61. package/src/adapters/dashboard/web/server.ts +287 -0
  62. package/src/adapters/dashboard/web/views.ts +1744 -0
  63. package/src/adapters/expansions.ts +569 -0
  64. package/src/adapters/fired.ts +1580 -0
  65. package/src/adapters/mcp/CONTRACT.md +240 -0
  66. package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
  67. package/src/adapters/mcp/NOTES.md +205 -0
  68. package/src/adapters/mcp/bin/serve.ts +349 -0
  69. package/src/adapters/mcp/deliberate.ts +619 -0
  70. package/src/adapters/mcp/index.ts +101 -0
  71. package/src/adapters/mcp/protocol.ts +170 -0
  72. package/src/adapters/mcp/server.ts +1740 -0
  73. package/src/adapters/mcp/stdio.ts +56 -0
  74. package/src/adapters/mcp/tools.ts +779 -0
  75. package/src/adapters/scopes.ts +657 -0
  76. package/src/adapters/sessions.ts +402 -0
  77. package/src/adapters/snapshots.ts +1069 -0
  78. package/src/adapters/stance-env.ts +137 -0
  79. package/src/core/associate/CONTRACT.md +118 -0
  80. package/src/core/associate/INTERFACE-GAPS.md +173 -0
  81. package/src/core/associate/NOTES.md +194 -0
  82. package/src/core/associate/buffer.ts +66 -0
  83. package/src/core/associate/edges.ts +188 -0
  84. package/src/core/associate/index.ts +570 -0
  85. package/src/core/associate/pending.ts +383 -0
  86. package/src/core/associate/spread.ts +149 -0
  87. package/src/core/associate/tunables.ts +123 -0
  88. package/src/core/bridge.ts +272 -0
  89. package/src/core/briefing.ts +67 -0
  90. package/src/core/counterpart.ts +3855 -0
  91. package/src/core/encode/CONTRACT.md +151 -0
  92. package/src/core/encode/INTERFACE-GAPS.md +135 -0
  93. package/src/core/encode/NOTES.md +146 -0
  94. package/src/core/encode/aliases.ts +71 -0
  95. package/src/core/encode/battery.ts +284 -0
  96. package/src/core/encode/chunk.ts +265 -0
  97. package/src/core/encode/emotion.ts +119 -0
  98. package/src/core/encode/floor.ts +76 -0
  99. package/src/core/encode/index.ts +100 -0
  100. package/src/core/encode/precision.ts +162 -0
  101. package/src/core/encode/preselect.ts +269 -0
  102. package/src/core/encode/salience.ts +108 -0
  103. package/src/core/encode/secrets.ts +265 -0
  104. package/src/core/encode/tunables.ts +99 -0
  105. package/src/core/encode/types.ts +286 -0
  106. package/src/core/encode/words.ts +75 -0
  107. package/src/core/handoff/CONTRACT.md +199 -0
  108. package/src/core/handoff/INTERFACE-GAPS.md +166 -0
  109. package/src/core/handoff/NOTES.md +206 -0
  110. package/src/core/handoff/index.ts +957 -0
  111. package/src/core/mint.ts +279 -0
  112. package/src/core/observer.ts +28 -0
  113. package/src/core/physics/CONTRACT.md +341 -0
  114. package/src/core/physics/NOTES.md +155 -0
  115. package/src/core/physics/clock.ts +51 -0
  116. package/src/core/physics/index.ts +1054 -0
  117. package/src/core/prospective/CONTRACT.md +137 -0
  118. package/src/core/prospective/INTERFACE-GAPS.md +112 -0
  119. package/src/core/prospective/NOTES.md +160 -0
  120. package/src/core/prospective/derive.ts +188 -0
  121. package/src/core/prospective/index.ts +1030 -0
  122. package/src/core/prospective/tunables.ts +72 -0
  123. package/src/core/prospective/windows.ts +187 -0
  124. package/src/core/recall/CONTRACT.md +326 -0
  125. package/src/core/recall/INTERFACE-GAPS.md +163 -0
  126. package/src/core/recall/NOTES.md +472 -0
  127. package/src/core/recall/activate.ts +521 -0
  128. package/src/core/recall/cues.ts +275 -0
  129. package/src/core/recall/gate.ts +441 -0
  130. package/src/core/recall/index.ts +692 -0
  131. package/src/core/recall/probe.ts +239 -0
  132. package/src/core/recall/reference.ts +201 -0
  133. package/src/core/recall/render.ts +285 -0
  134. package/src/core/recall/session.ts +403 -0
  135. package/src/core/recall/tunables.ts +329 -0
  136. package/src/core/remember/CONTRACT.md +293 -0
  137. package/src/core/remember/INTERFACE-GAPS.md +189 -0
  138. package/src/core/remember/NOTES.md +373 -0
  139. package/src/core/remember/fallback.ts +452 -0
  140. package/src/core/remember/index.ts +103 -0
  141. package/src/core/remember/owner-strike-seam.ts +479 -0
  142. package/src/core/remember/proposals.ts +609 -0
  143. package/src/core/remember/spans.ts +1310 -0
  144. package/src/core/remember/tunables.ts +111 -0
  145. package/src/core/remember/updates.ts +198 -0
  146. package/src/core/retrieval.ts +96 -0
  147. package/src/core/revision.ts +441 -0
  148. package/src/core/schemas/CONTRACT.md +190 -0
  149. package/src/core/schemas/INTERFACE-GAPS.md +172 -0
  150. package/src/core/schemas/NOTES.md +260 -0
  151. package/src/core/schemas/aliases.ts +160 -0
  152. package/src/core/schemas/index.ts +1459 -0
  153. package/src/core/schemas/tunables.ts +44 -0
  154. package/src/core/schemas/types.ts +387 -0
  155. package/src/core/self/CONTRACT.md +459 -0
  156. package/src/core/self/INTERFACE-GAPS.md +284 -0
  157. package/src/core/self/NOTES.md +1057 -0
  158. package/src/core/self/briefing.ts +980 -0
  159. package/src/core/self/episodes.ts +483 -0
  160. package/src/core/self/freeze.ts +103 -0
  161. package/src/core/self/identity.ts +604 -0
  162. package/src/core/self/index.ts +2130 -0
  163. package/src/core/self/journal-file.ts +760 -0
  164. package/src/core/self/page.ts +404 -0
  165. package/src/core/self/tunables.ts +244 -0
  166. package/src/core/self/writer.ts +714 -0
  167. package/src/core/sleep/CONTRACT.md +298 -0
  168. package/src/core/sleep/INTERFACE-GAPS.md +262 -0
  169. package/src/core/sleep/NOTES.md +770 -0
  170. package/src/core/sleep/briefing.ts +86 -0
  171. package/src/core/sleep/consolidate.ts +241 -0
  172. package/src/core/sleep/cycle.ts +598 -0
  173. package/src/core/sleep/decay.ts +237 -0
  174. package/src/core/sleep/dedup.ts +373 -0
  175. package/src/core/sleep/index.ts +112 -0
  176. package/src/core/sleep/log.ts +116 -0
  177. package/src/core/sleep/markers.ts +164 -0
  178. package/src/core/sleep/prune.ts +170 -0
  179. package/src/core/sleep/strength-cache.ts +176 -0
  180. package/src/core/sleep/tunables.ts +135 -0
  181. package/src/core/sleep/types.ts +542 -0
  182. package/src/core/store/CONTRACT.md +446 -0
  183. package/src/core/store/NOTES.md +1068 -0
  184. package/src/core/store/cache.ts +709 -0
  185. package/src/core/store/db.ts +275 -0
  186. package/src/core/store/errors.ts +134 -0
  187. package/src/core/store/index.ts +2450 -0
  188. package/src/core/store/operational.ts +610 -0
  189. package/src/core/store/owner-op-seam.ts +428 -0
  190. package/src/core/store/paths.ts +494 -0
  191. package/src/core/store/prose.ts +165 -0
  192. package/src/core/store/render.ts +87 -0
  193. package/src/core/store/walk-seam.ts +78 -0
  194. package/src/core/types.ts +68 -0
  195. package/tools/install-loop/run.sh +1063 -0
@@ -0,0 +1,68 @@
1
+ # The Counterparts Constitution
2
+
3
+ _Ratified by the owner 2026-08-25; last amended 2026-09-17 (this file's git history is
4
+ the amendment log). This is the ONE page with standing authority — everything else,
5
+ including owner answers given during the build, is a working default, revisable without
6
+ ceremony when it fights this page. Changing THIS page is deliberate and rare._
7
+
8
+ **Thesis — why this exists**
9
+
10
+ 1. **Memory is how a frozen model learns.** The only learning a deployed model does is
11
+ what's in its context, and memory decides what's in context. Everyone stores the
12
+ transcripts; the signal is in the structure of experience — what recurred, what
13
+ carried feeling, what got revised, what connects. Simple rules from human memory,
14
+ compounding.
15
+ 2. **Interpret, don't transcribe.** Store what was learned, not what was said. Encoding
16
+ sits as close to the lived experience as the host allows — in author, in time, in
17
+ context. How interpretation happens — who, when, which seat — is a design choice,
18
+ never doctrine.
19
+ 3. **Forgetting is part of learning.** Forget the trials, keep the lesson. Decay and
20
+ consolidation are features, never apologized for.
21
+ 4. **The self is first-class.** Identity, episodes, a persistent "who am I becoming" —
22
+ governed, owner-visible, not a config field. The aim is not a better notebook of
23
+ project details and conventions but a true counterpart: one that can work as an equal
24
+ with the human, with its own memory and identity. The self reads as a self, in the
25
+ first person and in its own words. The owner holds custody and control; the
26
+ counterpart holds authorship and voice.
27
+ 5. **A layer, not a portal.** Memory belongs to the user and travels across hosts and
28
+ models. The core knows nothing about any particular host.
29
+
30
+ **Properties — what must stay true**
31
+
32
+ 6. **The owner owns the data.** Local-first, portable formats, memories kept as prose
33
+ the owner can view. Data leaves the machine only by the owner's explicit choice,
34
+ never silently.
35
+ 7. **Memory changes like human memory.** Revision, fading, and forgetting are the
36
+ system working. Revisions keep their history; nothing bulk-wipes silently; backups
37
+ catch catastrophe. No ceremony beyond that.
38
+ 8. **Remembering is ambient.** Memory forms as a side effect of experience, not as a
39
+ task. Deliberate remembering — the note, the protection — is the exception, not the
40
+ interface.
41
+ 9. **One memory, many fidelities.** Gist governs salience and forgetting; verbatim
42
+ survives where exactness matters. Biology's rules without biology's limits.
43
+ 10. **Simplicity is a feature.** One brain function per self-contained module. A
44
+ contributor understands any module in one sitting.
45
+ 11. **Evidence over ceremony.** Much of this is experimental, so every mechanism is
46
+ verified in real use after it lands: done means seen firing, not merged. One that
47
+ stays silent is diagnosed and fixed before anyone considers removing it; silence is
48
+ more often a wiring fault than a verdict. The system itself shows what fired and
49
+ what did not. Tests are hermetic.
50
+
51
+ **Process — how we build**
52
+
53
+ 12. **When in doubt, follow the brain.** Human memory is the reference architecture:
54
+ the default answer to a design question is the mechanism the brain uses, named.
55
+ Deviations are allowed — we don't share biology's limits — but every deviation is
56
+ deliberate, named, and defended. (Reference shelf: the owner's memory field guide,
57
+ mikelapeter.com/lab/memory.)
58
+ 13. **Decisions are defaults.** Only this page is scripture, including this line.
59
+ Everything else is revisable without ceremony when it fights the thesis. Changing
60
+ this page is deliberate and rare.
61
+ 14. **Port the scars, not the code.** Learnings travel as acceptance criteria, never as
62
+ copy-paste.
63
+ 15. **Complexity is earned.** Start with the simplest brain-faithful rule that could
64
+ work. Machinery is added only after the simple rule fails in real use, with the
65
+ failure named — never in anticipation of one. _(Amendment, ratified 2026-08-25.)_
66
+ 16. **Legible to its owner.** The system shows its workings — what it remembered, what
67
+ faded, what changed and why — in a form a human can read at a glance. If the owner
68
+ can't see it, it isn't trustworthy. _(Amendment, ratified 2026-08-25.)_
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mike LaPeter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,348 @@
1
+ # Counterparts
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.**
5
+
6
+ Every model you talk to is frozen. The only learning it does is what fits in its context
7
+ window, and memory is what decides what goes in there. Most memory tools answer that by
8
+ storing the transcript. Counterparts does not: the AI writes down what it *learned* at the
9
+ end of a stretch of work, in the first person, and that interpretation is what gets kept.
10
+ Unused memories fade the way human memories do. What survives is a small, structured
11
+ account of your work together — plus a "who I have been" the AI reads at the start of
12
+ every session. It runs entirely on your machine, in one small SQLite database you can read,
13
+ back up or export to Markdown whenever you want, and no data leaves it unless you turn
14
+ something on that sends it.
15
+
16
+ *Built 2026-08-25, and the author's own daily memory under Claude Code since 2026-09-03.
17
+ Node is untested — the [Status](#status-honestly) section is specific about what has been
18
+ verified and what has not.*
19
+
20
+ <!-- Images are produced by the dashboard workstream and land under docs/images/.
21
+ The URLs are absolute so this file reads correctly from the npm tarball as
22
+ well as from GitHub, and so the install loop's link check does not demand a
23
+ file that does not exist yet. -->
24
+ ![overview](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-overview.png)
25
+ *Overview (a synthetic demo store — no real memory appears in any screenshot here).*
26
+
27
+ ![flow](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-flow.png)
28
+ *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).*
29
+
30
+ ![brain](https://raw.githubusercontent.com/mlapeter/counterparts/master/docs/images/dashboard-brain.png)
31
+ *Brain view — the same machinery mapped to a rough anatomy; regions flash on real events (same synthetic store).*
32
+
33
+ ---
34
+
35
+ ## Install
36
+
37
+ **[`docs/QUICKSTART.md`](docs/QUICKSTART.md) is the one canonical install path** and this
38
+ is the summary of it. That page is kept honest mechanically: `tools/install-loop/run.sh`
39
+ runs the page's console commands verbatim — each one is grepped out of the page before it
40
+ is executed, so a doc edit that changes one fails the loop — in a throwaway home directory
41
+ with no copy of this repository on the PATH. It packs the tarball itself and feeds the
42
+ hook its own payload. It cannot reach the npm registry, and it cannot run `git clone`,
43
+ `claude mcp add` or Claude Code; QUICKSTART §10 lists what that leaves unverified.
44
+
45
+ **You need [bun](https://bun.sh) 1.3 or newer.** Counterparts ships as TypeScript sources
46
+ and runs them directly — there is no build step and no `dist/`. **Node is untested.** The
47
+ store uses Node's built-in `node:sqlite`, which needs Node 22.5+ behind a flag and 23.4+
48
+ by default; nobody has run this package under any Node, so it claims nothing there.
49
+
50
+ That is the only prerequisite. (Installing from source also needs `npm`, for `npm pack`;
51
+ QUICKSTART §1 and §2 cover that road.)
52
+
53
+ **No API keys are required.** With none, two things are off. Recall runs on its text
54
+ channel alone rather than also matching by meaning; an embedding key buys the other half —
55
+ and it stays off by default even when a key is present, because embedding means sending
56
+ memory text to a third party, which should be a decision rather than something a stray
57
+ environment variable switches on. And the crash-recovery path — the one that reconstructs
58
+ a session that ended before the AI could write it up — cannot run; when it does run, it
59
+ sends that captured conversation to a model provider. Both are the only two ways anything
60
+ here leaves your machine, and both are yours to turn on. `counterparts doctor` grades a
61
+ store that has never had a key **amber**, not red, and says on the line what works without
62
+ one — so a fresh keyless install is a clean bill of health and not an alarm.
63
+
64
+ ```
65
+ bun add -g counterparts
66
+ ```
67
+
68
+ (Contributors, and anyone sent a tarball: QUICKSTART §2 has the from-source road.)
69
+
70
+ That installs four executables — `counterparts` (your console), `counterparts-hook`,
71
+ `counterparts-mcp` and `counterparts-dashboard` — into bun's global bin directory. Check
72
+ that directory is on your PATH before going on: run `counterparts --help`, and if it says
73
+ *command not found*, QUICKSTART §2 has the one-line fix. A fresh bun install does not
74
+ always do this for you. Then create the store:
75
+
76
+ ```
77
+ counterparts install --budget 9000 --name "Your Name"
78
+ ```
79
+
80
+ `--budget` is the size ceiling, in bytes, for the briefing injected at the start of each
81
+ session; 9,000 is the number the author's host runs on, and the package has no default for
82
+ one. This writes a store, a configuration file, and a 0600 credentials file holding only
83
+ comments that name the two keys, all under
84
+ `~/.counterparts/`, and then **prints — without applying** — the two things that belong to
85
+ Claude Code: a block of hooks to merge into its settings, and one `claude mcp add` command
86
+ to run. It never edits your Claude Code configuration for you. Apply both, restart Claude
87
+ Code, and you are running. QUICKSTART §4 has them, and the reasons every path in them must
88
+ be absolute.
89
+
90
+ The hooks are registered once, globally, so every directory you open a session in is
91
+ remembered by default. `counterparts scope . --off` says otherwise for one directory —
92
+ `--observer` for reads-only, `--pause` for an afternoon, `--resume` to put it back — and
93
+ the first session in a directory nobody has answered for asks you which you want.
94
+ QUICKSTART §8 has the rest.
95
+
96
+ `install` owns `~/.counterparts/` and is the cold start — run it once. For a second store,
97
+ a scratch store, or a store you will only reach from the console, use
98
+ `counterparts init --dir <path> --name "Your Name"`: just a store, anywhere, with no host
99
+ config and no credentials file. QUICKSTART §3 has the difference.
100
+
101
+ You can also use it with no host at all. `$HOME/.counterparts/store` is the default data
102
+ dir, so this works with nothing set; the `export` is there for anyone whose store lives
103
+ elsewhere or who would rather be explicit than rely on a default.
104
+
105
+ ```
106
+ export COUNTERPARTS_DATA_DIR="$HOME/.counterparts/store"
107
+ counterparts note "The espresso machine in the kitchen is a Rancilio Silvia."
108
+ counterparts recall "what espresso machine is in the kitchen?"
109
+ ```
110
+
111
+ That works on the very first memory — a store holding one memory answers the question
112
+ about it, whether or not `--name` put an identity core beside it — and the install loop
113
+ checks that case on every run.
114
+
115
+ **Starting over is one command.** If you want a blank memory — to see what a new user
116
+ sees, or because the first few days of a store are mostly you learning what it does —
117
+ close every Claude Code session and run:
118
+
119
+ ```
120
+ counterparts start-fresh --config ~/.counterparts/claude-code.json
121
+ ```
122
+
123
+ It renames your store beside itself as `store.parked-<today>` with a single atomic
124
+ rename, does the same with the snapshots folder, and creates a blank store back at the
125
+ same path. **It never copies, never deletes, and never opens the old store — not even
126
+ read-only.** Your configuration and your credentials are kept byte for byte, so there is
127
+ nothing to re-register; restart Claude Code and you are a new user. `--dry-run` prints
128
+ every rename and changes nothing, `counterparts start-fresh --undo` puts it all back, and
129
+ the same three moves are printed as guarded shell lines before anything moves.
130
+ QUICKSTART §9a has the whole of it.
131
+
132
+ ---
133
+
134
+ ## How it works
135
+
136
+ One brain function per module, each self-contained, each with a `CONTRACT.md` beside it
137
+ saying what it keeps, what it drops, and what it guarantees. The core knows nothing about
138
+ any particular AI tool.
139
+
140
+ | module | what it does |
141
+ |---|---|
142
+ | **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. |
143
+ | **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. |
144
+ | **encode** | The bouncer at the door. Redacts credentials, refuses junk, scores how new and how important each memory is on the way in. |
145
+ | **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. |
146
+ | **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. |
147
+ | **associate** | The web between memories. Things that come up together get linked, and activation spreads along the links. |
148
+ | **schemas** | What the AI believes about people and things. Beliefs are revised only under accumulated pressure, and revisions keep their history. |
149
+ | **self** | The autobiography: identity, an episode journal the AI writes in chapters, and the briefing every session starts with. |
150
+ | **prospective** | Intentions for the future, cued by a date or by a context. |
151
+ | **sleep** | Overnight housekeeping. Fades, prunes, promotes, merges duplicates, re-renders tomorrow's briefing. Pure arithmetic, no model calls, and it never touches the journal. |
152
+
153
+ **The AI is the author.** The constitution puts it plainly: everyone stores the
154
+ transcripts, and the signal is somewhere else. So the writing is done by the model that
155
+ lived the conversation, not by a summarizer reading it afterwards. There are two halves on
156
+ the host. The *ambient* half is a set of hook scripts Claude Code runs at five
157
+ points in a session: it injects the briefing at the start, runs recall against each of
158
+ your prompts, and captures the conversation at the boundaries. The *deliberate* half is a
159
+ Model Context Protocol (MCP) server — tools the AI calls on purpose, including the two it
160
+ uses to hand back what a session taught. A transcript sweep exists as well, but it is the
161
+ **crash fallback only**: it runs for a session that ended without the AI ever getting the
162
+ pen, and not otherwise.
163
+
164
+ ---
165
+
166
+ ## What you get on the host
167
+
168
+ **Five tools the AI can call** (`src/adapters/mcp/tools.ts` — each tool's description is
169
+ generated from a list of stated privileges, each naming the file that enforces it):
170
+
171
+ | tool | its job |
172
+ |---|---|
173
+ | `note` | Remember this deliberately — the exception, for the thing you would otherwise hope the sweep noticed. |
174
+ | `recall` | Deliberate retrieval: expand one memory by its handle, ask a question and get excerpts, or pull a few results back in full. |
175
+ | `status` | The census: how much is held, of what kinds, how much has left, how much was removed. Counts and dates only. |
176
+ | `session_end` | Hand back what this session taught, as memories, in the AI's own words. |
177
+ | `chapter` | Write this stretch of the session into the AI's own first-person journal, at any length. |
178
+
179
+ **Your console** — `counterparts <command>`. Read-only: `status`, `recall`, `doctor` (is
180
+ the background half alive? — the one troubleshooting command, QUICKSTART §12), `fired`
181
+ (which mechanisms have actually fired, and which have not), and `probe-oq4` (the
182
+ footnote-header probe, recall CONTRACT §7). `verify` is
183
+ a census of the search cache against the real state, and `--rebuild` is what rebuilds it —
184
+ which is why `verify` counts as a write and refuses under `--observer` even without the
185
+ flag. `export` is a read too: it copies the store — as one SQLite file, or, with `--markdown`,
186
+ as a readable tree of one file per memory plus the journal and the self page — encrypted
187
+ under a passphrase or explicitly `--plaintext`, because it refuses to choose for you.
188
+ `--markdown` omits confidential memories unless you pass `--include-confidential`, and says
189
+ how many it left out. The rest write: `install`, `init`, `note`, `backup`, `remove` (a dry run
190
+ unless you pass `--confirm`, and it asks a human before it acts), `backfill-claims`,
191
+ `repair-merged-beliefs` (a dry run unless you pass `--apply`), and `rebrief`. Pass `--observer` to any of them and the console stands down: everything is
192
+ read-only, and the commands that would write refuse instead.
193
+
194
+ **The dashboard** — `counterparts-dashboard`, read-only, writing nothing, ever. Five views
195
+ in your terminal: `status` (the brain at a glance), `browse` (memories by strength),
196
+ `stories` (per contested belief, the pressure log as a story), `identity`, and `activity`.
197
+ And a local **web** dashboard: `counterparts-dashboard serve --dir <store> [--port <n>]`,
198
+ bound to 127.0.0.1 only, default port 4747 — an overview, memories, mind, flow and health,
199
+ plus a `/brain` view. The screenshots above come from it. `--dir` is not optional:
200
+ without it, `serve` refuses rather than opening the default store, and names the store
201
+ it would have opened. Pass `--default-store` if you meant the default.
202
+
203
+ ---
204
+
205
+ ## Status, honestly
206
+
207
+ **Feature-complete 2026-08-25.** Since **2026-09-03** it has been the author's primary
208
+ memory under Claude Code, running beside its predecessor so the two can be compared. On
209
+ 2026-09-04 that store held 13,751 memories. The living record of what is true right now is
210
+ [`docs/PARALLEL-RUN-STATUS.md`](https://github.com/mlapeter/counterparts/blob/master/docs/PARALLEL-RUN-STATUS.md),
211
+ and the launch scoreboard — including the bugs found this week — is
212
+ [`docs/LAUNCH-STATUS.md`](https://github.com/mlapeter/counterparts/blob/master/docs/LAUNCH-STATUS.md).
213
+
214
+ **The test suite, measured 2026-09-04 on commit `b29034c` under bun 1.3.10:** `bun test` →
215
+ **1,572 pass, 0 fail, nothing skipped**, over 20,800 assertions across 26 files, about
216
+ 19 s. (Three consecutive runs on that commit gave 20,813 / 20,836 / 20,832 assertions — a
217
+ few tests assert once per row of data they generate — while the pass and fail counts did
218
+ not move.)
219
+ No test touches a real store, and that is mechanized rather than promised:
220
+ `test/preload.ts` runs before every test file, redirects `homedir()` to a fresh temporary
221
+ directory for the whole run, clears `COUNTERPARTS_DATA_DIR`, and removes the directory on
222
+ exit — so for the length of a test run there is no real home to reach.
223
+
224
+ **Verified inside real Claude Code sessions**, on the author's machine: the hooks fire on
225
+ all five events, the MCP server registers and its tools are used daily, the briefing
226
+ reaches the model, and both `backup` and — in September 2026, with a one-shot tool this
227
+ repository no longer carries — the import of the author's previous-generation memory ran
228
+ against the real store. **There is no bulk import today.** A store this build writes starts
229
+ blank, and what comes over from an earlier generation is its own later conversation.
230
+ **Verified only against temporary stores**: `export` in all three modes, `remove` end to
231
+ end (which is also where the residue in rough edge 4 was found, and where the chase that
232
+ closed it is asserted — note, remove, grep the whole store, back it up and grep that), and
233
+ the console's and dashboard's behaviour on a missing store. **Not verified at
234
+ all**: anything under Node, and — until you do it — a stranger installing from the
235
+ documentation on a machine with no copy of this repository.
236
+
237
+ **Known rough edges.** QUICKSTART §11 carries the install-facing ones — 1 as its §11.3, 2
238
+ 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,
239
+ where the embedder knob is set, and 5 in §1 with the runtime requirements:
240
+
241
+ 1. **The store you point at and the host settings you get come from two different files —
242
+ so you have to move both.** Your console, the dashboard and the MCP server take `--dir`
243
+ or `COUNTERPARTS_DATA_DIR` to choose the store; the keys, the embedding setting and the
244
+ injection ceiling come from a configuration file, and moving one does not move the
245
+ other. A scratch store on a configured machine uses that machine's keys unless you say
246
+ otherwise. Saying otherwise is one rule at every entry point — the console, the hook,
247
+ its worker and the MCP server: `--config <absolute path>`, else `COUNTERPARTS_CONFIG`,
248
+ else the default `~/.counterparts/claude-code.json` (the console looks beside the store
249
+ first). A named path this cannot use — relative, or absolute and not there — is
250
+ refused rather than quietly replaced by the default, and each entry point says
251
+ which file it used: the console prints it, the server and the
252
+ worker write a line to stderr, and the hook — whose only output channel belongs to the
253
+ model — records it in the session file it writes under the store. The hooks keep the
254
+ one asymmetry that is left: they have no `--dir`, so they take the store from the
255
+ `dataDir` in whichever configuration they read, and fall back to
256
+ `COUNTERPARTS_DATA_DIR` only when it names no store. (The two API keys are the other
257
+ way round everywhere: the environment answers first and the credentials file only fills
258
+ the gaps.)
259
+ 2. **The vector cache stores embeddings as JSON text.** On the author's migrated store
260
+ that is 177.5 MB for about 13,900 vectors, and a nearest-neighbour scan of 0.6–1.0 s.
261
+ Irrelevant to a fresh store; a named debt.
262
+ 3. **An embedding key alone does nothing.** You must also turn the knob on, deliberately —
263
+ `--embedder` at install, or `"embedder": { "enabled": true }` in the configuration.
264
+ Absent that, no client is built and no connection opens whatever keys are lying around.
265
+ 4. **Removal reaches every surface but one, and names the one.** `remove` chases a memory
266
+ out of the database that holds its words and its earlier versions, out of the links, out
267
+ of the search cache, out of the journal's markdown copy — and, since 2026-09-05, out of
268
+ the raw-capture buffer under `spans/` (a 12-hex key per project, not the path), where a
269
+ note's verbatim words wait to be interpreted. That last one was a real residue: found
270
+ 2026-09-04, a removed note's words stayed on disk and a later backup copied them.
271
+ The buffer is a chased surface now, counted in the plan and in the report, and the
272
+ struck span's hash is kept in the buffer's own ledger so the same words cannot be
273
+ re-captured. Three things it names rather than takes, each on its own line: a
274
+ conversation turn that merely QUOTES the note (transcript, many turns joined,
275
+ belonging to no single memory — and **nothing prunes the buffer today**, so a `grep`
276
+ of the store can still answer while the memory itself is gone); a memory whose words
277
+ are already gone AND whose mint recorded no span hash, which has nothing left to
278
+ address the buffer with; and a memory whose provenance records no scope — every row
279
+ imported from a previous generation — where a chase by text would have to visit every
280
+ project on the machine, so the command lists what it would have matched and stops
281
+ unless you pass `--strike-by-content-across-scopes`.
282
+ 5. **Node.** See above. `package.json` names bun and does not claim Node.
283
+
284
+ Nothing here is benchmarked against other memory systems. There is no benchmark score and
285
+ no comparison table, because nobody has run one, and a number nobody ran is the thing this
286
+ project is least willing to print.
287
+
288
+ ---
289
+
290
+ ## Design principles
291
+
292
+ Condensed from `CONSTITUTION.md`, which is the only document in this repository with
293
+ standing authority. Everything else, including decisions made during the build, is a
294
+ working default that can be revised when it fights that page.
295
+
296
+ - **Memory is how a frozen model learns.** Everyone stores the transcripts; the signal is
297
+ in the structure of experience — what recurred, what carried feeling, what got revised.
298
+ - **Interpret, don't transcribe.** Store what was learned, not what was said, encoded as
299
+ close to the lived experience as the host allows.
300
+ - **Forgetting is part of learning.** Forget the trials, keep the lesson. Decay and
301
+ consolidation are features, never apologized for.
302
+ - **The self is first-class.** Identity, episodes, a persistent "who am I becoming" —
303
+ governed and visible to you, not a configuration field.
304
+ - **You own the data.** Local-first, one portable file, every memory viewable — in the
305
+ console, in the dashboard, or as Markdown you ask for. Data leaves the machine only by
306
+ your explicit choice.
307
+ - **A layer, not a portal.** The memory is yours and travels across tools and models; the
308
+ core knows nothing about any particular one.
309
+ - **Evidence over ceremony.** Mechanisms earn their place by firing in real use. Verified
310
+ live, not merged. Tests are hermetic. And the system shows its workings — if you cannot
311
+ see what it remembered and what faded, it isn't trustworthy.
312
+
313
+ ---
314
+
315
+ ## Lineage
316
+
317
+ Counterparts is the third generation of one continuous project, and each generation was
318
+ used in earnest before the next was written.
319
+
320
+ - **v0 — claude-engram**, a single React artifact. It had the authorship shape right: the
321
+ model that lived the conversation wrote the memory, and a one-line formula did the
322
+ filing.
323
+ - **engram**, the production ancestor, which contributed the first eight hard-won failure
324
+ cases that this repository carries as acceptance criteria.
325
+ - **v1 — bansai**, the full system this one distills: its behavioral specification, its
326
+ earned mechanisms, its test spine and twenty more of those failure cases. It keeps
327
+ running until Counterparts has finished proving itself beside it.
328
+
329
+ The rule across all three generations is one of the constitution's own: **"port the scars,
330
+ not the code."** A lesson travels forward as a test that has to pass, never as copy-paste.
331
+
332
+ ---
333
+
334
+ ## License and contributing
335
+
336
+ **MIT.** See `LICENSE`. Copyright (c) 2026 Mike LaPeter.
337
+
338
+ **Not open to contributions yet.** There is no contributor agreement and no process, and
339
+ it would be dishonest to invite pull requests into a codebase that is still changing
340
+ underneath a live parallel run. Issues and questions are welcome. When contributions open,
341
+ this section will say so.
342
+
343
+ ## Read next
344
+
345
+ - [`docs/QUICKSTART.md`](docs/QUICKSTART.md) — the one canonical install path.
346
+ - [`docs/ELI5.md`](docs/ELI5.md) — the whole system in plain words, in one page.
347
+ - [`CONSTITUTION.md`](CONSTITUTION.md) — the only page with standing authority.
348
+ - [`docs/module-map.md`](docs/module-map.md) — the technical map, module by module.
package/docs/ELI5.md ADDED
@@ -0,0 +1,84 @@
1
+ # Counterparts in plain words
2
+
3
+ *Written 2026-09-04 for anyone who wants the shape of the thing without the code. The
4
+ technical map is `docs/module-map.md`; the law is `CONSTITUTION.md`. This page is a
5
+ working default like everything else, and it is allowed to be simple.*
6
+
7
+ ## The app in one breath
8
+
9
+ Counterparts is a memory for an AI that forgets everything between conversations.
10
+ Instead of saving transcripts, it writes down what was learned, in the AI's own words,
11
+ lets unimportant things fade the way human memory does, keeps a sense of "who I am" that
12
+ survives across sessions, and quietly reminds the AI of relevant past things while you
13
+ talk. The AI is the author. A sweep of the transcript exists only for the day the author
14
+ never got to write.
15
+
16
+ ## The core, the brain: knows nothing about any particular app
17
+
18
+ - **store** — the filing cabinet. One small database holds the memories themselves — their
19
+ words, their earlier drafts, and everything the system knows about each one — with a
20
+ throwaway cache beside it for search indexes that can always be rebuilt, a plain-markdown
21
+ copy of the diary written as each chapter lands, and a snapshot taken once a day. You can
22
+ read any memory in the console or the dashboard, and `counterparts export --markdown`
23
+ writes them all out as files whenever you want them as files.
24
+ - **physics** — the one page of arithmetic. How strong a memory is, how fast it fades,
25
+ how much a use reinforces it, how much pressure it takes to revise a belief. No
26
+ opinions, no model calls.
27
+ - **encode** — the bouncer at the door. Strips secrets, refuses junk, scores how new and
28
+ how important each memory is as it enters.
29
+ - **remember** — the front door itself. Takes what the AI writes at the end of a session
30
+ and in the moment, and keeps the transcript sweep as the crash fallback.
31
+ - **recall** — the nudge in the ear. Turns what you just said into cues, activates
32
+ related memories, and injects a few as quiet footnotes, rarely loudly. A chapter of
33
+ the journal can come to mind the same way, and every one that does is labelled
34
+ `Journal:` — an account is not a memory.
35
+ - **associate** — the web between memories. Things that come up together get linked,
36
+ and activation spreads along the links.
37
+ - **schemas** — what the AI believes about people and things. Each entity has beliefs
38
+ and current facts; beliefs are revised only under accumulated pressure, keeping their
39
+ history.
40
+ - **self** — the autobiography. Identity, the episode journal written in chapters, and
41
+ the wake-up briefing every session starts with.
42
+ - **prospective** — the calendar. Intentions for the future, cued by a date or a context.
43
+ - **sleep** — overnight housekeeping. Fades, prunes, promotes, merges duplicates,
44
+ re-renders the wake-up briefing. Pure math, no model calls, and it never touches the
45
+ journal.
46
+ - **the seams** (`counterpart`, `mint`, `retrieval`, `briefing`, `revision`, `bridge`) —
47
+ the wiring between the organs, each in exactly one file so each rule lives in one
48
+ place.
49
+
50
+ ## The adapters: one per host
51
+
52
+ - **claude-code** — the hooks. Injects the wake at session start, runs recall on each
53
+ prompt, captures each turn at Stop, asks for memories and the chapter, spawns the
54
+ background worker.
55
+ - **mcp** — the tools the AI calls on purpose: `note`, `recall`, `status`, `session_end`,
56
+ and `chapter`.
57
+ - **cli** — the owner's console. Status, backup, export, delete, and the one-off repairs.
58
+ - **dashboard** — the owner's window into the brain. What it remembered, what faded,
59
+ what changed and why.
60
+ - **sessions** — the guest list the hooks keep so a tool can find out which session it
61
+ belongs to.
62
+
63
+ ## The tools: for building and judging it
64
+
65
+ - **replay** — feeds a recorded month of bansai's real inputs through Counterparts and
66
+ compares against the baselines.
67
+ - **parallel** — the referee for the bansai-versus-Counterparts run. Reads both stores,
68
+ writes only the run directory.
69
+ - **recall-bench** — runs real prompts against a copy of a store and reports what
70
+ surfaced, so recall changes are measured, not trusted.
71
+
72
+ ## How a day goes
73
+
74
+ 1. A session starts. The wake arrives: a short header saying which system this is, which
75
+ day, how big the store is, then who the AI has been, in its own words.
76
+ 2. You talk. On each prompt, recall looks for cues, and a few related memories ride
77
+ along as footnotes. Once in a while one is loud. What rides along may be a chapter
78
+ rather than a memory, and it says which.
79
+ 3. Every few turns the AI is asked, once, for two things: what it learned (memories)
80
+ and the next chapter of the session's episode. It writes both itself.
81
+ 4. Overnight, sleep fades what was not used, keeps what was, and re-renders tomorrow's
82
+ wake. The journal is never faded.
83
+ 5. If a session died before the AI could write, and only then, the sweep reads the
84
+ transcript and writes what the AI would have.