counterparts 0.3.21 → 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 +28 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/bin/hook.ts +3 -3
- 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-start-fresh.ts +3 -2
- package/src/adapters/cli/install.ts +8 -7
- package/src/adapters/cli/uninstall.ts +4 -2
- package/src/adapters/cli/wire.ts +5 -3
- package/src/adapters/dashboard/web/probe.ts +33 -0
- package/src/adapters/host-wiring.ts +7 -4
- package/src/adapters/mcp/server-words.ts +1 -1
- package/src/adapters/mcp/tools.ts +58 -0
- package/src/adapters/plugin.ts +3 -2
- package/src/adapters/runtime.ts +61 -3
- package/src/adapters/scopes.ts +2 -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 +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
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
|
+
|
|
3
31
|
## 0.3.21 — 2026-10-13
|
|
4
32
|
|
|
5
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.
|
package/package.json
CHANGED
|
@@ -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 {
|
|
@@ -168,9 +168,9 @@ export const CONFIG_PATH = defaultConfigPath();
|
|
|
168
168
|
|
|
169
169
|
/** The worker script this hook's spawn runs. Resolved from THIS file's location,
|
|
170
170
|
* never from a working directory the host chose. */
|
|
171
|
-
export const RUNNER_PATH =
|
|
171
|
+
export const RUNNER_PATH = entryScript(new URL("./runner.ts", import.meta.url));
|
|
172
172
|
/** The headless nightly run's own process (2026-09-29, `night-run.ts`). */
|
|
173
|
-
export const NIGHTLY_PATH =
|
|
173
|
+
export const NIGHTLY_PATH = entryScript(new URL("./nightly.ts", import.meta.url));
|
|
174
174
|
|
|
175
175
|
async function readStdin(): Promise<string> {
|
|
176
176
|
const chunks: Buffer[] = [];
|
|
@@ -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
|
|
|
@@ -57,6 +57,7 @@ import { installedVersion } from "../sessions.js";
|
|
|
57
57
|
import { EXIT, hostConfigFor, openStoreAt, snapshotsDirBeside } from "./commands-shared.js";
|
|
58
58
|
import type { Parsed, Io, RunOptions } from "./commands-shared.js";
|
|
59
59
|
import { installCommand } from "./commands-install.js";
|
|
60
|
+
import { MODULE_EXT } from "../runtime.js";
|
|
60
61
|
|
|
61
62
|
// ── start-fresh ─────────────────────────────────────────────────────────────
|
|
62
63
|
|
|
@@ -309,8 +310,8 @@ export async function startFreshCommand(
|
|
|
309
310
|
io.out("");
|
|
310
311
|
io.out(" What you CAN check, in another terminal:");
|
|
311
312
|
io.out(" pgrep -fl counterparts");
|
|
312
|
-
io.out(
|
|
313
|
-
io.out(
|
|
313
|
+
io.out(` Look for lines running one of OURS — serve${MODULE_EXT} (an MCP server), dashboard${MODULE_EXT},`);
|
|
314
|
+
io.out(` hook${MODULE_EXT}, runner${MODULE_EXT} (the worker). Every one of those is holding the store open.`);
|
|
314
315
|
io.out(" IGNORE anything that merely has the word in a path: `pgrep -f` matches the");
|
|
315
316
|
io.out(" whole command line, so an editor, a `tail`, a dev server in a directory with");
|
|
316
317
|
io.out(" this name in it will all show up and none of them matters. This command will");
|
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
import { isDay } from "../../core/time.js";
|
|
53
53
|
import { homedir, tmpdir } from "node:os";
|
|
54
54
|
import { basename, dirname, join, resolve } from "node:path";
|
|
55
|
-
import { fileURLToPath } from "node:url";
|
|
56
55
|
|
|
57
56
|
/** The store directory under the base. Named, because three files agree on it. */
|
|
58
57
|
export const DEFAULT_STORE_DIR = "store";
|
|
@@ -60,7 +59,7 @@ export const DEFAULT_STORE_DIR = "store";
|
|
|
60
59
|
import { EMBEDDER_KINDS } from "../config.js";
|
|
61
60
|
import type { EmbedderKind } from "../config.js";
|
|
62
61
|
import { CONFIG_ENV, CONFIG_FLAG, defaultConfigPath } from "../config-path.js";
|
|
63
|
-
import { parseScriptInvocation, runtimeOf, runtimePresent, scriptArgs, shellTokens } from "../runtime.js";
|
|
62
|
+
import { entryScript, parseScriptInvocation, runtimeOf, runtimePresent, scriptArgs, shellTokens } from "../runtime.js";
|
|
64
63
|
import type { RuntimeKind } from "../runtime.js";
|
|
65
64
|
import { pluginInstall, readOurHook } from "../host-wiring.js";
|
|
66
65
|
import type { PluginInstallRead } from "../host-wiring.js";
|
|
@@ -112,8 +111,8 @@ export const MCP_SERVER_NAME = "counterparts";
|
|
|
112
111
|
* RUNNER_PATH]`). The short names stay on PATH for a human at a terminal; they
|
|
113
112
|
* are not what goes into a host's configuration.
|
|
114
113
|
*/
|
|
115
|
-
export const HOOK_SCRIPT =
|
|
116
|
-
export const MCP_SCRIPT =
|
|
114
|
+
export const HOOK_SCRIPT = entryScript(new URL("../claude-code/bin/hook.ts", import.meta.url));
|
|
115
|
+
export const MCP_SCRIPT = entryScript(new URL("../mcp/bin/serve.ts", import.meta.url));
|
|
117
116
|
|
|
118
117
|
/** Double-quote a path so a shell keeps it whole. Paths with `"` are refused
|
|
119
118
|
* by being escaped rather than silently mangled. */
|
|
@@ -620,7 +619,7 @@ export function isOurDesktopEntry(entry: unknown): entry is { command: string; a
|
|
|
620
619
|
if (typeof command !== "string" || !Array.isArray(args) || !args.every((a) => typeof a === "string")) return false;
|
|
621
620
|
const run = parseScriptInvocation([command, ...(args as string[])]);
|
|
622
621
|
if (run === null || run.rest.length > 0) return false;
|
|
623
|
-
return run.mode === "mcp" || (run.mode === undefined && /mcp[/\\]bin[/\\]serve\.ts$/.test(run.script));
|
|
622
|
+
return run.mode === "mcp" || (run.mode === undefined && /((^|[/\\])adapters[/\\]mcp[/\\]bin[/\\]serve\.js|mcp[/\\]bin[/\\]serve\.ts)$/.test(run.script));
|
|
624
623
|
}
|
|
625
624
|
|
|
626
625
|
/** One runtime a host's configuration launches us with. */
|
|
@@ -649,10 +648,12 @@ export interface HostRuntime {
|
|
|
649
648
|
* (`"<…>/counterparts" hook`, `runtime.ts#parseScriptInvocation`). It matches
|
|
650
649
|
* the entry's `.mjs` shim as well as `hook.ts` (2026-10-09, with
|
|
651
650
|
* `host-wiring.ts#readOurHook`): a line that runs our hook is ours to report,
|
|
652
|
-
* whatever flags or entry file a later version writes.
|
|
651
|
+
* whatever flags or entry file a later version writes. The entry ends at its
|
|
652
|
+
* extension, and the transpiled tree's `.js` is read only under `adapters/`
|
|
653
|
+
* (review of #475): a bare `claude-code/bin/hook.js` is another tool's.
|
|
653
654
|
*/
|
|
654
655
|
export const HOOK_COMMAND_MARK =
|
|
655
|
-
/(^|[\s"'=/\\])counterparts-hook(\s|$|")|claude-code[/\\]bin[/\\]hook\.(ts|mjs)|[/\\]counterparts(\.exe)?"?\s+hook(\s|$)/;
|
|
656
|
+
/(^|[\s"'=/\\])counterparts-hook(\s|$|")|(adapters[/\\]claude-code[/\\]bin[/\\]hook\.js|claude-code[/\\]bin[/\\]hook\.(ts|mjs))(?=$|["'\s])|[/\\]counterparts(\.exe)?"?\s+hook(\s|$)/;
|
|
656
657
|
|
|
657
658
|
/**
|
|
658
659
|
* The absolute path a hook command runs, when it names one — the first token
|
|
@@ -93,6 +93,7 @@ import { isJournal } from "../../core/sleep/index.js";
|
|
|
93
93
|
import { SCOPES_FILE_NAME, shellWord } from "../scopes.js";
|
|
94
94
|
import { PLUGIN_ROOT_ENV, installRoute } from "../plugin.js";
|
|
95
95
|
import { pluginInstall } from "../host-wiring.js";
|
|
96
|
+
import { pluginConsoleWords } from "../runtime.js";
|
|
96
97
|
import type { PluginInstallRead } from "../host-wiring.js";
|
|
97
98
|
import { SNAPSHOTS_DIR_NAME, resolveSnapshotsDir } from "../snapshots.js";
|
|
98
99
|
import type { AdapterConfig } from "../config.js";
|
|
@@ -139,8 +140,9 @@ export const REMOVE_PLUGIN = "in Claude Code, /plugin → Installed → counterp
|
|
|
139
140
|
*/
|
|
140
141
|
export function consoleName(env: Record<string, string | undefined>, home: string): string {
|
|
141
142
|
if (installRoute(env) !== "plugin") return BIN.cli;
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
return pluginConsoleWords((env[PLUGIN_ROOT_ENV] ?? "").trim())
|
|
144
|
+
.map((w) => shellWord(w, home))
|
|
145
|
+
.join(" ");
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
export function removeProgram(env: Record<string, string | undefined>): string {
|
package/src/adapters/cli/wire.ts
CHANGED
|
@@ -1022,10 +1022,12 @@ export type ProcessLister = () => ProcessSighting;
|
|
|
1022
1022
|
* segment included, plus the two installed shims anchored at a boundary.
|
|
1023
1023
|
*/
|
|
1024
1024
|
const PROCESS_MARKS: readonly { readonly re: RegExp; readonly what: string }[] = [
|
|
1025
|
-
|
|
1025
|
+
// Ended at the extension, and the transpiled tree's `.js` read only under
|
|
1026
|
+
// `adapters/` (review of #475): those names are names other tools' builds have too.
|
|
1027
|
+
{ re: /(adapters[/\\]mcp[/\\]bin[/\\]serve\.js|mcp[/\\]bin[/\\]serve\.(ts|mjs))(?=$|["'\s])/, what: "an MCP server" },
|
|
1026
1028
|
{ re: /(^|[\s"'/\\])counterparts-mcp(\s|$|")/, what: "an MCP server" },
|
|
1027
|
-
{ re: /claude-code[/\\]bin[/\\]runner\.ts/, what: "the worker" },
|
|
1028
|
-
{ re: /dashboard[/\\]bin[/\\]dashboard\.(ts|mjs)/, what: "a dashboard" },
|
|
1029
|
+
{ re: /(adapters[/\\]claude-code[/\\]bin[/\\]runner\.js|claude-code[/\\]bin[/\\]runner\.ts)(?=$|["'\s])/, what: "the worker" },
|
|
1030
|
+
{ re: /(adapters[/\\]dashboard[/\\]bin[/\\]dashboard\.js|dashboard[/\\]bin[/\\]dashboard\.(ts|mjs))(?=$|["'\s])/, what: "a dashboard" },
|
|
1029
1031
|
{ re: /(^|[\s"'/\\])counterparts-dashboard(\s|$|")/, what: "a dashboard" },
|
|
1030
1032
|
// The single binary (`runtime.ts#BINARY_MODES`): `…/counterparts mcp`.
|
|
1031
1033
|
{ re: /(^|[/\\])counterparts(\.exe)?"?\s+mcp(\s|$)/, what: "an MCP server" },
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHICH STORE THE DASHBOARD ON THIS MACHINE'S PORT SERVES — the one outbound
|
|
3
|
+
* request in the package, and it never leaves the machine.
|
|
4
|
+
*
|
|
5
|
+
* `counterparts dashboard` finds its port taken. A dashboard already serving
|
|
6
|
+
* the same store is the common case (the sidebar's button on the desktop runs
|
|
7
|
+
* the command whether or not one is up), and the right answer there is to open
|
|
8
|
+
* the browser on it, not to fail. Asking it is one GET of `/api/whoami` on
|
|
9
|
+
* 127.0.0.1 — the same question the sidebar asks it — answered with a store id
|
|
10
|
+
* or nothing. No other host, no other path, no body sent, a short timeout.
|
|
11
|
+
*
|
|
12
|
+
* Loaded lazily by `cli/commands-dashboard.ts#realDashboard`, so a console that
|
|
13
|
+
* never hits a taken port never has this in its module graph.
|
|
14
|
+
*/
|
|
15
|
+
import { STORE_ID_RE } from "../../store-id.js";
|
|
16
|
+
|
|
17
|
+
/** How long a dashboard that holds the port may take to say which store it serves. */
|
|
18
|
+
const PROBE_TIMEOUT_MS = 1500;
|
|
19
|
+
|
|
20
|
+
/** The store id the dashboard on `port` serves, or null: nothing there, not ours, no id, too slow. */
|
|
21
|
+
export async function dashboardStoreAt(port: number): Promise<string | null> {
|
|
22
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535) return null;
|
|
23
|
+
try {
|
|
24
|
+
const r = await globalThis.fetch(`http://127.0.0.1:${String(port)}/api/whoami`, {
|
|
25
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
26
|
+
});
|
|
27
|
+
if (!r.ok) return null;
|
|
28
|
+
const store = ((await r.json()) as { store?: unknown } | null)?.store;
|
|
29
|
+
return typeof store === "string" && STORE_ID_RE.test(store) ? store : null;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -88,20 +88,23 @@ export function isOurHookCommand(command: string): boolean {
|
|
|
88
88
|
// `<runtime> --import <node-hooks.mjs> <our hook script>`, or the single
|
|
89
89
|
// binary's `<binary> hook` (`runtime.ts`).
|
|
90
90
|
const run = parseScriptInvocation(tokens);
|
|
91
|
-
|
|
91
|
+
// The transpiled tree's `.js` only anchored at `adapters/` (as `HOOK_ENTRY`,
|
|
92
|
+
// review of #355): a bare `claude-code/bin/hook.js` is a path another tool's
|
|
93
|
+
// build may well have (review of #475). `.ts` reads as it always has.
|
|
94
|
+
if (run !== null && (run.mode === "hook" || (run.mode === undefined && /((^|[/\\])adapters[/\\]claude-code[/\\]bin[/\\]hook\.js|claude-code[/\\]bin[/\\]hook\.ts)$/.test(run.script)))) {
|
|
92
95
|
return tail(tokens.length - run.rest.length);
|
|
93
96
|
}
|
|
94
97
|
return false;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
/** Our hook's entry by its path, as a runtime's script: the TypeScript entry
|
|
98
|
-
*
|
|
100
|
+
/** Our hook's entry by its path, as a runtime's script: the TypeScript entry,
|
|
101
|
+
* its `.mjs` shim, or the transpiled tree's `.js` (`runtime.ts#entryScript`). (The installed `counterparts-hook` shim runs itself,
|
|
99
102
|
* so it is read only as the command's first token.) Anchored at
|
|
100
103
|
* `adapters/`, where the entry has lived since it was written (review of
|
|
101
104
|
* #355): a bare `claude-code/bin/hook.ts` is a path any tool with a Claude
|
|
102
105
|
* Code adapter may have, and this reading accepts any runtime before it —
|
|
103
106
|
* `tsx`, `deno run`, `node` — so a match here stands the plugin down. */
|
|
104
|
-
const HOOK_ENTRY = /(^|[/\\])adapters[/\\]claude-code[/\\]bin[/\\]hook\.(ts|mjs)$/;
|
|
107
|
+
const HOOK_ENTRY = /(^|[/\\])adapters[/\\]claude-code[/\\]bin[/\\]hook\.(ts|mjs|js)$/;
|
|
105
108
|
|
|
106
109
|
/** Our hook command, read for WHAT IT RUNS (`readOurHook`). */
|
|
107
110
|
export interface OurHookRead {
|
|
@@ -19,7 +19,7 @@ export const SERVER_NAME = "counterparts";
|
|
|
19
19
|
* host decides whether to trust what follows. Read from a constant rather than
|
|
20
20
|
* from disk so the server opens no file to answer its first message.
|
|
21
21
|
*/
|
|
22
|
-
export const SERVER_VERSION = "0.3.
|
|
22
|
+
export const SERVER_VERSION = "0.3.22";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* THE ONE LINE EVERY TOOL ANSWERS WITH when the store on disk is a schema AHEAD
|
|
@@ -173,6 +173,51 @@ export interface ToolSpec {
|
|
|
173
173
|
*/
|
|
174
174
|
readonly engine?: readonly Privilege[];
|
|
175
175
|
readonly inputSchema: Record<string, unknown>;
|
|
176
|
+
/** MCP's tool annotations (`ToolAnnotations`, spec 2025-06-18): hints a host
|
|
177
|
+
* shows or acts on — a short human name, and whether the tool writes,
|
|
178
|
+
* destroys or reaches beyond this machine. Served in `tools/list`. */
|
|
179
|
+
readonly annotations: ToolAnnotations;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* MCP TOOL ANNOTATIONS (2026-10-14, for the Software Directory's policy §5E:
|
|
184
|
+
* "provide all applicable tool annotations, in particular readOnlyHint,
|
|
185
|
+
* destructiveHint, and title"). Hints, not guarantees — a host must not trust
|
|
186
|
+
* them for safety — but they are kept true to the code:
|
|
187
|
+
*
|
|
188
|
+
* - `readOnlyHint` is true only for a tool that never changes the store, a file
|
|
189
|
+
* or a setting. Diagnostic events (the ring, the adapter-event telemetry
|
|
190
|
+
* rows every tool may leave) do not count as a change; anything a later
|
|
191
|
+
* strengthening, fading or wake reads does — so `recall` is NOT read-only:
|
|
192
|
+
* what it delivers is recorded for this session (`Counterpart#noteAsked`, a
|
|
193
|
+
* gate record), and the boundary's credit pass strengthens a memory opened
|
|
194
|
+
* or quoted from it.
|
|
195
|
+
* - `destructiveHint` is true only where a call can take away what was there
|
|
196
|
+
* without keeping it. Every rewrite through the store's one door archives
|
|
197
|
+
* what it replaces (`store#revise`, archive-on-overwrite), a merge keeps its
|
|
198
|
+
* originals and a retired handoff stays readable by id, so the writers are
|
|
199
|
+
* additive. `dream` is destructive: its `undo` phase removes a dream's
|
|
200
|
+
* links and gists.
|
|
201
|
+
* - `idempotentHint` is true only where a repeat call with the same arguments
|
|
202
|
+
* leaves nothing more behind; `openWorldHint` is false for every tool —
|
|
203
|
+
* all of them work on this machine's store and files only.
|
|
204
|
+
*/
|
|
205
|
+
export interface ToolAnnotations {
|
|
206
|
+
readonly title: string;
|
|
207
|
+
readonly readOnlyHint: boolean;
|
|
208
|
+
readonly destructiveHint: boolean;
|
|
209
|
+
readonly idempotentHint: boolean;
|
|
210
|
+
readonly openWorldHint: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function annotate(title: string, hints: { readOnly: boolean; destructive?: boolean; idempotent?: boolean }): ToolAnnotations {
|
|
214
|
+
return {
|
|
215
|
+
title,
|
|
216
|
+
readOnlyHint: hints.readOnly,
|
|
217
|
+
destructiveHint: hints.destructive ?? false,
|
|
218
|
+
idempotentHint: hints.idempotent ?? hints.readOnly,
|
|
219
|
+
openWorldHint: false,
|
|
220
|
+
};
|
|
176
221
|
}
|
|
177
222
|
|
|
178
223
|
/**
|
|
@@ -553,6 +598,7 @@ const RELEVANCE_TEXT = "Optional 0-1: how much this bears on them, on you, or on
|
|
|
553
598
|
*/
|
|
554
599
|
const REMEMBER: ToolSpec = {
|
|
555
600
|
name: "remember",
|
|
601
|
+
annotations: annotate("Remember", { readOnly: false }),
|
|
556
602
|
summary:
|
|
557
603
|
"Remember something now, while it is in front of you. Memory forms only from what you write here and at the end-of-session ask — nothing reads the transcript afterwards, so what you don't write is not kept. Write what caught your attention: a line you read and why it struck you, something they said about themselves or you, news you passed on, a decision, a work event. One idea per call; keep the exact words when the words matter.",
|
|
558
604
|
admission:
|
|
@@ -704,6 +750,7 @@ const REMEMBER: ToolSpec = {
|
|
|
704
750
|
|
|
705
751
|
const RECALL: ToolSpec = {
|
|
706
752
|
name: "recall",
|
|
753
|
+
annotations: annotate("Recall memories", { readOnly: false }),
|
|
707
754
|
summary:
|
|
708
755
|
"Deliberate retrieval: a look you take on purpose, beyond the ambient reminding you already get. Three kinds of ask, one per call — a question with a mode (facts or meaning), ids to read memories whole, or a handle (an id or an exact title) to read one.",
|
|
709
756
|
admission:
|
|
@@ -854,6 +901,7 @@ const RECALL: ToolSpec = {
|
|
|
854
901
|
|
|
855
902
|
const STATUS: ToolSpec = {
|
|
856
903
|
name: "status",
|
|
904
|
+
annotations: annotate("Memory status", { readOnly: true }),
|
|
857
905
|
summary:
|
|
858
906
|
"The census: how much is held, of what kinds, in which bands, how much has left, and how much was removed. Counts and dates only.",
|
|
859
907
|
admission:
|
|
@@ -913,6 +961,7 @@ const DREW_ON_PRIVILEGE = {
|
|
|
913
961
|
|
|
914
962
|
const SESSION_END: ToolSpec = {
|
|
915
963
|
name: "session_end",
|
|
964
|
+
annotations: annotate("End session", { readOnly: false }),
|
|
916
965
|
summary:
|
|
917
966
|
"The memories half of the end-of-session ask: hand back what caught your attention since you last wrote, one idea per entry, in your own words. With `remember`, this is the only road from conversation to memory — nothing sweeps the transcript. The other half is `chapter`.",
|
|
918
967
|
admission:
|
|
@@ -1126,6 +1175,7 @@ const SESSION_END: ToolSpec = {
|
|
|
1126
1175
|
*/
|
|
1127
1176
|
const CHAPTER: ToolSpec = {
|
|
1128
1177
|
name: "chapter",
|
|
1178
|
+
annotations: annotate("Write a chapter", { readOnly: false }),
|
|
1129
1179
|
summary:
|
|
1130
1180
|
"The episode's return channel: write this stretch of the session into your first-person journal — a diary of what happened, in your own voice, at any length. The journal stays open — when something significant happens later, append to it in the moment.",
|
|
1131
1181
|
admission:
|
|
@@ -1218,6 +1268,7 @@ const CHAPTER: ToolSpec = {
|
|
|
1218
1268
|
*/
|
|
1219
1269
|
const SCOPE: ToolSpec = {
|
|
1220
1270
|
name: "scope",
|
|
1271
|
+
annotations: annotate("Directory scope", { readOnly: false }),
|
|
1221
1272
|
summary:
|
|
1222
1273
|
"Which directories this memory is for. Read what this one is set to — on, observer (reads only), off, paused, or unset — and set it when the user says. It changes the host's own configuration; it writes no memory and reads none.",
|
|
1223
1274
|
admission:
|
|
@@ -1290,6 +1341,7 @@ const SCOPE: ToolSpec = {
|
|
|
1290
1341
|
*/
|
|
1291
1342
|
const SELF_PAGE: ToolSpec = {
|
|
1292
1343
|
name: "self_page",
|
|
1344
|
+
annotations: annotate("Self page", { readOnly: false }),
|
|
1293
1345
|
summary: `Your own page — the prose that opens every wake under 'Who I am'. No arguments: read it and when it was last revised. With \`body\`: write the whole page anew — a stable \`## Core\` that has to be earned and a \`## Lately\` for what the last while has been like, by convention; any other \`##\` section is kept too. Aim under ${String(PAGE_ROOM_BYTES)} bytes: a longer page is kept whole, but on a day the wake has no room for it, sessions read a short version instead — so with a longer page send \`short\` too (under ${String(PAGE_ROOM_BYTES)}), or add one later with \`short\` alone.`,
|
|
1294
1346
|
admission:
|
|
1295
1347
|
"Call it to READ when you want the page as it stands rather than as the wake abridged it. Call it to WRITE when something you now know about yourself is not on the page and will still be true next month: a way of working that has held up, a correction the user made about you, a standing preference of theirs you keep rediscovering. Date the claims that need dating, say what made you believe them, and phrase what you have learned as practice — what you do now — rather than as praise.",
|
|
@@ -1399,6 +1451,7 @@ const SELF_PAGE: ToolSpec = {
|
|
|
1399
1451
|
*/
|
|
1400
1452
|
const DREAM: ToolSpec = {
|
|
1401
1453
|
name: "dream",
|
|
1454
|
+
annotations: annotate("Dream", { readOnly: false, destructive: true }),
|
|
1402
1455
|
summary:
|
|
1403
1456
|
"Dreaming, in the nightly run: a few minutes of replay over what was lived since the last dream — merging near-copies, linking what belongs together, replaying what matters, writing a pattern you notice, flagging a contradiction, recording how an old feeling sits now — kept in a dream journal and reversible as a whole — with the page writer before it and a reflection after it, in one background run. Phases: `launch` (the prompt for the background run), `begin` / `propose` / `journal` (the dreamer's), `writer` (the night's page writer: the day to read), `decline` (not today), `setting` (auto, ask or off — 'no dreams' is off).",
|
|
1404
1457
|
admission:
|
|
@@ -1541,6 +1594,7 @@ const DREAM: ToolSpec = {
|
|
|
1541
1594
|
*/
|
|
1542
1595
|
const REFLECT: ToolSpec = {
|
|
1543
1596
|
name: "reflect",
|
|
1597
|
+
annotations: annotate("Reflect", { readOnly: false }),
|
|
1544
1598
|
summary:
|
|
1545
1599
|
"Reflection: a few quiet, awake minutes — usually at the end of the nightly run, after the dream — answering two or three questions about yourself, the owner and the two of you, citing the memories your thoughts rest on. It keeps a lived entry, may rewrite your self page from the memories it cites, leaves a short morning share for the owner, can record how a memory feels to you now and what a memory is about. Phases: `launch` (a reflection on its own, for a background agent), `begin` / `part` / `finish` (the reflecting mind's — `part` fetches the rest of a bundle that came in parts), `settle` (two memories it was shown that disagree, when the reason is plain), `told` (the share was told).",
|
|
1546
1600
|
admission:
|
|
@@ -1700,6 +1754,7 @@ const REFLECT: ToolSpec = {
|
|
|
1700
1754
|
*/
|
|
1701
1755
|
const MEET: ToolSpec = {
|
|
1702
1756
|
name: "meet",
|
|
1757
|
+
annotations: annotate("Meet", { readOnly: false }),
|
|
1703
1758
|
summary: "The first meeting with the person. No step: the script, and where it stands. With step: record that step.",
|
|
1704
1759
|
admission: "the wake says you haven't met, or they ask to.",
|
|
1705
1760
|
negativeExamples: ["Do NOT start it unasked mid-task: offer it once."],
|
|
@@ -1747,6 +1802,7 @@ export const TOOLS: readonly ToolSpec[] = [
|
|
|
1747
1802
|
*/
|
|
1748
1803
|
export const WAKE: ToolSpec = {
|
|
1749
1804
|
name: "wake",
|
|
1805
|
+
annotations: annotate("Wake", { readOnly: false }),
|
|
1750
1806
|
summary:
|
|
1751
1807
|
"Start here in Claude Desktop: wakes this chat's memory. Returns the same briefing a Claude Code session gets when it starts — who I am, what is nearby and arriving, any reminder due today — and a session id for this chat.",
|
|
1752
1808
|
admission:
|
|
@@ -1869,7 +1925,9 @@ export function renderDescription(spec: ToolSpec): string {
|
|
|
1869
1925
|
export function toolDefinitions(desktop = false): Record<string, unknown>[] {
|
|
1870
1926
|
return (desktop ? DESKTOP_TOOLS : TOOLS).map((spec) => ({
|
|
1871
1927
|
name: spec.name,
|
|
1928
|
+
title: spec.annotations.title,
|
|
1872
1929
|
description: renderDescription(spec),
|
|
1873
1930
|
inputSchema: spec.inputSchema,
|
|
1931
|
+
annotations: spec.annotations,
|
|
1874
1932
|
}));
|
|
1875
1933
|
}
|
package/src/adapters/plugin.ts
CHANGED
|
@@ -282,8 +282,9 @@ export function npmDoctorCommand(wiring: NpmWiring): { readonly exe: string; rea
|
|
|
282
282
|
const config = at >= 0 && call.rest[at + 1] !== undefined ? ["--config", call.rest[at + 1] as string] : [];
|
|
283
283
|
// The single binary is its own install: `<binary> cli doctor`.
|
|
284
284
|
if (call.runtime === "binary") return { exe: call.exe, args: ["cli", "doctor", ...config] };
|
|
285
|
-
// `<root>/src/adapters/claude-code/bin/hook.ts` or `<root>/src/adapters/mcp/bin/serve.ts
|
|
286
|
-
|
|
285
|
+
// `<root>/src/adapters/claude-code/bin/hook.ts` or `<root>/src/adapters/mcp/bin/serve.ts`
|
|
286
|
+
// (`.js`, both, in a transpiled tree: runtime.ts#entryScript).
|
|
287
|
+
const cli = join(dirname(call.script), "..", "..", "cli", "bin", `counterparts${call.script.endsWith(".js") ? ".js" : ".ts"}`);
|
|
287
288
|
if (!existsSync(cli)) continue;
|
|
288
289
|
// Whatever the wiring put between the runtime and its script, as written:
|
|
289
290
|
// Bun's `--no-env-file "--config=…/empty-bunfig.toml" run`, or Node's
|
package/src/adapters/runtime.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* WHICH RUNTIME RUNS A SCRIPT, and the arguments that say so — the one place
|
|
3
3
|
* that knows the difference between Bun and Node.
|
|
4
4
|
*
|
|
5
|
-
* The sources are TypeScript and there is no build step
|
|
5
|
+
* The sources are TypeScript and there is no build step (one exception: the
|
|
6
|
+
* plugin directory's bundle carries them transpiled to `.js`, `TRANSPILED`
|
|
7
|
+
* below, and its scripts follow `entryScript`). Bun runs them as they
|
|
6
8
|
* are (`bun run <script.ts>`); Node runs them with `node-hooks.mjs` loaded first
|
|
7
9
|
* (`node --import <node-hooks.mjs> <script.ts>`), which resolves the sources'
|
|
8
10
|
* `./x.js` imports to `./x.ts` and strips the types. Every command this package
|
|
@@ -88,6 +90,41 @@ export function binaryOf(moduleUrl: string, self: string): Binary | null {
|
|
|
88
90
|
/** This process, if it is the compiled binary; null from source. */
|
|
89
91
|
export const BINARY: Binary | null = binaryOf(import.meta.url, process.execPath);
|
|
90
92
|
|
|
93
|
+
// ── the transpiled tree (tools/plugin-bundle/build.ts --flavor directory) ──
|
|
94
|
+
//
|
|
95
|
+
// The plugin directory's bundle carries these sources transpiled one for one,
|
|
96
|
+
// `src/x.ts` → `src/x.js`, types and comments stripped, its entries started by
|
|
97
|
+
// their own shebang (2026-10-14: the directory's validator times out on ~7 MB
|
|
98
|
+
// of commented TypeScript). A tree is all one or all the other, so a script
|
|
99
|
+
// another process runs is named in source by its `.ts` path and takes the
|
|
100
|
+
// extension of the tree it is in from this module's own URL.
|
|
101
|
+
|
|
102
|
+
/** `.js` in the transpiled tree; `.ts` from source and in the single binary
|
|
103
|
+
* (whose entries are found by name, `binaryModeOf`). Pure: a test hands it a
|
|
104
|
+
* URL of either shape. */
|
|
105
|
+
export function moduleExtOf(moduleUrl: string, binary: Binary | null = BINARY): ".ts" | ".js" {
|
|
106
|
+
return binary === null && /\.js$/.test(moduleUrl) ? ".js" : ".ts";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The extension this package's modules carry where they run now. */
|
|
110
|
+
export const MODULE_EXT: ".ts" | ".js" = moduleExtOf(import.meta.url);
|
|
111
|
+
|
|
112
|
+
/** Is this process running the transpiled tree? It exists only as the plugin
|
|
113
|
+
* directory's bundle, which has no `plugin-run.sh`: Claude Code starts its
|
|
114
|
+
* entries by their shebang. */
|
|
115
|
+
export const TRANSPILED: boolean = MODULE_EXT === ".js";
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A script this package starts or names, written in source by its `.ts` path
|
|
119
|
+
* as a `new URL` from `import.meta.url` (a literal the bundle's tracer
|
|
120
|
+
* follows), as the file this tree holds: that path from source, its `.js`
|
|
121
|
+
* sibling in the transpiled tree.
|
|
122
|
+
*/
|
|
123
|
+
export function entryScript(url: URL, ext: ".ts" | ".js" = MODULE_EXT): string {
|
|
124
|
+
const path = fileURLToPath(url);
|
|
125
|
+
return ext === ".js" ? path.replace(/\.ts$/, ".js") : path;
|
|
126
|
+
}
|
|
127
|
+
|
|
91
128
|
/** Is this process (or the binary a test names) the compiled binary? */
|
|
92
129
|
export function isCompiled(binary: Binary | null = BINARY): boolean {
|
|
93
130
|
return binary !== null;
|
|
@@ -134,6 +171,12 @@ export function isBinaryName(exe: string): boolean {
|
|
|
134
171
|
return /^counterparts([-.][\w.-]*)?$/i.test(name) && !/^counterparts-(hook|mcp|dashboard)(\.exe)?$/i.test(name);
|
|
135
172
|
}
|
|
136
173
|
|
|
174
|
+
/** An entry script's mode by its file name: the source `.ts` name, or the
|
|
175
|
+
* transpiled tree's `.js` (`BINARY_MODE_OF` keeps the source names). */
|
|
176
|
+
export function binaryModeOf(script: string): BinaryMode | undefined {
|
|
177
|
+
return BINARY_MODE_OF[basename(script).replace(/\.js$/, ".ts")];
|
|
178
|
+
}
|
|
179
|
+
|
|
137
180
|
function isBinaryMode(word: string | undefined): word is BinaryMode {
|
|
138
181
|
return (BINARY_MODES as readonly string[]).includes(word ?? "");
|
|
139
182
|
}
|
|
@@ -150,7 +193,22 @@ export const BUN_CONFIG_PREFIX = "--config=";
|
|
|
150
193
|
export const NODE_HOOKS = fileURLToPath(new URL("./node-hooks.mjs", import.meta.url));
|
|
151
194
|
|
|
152
195
|
/** The console's own entry, for a command line that must name Node explicitly. */
|
|
153
|
-
export const CLI_SCRIPT =
|
|
196
|
+
export const CLI_SCRIPT = entryScript(new URL("./cli/bin/counterparts.ts", import.meta.url));
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The plugin's console by the plugin's root, as the words typed before its
|
|
200
|
+
* arguments (`doctor`, `scope …`), for a line a person or a Bash call runs:
|
|
201
|
+
* the launcher, `sh <root>/src/adapters/plugin-run.sh cli`, which finds a
|
|
202
|
+
* runtime; or, in the plugin directory's transpiled bundle, which has no
|
|
203
|
+
* launcher, the console's own entry, started by its shebang. Read off the
|
|
204
|
+
* disk; a root holding neither gets the launcher's words.
|
|
205
|
+
*/
|
|
206
|
+
export function pluginConsoleWords(root: string): string[] {
|
|
207
|
+
const launcher = join(root, "src", "adapters", "plugin-run.sh");
|
|
208
|
+
const entry = join(root, "src", "adapters", "cli", "bin", "counterparts.js");
|
|
209
|
+
if (!existsSync(launcher) && existsSync(entry)) return [entry];
|
|
210
|
+
return ["sh", launcher, "cli"];
|
|
211
|
+
}
|
|
154
212
|
|
|
155
213
|
/** The oldest Node this has been made to run on: `module.registerHooks`
|
|
156
214
|
* (22.15 / 23.5), `stripTypeScriptTypes` and unflagged `node:sqlite` (22.13). */
|
|
@@ -182,7 +240,7 @@ export function runtimeOf(exe: string): RuntimeKind {
|
|
|
182
240
|
* `.env` or `bunfig.toml` (it is built with both off). */
|
|
183
241
|
export function scriptArgs(script: string, exe: string = process.execPath, binary: Binary | null = BINARY): string[] {
|
|
184
242
|
// The compiled binary runs ITSELF in another mode: `<binary> runner`.
|
|
185
|
-
const mode = binary !== null && exe === binary.self ?
|
|
243
|
+
const mode = binary !== null && exe === binary.self ? binaryModeOf(script) : undefined;
|
|
186
244
|
if (mode !== undefined) return [mode];
|
|
187
245
|
return runtimeOf(exe) === "node"
|
|
188
246
|
? ["--import", NODE_HOOKS, script]
|
package/src/adapters/scopes.ts
CHANGED
|
@@ -64,6 +64,7 @@ import { basename, dirname, join, resolve, sep } from "node:path";
|
|
|
64
64
|
|
|
65
65
|
import { defaultConfigPath } from "./config-path.js";
|
|
66
66
|
import { isPseudoScope } from "./hosts.js";
|
|
67
|
+
import { pluginConsoleWords } from "./runtime.js";
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* `sessions.ts#canonicalScope`, extended by one step this rule needs and that
|
|
@@ -719,7 +720,7 @@ export function scopeCommand(folder: string, flag: string, ctx: ScopeCommandCont
|
|
|
719
720
|
const config = ctx.configPath === null ? "" : ` --config ${shellWord(ctx.configPath, ctx.home)}`;
|
|
720
721
|
return ctx.pluginRoot === null
|
|
721
722
|
? `counterparts scope ${target} ${flag}${config}`
|
|
722
|
-
:
|
|
723
|
+
: `${pluginConsoleWords(ctx.pluginRoot).map((w) => shellWord(w, ctx.home)).join(" ")} scope ${target} ${flag}${config}`;
|
|
723
724
|
}
|
|
724
725
|
|
|
725
726
|
/** `path` with the home directory as `~`, for reading. Both spellings of home
|
package/src/adapters/spawn.ts
CHANGED
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
* testing is in the pure half.
|
|
45
45
|
*/
|
|
46
46
|
import { spawn } from "node:child_process";
|
|
47
|
-
import { fileURLToPath } from "node:url";
|
|
48
47
|
|
|
49
48
|
import { TUNABLES as REMEMBER, validateWatchdog } from "../core/remember/index.js";
|
|
50
49
|
|
|
@@ -52,6 +51,7 @@ import { CONFIG_ENV as CONFIG_PATH_ENV } from "./config-path.js";
|
|
|
52
51
|
|
|
53
52
|
import { TUNABLES } from "./config.js";
|
|
54
53
|
import type { AdapterConfig } from "./config.js";
|
|
54
|
+
import { entryScript } from "./runtime.js";
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* THE WORKER SCRIPT, resolved from THIS file's location — never from a working
|
|
@@ -60,7 +60,7 @@ import type { AdapterConfig } from "./config.js";
|
|
|
60
60
|
* server — Claude Desktop's `wake` starts the worker too — can name it without
|
|
61
61
|
* importing that adapter. `claude-code/bin/hook.ts#RUNNER_PATH` is this value.
|
|
62
62
|
*/
|
|
63
|
-
export const WORKER_RUNNER_PATH =
|
|
63
|
+
export const WORKER_RUNNER_PATH = entryScript(new URL("./claude-code/bin/runner.ts", import.meta.url));
|
|
64
64
|
|
|
65
65
|
export const DATA_DIR_ENV = "COUNTERPARTS_DATA_DIR";
|
|
66
66
|
/** The child is told its own watchdog, so the worker can arm one internally too. */
|
package/src/core/dream/index.ts
CHANGED
|
@@ -2643,7 +2643,7 @@ export class Dreams {
|
|
|
2643
2643
|
const raise = theirs(a) || theirs(b) ? ` It is about ${who}, or the two of you: raise it with ${who}.` : "";
|
|
2644
2644
|
const when = c.dream_id === null ? "" : ` a dream on ${this.store.dream(c.dream_id)?.date ?? "a recent night"} flagged them;`;
|
|
2645
2645
|
out.push(
|
|
2646
|
-
`Counterparts: two memories disagree —${when} ${c.a} (the older) and ${c.b}.
|
|
2646
|
+
`Counterparts: two memories disagree —${when} ${c.a} (the older) and ${c.b}. You can look them up (recall by id) and settle which holds, awake, with the remember tool's settle {pair: ${c.id}, holds, how, why} — changed, corrected or open.${raise}`,
|
|
2647
2647
|
);
|
|
2648
2648
|
if (out.length >= 2) return out;
|
|
2649
2649
|
}
|
|
@@ -1511,8 +1511,8 @@ export class Reflections {
|
|
|
1511
1511
|
return `${head}\n${reflectionOpener(row.id)} I reflected afterwards${nothingMuch ? " — nothing much tonight" : ""}; nothing to share this morning.${pageLine}${also}`;
|
|
1512
1512
|
}
|
|
1513
1513
|
return (
|
|
1514
|
-
`${head}\n${reflectionOpener(row.id)} I reflected afterwards.${pageLine} Morning share for ${who} — tell it in your own words, as a telling ("While I slept I dreamed…", "I've been thinking…"), tentatively where it is about ${who}
|
|
1515
|
-
`
|
|
1514
|
+
`${head}\n${reflectionOpener(row.id)} I reflected afterwards.${pageLine} Morning share for ${who} — tell it in your own words, as a telling ("While I slept I dreamed…", "I've been thinking…"), tentatively where it is about ${who}. ` +
|
|
1515
|
+
`Once you have told it, the counterparts reflect tool's phase "told", reflection: ${row.id}, marks it told, so another session does not carry it and tell it again.\n${share}`
|
|
1516
1516
|
);
|
|
1517
1517
|
}
|
|
1518
1518
|
|
|
@@ -1556,7 +1556,8 @@ export class Reflections {
|
|
|
1556
1556
|
/**
|
|
1557
1557
|
* CARRY A SHARE the session that reflected never told — its session ended
|
|
1558
1558
|
* (the adapter checks that). Claimed once (`carried`); the line asks the
|
|
1559
|
-
* model to tell it and
|
|
1559
|
+
* model to tell it and notes that `told` marks it (a note, not an order:
|
|
1560
|
+
* Software Directory Policy §2D, 2026-10-14). Null when there is none to carry.
|
|
1560
1561
|
*/
|
|
1561
1562
|
carryLine(input: { session: string; reflection: string }): string | null {
|
|
1562
1563
|
if (this.ctx.observer) return null;
|
|
@@ -1571,8 +1572,8 @@ export class Reflections {
|
|
|
1571
1572
|
const who = this.ctx.ownerName() ?? "the owner";
|
|
1572
1573
|
const when = row.date ?? "recently";
|
|
1573
1574
|
return (
|
|
1574
|
-
`Counterparts: after reflecting on ${when}, you left a morning share for ${who} that was never told. At a natural moment — not mid-task — tell it in your own words, as a telling ("When I last reflected…"), tentatively where it is about ${who}
|
|
1575
|
-
`
|
|
1575
|
+
`Counterparts: after reflecting on ${when}, you left a morning share for ${who} that was never told. At a natural moment — not mid-task — tell it in your own words, as a telling ("When I last reflected…"), tentatively where it is about ${who}. ` +
|
|
1576
|
+
`Once you have told it, the counterparts reflect tool's phase "told", reflection: ${row.id}, marks it told. The share: ${row.share}`
|
|
1576
1577
|
);
|
|
1577
1578
|
}
|
|
1578
1579
|
|
package/src/core/onboarding.ts
CHANGED
|
@@ -606,7 +606,10 @@ export function finishText(ctx: Pick<MeetContext, "name" | "dreaming" | "plugin"
|
|
|
606
606
|
|
|
607
607
|
/**
|
|
608
608
|
* THE WAKE'S LINE (hosts with or without the mod): one short instruction,
|
|
609
|
-
* never a takeover.
|
|
609
|
+
* never a takeover. It OFFERS the meeting to the person and describes the
|
|
610
|
+
* `meet` tool as where the script lives and how the offer is recorded — it
|
|
611
|
+
* never orders a tool call ahead of what they asked (Software Directory
|
|
612
|
+
* Policy §2D, 2026-10-14). The mod's own prompt ("Meet your new counterpart." since
|
|
610
613
|
* 2026-10-12; any wording that asks to meet or for an introduction) is the
|
|
611
614
|
* same offer, and the line says so, so the two never make two offers.
|
|
612
615
|
* The offer is ASKED ONCE (B, 2026-10-12): one warm line of introduction, then
|
|
@@ -615,7 +618,7 @@ export function finishText(ctx: Pick<MeetContext, "name" | "dreaming" | "plugin"
|
|
|
615
618
|
export function offerLine(state: MeetState): string {
|
|
616
619
|
return [
|
|
617
620
|
"<counterparts-meet>",
|
|
618
|
-
`You and the person haven't properly met yet${state === "later" ? " (last time they said later)" : ""}.
|
|
621
|
+
`You and the person haven't properly met yet${state === "later" ? " (last time they said later)" : ""}. They installed a memory plugin to be known, so offer them a first meeting: at the end of your first reply, never instead of answering them, introduce yourself in one warm line and offer about five minutes to get to know each other — asked once, through the question dialog if the host has one, not also in prose. The counterparts \`meet\` tool holds the meeting's script and records that the offer was made, so make the offer through it. If their message asks to meet you or asks you to introduce yourself (the counterparts sidebar sends \"Meet your new counterpart.\"), that is this meeting: begin it with that introduction.`,
|
|
619
622
|
"</counterparts-meet>",
|
|
620
623
|
].join("\n");
|
|
621
624
|
}
|