counterparts 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +183 -0
- package/README.md +9 -3
- package/docs/QUICKSTART.md +3 -2
- package/package.json +9 -7
- package/src/adapters/claude-code/CONTRACT.md +44 -2
- package/src/adapters/claude-code/NOTES.md +17 -0
- package/src/adapters/claude-code/bin/hook.mjs +8 -0
- package/src/adapters/claude-code/bin/hook.ts +29 -4
- package/src/adapters/claude-code/bin/nightly.ts +1 -0
- package/src/adapters/claude-code/doctor.ts +90 -6
- package/src/adapters/claude-code/hooks.ts +144 -11
- package/src/adapters/claude-code/night-catch-up.ts +543 -0
- package/src/adapters/claude-code/night-run.ts +53 -8
- package/src/adapters/claude-code/standdown.ts +10 -1
- package/src/adapters/cli/bin/counterparts.mjs +8 -0
- package/src/adapters/cli/commands.ts +21 -6
- package/src/adapters/cli/desktop.ts +25 -3
- package/src/adapters/cli/install.ts +51 -2
- package/src/adapters/cli/wire.ts +12 -49
- package/src/adapters/config.ts +17 -0
- package/src/adapters/dashboard/NOTES.md +36 -0
- package/src/adapters/dashboard/bin/dashboard.mjs +8 -0
- package/src/adapters/dashboard/bin/dashboard.ts +10 -4
- package/src/adapters/dashboard/registries.ts +6 -0
- package/src/adapters/dashboard/upgrade.ts +15 -3
- package/src/adapters/dashboard/web/flow.ts +1 -0
- package/src/adapters/dashboard/web/lanes.ts +1 -0
- package/src/adapters/dashboard/web/narrate.ts +28 -2
- package/src/adapters/dashboard/web/pages/health/sections/archive.js +22 -10
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +37 -2
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +41 -4
- package/src/adapters/dashboard/web/pages/memories/index.js +1 -1
- package/src/adapters/dashboard/web/pages/self/sections/dreams.js +4 -2
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +6 -1
- package/src/adapters/dashboard/web/pages/self/self.css +1 -0
- package/src/adapters/dashboard/web/server.ts +8 -8
- package/src/adapters/dashboard/web/views/dreams.ts +20 -1
- package/src/adapters/dashboard/web/views/health.ts +164 -25
- package/src/adapters/fired.ts +3 -0
- package/src/adapters/hosts.ts +43 -1
- package/src/adapters/launch.mjs +30 -0
- package/src/adapters/lifecycle.ts +65 -9
- package/src/adapters/log/index.ts +5 -0
- package/src/adapters/mcp/CONTRACT.md +76 -16
- package/src/adapters/mcp/NOTES.md +107 -1
- package/src/adapters/mcp/bin/serve.mjs +8 -0
- package/src/adapters/mcp/bin/serve.ts +2 -1
- package/src/adapters/mcp/deliberate.ts +108 -35
- package/src/adapters/mcp/index.ts +2 -0
- package/src/adapters/mcp/server.ts +274 -38
- package/src/adapters/mcp/tools.ts +36 -8
- package/src/adapters/mcp/write-up.ts +124 -27
- package/src/adapters/node-hooks.mjs +108 -0
- package/src/adapters/runtime.ts +126 -0
- package/src/adapters/sessions.ts +287 -30
- package/src/core/briefing.ts +8 -2
- package/src/core/counterpart.ts +379 -27
- package/src/core/coverage/INTERFACE-GAPS.md +11 -9
- package/src/core/dream/CONTRACT.md +6 -1
- package/src/core/dream/index.ts +105 -6
- package/src/core/dream/reflect.ts +7 -2
- package/src/core/handoff/CONTRACT.md +39 -6
- package/src/core/handoff/NOTES.md +50 -1
- package/src/core/handoff/index.ts +116 -5
- package/src/core/handoff/last-here.ts +223 -7
- package/src/core/mint.ts +20 -1
- package/src/core/recall/CONTRACT.md +24 -8
- package/src/core/recall/NOTES.md +111 -7
- package/src/core/recall/activate.ts +89 -14
- package/src/core/recall/feeling-ask.ts +335 -19
- package/src/core/remember/proposals.ts +13 -1
- package/src/core/self/CONTRACT.md +36 -4
- package/src/core/self/INTERFACE-GAPS.md +5 -0
- package/src/core/self/NOTES.md +122 -0
- package/src/core/self/briefing.ts +76 -11
- package/src/core/self/covered.ts +104 -0
- package/src/core/self/episodes.ts +11 -1
- package/src/core/self/identity.ts +57 -1
- package/src/core/self/index.ts +173 -7
- package/src/core/self/tunables.ts +20 -3
- package/src/core/self/work.ts +209 -0
- package/src/core/self/writer.ts +27 -2
- package/src/core/store/NOTES.md +24 -0
- package/src/core/store/db.ts +29 -6
- package/src/core/store/index.ts +76 -0
- package/src/core/types.ts +21 -0
- package/tools/install-loop/run.sh +94 -90
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,188 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.11 — 2026-10-01
|
|
4
|
+
|
|
5
|
+
The nightly run now writes up the sessions that ended before they were written up, in
|
|
6
|
+
any directory, before it writes the page, and the wake gets a dated "Yesterday" line.
|
|
7
|
+
The wake splits work from personal: "Work here" lists the work done in the directory the
|
|
8
|
+
session opens in, and Nearby keeps what is personal, so a session in one project no
|
|
9
|
+
longer wakes to another project's plumbing. Counterparts runs under Node 22.15 or newer,
|
|
10
|
+
and on Linux. Claude Desktop's Code tab files its memories under its own session again,
|
|
11
|
+
asking by feeling finds more of what was felt, and the wake says when a handoff may be
|
|
12
|
+
out of date. **The store's format does not change** (still v11): nothing is upgraded and
|
|
13
|
+
no pre-migration copy is taken, and 0.3.10 can open a store 0.3.11 has used.
|
|
14
|
+
|
|
15
|
+
The morning catch-up and the "Yesterday" line (#308).
|
|
16
|
+
|
|
17
|
+
- **The nightly run writes up what was left unwritten, in any directory, before it
|
|
18
|
+
writes the page.** Until now a conversation that ended before it was written up waited
|
|
19
|
+
for the next session opened in the same directory, and a project nobody reopened within
|
|
20
|
+
two days of use simply let it lapse. Now, when the day's first prompt starts the
|
|
21
|
+
nightly run (dreaming `auto`), a short `claude -p` of its own goes first: it is allowed
|
|
22
|
+
one tool (`session_end`), and it writes up at most 4 sessions or about 96 KB of their
|
|
23
|
+
words a night, oldest first. What it leaves stays owed, for another night or a session
|
|
24
|
+
in its directory. It costs one more `claude -p` start on a night with something owed,
|
|
25
|
+
and nothing on a night without. That run can only write up: it can't write memories
|
|
26
|
+
of its own, notes, chapters or handoffs. A run that stops early (a usage limit, say)
|
|
27
|
+
is recorded as partial, and one whose process was killed has its permission ended at
|
|
28
|
+
the next run.
|
|
29
|
+
- **A written-up memory belongs to the conversation it came from.** It carries that
|
|
30
|
+
session and its directory, is marked as written up second-hand (and by whom), and its
|
|
31
|
+
"happened" date is the day the conversation was lived. Its "learned" date stays the day
|
|
32
|
+
it was written. The page writer reads it on the day it happened, not the day it was
|
|
33
|
+
written. This is true of the in-session catch-up too.
|
|
34
|
+
- **The writer now sees both sides.** The part handed over carries the session's own
|
|
35
|
+
replies, labelled `[its reply]` and each cut at about 1.5 KB, beside what was said to
|
|
36
|
+
it. A part may hold a little less of what was said than before.
|
|
37
|
+
- **Two writers never write the same stretch.** Whoever fetches a stretch holds it until
|
|
38
|
+
it comes back (at most two hours). The session-start pointer passes over one the
|
|
39
|
+
nightly run holds, and a session that tries to fetch one gets "the nightly run is
|
|
40
|
+
writing that session up now".
|
|
41
|
+
- **A conversation that crashed without an end can be written up from another
|
|
42
|
+
directory.** "Ended" is now read the same way the rest of the write-up rule reads it:
|
|
43
|
+
nothing captured since the date changed. A refusal always says why.
|
|
44
|
+
- **The wake has a "Yesterday" line**: yesterday's chapter titles with their ids, with
|
|
45
|
+
the date in the line ("Yesterday, 09-30: …"), so a wake composed late at night still
|
|
46
|
+
reads right in the morning. It takes its room from the wake's existing budget.
|
|
47
|
+
- **`counterparts doctor`** says what the nightly run's catch-up did (written up, left
|
|
48
|
+
owed) on the Nightly run and Write-ups lines, and counts yesterday's Claude Desktop
|
|
49
|
+
chats as unmeasured rather than lost. `counterparts log` shows an
|
|
50
|
+
`adapter.night.writeup` line for it.
|
|
51
|
+
|
|
52
|
+
The wake: work here, and what is personal (#313).
|
|
53
|
+
|
|
54
|
+
- The wake's craft lane is now the work done in the directory the session opens in: "Work
|
|
55
|
+
here, if it helps:" lists that directory's newest few work memories (marked `work`, or
|
|
56
|
+
unmarked skills and facts written there), each a title, a short excerpt and its id.
|
|
57
|
+
Nearby keeps what is personal, so a session in one project no longer wakes to another
|
|
58
|
+
project's plumbing.
|
|
59
|
+
- The chapter tool takes `about` (me, us, owner, work or world), and the chapter's memory
|
|
60
|
+
copy keeps it. A chapter marked me, us or owner reaches the wake in other directories;
|
|
61
|
+
one marked work stays in its own.
|
|
62
|
+
- `note` and `session_end` entries take `unresolved: true` for an open question or a
|
|
63
|
+
promise still pending; the wake shows those under "Still open:" (at most five). A later
|
|
64
|
+
write that `updates` one with `unresolved: false`, or with `how: "changed"` and the
|
|
65
|
+
answer, closes it.
|
|
66
|
+
- The end-of-session ask (and Desktop's write-up ask) now says to close anything dated or
|
|
67
|
+
open that got done in the session, so a finished follow-up stops coming back.
|
|
68
|
+
- The day's lines (the dream line, the night run's report, plain reminders, the update
|
|
69
|
+
notice) go only to a session someone can see: the terminal or Desktop's Code tab, not
|
|
70
|
+
`claude -p` or the SDK. A headless session can still start the nightly run, and the next
|
|
71
|
+
session you are in says so. The assistant now says the day's dream line itself, once, in
|
|
72
|
+
its first reply; the terminal line is extra.
|
|
73
|
+
|
|
74
|
+
Node and Linux (#312).
|
|
75
|
+
|
|
76
|
+
- **Runs under Node 22.15 or newer, and on Linux.** `npm install -g counterparts` works
|
|
77
|
+
without bun. The setup wires Claude Code to whichever runtime ran it (`bun run …` under
|
|
78
|
+
bun, `node --import …/node-hooks.mjs …` under Node), and `counterparts doctor` has a
|
|
79
|
+
Runtime line naming it and saying whether it is still there. The four commands now
|
|
80
|
+
start under bun when bun is on PATH, else Node. On Linux, `install --host
|
|
81
|
+
claude-desktop` says Claude Desktop is not available there instead of writing a config.
|
|
82
|
+
Tested on Node 22 and 24, macOS and Linux (Debian, arm64); no daily user on Node yet.
|
|
83
|
+
|
|
84
|
+
Continuity, round 2 (#311).
|
|
85
|
+
|
|
86
|
+
- A handoff that may be out of date says so at the wake: "written 09-30 18:45 by session
|
|
87
|
+
a1b2c3d4, before 0.3.10 was installed" when an older release wrote it, or "a newer chapter
|
|
88
|
+
here since" when another session wrote a chapter in that directory after it. The end-of-
|
|
89
|
+
session ask now says any session may retire a handoff here whose work is done.
|
|
90
|
+
- Recalled by its id, a handoff says who wrote it and when, not "an earlier session" and the
|
|
91
|
+
date its row was first made.
|
|
92
|
+
- "Last here" shows the first sentence of the chapter the episode's title was written with
|
|
93
|
+
(and "2 chapters" when there are more), not a later chapter's under the first one's title.
|
|
94
|
+
A question about time in recall does the same (for "yesterday" or "this morning", the first
|
|
95
|
+
chapter written then), and says how many chapters there are.
|
|
96
|
+
- A note written before the memory server knows its session is filed under the session its
|
|
97
|
+
host opened in that directory, when that match is exact. An older such note, written
|
|
98
|
+
inside exactly one session's stretch, says "session a1b2c3d4 (placed by when it was
|
|
99
|
+
written)".
|
|
100
|
+
- Nearby leaves out what the self page already says, a memory a later one has settled
|
|
101
|
+
(changed or corrected), and a memory already under Arriving; and it no longer ends with a
|
|
102
|
+
"(331 more nearby; recall ids…)" line.
|
|
103
|
+
- A chapter about me written in another directory reaches the wake elsewhere, as one line,
|
|
104
|
+
when its memory is marked about me, us or the owner, the directory it came from is on, and
|
|
105
|
+
it is not confidential. A confidential chapter is named in "Last here" to the owner only.
|
|
106
|
+
- A "Last here" line dropped for room now leaves a record, and the dashboard's Health wake
|
|
107
|
+
bar goes amber for it.
|
|
108
|
+
- recall says why `considered` can be above `consideredCap` (links between memories and a
|
|
109
|
+
feeling the question named have their own bounds).
|
|
110
|
+
- With only Claude Desktop, an older store waiting for its upgrade says to open Desktop or
|
|
111
|
+
start a new chat in it, not to quit and reopen it.
|
|
112
|
+
|
|
113
|
+
Claude Desktop's Code tab (#309).
|
|
114
|
+
|
|
115
|
+
- Claude Desktop's Code tab files its memories under its own session again. There, the
|
|
116
|
+
counterparts tools the assistant sees turned out to be Claude Desktop's memory server, not
|
|
117
|
+
the session's own (both are named `counterparts`, and Desktop's wins), so a Code-tab
|
|
118
|
+
session's notes, chapters and write-ups were filed under the most recent Desktop chat, or
|
|
119
|
+
refused. Now the Code tab's wake gives the assistant one line with its session id, and a
|
|
120
|
+
call that passes that id is filed exactly as Claude Code would file it: in that session's
|
|
121
|
+
folder, under that session, with no Desktop write-up reminder added. Only a session Claude
|
|
122
|
+
Code's hooks recorded, and that is still running, is taken this way, and only for that one
|
|
123
|
+
call, so it can't spill into a Desktop chat's next call. A Code-tab call that passes no id
|
|
124
|
+
still lands under the most recent Desktop chat; its result now says which chat, and tells a
|
|
125
|
+
Claude Code session to pass its own id. The `wake` tool's description no longer says it is
|
|
126
|
+
never offered in Claude Code, and doctor's Claude Desktop line says the Code tab's tools
|
|
127
|
+
come from Desktop's server. Terminal sessions are unchanged. Each prompt now also marks
|
|
128
|
+
its session as still running, so a Code-tab session left idle for hours is recognised
|
|
129
|
+
again at its next prompt, and a call whose session id wasn't accepted says why.
|
|
130
|
+
|
|
131
|
+
Recall by feeling, round 2 (#310).
|
|
132
|
+
|
|
133
|
+
- Asking recall by feeling finds more of what was felt. Any feeling word reaches its family on
|
|
134
|
+
the wheel: "when was I afraid", with nothing recorded as afraid, answers with the strongest
|
|
135
|
+
uneasy moments, and a moment recorded as afraid still comes first. Everyday words off the
|
|
136
|
+
wheel ("shame", "dread", "relief"), forms like "happiest" or "sadness", and phrases like
|
|
137
|
+
"caught out" are understood, and so is your name in the possessive ("Mike's feelings"). Asking for the most, the
|
|
138
|
+
strongest, or "ever" ranks by how strongly something was felt at the time, not by how fresh
|
|
139
|
+
it is. Memories that only talk about feelings (notes on the wheel itself, say) no longer
|
|
140
|
+
crowd out the moments that were actually felt.
|
|
141
|
+
|
|
142
|
+
Dashboard Health (#306).
|
|
143
|
+
|
|
144
|
+
- A full wake is the normal state, so the Health wake bar is green for it ("The wake is
|
|
145
|
+
full — normal: …"). It turns amber only when being full cost something (the self page
|
|
146
|
+
cut or left out, a handoff a session start had no room for, the page writer held back
|
|
147
|
+
for room), and the line names the cost.
|
|
148
|
+
- The archive list shows one line per memory: a chapter's copies are one item that says
|
|
149
|
+
how many times, and opens the newest.
|
|
150
|
+
- The folded rows under "all fine" use the same plain words as the main rows ("… —
|
|
151
|
+
harmless; nothing to do") and no longer say "You may remove".
|
|
152
|
+
- The last sleep shown is the last one that did something, not a check that found
|
|
153
|
+
nothing to do. The map's `?` describes the three named rings.
|
|
154
|
+
- The Lookups row is "Looked up in dreams and reflections", in doctor's words. A dream's
|
|
155
|
+
start says how many memories wait for the next night and how many aged out, and a merge
|
|
156
|
+
the dream saw less than whole says so ("seen only as a line").
|
|
157
|
+
|
|
158
|
+
Small fixes (#307).
|
|
159
|
+
|
|
160
|
+
- The wake's "Arriving:" lines say when each thing is due, not only when it was learned:
|
|
161
|
+
`2026-09-27 (due 2026-10-03) · …`.
|
|
162
|
+
- When the console or the dashboard meets a store still waiting for its upgrade, it says who
|
|
163
|
+
will upgrade it in your hosts' words: with only Claude Desktop it no longer tells you to
|
|
164
|
+
wait for a Claude Code session.
|
|
165
|
+
- Whoever rewrites the self page (the page writer, or the nightly reflection) is asked to name
|
|
166
|
+
the model when a claim is about one model, to write dates rather than "tonight" or
|
|
167
|
+
"today" (the page is read on later days), and not to add a revised-on line of its own.
|
|
168
|
+
- Wake labels: the line under the header no longer also starts "Counterparts memory", and it
|
|
169
|
+
says only the listed memories open with a date (the page is dated on its own line); a
|
|
170
|
+
memory whose words already start with its date shows that date once; and the closing
|
|
171
|
+
comment says `page=1` beside `identity=0` when the wake carries the page.
|
|
172
|
+
- The install loop (`tools/install-loop`, in the package) reads what it captured with a
|
|
173
|
+
here-string, so a long output can no longer fail a check that had matched.
|
|
174
|
+
|
|
175
|
+
Not proven here.
|
|
176
|
+
|
|
177
|
+
- No one uses Counterparts on Node daily yet. Linux was tested on arm64 Debian, in a
|
|
178
|
+
container. Dreaming and the nightly run under Node go through the same wiring, but
|
|
179
|
+
were not run, since that needs a real `claude`. Windows was not attempted.
|
|
180
|
+
- The night catch-up was checked in tests and in a throwaway home with a stand-in
|
|
181
|
+
`claude` that drives the memory server as the real one's single tool would, never with
|
|
182
|
+
a real `claude -p` or on a real store.
|
|
183
|
+
- The Code tab's sessions were measured read-only on a real Desktop, and the serving was
|
|
184
|
+
checked in tests, not on a day's real use.
|
|
185
|
+
|
|
3
186
|
## 0.3.10 — 2026-09-30
|
|
4
187
|
|
|
5
188
|
Feelings now sit on a new wheel of seven cores — happy, warm, calm, curious, sad,
|
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@ its memories itself, and they fade and grow the way yours do. It runs today with
|
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
-
You need [bun](https://bun.sh) 1.3 or newer (
|
|
13
|
+
You need [bun](https://bun.sh) 1.3 or newer, or [Node](https://nodejs.org) 22.15 or newer.
|
|
14
|
+
macOS and Linux.
|
|
14
15
|
|
|
15
16
|
```
|
|
16
17
|
curl -fsSL https://bun.sh/install | bash # if you don't have bun
|
|
@@ -18,6 +19,9 @@ bun add -g counterparts
|
|
|
18
19
|
counterparts
|
|
19
20
|
```
|
|
20
21
|
|
|
22
|
+
With Node instead: `npm install -g counterparts`, then `counterparts`. Whichever runtime
|
|
23
|
+
runs the setup is the one Claude Code's hooks and memory tools are wired to.
|
|
24
|
+
|
|
21
25
|
`counterparts` walks you through setup: your name and connecting Claude Code. No API
|
|
22
26
|
keys. Then restart Claude Code and check it:
|
|
23
27
|
|
|
@@ -106,8 +110,10 @@ More: [`docs/ELI5.md`](docs/ELI5.md) (the whole system in plain words) and
|
|
|
106
110
|
|
|
107
111
|
## Status
|
|
108
112
|
|
|
109
|
-
Early. It's been the author's daily memory since September 2026
|
|
110
|
-
|
|
113
|
+
Early. It's been the author's daily memory since September 2026, on bun and macOS; Node
|
|
114
|
+
(22.15+) and Linux pass a smoke test and an install run but have no daily user yet.
|
|
115
|
+
Claude Desktop has no Linux build, so on Linux it is Claude Code only. Expect rough
|
|
116
|
+
edges, and please
|
|
111
117
|
[open an issue](https://github.com/mlapeter/counterparts/issues) when you hit one.
|
|
112
118
|
|
|
113
119
|
There are no API keys, and nothing leaves your machine except through Claude Code
|
package/docs/QUICKSTART.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Install
|
|
4
4
|
|
|
5
|
-
You need [bun](https://bun.sh) 1.3 or newer
|
|
6
|
-
|
|
5
|
+
You need [bun](https://bun.sh) 1.3 or newer, or [Node](https://nodejs.org) 22.15 or newer,
|
|
6
|
+
on macOS or Linux. With Node, install with `npm install -g counterparts` instead of the
|
|
7
|
+
`bun add` line below; the rest is the same.
|
|
7
8
|
|
|
8
9
|
```
|
|
9
10
|
curl -fsSL https://bun.sh/install | bash # if you don't have bun
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "counterparts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
|
|
6
6
|
"repository": {
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
22
|
"engines": {
|
|
23
|
-
"bun": ">=1.3.0"
|
|
23
|
+
"bun": ">=1.3.0",
|
|
24
|
+
"node": ">=22.15.0"
|
|
24
25
|
},
|
|
25
26
|
"bin": {
|
|
26
|
-
"counterparts": "./src/adapters/cli/bin/counterparts.
|
|
27
|
-
"counterparts-hook": "./src/adapters/claude-code/bin/hook.
|
|
28
|
-
"counterparts-mcp": "./src/adapters/mcp/bin/serve.
|
|
29
|
-
"counterparts-dashboard": "./src/adapters/dashboard/bin/dashboard.
|
|
27
|
+
"counterparts": "./src/adapters/cli/bin/counterparts.mjs",
|
|
28
|
+
"counterparts-hook": "./src/adapters/claude-code/bin/hook.mjs",
|
|
29
|
+
"counterparts-mcp": "./src/adapters/mcp/bin/serve.mjs",
|
|
30
|
+
"counterparts-dashboard": "./src/adapters/dashboard/bin/dashboard.mjs"
|
|
30
31
|
},
|
|
31
32
|
"main": "./src/core/counterpart.ts",
|
|
32
33
|
"types": "./src/core/counterpart.ts",
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
},
|
|
65
66
|
"scripts": {
|
|
66
67
|
"test": "bun test",
|
|
67
|
-
"typecheck": "tsc --noEmit"
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"test:node": "node --import ./src/adapters/node-hooks.mjs --test test/node-smoke.ts"
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -254,8 +254,10 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
254
254
|
later hook process needs: which configuration was read, whether the first-launch
|
|
255
255
|
question went out, the wake's sentinel and whether its arrival has been checked, the
|
|
256
256
|
model that last answered — which the `chapter` tool records per chapter), Stop
|
|
257
|
-
refreshes the clock — creating the record when it is missing —
|
|
258
|
-
it
|
|
257
|
+
refreshes the clock — creating the record when it is missing — UserPromptSubmit
|
|
258
|
+
refreshes it too but never creates one (2026-10-01: so a session idle past the TTL
|
|
259
|
+
is live again before its model's first call; a missing record stays the off→on
|
|
260
|
+
signal), and SessionEnd closes it. The writes
|
|
259
261
|
are atomic (temp + rename), tiny, and silent on failure, because a hook may not fail
|
|
260
262
|
the host (G2) and SessionEnd's hooks share 1.5 s between them. It exists because this
|
|
261
263
|
host launches its MCP servers from a static configuration and cannot tell them which
|
|
@@ -610,6 +612,21 @@ line is claimed once a day across sessions (`dream_asks`), and again only for a
|
|
|
610
612
|
behind (a dream begun and quiet for 30 minutes, or — `auto` — a launch no dream followed),
|
|
611
613
|
at most twice a day.
|
|
612
614
|
|
|
615
|
+
**[M] Only a session someone can see claims the day's told lines (2026-10-01, lane 8, a
|
|
616
|
+
working default).** `hooks.ts#isInteractive`: the host's own `CLAUDE_CODE_SESSION_ATTENDED`
|
|
617
|
+
(`1` / `0`) decides when it is set; otherwise a session whose `entrypoint` is one of
|
|
618
|
+
`sessions.ts#NON_INTERACTIVE_ENTRYPOINTS` (`sdk-cli` is `claude -p`; the SDKs; `mcp`; the
|
|
619
|
+
GitHub action) claims none of them — the dream line, a night run's hand-back, a carried
|
|
620
|
+
share, a raised contradiction, plain reminders (at SessionStart and at a prompt), the update
|
|
621
|
+
notice. An unknown or absent value is a person's. It may still START the day's headless run
|
|
622
|
+
(`startUnwatched`); the line it would have been told is held (`Dreams#holdTold`) and the next
|
|
623
|
+
interactive prompt says it while the run is still going, claimed at delivery (`claimHeld`,
|
|
624
|
+
an event latch per run) — once the run has ended its hand-back tells what it did instead. An
|
|
625
|
+
`ask` is left unclaimed for the next interactive session. Every day's line now tells the
|
|
626
|
+
model to say it ONCE, in its first reply, as one plain sentence (`dream/#sayOnce`); the
|
|
627
|
+
terminal line is the extra. Measured that morning: the day's first prompt came from an SDK
|
|
628
|
+
session with no terminal, which started the run (fine) and claimed the line nobody saw.
|
|
629
|
+
|
|
613
630
|
**[M] The writer moved out of the wake and into the run (2026-09-28).** The SessionStart ask
|
|
614
631
|
that handed the first session of a day the day just gone (S2's session mode, 2026-09-20) is
|
|
615
632
|
RETIRED, and with it its deferral (`no-room`), its contest with the first-launch question
|
|
@@ -687,6 +704,27 @@ child's own host-minted session is QUIET (`HookInput.nightRun`, from
|
|
|
687
704
|
lines, plain reminders, Stop ask, write-up pointer or first-launch question. It still wakes
|
|
688
705
|
with the ordinary wake.
|
|
689
706
|
|
|
707
|
+
**[M] The morning catch-up runs first (2026-10-01, wake build 3 — held lightly).** A `night`
|
|
708
|
+
run (never a reflection-alone one) writes up owed stretches, in ANY directory, before it
|
|
709
|
+
composes its launch prompt (`night-catch-up.ts#runCatchUp`): every session that owes a
|
|
710
|
+
write-up a person's conversation left (`sessions.ts#pointable`), oldest stretch first,
|
|
711
|
+
bounded by `NIGHT_WRITE_UP_SESSIONS` (4) and `NIGHT_WRITE_UP_BYTES` (96 KB, whole parts;
|
|
712
|
+
the first part always). Its runner is a session id of its own, `writeup-<run>`: the
|
|
713
|
+
launcher writes the grant on the runner's record (`grantWriteUps`) and claims every subject
|
|
714
|
+
(`WriteUpProgress.claim`, with `upTo` the last part allowed tonight) before a SECOND
|
|
715
|
+
`claude -p` starts, pinned to that runner, locked down like the first but with
|
|
716
|
+
`--allowedTools` exactly `mcp__counterparts__session_end`, `NIGHT_WRITE_UP_MAX_TURNS` (40)
|
|
717
|
+
and its own watchdog `NIGHT_WRITE_UP_MS` (10 minutes). When it ends, whatever became of it,
|
|
718
|
+
the claims are let go, the grant withdrawn and the runner's record ended; one durable row
|
|
719
|
+
(`adapter.night.writeup`: granted, written, parts, left owed, over the bound, busy elsewhere,
|
|
720
|
+
state) and a process-log line record it, and doctor's Nightly run and Write-ups lines read
|
|
721
|
+
it. Nothing owed: no child, no row. The run's row carries the catch-up's time on its
|
|
722
|
+
watchdog, so a run still going is not read as lost. A clean exit that stopped short of
|
|
723
|
+
its allowance — some granted session neither written up nor brought to its `upTo` part —
|
|
724
|
+
is recorded `partial`, not `done` (a usage limit exits 0 too; its output is not read); a
|
|
725
|
+
bounded night that did every part it was allowed is `done`. A runner record a killed process left open is ended at the
|
|
726
|
+
next run's start (`endStaleRunners`).
|
|
727
|
+
|
|
690
728
|
**[M] The person sees it, and a run that cannot do its job falls back to asking.** The prompt
|
|
691
729
|
hook's `systemMessage` carries "dreaming in the background (a few minutes). Say "no dreams"
|
|
692
730
|
to turn it off." when the envelope has room (the model's line never claims it was shown).
|
|
@@ -718,6 +756,10 @@ did not get.
|
|
|
718
756
|
longer the reported injection budget) → plain reminders due today (they wait for the
|
|
719
757
|
first prompt, unclaimed) → the wake, which is never cut at delivery: it was composed to
|
|
720
758
|
its own budget at the boundary, trimming hints → craft → threads → horizon → identity.
|
|
759
|
+
The clock line rides with the wake — and, in Desktop's Code tab only (entrypoint
|
|
760
|
+
`claude-desktop`, 2026-10-01), one line under it naming the session id to pass as
|
|
761
|
+
`session`, because there the counterparts tools are Desktop's server
|
|
762
|
+
(`hooks.ts#codeTabSessionLine`; mcp CONTRACT G21). A terminal session's wake is unchanged.
|
|
721
763
|
A reminder reaches the person only in the JSON form, so when one is due and it fits
|
|
722
764
|
beside the wake in that form, the two asks are measured against THAT form (escaped,
|
|
723
765
|
under 9,500) and it is they that give way (review of #285, S2). A wake too full for the
|
|
@@ -1880,3 +1880,20 @@ Working defaults, held lightly.
|
|
|
1880
1880
|
nightly run's planner still live here; a host that starts either from the MCP server
|
|
1881
1881
|
needs their paths, not an import. `deliverWriteUpAsk`'s default limit is still this
|
|
1882
1882
|
host's `HOST_OUTPUT_CHARS`; a tool result has no such cap and should pass its own.
|
|
1883
|
+
|
|
1884
|
+
## 2026-10-01 — the day's lines reach a session someone can see (lane 8, build 4)
|
|
1885
|
+
|
|
1886
|
+
An SDK session (`claude -p`, `entrypoint: sdk-cli`, ~/general) sent the day's first prompt at
|
|
1887
|
+
09:00: it started the nightly run and claimed the once-a-day line, which nobody saw. Now
|
|
1888
|
+
`isInteractive` gates every told line (dream line, hand-back, carried share, raised
|
|
1889
|
+
contradiction, plain reminders, update notice). A headless session still starts the run
|
|
1890
|
+
(`startUnwatched`) and holds its line (`Dreams#holdTold`); the next interactive prompt says it
|
|
1891
|
+
if the run is still going, claimed at delivery (`claimHeld`, `deliverTurn`'s `held` branch,
|
|
1892
|
+
stripped from the model's context when the claim is lost). The model is told to say the line
|
|
1893
|
+
once in its first reply, one plain sentence. Not gated: the doctor notice (it returns at the
|
|
1894
|
+
next start) and the write-up pointer (a headless session can do a write-up).
|
|
1895
|
+
|
|
1896
|
+
Review of #313: Claude Code exports `CLAUDE_CODE_SESSION_ATTENDED` to the processes it
|
|
1897
|
+
starts. Measured in a terminal session's child: `1`, beside `CLAUDE_CODE_ENTRYPOINT=cli`. Not
|
|
1898
|
+
measured under `claude -p`. When the variable says `1` or `0` it decides `isInteractive`; the
|
|
1899
|
+
entrypoint list is the fallback when it is absent or unreadable (`bin/hook.ts#attendedOf`).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
':' //; if command -v bun >/dev/null 2>&1; then exec bun "$0" "$@"; elif command -v node >/dev/null 2>&1; then exec node "$0" "$@"; else echo "counterparts: needs Bun 1.3+ or Node 22.15+ on PATH" >&2; exit 127; fi
|
|
3
|
+
// A shell script and an ES module at once: the line above is a no-op string to
|
|
4
|
+
// JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node).
|
|
5
|
+
// See `adapters/launch.mjs`.
|
|
6
|
+
import { launch } from "../../launch.mjs";
|
|
7
|
+
|
|
8
|
+
await launch(new URL("./hook.ts", import.meta.url));
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
} from "../standdown.js";
|
|
57
57
|
import type { SaysSoHook, StandDownFault } from "../standdown.js";
|
|
58
58
|
import { readTranscript } from "../transcript.js";
|
|
59
|
+
import { scriptArgs } from "../../runtime.js";
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* The host's own spellings of the two events that carry a notice — one
|
|
@@ -403,6 +404,9 @@ export function toHookInput(
|
|
|
403
404
|
...(isEntrypoint((opts.env ?? process.env)["CLAUDE_CODE_ENTRYPOINT"])
|
|
404
405
|
? { entrypoint: (opts.env ?? process.env)["CLAUDE_CODE_ENTRYPOINT"] as string }
|
|
405
406
|
: {}),
|
|
407
|
+
// IS SOMEONE THERE (2026-10-01, lane 8): the host's own word, when it
|
|
408
|
+
// gives one, ahead of the entrypoint list (`hooks.ts#isInteractive`).
|
|
409
|
+
...attendedOf((opts.env ?? process.env)["CLAUDE_CODE_SESSION_ATTENDED"]),
|
|
406
410
|
// THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
|
|
407
411
|
// hook's rows, the wake preface, the prospective "today" and the date the
|
|
408
412
|
// boundary hands the lived clock — which is why the lived clock can see a
|
|
@@ -716,8 +720,8 @@ async function runHook(
|
|
|
716
720
|
const toLog = (e: LogEvent): void => log?.event(e);
|
|
717
721
|
const adapter = openAdapter(config, {
|
|
718
722
|
command: process.execPath,
|
|
719
|
-
args:
|
|
720
|
-
nightArgs:
|
|
723
|
+
args: scriptArgs(RUNNER_PATH),
|
|
724
|
+
nightArgs: scriptArgs(NIGHTLY_PATH),
|
|
721
725
|
// WHICH FILE THIS RUN READ, carried into the adapter so it can be RECORDED:
|
|
722
726
|
// a hook cannot print to the owner (its stdout is the model's context), so
|
|
723
727
|
// the answer goes into the session registry record and the event ring
|
|
@@ -826,6 +830,15 @@ async function runHook(
|
|
|
826
830
|
opened.end(outcome);
|
|
827
831
|
}
|
|
828
832
|
|
|
833
|
+
/** `CLAUDE_CODE_SESSION_ATTENDED` as `HookInput.attended`: `1`/`true` and
|
|
834
|
+
* `0`/`false`; anything else says nothing. */
|
|
835
|
+
export function attendedOf(raw: string | undefined): { attended?: boolean } {
|
|
836
|
+
const v = (raw ?? "").trim().toLowerCase();
|
|
837
|
+
if (v === "1" || v === "true") return { attended: true };
|
|
838
|
+
if (v === "0" || v === "false") return { attended: false };
|
|
839
|
+
return {};
|
|
840
|
+
}
|
|
841
|
+
|
|
829
842
|
/** The two adapter doors `deliverTurn` needs — structural, so a test can
|
|
830
843
|
* hand it doors that throw. */
|
|
831
844
|
export interface UpdateNoticeDoors {
|
|
@@ -843,6 +856,12 @@ export interface UpdateNoticeDoors {
|
|
|
843
856
|
* line is not shown and waits for a later prompt.
|
|
844
857
|
*/
|
|
845
858
|
claimDream?(input: HookInput, offer: DreamOffer): boolean;
|
|
859
|
+
/**
|
|
860
|
+
* Claim a HELD dream line — a run a session nobody watched started — this
|
|
861
|
+
* delivery is certainly about to show (`ClaudeCodeAdapter#claimHeld`,
|
|
862
|
+
* 2026-10-01). Absent: nothing can be claimed, so it waits.
|
|
863
|
+
*/
|
|
864
|
+
claimHeld?(input: HookInput, run: string): boolean;
|
|
846
865
|
/** Claim the one-time line about `auto` set back to `ask` (`ClaudeCodeAdapter#claimDreamNote`). */
|
|
847
866
|
claimDreamNote?(input: HookInput): boolean;
|
|
848
867
|
/**
|
|
@@ -936,7 +955,13 @@ export function deliverTurn(
|
|
|
936
955
|
const probe = hostDelivery(name, r, payload, [...(ordered ?? []), told.notice]);
|
|
937
956
|
let showDream = false;
|
|
938
957
|
if (probe.dropped === null) {
|
|
939
|
-
if (told.
|
|
958
|
+
if (told.held !== undefined) {
|
|
959
|
+
try {
|
|
960
|
+
showDream = doors.claimHeld?.(input, told.held) ?? false;
|
|
961
|
+
} catch {
|
|
962
|
+
showDream = false;
|
|
963
|
+
}
|
|
964
|
+
} else if (told.offer === null) showDream = true;
|
|
940
965
|
else {
|
|
941
966
|
try {
|
|
942
967
|
showDream = doors.claimDream?.(input, told.offer) ?? false;
|
|
@@ -949,7 +974,7 @@ export function deliverTurn(
|
|
|
949
974
|
gaveWay(doors, input, "dream", 1);
|
|
950
975
|
}
|
|
951
976
|
if (showDream) ordered = [...(ordered ?? []), told.notice];
|
|
952
|
-
else if (told.offer !== null) r = withoutDream(r);
|
|
977
|
+
else if (told.offer !== null || told.held !== undefined) r = withoutDream(r);
|
|
953
978
|
}
|
|
954
979
|
// THE ONE-TIME RESET LINE (owner decision A), under the same rule.
|
|
955
980
|
const note = r.dreamNote;
|