counterparts 0.3.20 → 0.3.22
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 +90 -0
- package/README.md +4 -1
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +2 -2
- package/src/adapters/claude-code/bin/hook.ts +10 -4
- package/src/adapters/claude-code/bin/runner.ts +31 -14
- package/src/adapters/claude-code/doctor.ts +24 -11
- package/src/adapters/claude-code/night-run.ts +2 -3
- package/src/adapters/claude-code/transcript.ts +1 -1
- package/src/adapters/cli/bin/counterparts.ts +9 -2
- package/src/adapters/cli/commands-dashboard.ts +31 -2
- package/src/adapters/cli/commands-delete.ts +273 -0
- package/src/adapters/cli/commands-note.ts +1 -1
- package/src/adapters/cli/commands-start-fresh.ts +3 -2
- package/src/adapters/cli/commands.ts +22 -3
- package/src/adapters/cli/help.ts +2 -0
- package/src/adapters/cli/install.ts +8 -7
- package/src/adapters/cli/removal.ts +1 -1
- package/src/adapters/cli/uninstall.ts +4 -2
- package/src/adapters/cli/wire.ts +5 -3
- package/src/adapters/config.ts +74 -0
- package/src/adapters/dashboard/web/actions.ts +21 -2
- package/src/adapters/dashboard/web/pages/memories/sections/tools.js +73 -3
- package/src/adapters/dashboard/web/probe.ts +33 -0
- package/src/adapters/fired.ts +1 -1
- package/src/adapters/host-wiring.ts +7 -4
- package/src/adapters/log/index.ts +21 -0
- package/src/adapters/mcp/server-words.ts +1 -1
- package/src/adapters/mcp/tools.ts +58 -0
- package/src/adapters/plugin.ts +34 -2
- package/src/adapters/runtime.ts +61 -3
- package/src/adapters/scopes.ts +2 -1
- package/src/adapters/sessions.ts +5 -2
- package/src/adapters/snapshots.ts +90 -1
- package/src/adapters/spawn.ts +2 -2
- package/src/core/dream/index.ts +1 -1
- package/src/core/dream/reflect.ts +6 -5
- package/src/core/onboarding.ts +14 -8
- package/src/core/recall/CONTRACT.md +3 -1
- package/src/core/recall/INTERFACE-GAPS.md +1 -1
- package/src/core/recall/NOTES.md +14 -0
- package/src/core/recall/session.ts +40 -1
- package/src/core/remember/CONTRACT.md +14 -8
- package/src/core/remember/owes.ts +68 -28
- package/src/core/remember/owner-strike-seam.ts +6 -3
- package/src/core/remember/spans.ts +3 -2
- package/src/core/remember/tunables.ts +18 -5
- package/src/core/remember/write-up-seam.ts +2 -1
- package/src/core/store/index.ts +39 -0
- package/src/core/store/paths.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.22 — 2026-10-14
|
|
4
|
+
|
|
5
|
+
The sidebar is ready for Anthropic's plugin directory, and the plugin now installs from a repository of its own. In the sidebar the search box is gone, COUNTERPARTS and a memory's `more` are links to the dashboard in a terminal and buttons in the desktop app, and the sidebar no longer runs a command to open a browser; `counterparts dashboard` opens the dashboard already running for your memory instead of failing on its port. The plugin's marketplace entry now names `counterparts-ai/counterparts-plugin`, a generated folder that holds only the plugin, so an install clones a few hundred files instead of the whole development repository; if you added the marketplace before, run `/plugin marketplace update counterparts` first, and your memory and the plugin's data folder stay where they are. Also: the memory tools tell a host which of them only read and which can take something away, and the context a session starts with offers the first meeting and its other steps instead of ordering them. No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.21, and `counterparts connect` is not needed.
|
|
6
|
+
|
|
7
|
+
- **The plugin installs from its own repository.** The marketplace entry now names
|
|
8
|
+
`https://github.com/counterparts-ai/counterparts-plugin.git` at the release tag: the
|
|
9
|
+
plugin alone, generated from this repository at each release, without its tests, docs
|
|
10
|
+
and development tools. The marketplace keeps its name, so the plugin's data folder and
|
|
11
|
+
your memory are unchanged. If you added the marketplace before, run
|
|
12
|
+
`/plugin marketplace update counterparts` first.
|
|
13
|
+
- **The memory tools now say what they do to a host.** Each one carries MCP's tool annotations: a
|
|
14
|
+
short title, and whether it only reads (`status`), writes, or can take something away (`dream`,
|
|
15
|
+
whose undo removes a dream's links and gists). A host can show these beside a tool or ask before
|
|
16
|
+
a call.
|
|
17
|
+
- **Session context offers rather than orders.** The first-meeting line now offers the
|
|
18
|
+
meeting to the person and describes the `meet` tool as where the script lives; the
|
|
19
|
+
morning share and the contradiction note describe the `told` and `settle` steps instead
|
|
20
|
+
of ordering a tool call nobody asked for.
|
|
21
|
+
- **The sidebar is ready for Anthropic's plugin directory.** The search box (hidden since
|
|
22
|
+
0.3.20) is gone. In a terminal, COUNTERPARTS and a memory's `more` are now ordinary links
|
|
23
|
+
to the dashboard, opened by your terminal (on some terminals with a ⌘- or Ctrl-click); in
|
|
24
|
+
the desktop app they are buttons that run `/counterparts:dashboard`. The sidebar no
|
|
25
|
+
longer runs a command to open a browser. The fox's pictures load from the plugin's own
|
|
26
|
+
image files.
|
|
27
|
+
- **`counterparts dashboard` opens the dashboard that is already running** for your memory,
|
|
28
|
+
instead of failing because its port is taken. A dashboard for another memory on that
|
|
29
|
+
port still fails, and says so.
|
|
30
|
+
|
|
31
|
+
## 0.3.21 — 2026-10-13
|
|
32
|
+
|
|
33
|
+
Your conversation text is kept for less time, and never in a backup. The text of a conversation is now deleted 3 days after it has been written up and the session has ended (it was 7), and it is never kept more than 14 days after the session's last activity, written up or not; both numbers can be changed with `"retention": {"afterWriteUpDays": 3, "maxDays": 14}` in `claude-code.json`. The first time the new version runs on an existing memory, everything older than those limits is deleted in one go, so if you want to keep more, add the `retention` setting before your first session on 0.3.21. Daily backups stop copying conversation text; backups made before this update still hold it until they rotate out, or until you run `counterparts delete backups`. New `counterparts delete conversation-text`, `delete backups` and `delete activity-log` (and "Delete data…" on the dashboard's Memories page) each delete one kind of data after showing what they would delete. The few words recall carries from your last message are cleared once a session has been quiet past the same 14-day limit. Also: the plugin installs over HTTPS without a GitHub SSH key (run `/plugin marketplace update counterparts` first if you added the marketplace before), "installed twice" is said once, the first meeting says where the sidebar appears, and the sidebar's fox and its look in the Claude Desktop app are polished (the Desktop shows the fox, not the brain, this version). No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.20, and `counterparts connect` is not needed.
|
|
34
|
+
|
|
35
|
+
- **The plugin installs without a GitHub SSH key.** On a computer with no SSH key that
|
|
36
|
+
GitHub accepts, `/plugin install counterparts@counterparts` failed with "Permission denied
|
|
37
|
+
(publickey)", even though adding the marketplace had worked. The marketplace now names the
|
|
38
|
+
repository by its `https://` address, which needs no key. If you added the marketplace
|
|
39
|
+
before, run `/plugin marketplace update counterparts` first, then install again.
|
|
40
|
+
- **"Installed twice" is said once.** With both the npm install and the plugin, the plugin
|
|
41
|
+
stands down and said so at the start of every session, which read like an error. It now
|
|
42
|
+
says it at the first session that finds both, then stays quiet; `counterparts doctor`
|
|
43
|
+
still shows it. Nothing about how the two share the memory has changed.
|
|
44
|
+
- **Conversation text is kept for less time, and never in a backup.** The text of your
|
|
45
|
+
conversations is deleted 3 days after it is written up and the session has ended (it
|
|
46
|
+
was 7), and is never kept more than 14 days after the session's last activity, written
|
|
47
|
+
up or not. Both can be changed in `claude-code.json`:
|
|
48
|
+
`"retention": {"afterWriteUpDays": 3, "maxDays": 14}`. Daily backups no longer copy it
|
|
49
|
+
at all, so restoring one loses whatever was not yet written up. Backups made before
|
|
50
|
+
this update still hold it until they rotate out, or until you delete them.
|
|
51
|
+
- **Delete one kind of data at a time.** `counterparts delete conversation-text`,
|
|
52
|
+
`delete backups` and `delete activity-log` each delete that one kind and nothing else.
|
|
53
|
+
Each shows what it would delete first (for conversation text, how many sessions were
|
|
54
|
+
still waiting to be written up and would be lost) and asks once; `--yes` skips the
|
|
55
|
+
question for a script. The dashboard's Memories page has the same three under
|
|
56
|
+
"Delete data…".
|
|
57
|
+
- **The first meeting says where the sidebar is.** In the plugin, the end of the first
|
|
58
|
+
meeting now says the memory sidebar appears on the right once the window is wide
|
|
59
|
+
enough.
|
|
60
|
+
- **The sidebar's fox is a little more alive, and calmer about it.** He does small things
|
|
61
|
+
more often (a blink, a flick of his tail tip, an ear twitch, a glance), and flicks his tail
|
|
62
|
+
within a few seconds of the sidebar opening. When something comes to mind he perks up,
|
|
63
|
+
curious, with one ear raised. Left alone, he lies down after 45 seconds and naps after two
|
|
64
|
+
minutes; anything you do gets him up. His small moves no longer make his whole body
|
|
65
|
+
flicker, in the desktop app and in Ghostty or kitty. In iTerm, WezTerm and VS Code he
|
|
66
|
+
now has his intended colours (a warmer orange, a cream chest), and his notepad shows.
|
|
67
|
+
- **A clearer hint when the window is too narrow for the sidebar.** The line under the
|
|
68
|
+
prompt now says to widen the window, instead of naming a command that can't open it there.
|
|
69
|
+
- **Your words from a session's last turn no longer stay in the database.** Recall keeps a
|
|
70
|
+
few words from your previous message to help with the next one. A session that ended,
|
|
71
|
+
or was closed abruptly, kept its last few words indefinitely. Now they are cleared once
|
|
72
|
+
the session has been quiet for the retention limit (14 days unless you changed it),
|
|
73
|
+
including for sessions from before this update. Backups taken from then on don't
|
|
74
|
+
contain them either.
|
|
75
|
+
- **The sidebar looks right in the Claude Desktop app.** It now uses the app's own colours (light or
|
|
76
|
+
dark), has no lines of dashes, wraps its text to the app's font, leaves a blank row between
|
|
77
|
+
items, and draws the "Mechanisms today" bars at a readable size. The fox no longer shows a dark
|
|
78
|
+
edge on the light page and fits a narrower pane.
|
|
79
|
+
- **The memory count sits on the sidebar's title row, beside the day** ("1511 memories · day 22",
|
|
80
|
+
shortened when the pane is narrow), in every app, and the search row appears only when search is
|
|
81
|
+
switched on.
|
|
82
|
+
- **The sidebar's "quietly available" titles read cleanly.** "Earlier (now [id]): ..." shows as
|
|
83
|
+
"Earlier: ...", "Unsettled - may be out of date, see [id]: ..." as "Unsettled: ...", "Corrected by
|
|
84
|
+
[id]: ..." as "Corrected: ...", and the trailing "(earlier: [id])" and "(corrects [id])" are left
|
|
85
|
+
off; a click on one opens that memory, not the one its note points at.
|
|
86
|
+
- **In the Desktop app the avatar is the fox or nothing.** The brain doesn't draw there yet, so the
|
|
87
|
+
avatar row offers animal and off, and a brain chosen in the terminal shows the fox on the Desktop. The
|
|
88
|
+
terminal keeps its brain.
|
|
89
|
+
- **Pressing the Counterparts switch in auto mode no longer shows an engine error.** When auto mode
|
|
90
|
+
declines the press, a short note says so and tells you what to ask Claude instead ("pause
|
|
91
|
+
Counterparts here"); the switch stays as it was.
|
|
92
|
+
|
|
3
93
|
## 0.3.20 — 2026-10-12
|
|
4
94
|
|
|
5
95
|
New installs from the plugin now remember from the second day. (Plugin first runs and scripted `install --yes` had never set a size limit for the wake, so every session opened on "No briefing has been composed yet"; earlier plugin installs had the same gap, and they are fixed automatically, with no action and no change to your configuration file; the first session after upgrading may still open on that line, and the wake is composed when that session ends.) The first meeting is the heart of this release. A new install now opens with a short, easy conversation where Claude introduces itself, asks one question at a time (all fine to pass), writes up what it learned right there, and ends with "What would you like to work on today?". Nothing interrupts it: no dream starts and the end-of-turn write-up waits, so the first dream comes the next day. Everyday words replace the internal ones: session starts say "Coming up:" and "Might be relevant:", dates read "Oct 11", and the dashboard uses the same words. A brand-new install's first `counterparts doctor` shows no ambers, a plugin install gets a one-line welcome, and the README is honest about what recall by meaning can and cannot find. The sidebar gains onboarding, a small fox, a second theme and the dashboard's store id; its Claude Code memory switch is gone, and the dead read of an A/B file in the home directory is removed. Reminders are no longer spent on a compaction nobody reads, and the wake never drops a section without saying so. No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.19, and `counterparts connect` is not needed.
|
package/README.md
CHANGED
|
@@ -49,7 +49,10 @@ to be deleted. The full walkthrough is in [`docs/QUICKSTART.md`](docs/QUICKSTART
|
|
|
49
49
|
- **Things come to mind.** As you talk, related memories surface quietly, the way one
|
|
50
50
|
thing reminds you of another.
|
|
51
51
|
- **It's yours.** Everything lives on your machine in one SQLite file you can read,
|
|
52
|
-
export or delete. No API keys, no accounts, nothing sent anywhere.
|
|
52
|
+
export or delete. No API keys, no accounts, nothing sent anywhere. The text of your
|
|
53
|
+
conversations is kept only until it's written up: deleted 3 days after that, never
|
|
54
|
+
kept more than 14 days, and never in a backup. You can delete the conversation text,
|
|
55
|
+
the backups or the activity log on their own at any time (`counterparts delete`).
|
|
53
56
|
|
|
54
57
|
## Who it's for
|
|
55
58
|
|
package/package.json
CHANGED
|
@@ -1005,8 +1005,8 @@ session the host's registry knows (one our hooks saw start), so the unbound MCP
|
|
|
1005
1005
|
shared `mcp` id is passed by, and only for a person's interactive conversation: a session
|
|
1006
1006
|
whose host entrypoint (`CLAUDE_CODE_ENTRYPOINT`, kept on the registry record) says
|
|
1007
1007
|
`claude -p`, the Agent SDK, `mcp` or a GitHub action owes no short write-up (N2). It is
|
|
1008
|
-
not a retention debt (text ages out
|
|
1009
|
-
after the write-up, like a full debt) and not in doctor's awaiting count. The headless
|
|
1008
|
+
not a retention debt (text ages out on the retention clock; a written-up one keeps it up to 3
|
|
1009
|
+
days after the write-up, like a full debt, and never past the 14-day ceiling) and not in doctor's awaiting count. The headless
|
|
1010
1010
|
nightly run's child and an observer capture nothing, so they owe nothing. When a pointer
|
|
1011
1011
|
defers for room, its record names what else rode beside the wake, and doctor's advice
|
|
1012
1012
|
names that rather than the wake's budget (M3).
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
} from "../standdown.js";
|
|
62
62
|
import type { SaysSoHook, StandDownFault } from "../standdown.js";
|
|
63
63
|
import { readTranscript } from "../transcript.js";
|
|
64
|
-
import { BINARY, scriptArgs } from "../../runtime.js";
|
|
64
|
+
import { BINARY, entryScript, scriptArgs } from "../../runtime.js";
|
|
65
65
|
import type { Binary } from "../../runtime.js";
|
|
66
66
|
import { npmWiring } from "../../host-wiring.js";
|
|
67
67
|
import {
|
|
@@ -71,9 +71,11 @@ import {
|
|
|
71
71
|
firstRunNoticePath,
|
|
72
72
|
hookGate,
|
|
73
73
|
installRoute,
|
|
74
|
+
markTwiceSaid,
|
|
74
75
|
pluginOrigin,
|
|
75
76
|
runningAsPlugin,
|
|
76
77
|
takeFirstRunNotice,
|
|
78
|
+
twiceNoticePath,
|
|
77
79
|
} from "../../plugin.js";
|
|
78
80
|
import { claimDelivery, deliveryClaimKey, finishClaim, firesOnce } from "../claim.js";
|
|
79
81
|
|
|
@@ -166,9 +168,9 @@ export const CONFIG_PATH = defaultConfigPath();
|
|
|
166
168
|
|
|
167
169
|
/** The worker script this hook's spawn runs. Resolved from THIS file's location,
|
|
168
170
|
* never from a working directory the host chose. */
|
|
169
|
-
export const RUNNER_PATH =
|
|
171
|
+
export const RUNNER_PATH = entryScript(new URL("./runner.ts", import.meta.url));
|
|
170
172
|
/** The headless nightly run's own process (2026-09-29, `night-run.ts`). */
|
|
171
|
-
export const NIGHTLY_PATH =
|
|
173
|
+
export const NIGHTLY_PATH = entryScript(new URL("./nightly.ts", import.meta.url));
|
|
172
174
|
|
|
173
175
|
async function readStdin(): Promise<string> {
|
|
174
176
|
const chunks: Buffer[] = [];
|
|
@@ -708,7 +710,11 @@ async function main(): Promise<void> {
|
|
|
708
710
|
// it was installed: a first run the plugin made beside it is not this
|
|
709
711
|
// hook's to announce, now or after a later move to the plugin.
|
|
710
712
|
takeFirstRunNotice(firstRunNoticePath(choice.path));
|
|
711
|
-
|
|
713
|
+
// Said at the first session start that finds both, then not again
|
|
714
|
+
// (`plugin.ts#twiceNoticePath`).
|
|
715
|
+
if (gate.line !== null && markTwiceSaid(twiceNoticePath(choice.path, process.env))) {
|
|
716
|
+
process.stdout.write(JSON.stringify({ systemMessage: gate.line }));
|
|
717
|
+
}
|
|
712
718
|
}
|
|
713
719
|
return;
|
|
714
720
|
}
|
|
@@ -36,13 +36,15 @@
|
|
|
36
36
|
* (`core/coverage/`);
|
|
37
37
|
* 3c. RAW TRANSCRIPT RETENTION (owner's ruling 2026-09-23): once per date —
|
|
38
38
|
* behind an `O_EXCL` latch under `spans/retention/` — a session's captured
|
|
39
|
-
* text is deleted
|
|
40
|
-
* registry does not hold it open
|
|
39
|
+
* text is deleted 3 days after it ended when it owes no write-up and the
|
|
40
|
+
* registry does not hold it open, and 14 days after its last activity
|
|
41
|
+
* whatever is true — the configuration's `retention` block may set both
|
|
42
|
+
* (`config.ts#retentionClocks`; `remember/owes.ts` decides,
|
|
41
43
|
* `remember/retention.ts` deletes, and this file is the only one that may
|
|
42
44
|
* import the second), and one `remember.prune` row says what was deleted,
|
|
43
|
-
* what is waiting on a write-up, what is
|
|
44
|
-
* still open. Keyless, like every step but the sweep.
|
|
45
|
-
*
|
|
45
|
+
* what is waiting on a write-up, what is inside its clock and what is
|
|
46
|
+
* still open. Keyless, like every step but the sweep. (Before the snapshot,
|
|
47
|
+
* which since 2026-10-13 copies no conversation text at all.)
|
|
46
48
|
* 4. the DAILY ROTATING SNAPSHOT (`adapters/snapshots.ts`), last and outside
|
|
47
49
|
* the cycle. Last because it copies the state the three steps above just
|
|
48
50
|
* left; outside because sleep must not learn that the floor is changing —
|
|
@@ -69,6 +71,7 @@ import { fileURLToPath } from "node:url";
|
|
|
69
71
|
|
|
70
72
|
import { Counterpart, RUNNER_FAILED_EVENT } from "../../../core/counterpart.js";
|
|
71
73
|
import { recordCoverage } from "../../../core/coverage/index.js";
|
|
74
|
+
import { clearIdleCarries } from "../../../core/recall/index.js";
|
|
72
75
|
import { RETENTION_EVENT, retentionRow, retentionRuns } from "../../../core/remember/index.js";
|
|
73
76
|
import type { HostSessionEvidence, RetentionReport } from "../../../core/remember/index.js";
|
|
74
77
|
// THE DELETING HALF, by path, and from this file alone (PR #189 review, B1):
|
|
@@ -92,7 +95,7 @@ import {
|
|
|
92
95
|
} from "../../config-path.js";
|
|
93
96
|
import type { ConfigChoice } from "../../config-path.js";
|
|
94
97
|
|
|
95
|
-
import { loadConfig, withBudgetDefault, withEmbedderDefault } from "../../config.js";
|
|
98
|
+
import { loadConfig, retentionClocks, withBudgetDefault, withEmbedderDefault } from "../../config.js";
|
|
96
99
|
import type { AdapterConfig } from "../../config.js";
|
|
97
100
|
import { openEmbedder } from "../index.js";
|
|
98
101
|
import type { LiveEmbedder } from "../embed-client.js";
|
|
@@ -198,6 +201,9 @@ export const retentionHost: (store: Store) => (session: string) => HostSessionEv
|
|
|
198
201
|
export function retentionJob(input: {
|
|
199
202
|
counterpart: Counterpart;
|
|
200
203
|
date: string;
|
|
204
|
+
/** The configuration's two clocks (`config.ts#retentionClocks`); the
|
|
205
|
+
* defaults when absent. */
|
|
206
|
+
clocks?: { retentionMs: number; maxMs: number };
|
|
201
207
|
onEvent?: (name: string, data: Record<string, string | number | boolean | null>) => void;
|
|
202
208
|
}): RetentionJobReport {
|
|
203
209
|
const { counterpart, date } = input;
|
|
@@ -210,7 +216,7 @@ export function retentionJob(input: {
|
|
|
210
216
|
// THE SAME SOURCES THE WRITE-UP READS (`sessions.ts#writeUpSources`), so
|
|
211
217
|
// what this pass keeps as owed and what the next session is asked to write
|
|
212
218
|
// up are one set, by construction rather than by two copies agreeing.
|
|
213
|
-
const sources = writeUpSources(store);
|
|
219
|
+
const sources = writeUpSources(store, input.clocks ?? {});
|
|
214
220
|
// THE DATE IS VISIBLE FROM THE MOMENT IT IS HELD (re-review R7): a
|
|
215
221
|
// `STARTED` row goes in as soon as the latch is taken, before anything is
|
|
216
222
|
// planned, so a run the watchdog kills halfway leaves "started, never
|
|
@@ -220,7 +226,7 @@ export function retentionJob(input: {
|
|
|
220
226
|
store.appendEvent({
|
|
221
227
|
name: RETENTION_EVENT,
|
|
222
228
|
day: store.livedDay(),
|
|
223
|
-
payload: retentionRow({ ...EMPTY_RETENTION, reason: "STARTED" }, date),
|
|
229
|
+
payload: retentionRow({ ...EMPTY_RETENTION, reason: "STARTED" }, date, sources),
|
|
224
230
|
dedupKey: `${RETENTION_EVENT}:${date}:started`,
|
|
225
231
|
});
|
|
226
232
|
} catch (err) {
|
|
@@ -236,7 +242,7 @@ export function retentionJob(input: {
|
|
|
236
242
|
store.appendEvent({
|
|
237
243
|
name: RETENTION_EVENT,
|
|
238
244
|
day: store.livedDay(),
|
|
239
|
-
payload: retentionRow({ ...EMPTY_RETENTION, reason: "LATCH_HELD" }, date),
|
|
245
|
+
payload: retentionRow({ ...EMPTY_RETENTION, reason: "LATCH_HELD" }, date, sources),
|
|
240
246
|
dedupKey: `${RETENTION_EVENT}:${date}:held`,
|
|
241
247
|
});
|
|
242
248
|
} catch (err) {
|
|
@@ -256,7 +262,7 @@ export function retentionJob(input: {
|
|
|
256
262
|
store.appendEvent({
|
|
257
263
|
name: RETENTION_EVENT,
|
|
258
264
|
day: store.livedDay(),
|
|
259
|
-
payload: retentionRow(report, date),
|
|
265
|
+
payload: retentionRow(report, date, sources),
|
|
260
266
|
dedupKey: `${RETENTION_EVENT}:${date}`,
|
|
261
267
|
});
|
|
262
268
|
recorded = true;
|
|
@@ -450,17 +456,28 @@ export async function runOnce(input: {
|
|
|
450
456
|
emit("coverage.threw", { code: err instanceof Error ? err.name : "UNKNOWN" });
|
|
451
457
|
}
|
|
452
458
|
// 3c. RETENTION — on the failed path as well as the good one (a day whose
|
|
453
|
-
// sweep broke still ages the
|
|
454
|
-
//
|
|
455
|
-
//
|
|
459
|
+
// sweep broke still ages the text of sessions that owe nothing), with the
|
|
460
|
+
// configuration's clocks. Its own try: a retention pass may not cost the
|
|
461
|
+
// snapshot.
|
|
456
462
|
try {
|
|
457
|
-
retentionReport = retentionJob({ counterpart, date: today, onEvent: emit });
|
|
463
|
+
retentionReport = retentionJob({ counterpart, date: today, clocks: retentionClocks(config), onEvent: emit });
|
|
458
464
|
if (retentionReport.reason === "failed") {
|
|
459
465
|
noteFailure(counterpart, emit, retentionReport.code ?? "UNKNOWN", "retention", today);
|
|
460
466
|
}
|
|
461
467
|
} catch (err) {
|
|
462
468
|
emit("retention.threw", { code: err instanceof Error ? err.name : "UNKNOWN" });
|
|
463
469
|
}
|
|
470
|
+
// 3d. TYPED WORDS LEAVE QUIET SESSIONS (2026-10-13): recall's carried cue
|
|
471
|
+
// tokens are emptied in every session idle past the same ceiling, so a
|
|
472
|
+
// session that ended or was killed does not keep them, and the copy below
|
|
473
|
+
// does not take them. Every run, not once a date: it reads only rows that
|
|
474
|
+
// still carry words. Its own try, like the steps above.
|
|
475
|
+
try {
|
|
476
|
+
const cleared = clearIdleCarries(counterpart.store, retentionClocks(config).maxMs);
|
|
477
|
+
if (cleared > 0) emit("runner.carries", { cleared });
|
|
478
|
+
} catch (err) {
|
|
479
|
+
emit("carries.threw", { code: err instanceof Error ? err.name : "UNKNOWN" });
|
|
480
|
+
}
|
|
464
481
|
// 4. THE DAY'S COPY OF THE STORE — after everything above has written, on
|
|
465
482
|
// the failed path as well as the good one, and before the store is closed.
|
|
466
483
|
// It never throws by construction (`adapters/snapshots.ts`); the try is
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
readSnapshotsDir,
|
|
101
101
|
resolveSnapshotsDir,
|
|
102
102
|
} from "../snapshots.js";
|
|
103
|
-
import { TUNABLES, resolveEmbedder, withEmbedderDefault } from "../config.js";
|
|
103
|
+
import { TUNABLES, resolveEmbedder, retentionClocks, withEmbedderDefault } from "../config.js";
|
|
104
104
|
import type { EmbedderSource } from "../config.js";
|
|
105
105
|
import { MODEL_FILE, STATIC_WEIGHTS_ENV, STATIC_WEIGHTS_PACKAGE, resolveStaticWeights } from "../../core/embed/static.js";
|
|
106
106
|
import { DATABASE_FILE, heldExits, readRollbackHold, rollbackHeld } from "../../core/store/index.js";
|
|
@@ -855,12 +855,12 @@ const KEY_HISTORY_ROWS = 200;
|
|
|
855
855
|
* RAW TRANSCRIPTS — how long the captured conversation is kept, and what the
|
|
856
856
|
* newest retention pass did (remember INTERFACE-GAPS §11; roadmap B3).
|
|
857
857
|
*
|
|
858
|
-
* The first clause is the POLICY,
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
*
|
|
858
|
+
* The first clause is the POLICY (Mike, 2026-10-13): the text is deleted a
|
|
859
|
+
* few days after a session is written up and ended, and never kept past the
|
|
860
|
+
* ceiling, owed or not; backups never hold it. Both numbers are read — the
|
|
861
|
+
* configuration's `retention` block, else `remember/`'s defaults, through
|
|
862
|
+
* `config.ts#retentionClocks` — never retyped. A field in that block this
|
|
863
|
+
* could not read is named, amber, the way the Snapshot line names its own.
|
|
864
864
|
*
|
|
865
865
|
* The rest is the newest `remember.prune` row, in sessions. Grades:
|
|
866
866
|
*
|
|
@@ -876,11 +876,24 @@ const KEY_HISTORY_ROWS = 200;
|
|
|
876
876
|
*/
|
|
877
877
|
function retentionFindings(input: DoctorInput, store: Store): Finding[] {
|
|
878
878
|
const TITLE = "Raw transcripts";
|
|
879
|
-
const
|
|
880
|
-
const
|
|
881
|
-
const policy =
|
|
879
|
+
const clocks = retentionClocks(input.config);
|
|
880
|
+
const days = clocks.afterWriteUpDays;
|
|
881
|
+
const policy = `deleted ${String(days)} day${days === 1 ? "" : "s"} after a session is written up and ended, never kept more than ${String(clocks.maxDays)} · never in backups`;
|
|
882
882
|
const run = lastRetentionRun(store);
|
|
883
|
-
const base = { retentionDays: days,
|
|
883
|
+
const base = { retentionDays: days, maxDays: clocks.maxDays };
|
|
884
|
+
const ignored = input.config.retention?.ignored ?? [];
|
|
885
|
+
if (ignored.length > 0) {
|
|
886
|
+
return [
|
|
887
|
+
finding(
|
|
888
|
+
"retention",
|
|
889
|
+
"amber",
|
|
890
|
+
TITLE,
|
|
891
|
+
`${policy} · the configuration's retention block was partly ignored: ${ignored.join("; ")}`,
|
|
892
|
+
`Fix "retention" in ${tilde(input.configPath)}: whole days, at least 1.`,
|
|
893
|
+
{ ...base, ran: run !== null, ignored: ignored.length },
|
|
894
|
+
),
|
|
895
|
+
];
|
|
896
|
+
}
|
|
884
897
|
if (run === null) {
|
|
885
898
|
return [finding("retention", "green", TITLE, `${policy} · not run yet`, "", { ...base, ran: false })];
|
|
886
899
|
}
|
|
@@ -75,14 +75,13 @@
|
|
|
75
75
|
* written in the PR, not claimed here.
|
|
76
76
|
*/
|
|
77
77
|
import { randomUUID } from "node:crypto";
|
|
78
|
-
import { fileURLToPath } from "node:url";
|
|
79
78
|
|
|
80
79
|
import { Counterpart, MCP_SPILLED_EVENT } from "../../core/counterpart.js";
|
|
81
80
|
import type { CounterpartEvent } from "../../core/counterpart.js";
|
|
82
81
|
import { CATCH_UP_ONLY_REASONS } from "../../core/dream/index.js";
|
|
83
82
|
import type { CatchUpOnlyReason, NightChildRun, NightPart, NightRun } from "../../core/dream/index.js";
|
|
84
83
|
import { CONFIG_ENV as CONFIG_PATH_ENV } from "../config-path.js";
|
|
85
|
-
import { scriptArgs } from "../runtime.js";
|
|
84
|
+
import { entryScript, scriptArgs } from "../runtime.js";
|
|
86
85
|
import { TOOL_RESULT_CEILING } from "../../core/fit/index.js";
|
|
87
86
|
import { installedVersion } from "../sessions.js";
|
|
88
87
|
import { OBSERVER_ENV, OWNER_ENV } from "../stance-env.js";
|
|
@@ -173,7 +172,7 @@ export const DREAM_CHILD_DENIED = ["mcp__counterparts__reflect"] as const;
|
|
|
173
172
|
export const NIGHT_MCP_SERVER = "counterparts";
|
|
174
173
|
|
|
175
174
|
/** The MCP entry point beside this adapter — what the install registers (`cli/install.ts#MCP_SCRIPT`). */
|
|
176
|
-
export const NIGHT_MCP_SCRIPT =
|
|
175
|
+
export const NIGHT_MCP_SCRIPT = entryScript(new URL("../mcp/bin/serve.ts", import.meta.url));
|
|
177
176
|
|
|
178
177
|
/**
|
|
179
178
|
* THE ONE MCP SERVER THE CHILD LOADS (owner decision B): counterparts, as the
|
|
@@ -713,7 +713,7 @@ export const WAKE_HEAD_MAX_LINES = 40;
|
|
|
713
713
|
* and the cost of missing it is a session that reads `not-found`, which is
|
|
714
714
|
* INTERFACE-GAPS §11's residual.
|
|
715
715
|
*/
|
|
716
|
-
export const COUNTERPARTS_HOOK_COMMAND = /claude-code[/\\]bin[/\\]hook\.ts|counterparts-hook/;
|
|
716
|
+
export const COUNTERPARTS_HOOK_COMMAND = /(adapters[/\\]claude-code[/\\]bin[/\\]hook\.js|claude-code[/\\]bin[/\\]hook\.ts)(?=$|["'\s])|counterparts-hook/;
|
|
717
717
|
|
|
718
718
|
/**
|
|
719
719
|
* The wake's two sentinels, recognised INSIDE a larger string rather than as a
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
* rather than resolving as an answer nobody gave.
|
|
30
30
|
*/
|
|
31
31
|
import { spawnSync } from "node:child_process";
|
|
32
|
+
import { realpathSync } from "node:fs";
|
|
32
33
|
import { homedir } from "node:os";
|
|
33
34
|
import { resolve } from "node:path";
|
|
34
35
|
import { fileURLToPath } from "node:url";
|
|
35
36
|
|
|
36
|
-
import { BINARY } from "../../runtime.js";
|
|
37
|
+
import { BINARY, TRANSPILED } from "../../runtime.js";
|
|
37
38
|
import type { Binary } from "../../runtime.js";
|
|
38
39
|
import { npmWiring } from "../../host-wiring.js";
|
|
39
|
-
import { npmDoctorCommand, pluginDoctorLine, pluginOrigin, runningAsPlugin } from "../../plugin.js";
|
|
40
|
+
import { PACKAGE_ROOT, PLUGIN_ROOT_ENV, npmDoctorCommand, pluginDoctorLine, pluginOrigin, runningAsPlugin } from "../../plugin.js";
|
|
40
41
|
|
|
41
42
|
import { run } from "../commands.js";
|
|
42
43
|
import { echoPrompt, hiddenPrompt } from "../ui.js";
|
|
@@ -151,6 +152,12 @@ export function isEntryPoint(argv1: string | undefined, url: string, binary: Bin
|
|
|
151
152
|
/** Run one console command and exit — what this file does as a script, and
|
|
152
153
|
* what the single binary's `cli` mode calls. */
|
|
153
154
|
export function start(): void {
|
|
155
|
+
// THE PLUGIN DIRECTORY'S BUNDLE (transpiled, no `plugin-run.sh`): this entry
|
|
156
|
+
// is what its commands run, from a Bash call that carries no
|
|
157
|
+
// CLAUDE_PLUGIN_ROOT, so it says what `plugin-run.sh cli` says for the full
|
|
158
|
+
// bundle: this console is the plugin's copy (`plugin.ts#runningAsPlugin`).
|
|
159
|
+
// The transpiled tree exists only as that bundle (`runtime.ts#TRANSPILED`).
|
|
160
|
+
if (TRANSPILED) process.env[PLUGIN_ROOT_ENV] = realpathSync(PACKAGE_ROOT);
|
|
154
161
|
void main().then(
|
|
155
162
|
(code) => process.exit(code),
|
|
156
163
|
(err: unknown) => {
|
|
@@ -15,6 +15,7 @@ import { tilde } from "./wire.js";
|
|
|
15
15
|
import { upgradeWords } from "../hosts.js";
|
|
16
16
|
import { hostsSeen } from "../sessions.js";
|
|
17
17
|
import { EXIT, hostConfigFor } from "./commands-shared.js";
|
|
18
|
+
import { storeId } from "../store-id.js";
|
|
18
19
|
import type { Parsed, Io, RunOptions } from "./commands-shared.js";
|
|
19
20
|
|
|
20
21
|
// ── dashboard ───────────────────────────────────────────────────────────────
|
|
@@ -70,6 +71,12 @@ export interface DashboardSeam {
|
|
|
70
71
|
open?(url: string): void;
|
|
71
72
|
/** Resolves when the person stops it. Ctrl-C, in a real run. */
|
|
72
73
|
until?(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Which store the dashboard already holding `port` serves (its `/api/whoami`, on
|
|
76
|
+
* 127.0.0.1), or null: nothing answered, or not with a store id. Asked only when
|
|
77
|
+
* the port is taken.
|
|
78
|
+
*/
|
|
79
|
+
storeAt?(port: number): Promise<string | null>;
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
/** The default port, restated rather than imported: naming it here costs one
|
|
@@ -157,9 +164,26 @@ export async function dashboardCommand(
|
|
|
157
164
|
});
|
|
158
165
|
} catch (err) {
|
|
159
166
|
if ((err as { code?: string }).code === "EADDRINUSE") {
|
|
167
|
+
// THE PORT IS TAKEN. When what holds it is this store's own dashboard (the
|
|
168
|
+
// sidebar's button runs this command whether or not one is up), open the
|
|
169
|
+
// browser on it and succeed; anything else fails as before, said plainly.
|
|
170
|
+
const errPort = (err as { port?: unknown }).port;
|
|
171
|
+
const taken = typeof errPort === "number" && errPort > 0 ? errPort : (port ?? DASHBOARD_DEFAULT_PORT);
|
|
172
|
+
const serving = (await seam.storeAt?.(taken)) ?? null;
|
|
173
|
+
const ours = storeId(dir);
|
|
174
|
+
if (serving !== null && ours !== null && serving === ours) {
|
|
175
|
+
const url = `http://127.0.0.1:${String(taken)}`;
|
|
176
|
+
io.out(`Dashboard: ${url} (already running for this store; this command started nothing)`);
|
|
177
|
+
io.out(`reading ${tilde(dir, home_)}`);
|
|
178
|
+
if (parsed.flags["no-open"] !== true) seam.open?.(url);
|
|
179
|
+
return EXIT.ok;
|
|
180
|
+
}
|
|
160
181
|
io.err(
|
|
161
|
-
|
|
162
|
-
|
|
182
|
+
serving !== null
|
|
183
|
+
? `Port ${String(taken)} is already in use by a dashboard serving another store. ` +
|
|
184
|
+
"Pass --port <n> to use another one."
|
|
185
|
+
: `Port ${String(taken)} is already in use — a dashboard may ` +
|
|
186
|
+
"already be running. Pass --port <n> to use another one.",
|
|
163
187
|
);
|
|
164
188
|
return EXIT.failed;
|
|
165
189
|
}
|
|
@@ -207,6 +231,11 @@ function realDashboard(env: Record<string, string | undefined>): DashboardSeam {
|
|
|
207
231
|
openInBrowser(url, env);
|
|
208
232
|
},
|
|
209
233
|
until: untilInterrupted,
|
|
234
|
+
async storeAt(port: number): Promise<string | null> {
|
|
235
|
+
// LAZY for the same reason as the server: only a taken port pulls it in.
|
|
236
|
+
const { dashboardStoreAt } = await import("../dashboard/web/probe.js");
|
|
237
|
+
return dashboardStoreAt(port);
|
|
238
|
+
},
|
|
210
239
|
};
|
|
211
240
|
}
|
|
212
241
|
|