counterparts 0.3.13 → 0.3.14
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 +160 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/bin/hook.mjs +4 -2
- package/src/adapters/claude-code/bin/hook.ts +11 -4
- package/src/adapters/claude-code/bin/nightly.ts +5 -1
- package/src/adapters/claude-code/bin/runner.ts +11 -3
- package/src/adapters/claude-code/doctor.ts +69 -5
- package/src/adapters/claude-code/embed-client.ts +3 -0
- package/src/adapters/cli/bin/counterparts.mjs +4 -2
- package/src/adapters/cli/bin/counterparts.ts +11 -3
- package/src/adapters/cli/commands.ts +65 -23
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +22 -9
- package/src/adapters/cli/settle.ts +39 -2
- package/src/adapters/cli/wire.ts +4 -0
- package/src/adapters/config.ts +29 -1
- package/src/adapters/dashboard/NOTES.md +33 -0
- package/src/adapters/dashboard/bin/dashboard.mjs +4 -2
- package/src/adapters/dashboard/bin/dashboard.ts +11 -3
- package/src/adapters/dashboard/index.ts +14 -0
- package/src/adapters/dashboard/source.ts +0 -8
- package/src/adapters/dashboard/web/fired.ts +8 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -1
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +7 -10
- package/src/adapters/dashboard/web/pages/memories/memories.css +3 -0
- package/src/adapters/dashboard/web/pages/memories/row.js +5 -2
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +2 -1
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +19 -3
- package/src/adapters/dashboard/web/server.ts +16 -4
- package/src/adapters/dashboard/web/shared/dates.js +6 -16
- package/src/adapters/dashboard/web/shared/memory-modal.js +21 -8
- package/src/adapters/dashboard/web/views/health.ts +11 -0
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +8 -5
- package/src/adapters/dashboard/web/views/memories.ts +26 -7
- package/src/adapters/dashboard/web/views/memory-words.ts +16 -0
- package/src/adapters/dashboard/web/views/memory.ts +51 -2
- package/src/adapters/dashboard/web/views/mind.ts +31 -6
- package/src/adapters/empty-bunfig.toml +5 -0
- package/src/adapters/fired.ts +6 -2
- package/src/adapters/host-wiring.ts +4 -3
- package/src/adapters/log/index.ts +2 -2
- package/src/adapters/mcp/CONTRACT.md +16 -2
- package/src/adapters/mcp/INTERFACE-GAPS.md +15 -1
- package/src/adapters/mcp/NOTES.md +243 -0
- package/src/adapters/mcp/bin/serve.mjs +4 -2
- package/src/adapters/mcp/bin/serve.ts +11 -4
- package/src/adapters/mcp/facts.ts +72 -4
- package/src/adapters/mcp/meaning.ts +218 -15
- package/src/adapters/mcp/server.ts +1 -1
- package/src/adapters/mcp/tools.ts +81 -57
- package/src/adapters/plugin-run.sh +405 -33
- package/src/adapters/plugin.ts +14 -2
- package/src/adapters/runtime.ts +192 -17
- package/src/adapters/sessions.ts +2 -2
- package/src/core/associate/NOTES.md +10 -0
- package/src/core/bridge.ts +1 -1
- package/src/core/briefing.ts +20 -3
- package/src/core/contradictions.ts +56 -20
- package/src/core/counterpart.ts +39 -17
- package/src/core/dream/CONTRACT.md +4 -12
- package/src/core/dream/INTERFACE-GAPS.md +3 -2
- package/src/core/dream/NOTES.md +10 -0
- package/src/core/dream/index.ts +10 -52
- package/src/core/embed/static.ts +5 -1
- package/src/core/encode/INTERFACE-GAPS.md +2 -1
- package/src/core/encode/NOTES.md +12 -0
- package/src/core/encode/chunk.ts +6 -30
- package/src/core/encode/index.ts +0 -1
- package/src/core/encode/types.ts +1 -13
- package/src/core/handoff/last-here.ts +18 -2
- package/src/core/physics/CONTRACT.md +6 -0
- package/src/core/physics/NOTES.md +33 -2
- package/src/core/physics/index.ts +22 -7
- package/src/core/prospective/CONTRACT.md +3 -1
- package/src/core/prospective/NOTES.md +15 -0
- package/src/core/recall/time-ask.ts +154 -19
- package/src/core/self/CONTRACT.md +23 -3
- package/src/core/self/NOTES.md +64 -0
- package/src/core/self/behind.ts +6 -3
- package/src/core/self/briefing.ts +272 -11
- package/src/core/self/index.ts +50 -4
- package/src/core/sleep/NOTES.md +32 -0
- package/src/core/store/NOTES.md +16 -0
- package/src/core/time.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,165 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.14 — 2026-10-09
|
|
4
|
+
|
|
5
|
+
The Claude Code plugin now runs on a Mac or Linux computer with neither Bun nor Node.js:
|
|
6
|
+
it downloads one prebuilt Counterparts program for that computer from this version's GitHub
|
|
7
|
+
release, checked against a sha256 the plugin carries. A project's `.env` and `bunfig.toml`
|
|
8
|
+
no longer reach into the hooks, the memory server or the `counterparts` command. **If you
|
|
9
|
+
installed through npm, run `counterparts connect` once after upgrading** to rewrite the
|
|
10
|
+
hooks and the server registration; until then doctor's Runtime line is amber. The wake keeps
|
|
11
|
+
the first "Still open" item beside a long self page and says when a reminder was due. Facts
|
|
12
|
+
recall names corrected memories with an id to open and reads amounts as amounts, meaning
|
|
13
|
+
recall says when the person asked about has no card, and the dashboard dates everything in
|
|
14
|
+
the configured zone. **No change to the store's format (still v12).** Going back to 0.3.13
|
|
15
|
+
takes three steps, in this order: `counterparts disconnect` while 0.3.14 is still installed,
|
|
16
|
+
then the 0.3.13 reinstall, then `counterparts connect`. 0.3.14's hook and server commands
|
|
17
|
+
name a file 0.3.13 doesn't ship, and 0.3.13's `connect` doesn't recognise them, so it would
|
|
18
|
+
add its own beside them.
|
|
19
|
+
|
|
20
|
+
A project's `.env` and `bunfig.toml` stay out (#349).
|
|
21
|
+
|
|
22
|
+
- **A project's `.env` and `bunfig.toml` no longer reach into Counterparts.** Bun reads
|
|
23
|
+
both from the folder it starts in, and Claude Code starts the hooks and the memory
|
|
24
|
+
server in your project. So a project whose `.env` set `COUNTERPARTS_DATA_DIR` or
|
|
25
|
+
`COUNTERPARTS_CONFIG` could send the plugin's server, an npm install's hooks or the
|
|
26
|
+
`counterparts` command to a different store, and a `bunfig.toml` with a `preload`
|
|
27
|
+
ran its own code inside them. Every place Counterparts starts Bun now passes
|
|
28
|
+
`--no-env-file` and `--config=` pointing at an empty bunfig in the package: the hook
|
|
29
|
+
and server commands `install` and `connect` write, the plugin's launcher, the
|
|
30
|
+
installed commands, and the workers and nightly run it starts itself. Node reads
|
|
31
|
+
neither on its own. **If you installed through npm, run `counterparts connect`
|
|
32
|
+
once** to rewrite your hooks and server registration. Until you do, doctor's Runtime
|
|
33
|
+
line is amber and says so. Plugin users get the change when the plugin updates.
|
|
34
|
+
|
|
35
|
+
The plugin on a computer with no Bun or Node (#351).
|
|
36
|
+
|
|
37
|
+
- **The plugin works on a Mac or Linux computer with no Bun or Node.js.** Until now it
|
|
38
|
+
gave up there. Now it downloads one prebuilt Counterparts program for that computer
|
|
39
|
+
(55–75 MB, over HTTPS, from this repository's GitHub releases), checks it against a
|
|
40
|
+
sha256 that ships inside the plugin, keeps it in the plugin's data folder, and runs
|
|
41
|
+
that. It re-checks the kept program too: the whole file each time the memory server
|
|
42
|
+
starts, and a quick stamp of it at every hook; one that changed is deleted and fetched
|
|
43
|
+
again. Windows isn't offered a program yet; there, the plugin still says to install
|
|
44
|
+
Bun or Node. The first session says it's getting ready and that memory starts in the
|
|
45
|
+
next one. A failed download says so once and tries again later; nothing unchecked is
|
|
46
|
+
ever run. `COUNTERPARTS_BINARY_DOWNLOAD=off` forbids the download. The program is the
|
|
47
|
+
whole of Counterparts, with the model and the dashboard packed in. It starts a little
|
|
48
|
+
faster than `bun` (a prompt's hook takes about 86 ms vs. about 102 ms). It won't wire
|
|
49
|
+
Claude Code or Claude Desktop itself: `counterparts connect` from it says to use the
|
|
50
|
+
npm install for that. How it is built and released: `docs/single-binary.md`.
|
|
51
|
+
|
|
52
|
+
The wake (#350).
|
|
53
|
+
|
|
54
|
+
- **"Still open" lists its first item beside a long self page, and never prints a heading
|
|
55
|
+
over a count.** With a long page, the Yesterday line and the Arriving lines taking the
|
|
56
|
+
room, a 9,000-byte wake could print "Still open:" with only "(20 more still open; recall
|
|
57
|
+
ids …)" under it. The self page is still never cut for this: it prints whole up to its
|
|
58
|
+
cap, as before. Instead "Still open" keeps its first item and its count, and the room
|
|
59
|
+
comes, in order, from the "Work here" lines (fewer of them that morning), Arriving past
|
|
60
|
+
its first line, and the Yesterday line's titles (fewer named, the rest counted). A lane
|
|
61
|
+
that still has room for nothing says so in one line: "Still open: 20 — no room to list
|
|
62
|
+
them in this wake; recall ids …".
|
|
63
|
+
- **An Arriving reminder past its date says it was due.** A one-off reminder stays under
|
|
64
|
+
"Arriving:" for a week after its date, and the wake written the evening before is read
|
|
65
|
+
the next morning, so "(due 2026-10-08)" was read on the 9th as if still to come. The
|
|
66
|
+
line now reads "(was due yesterday, 2026-10-08)" the morning after and "(was due
|
|
67
|
+
2026-10-05)" later. A reminder due on the day it was noted now reads "due 2026-10-08"
|
|
68
|
+
rather than the date alone.
|
|
69
|
+
- **A plain reminder said on its day leaves "Arriving:" at the next turn.** When the
|
|
70
|
+
day's wake was written before the reminder was said (a session running past midnight),
|
|
71
|
+
it stayed under "Arriving:" all day and into the next morning.
|
|
72
|
+
|
|
73
|
+
Recall (#345, #347, #348, #352).
|
|
74
|
+
|
|
75
|
+
- **Facts recall no longer reads an amount as a date, or "since 10/25" as an empty
|
|
76
|
+
window.** "7-8 hours", "3/4 cup", "5-10%" and "$5-10" were read as dates (July 8, March
|
|
77
|
+
4, May 10) and filtered the answer to them; they are amounts now, and a date later in
|
|
78
|
+
the question is still read. "Cut it by 1/2" or "reduced to 1/3" is a fraction, not a
|
|
79
|
+
deadline of January 2; "finish by 1/2" still is one. And "since 10/25" or "after 10/25"
|
|
80
|
+
asked before the 25th of this month means last year's 10/25, where it gave nothing (or
|
|
81
|
+
only what is still to come). "Before", "until" and "by" a coming day keep this year's.
|
|
82
|
+
"2-3 weeks ago" and "3 or 4 days ago" cover both ends, where only the far one was read,
|
|
83
|
+
and a zero-padded "09-28" stays a date whatever word follows it.
|
|
84
|
+
Questions with no time in them answer exactly as before.
|
|
85
|
+
- **Facts recall reads "by 12/20" asked in October as this year's December 20th.** A
|
|
86
|
+
date with no year under "by", "until", "up to" or "before", in a month that has not
|
|
87
|
+
begun yet, was read as last year's: "what's due by 12/20" asked on 10-09 kept only what
|
|
88
|
+
happened through 2025-12-20 and hid the ten months since. It is now this year's
|
|
89
|
+
whenever that is the nearer of the two, so those months are no longer cut off.
|
|
90
|
+
"Until Dec 30" asked on January 3rd is still the one four days back, and "since" and
|
|
91
|
+
"after" still reach back to last year's date as before.
|
|
92
|
+
- **Facts recall now names corrected memories, so they can be opened.** A memory
|
|
93
|
+
settled as corrected (it was wrong) is never offered as a fact. Facts answers used to
|
|
94
|
+
say only "1 corrected version hidden" under the memory that corrected it, with no way
|
|
95
|
+
to reach it, even when the question named it. If the correction itself pointed at the
|
|
96
|
+
wrong memory, a true memory became unreachable. Each one now gets a line under the
|
|
97
|
+
memory that corrected it, marked as wrong, with its id:
|
|
98
|
+
`corrected (was wrong): "…" (learned 09-10), corrected 09-11 · mem_…`. Opening that id
|
|
99
|
+
with `recall` shows the whole memory and which memory corrected it. Up to three are
|
|
100
|
+
named, the ones the question's words reach first, and any more are counted. The
|
|
101
|
+
dashboard's Ask shows them the same way, with links. Answers that have no corrected
|
|
102
|
+
versions are unchanged.
|
|
103
|
+
- **Meaning recall says when the person you asked about has no card.** "What has Han
|
|
104
|
+
been to Mike?" on a store where only Mike has a card used to come back as Mike's story
|
|
105
|
+
with no word about Han. Now the answer opens with "No card for Han yet; here is what
|
|
106
|
+
mentions Han", follows the memories that name Han, and lists Mike's card as one to ask
|
|
107
|
+
about. If nothing mentions Han, it says that instead. The name leads only when every
|
|
108
|
+
card the question names is mentioned in passing ("been to Mike", "since Driftwood").
|
|
109
|
+
When a card is asked about or named plainly ("how have Han and Oskar been?", "what did
|
|
110
|
+
Oskar say about Han?"), the answer follows that card as before and opens by saying Han
|
|
111
|
+
has none. The dashboard's Ask shows the same first line.
|
|
112
|
+
A question that names no card at all ("what has Han been up to?") is answered as
|
|
113
|
+
before, by its words and meaning. A first name of a card's longer name ("Marguerite"
|
|
114
|
+
for Marguerite Solberg), an acronym ("API", "Q3") and a question typed in Title Case
|
|
115
|
+
are never taken for a name with no card.
|
|
116
|
+
|
|
117
|
+
The dashboard, doctor and the tool descriptions (#343, #346, #347, #352).
|
|
118
|
+
|
|
119
|
+
- **The dashboard no longer says a repeating reminder is about to be put away.** A memory
|
|
120
|
+
whose date still repeats is kept for its next time however faint it has grown, so the
|
|
121
|
+
memories list no longer marks it "fading" and its card names no day it would be put
|
|
122
|
+
away. The row says how often it comes round instead ("repeats every May 14"), and the
|
|
123
|
+
card says "It comes round every May 14, so I'll keep it while it does." A protected
|
|
124
|
+
memory's card no longer names such a day either, since the nightly cleanup never lets
|
|
125
|
+
one go: it says "It's protected, so I'll keep it even if nobody uses it."
|
|
126
|
+
- **The dashboard dates everything in the zone the hooks use.** With a `timeZone` in the
|
|
127
|
+
configuration that differs from the computer's, the dashboard used the computer's zone
|
|
128
|
+
and the browser's own, so one page could show two days for one moment: a memory's
|
|
129
|
+
"recorded" chip on one, its "Written" line on the next. The dashboard now reads the
|
|
130
|
+
configuration's `timeZone` (the named one, else the one beside the store), every view
|
|
131
|
+
dates in it, and the card's "Written" day and the Health cycle line come from the
|
|
132
|
+
server already dated. The card's details row names that zone ("Sep 28th, 2026, 11:47
|
|
133
|
+
MDT") instead of printing UTC, and the Flow page's fired footer names it instead of a
|
|
134
|
+
stale "(UTC)". Without a `timeZone` set, nothing changes.
|
|
135
|
+
- **Doctor's prune line no longer reads BLOCKED over protected memories it was keeping
|
|
136
|
+
anyway.** The nightly cleanup counted every protected memory (the self page is one) as
|
|
137
|
+
a refusal every night, even when it was nowhere near being let go, and did the same for
|
|
138
|
+
a memory in the middle of being corrected. It now counts `protected` and
|
|
139
|
+
`in-live-revision-chain` only where that is what kept the memory, as it already did for
|
|
140
|
+
`recurring`. Nothing is cleaned up differently.
|
|
141
|
+
- **Doctor counts held corrections.** When a new memory says it changes or corrects one
|
|
142
|
+
that doesn't look related, the old one is left alone and the hold is recorded (0.3.13).
|
|
143
|
+
Doctor's Contradictions line now says how many were held in the last 7 lived days and
|
|
144
|
+
how many were settled by hand since ("2 corrections held because they didn't look
|
|
145
|
+
related to the memory they named, 1 settled by hand since; if the other was meant,
|
|
146
|
+
settle it with counterparts settle, which lists it"). It stays green. `counterparts
|
|
147
|
+
settle` lists the ones still held, each with the command that settles it.
|
|
148
|
+
- **Three more reads keep the newest rows.** Past the number of rows each reads,
|
|
149
|
+
`counterparts settle` (and doctor's held-corrections count) took the newest held
|
|
150
|
+
corrections for never settled, and the self tab's page history left its newest
|
|
151
|
+
versions and days undated. They read the newest now. Below those limits nothing
|
|
152
|
+
changes.
|
|
153
|
+
- **Tool descriptions put how to call each tool first.** Claude Code shows the model only
|
|
154
|
+
the first 2,048 characters of a tool's description when the tool is loaded up front:
|
|
155
|
+
with tool search off, behind a custom base URL or proxy, or on a model without tool
|
|
156
|
+
search. Seven of the nine descriptions are longer than that. Each tool's purpose, when
|
|
157
|
+
to call it and every "Do NOT" were already inside that first part. The cut fell in
|
|
158
|
+
the list of guarantees, so `note`, `recall`, `session_end` and `reflect` now lead
|
|
159
|
+
that list with the claims about how to call them: which fields are fields, that a
|
|
160
|
+
question needs a mode, that an empty `memories` is an answer. No wording changed, and
|
|
161
|
+
nothing behaves differently.
|
|
162
|
+
|
|
3
163
|
## 0.3.13 — 2026-10-09
|
|
4
164
|
|
|
5
165
|
A dated memory can now repeat (daily, weekly, monthly or yearly), and a reminder that
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
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
|
|
2
|
+
':' //; s="$0"; n=0; while [ -h "$s" ] && [ $n -lt 32 ]; do n=$((n+1)); l="$(readlink "$s")"; case "$l" in /*) s="$l" ;; *) s="${s%/*}/$l" ;; esac; done; c="${s%/*}/../../empty-bunfig.toml"; [ -f "$c" ] || c=/dev/null; if command -v bun >/dev/null 2>&1; then exec bun --no-env-file "--config=$c" "$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
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
|
|
4
|
+
// JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node;
|
|
5
|
+
// Bun with --no-env-file and --config=<empty-bunfig.toml>, found through any
|
|
6
|
+
// bin symlink, so a project's .env and bunfig.toml stay out: adapters/runtime.ts).
|
|
5
7
|
// See `adapters/launch.mjs`.
|
|
6
8
|
import { launch } from "../../launch.mjs";
|
|
7
9
|
|
|
@@ -57,7 +57,8 @@ import {
|
|
|
57
57
|
} from "../standdown.js";
|
|
58
58
|
import type { SaysSoHook, StandDownFault } from "../standdown.js";
|
|
59
59
|
import { readTranscript } from "../transcript.js";
|
|
60
|
-
import { scriptArgs } from "../../runtime.js";
|
|
60
|
+
import { BINARY, scriptArgs } from "../../runtime.js";
|
|
61
|
+
import type { Binary } from "../../runtime.js";
|
|
61
62
|
import { npmWiring } from "../../host-wiring.js";
|
|
62
63
|
import { ensureFirstRun, hookGate, runningAsPlugin } from "../../plugin.js";
|
|
63
64
|
|
|
@@ -1224,12 +1225,16 @@ export function hostDelivery(
|
|
|
1224
1225
|
|
|
1225
1226
|
/** True only when this file is the process entry point — so a test may import
|
|
1226
1227
|
* `toHookInput` and `hostConfig` without the script running itself. */
|
|
1227
|
-
export function isEntryPoint(argv1: string | undefined, url: string): boolean {
|
|
1228
|
-
|
|
1228
|
+
export function isEntryPoint(argv1: string | undefined, url: string, binary: Binary | null = BINARY): boolean {
|
|
1229
|
+
// Never in the single binary, where every module shares one URL: its
|
|
1230
|
+
// dispatcher (tools/single-binary/main.ts) calls `start()` itself.
|
|
1231
|
+
if (argv1 === undefined || binary !== null) return false;
|
|
1229
1232
|
return resolve(argv1) === fileURLToPath(new URL(url));
|
|
1230
1233
|
}
|
|
1231
1234
|
|
|
1232
|
-
|
|
1235
|
+
/** Run the hook and exit — what this file does as a script, and what the
|
|
1236
|
+
* single binary's `hook` mode calls. */
|
|
1237
|
+
export function start(): void {
|
|
1233
1238
|
void main().then(
|
|
1234
1239
|
() => process.exit(process.exitCode === 2 ? 2 : 0),
|
|
1235
1240
|
(err: unknown) => {
|
|
@@ -1249,3 +1254,5 @@ if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
|
1249
1254
|
},
|
|
1250
1255
|
);
|
|
1251
1256
|
}
|
|
1257
|
+
|
|
1258
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) start();
|
|
@@ -85,7 +85,9 @@ function standDown(config: Parameters<typeof openNightCounterpart>[0], run: stri
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
/** The nightly run, then exit — what this file does as a script, and what the
|
|
89
|
+
* single binary's `nightly` mode calls. */
|
|
90
|
+
export function start(): void {
|
|
89
91
|
void main().then(
|
|
90
92
|
() => process.exit(0),
|
|
91
93
|
(err: unknown) => {
|
|
@@ -94,3 +96,5 @@ if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
|
94
96
|
},
|
|
95
97
|
);
|
|
96
98
|
}
|
|
99
|
+
|
|
100
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) start();
|
|
@@ -79,6 +79,8 @@ import { dataDir, describeGuardRefusal } from "../../../core/store/index.js";
|
|
|
79
79
|
import type { Store } from "../../../core/store/index.js";
|
|
80
80
|
import { hostSessionEvidence, installedVersion, writeUpSources } from "../../sessions.js";
|
|
81
81
|
import { openLog } from "../../log/index.js";
|
|
82
|
+
import { BINARY } from "../../runtime.js";
|
|
83
|
+
import type { Binary } from "../../runtime.js";
|
|
82
84
|
|
|
83
85
|
import {
|
|
84
86
|
configLine,
|
|
@@ -544,8 +546,10 @@ export function pinnedScope(env: Record<string, string | undefined> = process.en
|
|
|
544
546
|
return raw !== undefined && raw.trim().length > 0 ? raw : null;
|
|
545
547
|
}
|
|
546
548
|
|
|
547
|
-
export function isEntryPoint(argv1: string | undefined, url: string): boolean {
|
|
548
|
-
|
|
549
|
+
export function isEntryPoint(argv1: string | undefined, url: string, binary: Binary | null = BINARY): boolean {
|
|
550
|
+
// Never in the single binary, where every module shares one URL: its
|
|
551
|
+
// dispatcher (tools/single-binary/main.ts) calls `start()` itself.
|
|
552
|
+
if (argv1 === undefined || binary !== null) return false;
|
|
549
553
|
return resolve(argv1) === fileURLToPath(new URL(url));
|
|
550
554
|
}
|
|
551
555
|
|
|
@@ -643,7 +647,9 @@ async function main(): Promise<void> {
|
|
|
643
647
|
}
|
|
644
648
|
}
|
|
645
649
|
|
|
646
|
-
|
|
650
|
+
/** One worker run, then exit — what this file does as a script, and what the
|
|
651
|
+
* single binary's `runner` mode calls. */
|
|
652
|
+
export function start(): void {
|
|
647
653
|
void main().then(
|
|
648
654
|
() => process.exit(0),
|
|
649
655
|
(err: unknown) => {
|
|
@@ -659,3 +665,5 @@ if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
|
659
665
|
},
|
|
660
666
|
);
|
|
661
667
|
}
|
|
668
|
+
|
|
669
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) start();
|
|
@@ -74,7 +74,8 @@ import {
|
|
|
74
74
|
preMigrationDir,
|
|
75
75
|
} from "../../core/store/index.js";
|
|
76
76
|
import { BUSY_TIMEOUT_MS, journalModeOf } from "../../core/store/db.js";
|
|
77
|
-
import {
|
|
77
|
+
import { heldCorrections } from "../../core/contradictions.js";
|
|
78
|
+
import { CLI_SCRIPT, NODE_HOOKS, bundledModelDir } from "../runtime.js";
|
|
78
79
|
import { acceptsReflectedFeeling, laterFeelingWasAwake, laterFeelingWasReflections, selfRelevantFeeling } from "../../core/sleep/index.js";
|
|
79
80
|
import { TUNABLES as ASSOCIATE_TUNABLES, isDead, pairKey } from "../../core/associate/index.js";
|
|
80
81
|
import type { EventRow } from "../../core/store/index.js";
|
|
@@ -1227,7 +1228,8 @@ function staticFinding(input: DoctorInput, data: Record<string, string | number
|
|
|
1227
1228
|
{ ...data, kind: "static", weights: str(row, "weights") },
|
|
1228
1229
|
);
|
|
1229
1230
|
}
|
|
1230
|
-
const
|
|
1231
|
+
const bundled = bundledModelDir();
|
|
1232
|
+
const found = resolveStaticWeights(bundled === undefined ? {} : { packageDir: bundled });
|
|
1231
1233
|
// THE TABLE FILE, not just a folder: a `COUNTERPARTS_STATIC_WEIGHTS_DIR`
|
|
1232
1234
|
// naming an empty or wrong folder is found by name and holds nothing, and a
|
|
1233
1235
|
// green here would last until the first worker row said NO_WEIGHTS.
|
|
@@ -2781,6 +2783,25 @@ export function recognitionLaneFindings(store: Store): Finding[] {
|
|
|
2781
2783
|
/** The lived days the Contradictions line covers. */
|
|
2782
2784
|
export const CONTRADICTION_WINDOW_DAYS = 7;
|
|
2783
2785
|
|
|
2786
|
+
/**
|
|
2787
|
+
* The Contradictions line's held part, plainly: "; 2 corrections held because
|
|
2788
|
+
* they didn't look related to the memory they named; if any were meant,
|
|
2789
|
+
* settle them with counterparts settle, which lists them". Empty when nothing
|
|
2790
|
+
* was held. Those settled by hand since are counted, and the pointer is only
|
|
2791
|
+
* for the ones still held — most are a wrong pointer caught, which needs nothing.
|
|
2792
|
+
*/
|
|
2793
|
+
export function heldLine(held: number, settledAfter: number): string {
|
|
2794
|
+
if (held <= 0) return "";
|
|
2795
|
+
const one = held === 1;
|
|
2796
|
+
const left = held - settledAfter;
|
|
2797
|
+
const head = `; ${String(held)} ${one ? "correction" : "corrections"} held because ${one ? "it" : "they"} didn't look related to the memory ${one ? "it" : "they"} named`;
|
|
2798
|
+
if (left <= 0) return `${head}, ${one ? "settled" : "all settled"} by hand since`;
|
|
2799
|
+
const since = settledAfter > 0 ? `, ${String(settledAfter)} settled by hand since` : "";
|
|
2800
|
+
const them = left === 1 ? "it" : "them";
|
|
2801
|
+
const was = left > 1 ? "any were" : one ? "it was" : held === 2 ? "the other was" : "the one left was";
|
|
2802
|
+
return `${head}${since}; if ${was} meant, settle ${them} with counterparts settle, which lists ${them}`;
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2784
2805
|
/**
|
|
2785
2806
|
* CONTRADICTIONS, informational (2026-09-29): over the last
|
|
2786
2807
|
* `CONTRADICTION_WINDOW_DAYS` lived days, how many pairs were flagged, how
|
|
@@ -2826,14 +2847,28 @@ export function contradictionFindings(store: Store): Finding[] {
|
|
|
2826
2847
|
.sort((a, b) => b[1] - a[1])
|
|
2827
2848
|
.map(([k, n]) => `${k === "owner" ? "you" : k} ${String(n)}`)
|
|
2828
2849
|
.join(", ");
|
|
2850
|
+
// HELD CORRECTIONS (mcp INTERFACE-GAPS §12, closed 2026-10-09): a write that
|
|
2851
|
+
// said it changed or corrected a memory that looked unrelated was held, so
|
|
2852
|
+
// nothing was settled. Informational, like the rest of this line: a hold is
|
|
2853
|
+
// the guard working. Unreadable, the line goes on without it.
|
|
2854
|
+
let heldWords = "";
|
|
2855
|
+
let heldData: Record<string, number> = { held: 0, heldSettledAfter: 0, heldByMeaning: 0, heldByWords: 0 };
|
|
2856
|
+
try {
|
|
2857
|
+
const h = heldCorrections(store, { sinceDay: since });
|
|
2858
|
+
heldData = { held: h.held, heldSettledAfter: h.settledAfter, heldByMeaning: h.byMeaning, heldByWords: h.byWords };
|
|
2859
|
+
heldWords = heldLine(h.held, h.settledAfter);
|
|
2860
|
+
} catch {
|
|
2861
|
+
// An event log this cannot read: the held count is left out, not guessed.
|
|
2862
|
+
}
|
|
2829
2863
|
return [
|
|
2830
2864
|
finding(
|
|
2831
2865
|
"contradictions",
|
|
2832
2866
|
"green",
|
|
2833
2867
|
"Contradictions",
|
|
2834
|
-
`last ${String(CONTRADICTION_WINDOW_DAYS)} lived days: ${String(flagged)} flagged, ${String(kept.length)} settled (${kinds})${kept.length > 0 ? ` by ${whoWords}` : ""}${undone > 0 ? `, ${String(undone)} undone` : ""}; standing: ${String(open)} open, ${String(unsettled)} unsettled${unsettled > 0 ? " (counterparts settle lists them)" : ""}`,
|
|
2868
|
+
`last ${String(CONTRADICTION_WINDOW_DAYS)} lived days: ${String(flagged)} flagged, ${String(kept.length)} settled (${kinds})${kept.length > 0 ? ` by ${whoWords}` : ""}${undone > 0 ? `, ${String(undone)} undone` : ""}; standing: ${String(open)} open, ${String(unsettled)} unsettled${unsettled > 0 ? " (counterparts settle lists them)" : ""}${heldWords}`,
|
|
2835
2869
|
"",
|
|
2836
2870
|
{
|
|
2871
|
+
...heldData,
|
|
2837
2872
|
flagged,
|
|
2838
2873
|
settled: kept.length,
|
|
2839
2874
|
changed: how["changed"] ?? 0,
|
|
@@ -4250,9 +4285,14 @@ export interface HostReading {
|
|
|
4250
4285
|
* (`cli/install.ts#readHost`); absent when not read. */
|
|
4251
4286
|
readonly runtimes?: readonly {
|
|
4252
4287
|
readonly exe: string;
|
|
4253
|
-
|
|
4288
|
+
/** `binary`: the single compiled binary (`runtime.ts#Binary`). */
|
|
4289
|
+
readonly kind: "bun" | "node" | "binary";
|
|
4254
4290
|
readonly present: boolean;
|
|
4255
4291
|
readonly used: readonly string[];
|
|
4292
|
+
/** Of `used`, the commands that let Bun read the project's `.env` or
|
|
4293
|
+
* `bunfig.toml` (wired before `--no-env-file` and an empty `--config=`);
|
|
4294
|
+
* absent on a reading that predates the field. */
|
|
4295
|
+
readonly projectEnv?: readonly string[];
|
|
4256
4296
|
}[];
|
|
4257
4297
|
/** The runtime this console is running under (`runtime.ts#runtimeLabel`). */
|
|
4258
4298
|
readonly consoleRuntime?: string;
|
|
@@ -4273,13 +4313,37 @@ export interface HostReading {
|
|
|
4273
4313
|
function runtimeFindings(reading: HostReading): Finding[] {
|
|
4274
4314
|
const rows = reading.runtimes ?? [];
|
|
4275
4315
|
if (rows.length === 0) return [];
|
|
4276
|
-
const said = rows
|
|
4316
|
+
const said = rows
|
|
4317
|
+
.map((r) => `${r.used.join(" and ")} ${r.kind === "binary" ? "run as the single binary" : `run under ${r.kind}`} (${r.exe})`)
|
|
4318
|
+
.join("; ");
|
|
4277
4319
|
const console_ = reading.consoleRuntime === undefined ? "" : `; this console is ${reading.consoleRuntime}`;
|
|
4278
4320
|
const data: Record<string, string | number | boolean | null> = {
|
|
4279
4321
|
runtimes: rows.map((r) => `${r.kind}:${r.exe}:${r.present ? "present" : "missing"}`).join(","),
|
|
4280
4322
|
console: reading.consoleRuntime ?? null,
|
|
4281
4323
|
};
|
|
4282
4324
|
const missing = rows.filter((r) => !r.present);
|
|
4325
|
+
// WIRED BEFORE `--no-env-file` AND `--config=<empty-bunfig.toml>`
|
|
4326
|
+
// (2026-10-09): Bun loads the project's `.env` into every hook and server it
|
|
4327
|
+
// starts there, so a project could name another store, and runs its
|
|
4328
|
+
// `bunfig.toml` preload inside them. A command missing EITHER flag counts,
|
|
4329
|
+
// so one `connect` closes both. Amber, because it is a hole and not a fault:
|
|
4330
|
+
// everything still runs, and `connect` rewrites the commands (it repairs an
|
|
4331
|
+
// entry that is ours in an older shape).
|
|
4332
|
+
const readsEnv = rows.flatMap((r) => r.projectEnv ?? []);
|
|
4333
|
+
data["projectEnv"] = readsEnv.length === 0 ? "ignored" : [...new Set(readsEnv)].sort().join(",");
|
|
4334
|
+
if (missing.length === 0 && readsEnv.length > 0) {
|
|
4335
|
+
const what = [...new Set(readsEnv)].sort().join(" and ");
|
|
4336
|
+
return [
|
|
4337
|
+
finding(
|
|
4338
|
+
"runtime",
|
|
4339
|
+
"amber",
|
|
4340
|
+
"Runtime",
|
|
4341
|
+
`${said}${console_}; the ${what} ${what.includes(" and ") ? "were" : "was"} wired before Counterparts told Bun to skip a project's .env and bunfig.toml, so a project whose .env sets COUNTERPARTS_DATA_DIR or COUNTERPARTS_CONFIG could point them at another memory, and its bunfig.toml could run its own code inside them`,
|
|
4342
|
+
"Run: counterparts connect — it rewrites the commands with --no-env-file and an empty --config. Then restart Claude Code.",
|
|
4343
|
+
data,
|
|
4344
|
+
),
|
|
4345
|
+
];
|
|
4346
|
+
}
|
|
4283
4347
|
if (missing.length === 0) return [finding("runtime", "green", "Runtime", `${said}${console_}`, "", data)];
|
|
4284
4348
|
return [
|
|
4285
4349
|
finding(
|
|
@@ -22,6 +22,7 @@ import type { Embedder, EmbedderIdentity } from "../../core/store/index.js";
|
|
|
22
22
|
import { hashText } from "../../core/store/index.js";
|
|
23
23
|
|
|
24
24
|
import type { AdapterConfig, EmbedderKind } from "../config.js";
|
|
25
|
+
import { bundledModelDir } from "../runtime.js";
|
|
25
26
|
|
|
26
27
|
/** One fill's failure, named — what the worker's backfill row persists as `codes`. */
|
|
27
28
|
export interface ChunkFailure {
|
|
@@ -197,9 +198,11 @@ export function unavailableStaticEmbedder(code: string): LiveEmbedder {
|
|
|
197
198
|
*/
|
|
198
199
|
export function openStaticEmbedder(opts: StaticEmbedderOptions = {}): LiveEmbedder {
|
|
199
200
|
const emit = opts.onEvent ?? ((): void => {});
|
|
201
|
+
const bundled = bundledModelDir();
|
|
200
202
|
const found = resolveStaticWeights({
|
|
201
203
|
...(opts.weightsDir === undefined ? {} : { dir: opts.weightsDir }),
|
|
202
204
|
...(opts.env === undefined ? {} : { env: opts.env }),
|
|
205
|
+
...(bundled === undefined ? {} : { packageDir: bundled }),
|
|
203
206
|
});
|
|
204
207
|
if (found === null) {
|
|
205
208
|
emit("embed.refused", { code: "NO_WEIGHTS", kind: "static" });
|
|
@@ -1,7 +1,9 @@
|
|
|
1
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
|
|
2
|
+
':' //; s="$0"; n=0; while [ -h "$s" ] && [ $n -lt 32 ]; do n=$((n+1)); l="$(readlink "$s")"; case "$l" in /*) s="$l" ;; *) s="${s%/*}/$l" ;; esac; done; c="${s%/*}/../../empty-bunfig.toml"; [ -f "$c" ] || c=/dev/null; if command -v bun >/dev/null 2>&1; then exec bun --no-env-file "--config=$c" "$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
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
|
|
4
|
+
// JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node;
|
|
5
|
+
// Bun with --no-env-file and --config=<empty-bunfig.toml>, found through any
|
|
6
|
+
// bin symlink, so a project's .env and bunfig.toml stay out: adapters/runtime.ts).
|
|
5
7
|
// See `adapters/launch.mjs`.
|
|
6
8
|
import { launch } from "../../launch.mjs";
|
|
7
9
|
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
import { resolve } from "node:path";
|
|
32
32
|
import { fileURLToPath } from "node:url";
|
|
33
33
|
|
|
34
|
+
import { BINARY } from "../../runtime.js";
|
|
35
|
+
import type { Binary } from "../../runtime.js";
|
|
34
36
|
import { run } from "../commands.js";
|
|
35
37
|
import { echoPrompt, hiddenPrompt } from "../ui.js";
|
|
36
38
|
|
|
@@ -101,12 +103,16 @@ async function main(): Promise<number> {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
/** True only when this file is the process entry point. */
|
|
104
|
-
export function isEntryPoint(argv1: string | undefined, url: string): boolean {
|
|
105
|
-
|
|
106
|
+
export function isEntryPoint(argv1: string | undefined, url: string, binary: Binary | null = BINARY): boolean {
|
|
107
|
+
// Never in the single binary, where every module shares one URL: its
|
|
108
|
+
// dispatcher (tools/single-binary/main.ts) calls `start()` itself.
|
|
109
|
+
if (argv1 === undefined || binary !== null) return false;
|
|
106
110
|
return resolve(argv1) === fileURLToPath(new URL(url));
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
/** Run one console command and exit — what this file does as a script, and
|
|
114
|
+
* what the single binary's `cli` mode calls. */
|
|
115
|
+
export function start(): void {
|
|
110
116
|
void main().then(
|
|
111
117
|
(code) => process.exit(code),
|
|
112
118
|
(err: unknown) => {
|
|
@@ -115,3 +121,5 @@ if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
|
115
121
|
},
|
|
116
122
|
);
|
|
117
123
|
}
|
|
124
|
+
|
|
125
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) start();
|