counterparts 0.3.22 → 0.3.23

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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.23 — 2026-10-14
4
+
5
+ The plugin's sidebar now shows your memory and does nothing else: it has no buttons and no links, runs no command, calls no tool and makes no network request. Its footer says how to do the rest yourself (`/counterparts:meet`, `/counterparts:dashboard`, say "pause memory here", `/counterparts quiet`). What it shows comes from a small file Counterparts writes for it, `~/.counterparts/sidebar.json`, only while the plugin is installed, so the dashboard no longer has to be running for the sidebar to show anything. The sidebar's brain is gone and the fox stays. The plugin directory's build of the plugin no longer reads Claude Code's user configuration file and leaves out the dashboard's 3D brain; beside an npm install it does not stand down, so keep one or the other. No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.22, and `counterparts connect` is not needed.
6
+
7
+ - **The sidebar shows memory and no longer acts.** It has no buttons: the "Start the
8
+ 5-minute intro" row, the desktop's dashboard buttons, the folder switch (on, paused, off)
9
+ and its confirm, and the view and avatar switches are gone. Its footer says how instead:
10
+ `/counterparts:meet` for the intro, `/counterparts:dashboard` for the dashboard, say
11
+ "pause memory here" to Claude to pause a folder, `/counterparts quiet` to hide it. A
12
+ paused folder still says so, with how to resume; `/counterparts resume` now says how
13
+ rather than resuming. COUNTERPARTS and a long memory's `more` are plain words, not links.
14
+ - **The sidebar makes no network request.** It used to ask the dashboard on 127.0.0.1;
15
+ now Counterparts' own background processes (the one after each reply, and the memory
16
+ server) write `~/.counterparts/sidebar.json` (mode 0600, beside `claude-code.json`) and
17
+ the sidebar reads it every 15 to 30 seconds while it is open. The file holds the day and
18
+ the count, today's counts, the last dream, recent activity and the memories it names
19
+ (title and the first 800 characters; a confidential memory's text is withheld). It is
20
+ written only while the plugin is installed; an npm-only install never writes it, and
21
+ once the plugin is gone the next Counterparts process deletes it. A surfaced memory's
22
+ title can take up to about 30 seconds to appear. `COUNTERPARTS_DASHBOARD_PORT` no longer
23
+ matters to the sidebar.
24
+ - **The sidebar's brain is gone; the fox stays.** `/counterparts avatar` takes `animal` or
25
+ `off`; a brain chosen before shows the fox. `/counterparts fps` is gone with it.
26
+ - **The directory build never reads `~/.claude.json`.** The plugin as built for
27
+ Anthropic's directory does not open Claude Code's user configuration file. The cost: it
28
+ can't see an npm install's memory server there, so beside a wired npm install it doesn't
29
+ stand down; both run on the same memory and Claude is offered the memory tools twice.
30
+ Keep one: `counterparts disconnect` and a restart keep only the plugin, uninstalling the
31
+ plugin keeps only the npm install. The npm install's doctor tells the two plugin builds
32
+ apart and says this. The marketplace's plugin (the full build) is unchanged and still
33
+ stands down.
34
+ - **The directory build leaves out the dashboard's 3D brain** (and three.js); its home
35
+ page draws without the picture. No file in that build is over 256 KiB.
36
+ - **Uninstalling the directory build with no `claude` on PATH keeps your memory.** It
37
+ can't confirm the memory server registration is gone, so it stops before deleting or
38
+ moving the store, and prints the `claude mcp remove` line to run.
39
+ - The dashboard's icon is now a file of its own (same address, same picture).
40
+
3
41
  ## 0.3.22 — 2026-10-14
4
42
 
5
43
  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.
@@ -55,6 +55,7 @@ input — does `encode` shrink to gates-and-tagging inside `remember`'s pipeline
55
55
  | `spawn.ts` | The detached worker's plan and start (`planSpawn`, `spawnDetached`): watchdog checked against the staleness window, environment pinned last. Moved out of `claude-code/` on **2026-09-30** so any host's adapter can start the same worker. |
56
56
  | `fired.ts` | Which mechanisms have fired and which have gone quiet, read only from the store's rows — `counterparts mechanisms`, the dashboard's panel. Each entry names the module that does the work. |
57
57
  | `snapshots.ts` | The daily rotating snapshot and its rotation — the one place this package deletes a copy of the memory, and only what it can prove is a snapshot. |
58
+ | `sidebar-status.ts` | The Claude Code sidebar's status file (`sidebar.json` beside the configuration): what the sidebar shows, built by the dashboard's view functions over an observer handle and written whole, by the worker after each boundary and by the memory server off its tool calls' path, so the sidebar makes no network request. |
58
59
  | `stance-env.ts` | `COUNTERPARTS_OBSERVER` / `COUNTERPARTS_OWNER`, read the way the explicit-dir guard is, each failing toward less power. Unset, the configuration's `owner: true` decides for a server Claude Code starts (`mcp/bin/serve.ts#ownerStance`, 2026-10-02). |
59
60
  | `log/` | A shared leaf with its own CONTRACT: the process log — one line per allowlisted event (failures, stand-downs, turn ends, write-ups, the night, the wake) from the hook, the worker, the nightly run and the MCP server, to `<dataDir>/sessions/log/<date>.log`, ids and codes only, kept 7 days. Read by `counterparts log` and one doctor line. **Added 2026-09-30**: none of the four processes wired its `onEvent`, so ~270 event names died with their process. |
60
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.22",
3
+ "version": "0.3.23",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -66,6 +66,7 @@
66
66
  * It exits 0 on every path. Nothing about a failed run may reach the host.
67
67
  */
68
68
  import { readFileSync } from "node:fs";
69
+ import { homedir } from "node:os";
69
70
  import { resolve } from "node:path";
70
71
  import { fileURLToPath } from "node:url";
71
72
 
@@ -102,6 +103,8 @@ import type { LiveEmbedder } from "../embed-client.js";
102
103
  import { DATA_DIR_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV } from "../../spawn.js";
103
104
  import { backfillVectors, laggedSemantic } from "../vectors.js";
104
105
  import type { BackfillReport, LagReport } from "../vectors.js";
106
+ import { removeSidebarStatus, sidebarInstalled, writeSidebarStatus } from "../../sidebar-status.js";
107
+ import type { SidebarWrite } from "../../sidebar-status.js";
105
108
  import { runSnapshot } from "../../snapshots.js";
106
109
  import type { SnapshotRunReport } from "../../snapshots.js";
107
110
 
@@ -142,6 +145,9 @@ export interface RunReport {
142
145
  /** The day's retention pass, or why it did not run. Null when the run refused
143
146
  * before it opened a store at all. */
144
147
  readonly retention: RetentionJobReport | null;
148
+ /** The sidebar's status file (`adapters/sidebar-status.ts`), written after the
149
+ * store closed; absent when the run was not asked to (no configuration path). */
150
+ readonly sidebar?: SidebarWrite;
145
151
  }
146
152
 
147
153
  /** What the retention step came to on one worker run. */
@@ -310,6 +316,9 @@ export async function runOnce(input: {
310
316
  /** The package version this run is, for the wake's build stamp. Absent: the
311
317
  * installed manifest's (`installedVersion`). Injected so a test can be an upgrade. */
312
318
  build?: string | null;
319
+ /** The configuration this run read: the sidebar's status file is written
320
+ * beside it once the run is done (`adapters/sidebar-status.ts`). Absent: none. */
321
+ sidebarConfigPath?: string;
313
322
  onEvent?: (name: string, data: Record<string, string | number | boolean | null>) => void;
314
323
  }): Promise<RunReport> {
315
324
  const { config } = input;
@@ -503,7 +512,20 @@ export async function runOnce(input: {
503
512
  }
504
513
  counterpart.close();
505
514
  }
506
- return { ...result, snapshot: snapshotReport, retention: retentionReport };
515
+ // 5. THE SIDEBAR'S STATUS FILE (2026-10-14), last: what the Claude Code
516
+ // sidebar shows, from what every step above left, through a handle of its
517
+ // own (observer) opened after this run's closed. Detached, so no hook waits
518
+ // on it; it never throws.
519
+ let sidebar: SidebarWrite | undefined;
520
+ if (input.sidebarConfigPath !== undefined && input.sidebarConfigPath.length > 0) {
521
+ sidebar = writeSidebarStatus({
522
+ configPath: input.sidebarConfigPath,
523
+ dataDir: config.dataDir,
524
+ ...(config.timeZone === undefined ? {} : { timeZone: config.timeZone }),
525
+ });
526
+ emit("runner.sidebar", { written: sidebar.written, reason: sidebar.reason, bytes: sidebar.bytes, ms: sidebar.ms });
527
+ }
528
+ return { ...result, snapshot: snapshotReport, retention: retentionReport, ...(sidebar === undefined ? {} : { sidebar }) };
507
529
  }
508
530
 
509
531
  /**
@@ -653,12 +675,16 @@ async function main(): Promise<void> {
653
675
  observer: config.observer === true,
654
676
  });
655
677
  log.start();
678
+ const sidebarWanted = sidebarInstalled(process.env, homedir());
679
+ if (!sidebarWanted && removeSidebarStatus(choice.path)) log.event({ name: "runner.sidebar", data: { removed: true } });
656
680
  try {
657
681
  const report = await runOnce({
658
682
  config,
659
683
  signal: controller.signal,
660
684
  ...(pinnedSession() === null ? {} : { session: pinnedSession() as string }),
661
685
  ...(pinnedScope() === null ? {} : { scope: pinnedScope() as string }),
686
+ // Only where the sidebar is installed (the plugin); otherwise an old file goes.
687
+ ...(sidebarWanted ? { sidebarConfigPath: choice.path } : {}),
662
688
  onEvent: (name, data) => log.event({ name, data }),
663
689
  });
664
690
  log.end(report.reason, { swept: report.swept, minted: report.minted, code: report.code });
@@ -51,6 +51,10 @@ export interface HostReading {
51
51
  readonly mcpFile: string;
52
52
  /** The MCP file exists but could not be read or parsed. */
53
53
  readonly mcpUnreadable: boolean;
54
+ /** False: this build does not open the MCP file at all (the plugin
55
+ * directory's, `runtime.ts#readsHostUserConfig`), so there is no MCP clause,
56
+ * and its plugin does not stand down beside the npm install. Absent: read. */
57
+ readonly mcpRead?: boolean;
54
58
  /**
55
59
  * Whether a `claude` executable is on the PATH the caller would run
56
60
  * `counterparts connect` with (the go-public Phase C walk, 2026-09-23).
@@ -281,15 +285,17 @@ export function hostFindings(reading: HostReading): Finding[] {
281
285
  stale: stale.map((s) => `${s.event}→${s.path}`).join(","),
282
286
  settingsRead: reading.settingsRead.join(","),
283
287
  settingsUnreadable: reading.settingsUnreadable.join(","),
284
- mcp: reading.mcp,
285
- mcpFile: reading.mcpFile,
288
+ // Null when this build never opened the MCP file (`mcpRead`).
289
+ mcp: reading.mcpRead === false ? null : reading.mcp,
290
+ mcpFile: reading.mcpRead === false ? null : reading.mcpFile,
286
291
  };
287
292
  // THE PLUGIN (prototype, 2026-10-09). A plugin install wires nothing in
288
293
  // these files — Claude Code loads its hooks and server from the plugin — so
289
294
  // without this the line told a plugin user "no hook of ours is connected,
290
295
  // run counterparts connect", which would wire the host twice. Enabled and
291
- // alone: connected. Enabled beside live npm wiring: the plugin stands down
292
- // (`adapters/plugin.ts`), which works, and is said, with both ways out.
296
+ // alone: connected. Enabled beside live npm wiring: the launcher flavor
297
+ // stands down (`adapters/plugin.ts`), the directory flavor runs beside it
298
+ // (below); either is said, with both ways out.
293
299
  const plugin = reading.plugin !== undefined && reading.plugin !== null && reading.plugin.enabled ? reading.plugin : null;
294
300
  data["plugin"] = plugin === null ? null : plugin.id;
295
301
  const npmAny = reading.events.length > 0 || reading.mcp;
@@ -305,13 +311,26 @@ export function hostFindings(reading: HostReading): Finding[] {
305
311
  ),
306
312
  ];
307
313
  }
314
+ // THE PLUGIN DIRECTORY'S BUILD DOES NOT STAND DOWN (2026-10-14): it never
315
+ // reads `~/.claude.json`, so it cannot tell this wiring is there, and both
316
+ // run, on the same memory, until a marker-based check lands (docs/plugin.md).
317
+ // Known two ways: this doctor IS that build (`mcpRead` false), or the
318
+ // installed plugin is (`standsDown` false, read from its `installPath`, the
319
+ // case of an npm doctor beside it). Unknown (null) keeps the launcher's word.
320
+ const bothRun = plugin !== null && (reading.mcpRead === false || plugin.standsDown === false);
308
321
  const twiceClause =
309
- plugin === null ? "" : `ALSO installed as the Claude Code plugin (${plugin.id}), which stands down while this wiring is live`;
322
+ plugin === null
323
+ ? ""
324
+ : bothRun
325
+ ? `ALSO installed as the Claude Code plugin (${plugin.id}), whose build does not check for the other install, so both are running, on the same memory: every hook and memory tool is wired twice until a later version checks`
326
+ : `ALSO installed as the Claude Code plugin (${plugin.id}), which stands down while this wiring is live`;
310
327
  const twiceFix =
311
328
  plugin === null
312
329
  ? ""
313
- : `Installed twice: to keep only the plugin, run \`counterparts disconnect\` and restart Claude Code; to keep only this install, run \`claude plugin uninstall ${plugin.id}\`. Same memory either way.`;
314
- const mcpClause = reading.mcp
330
+ : `Installed twice${bothRun ? "; remove one" : ""}: to keep only the plugin, run \`counterparts disconnect\` and restart Claude Code; to keep only this install, run \`claude plugin uninstall ${plugin.id}\`. Same memory either way.`;
331
+ const mcpClause = reading.mcpRead === false
332
+ ? ""
333
+ : reading.mcp
315
334
  ? `the MCP server is registered in ${reading.mcpFile}`
316
335
  : reading.mcpUnreadable
317
336
  ? `${reading.mcpFile} could not be read, so the MCP registration could not be checked`
@@ -362,8 +381,8 @@ export function hostFindings(reading: HostReading): Finding[] {
362
381
  // that one case the fix is the line `connect` itself prints: run it wherever
363
382
  // `claude` works. The hooks half, if it is owed, is still `connect`'s.
364
383
  const cannotRegister =
365
- !reading.mcp && !reading.mcpUnreadable && reading.claudeOnPath === false && reading.mcpAddLine !== undefined;
366
- if (!reading.mcp && !reading.mcpUnreadable && !cannotRegister) does.push("registers the memory tools");
384
+ reading.mcpRead !== false && !reading.mcp && !reading.mcpUnreadable && reading.claudeOnPath === false && reading.mcpAddLine !== undefined;
385
+ if (reading.mcpRead !== false && !reading.mcp && !reading.mcpUnreadable && !cannotRegister) does.push("registers the memory tools");
367
386
  const byHand = cannotRegister
368
387
  ? `\`claude\` is not on this PATH, so \`counterparts connect\` cannot register the memory tools: run this where \`claude\` works — ${reading.mcpAddLine ?? ""} — then restart Claude Code.`
369
388
  : "";
@@ -1,5 +1,6 @@
1
1
  /** `start-fresh`, its `--undo`, and `rollback` (moved out of `commands.ts`, 2026-10-11). */
2
2
  import { existsSync, renameSync } from "node:fs";
3
+ import { sidebarStatusPath, writeSidebarStatus } from "../sidebar-status.js";
3
4
  import { homedir } from "node:os";
4
5
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
5
6
  import {
@@ -525,6 +526,13 @@ export async function startFreshCommand(
525
526
 
526
527
  const created = parking ? final.storeDir : installTarget;
527
528
 
529
+ // THE SIDEBAR'S STATUS FILE (2026-10-14) showed the store just set aside, a
530
+ // few of its memories' words included: written again, now, for the new one
531
+ // (which is nothing yet). Only where there is one: the sidebar is installed.
532
+ if (existsSync(sidebarStatusPath(configPath))) {
533
+ writeSidebarStatus({ configPath, dataDir: created, ...(host.config.timeZone === undefined ? {} : { timeZone: host.config.timeZone }) });
534
+ }
535
+
528
536
  // ── the record the new store keeps of its own beginning ───────────────────
529
537
  //
530
538
  // Box 2's meta table, which is this store's general-purpose key space. NOT a
@@ -39,7 +39,7 @@ import { existsSync, readFileSync } from "node:fs";
39
39
  import { dirname } from "node:path";
40
40
 
41
41
  import { CONFIG_ENV } from "../config-path.js";
42
- import { scriptArgs } from "../runtime.js";
42
+ import { readsHostUserConfig, scriptArgs } from "../runtime.js";
43
43
  import { BIN, desktopConfigPath, hostConfigBase, hostMcpFile, isOurDesktopEntry, MCP_SCRIPT, MCP_SERVER_NAME } from "./install.js";
44
44
  import { sightSettings, tilde, unparsedSettingsWhy, writeSettings } from "./wire.js";
45
45
 
@@ -288,15 +288,20 @@ function dataDirOf(entry: unknown): string | null {
288
288
 
289
289
  /**
290
290
  * READ DESKTOP'S CONFIG FOR DOCTOR — two small file reads, never a write:
291
- * Desktop's own file, and Claude Code's `~/.claude.json` for the name clash.
291
+ * Desktop's own file, and Claude Code's `~/.claude.json` for the name clash —
292
+ * not opened by the plugin directory's build (`runtime.ts#readsHostUserConfig`),
293
+ * which then reports no clash.
292
294
  */
293
- export function readDesktop(home: string, env: Record<string, string | undefined> = {}): DesktopConfigReading {
295
+ export function readDesktop(
296
+ home: string,
297
+ env: Record<string, string | undefined> = {},
298
+ readsUserConfig: boolean = readsHostUserConfig(),
299
+ ): DesktopConfigReading {
294
300
  const path = desktopConfigPath(home);
295
301
  const read = readObject(path);
296
302
  const servers = read.value["mcpServers"];
297
303
  const ours = isRecord(servers) ? servers[MCP_SERVER_NAME] : undefined;
298
- const code = readObject(hostMcpFile(hostConfigBase(home, env)));
299
- const codeServers = code.value["mcpServers"];
304
+ const codeServers = readsUserConfig ? readObject(hostMcpFile(hostConfigBase(home, env))).value["mcpServers"] : undefined;
300
305
  const codeOurs = isRecord(codeServers) ? codeServers[MCP_SERVER_NAME] : undefined;
301
306
  return {
302
307
  path,
@@ -470,9 +470,10 @@ export const COMMAND_DETAIL: Record<string, readonly string[]> = {
470
470
  "A settings file it cannot parse is a refusal: it changes nothing and",
471
471
  "prints the block for you to merge by hand.",
472
472
  "",
473
- "The MCP server is registered by running `claude mcp add`; it never writes",
474
- "~/.claude.json itself, because Claude Code owns that file. If `claude` is",
475
- "not on your PATH the hooks still go in and the line is printed for you.",
473
+ "The MCP server is registered by running `claude mcp add`; it never edits",
474
+ "Claude Code's user configuration file itself, because Claude Code owns it.",
475
+ "If `claude` is not on your PATH the hooks still go in and the line is",
476
+ "printed for you.",
476
477
  "",
477
478
  "Claude Code is the one host it knows today, so `counterparts connect` and",
478
479
  "`counterparts connect claude-code` are the same thing and any other name",
@@ -59,7 +59,7 @@ export const DEFAULT_STORE_DIR = "store";
59
59
  import { EMBEDDER_KINDS } from "../config.js";
60
60
  import type { EmbedderKind } from "../config.js";
61
61
  import { CONFIG_ENV, CONFIG_FLAG, defaultConfigPath } from "../config-path.js";
62
- import { entryScript, parseScriptInvocation, runtimeOf, runtimePresent, scriptArgs, shellTokens } from "../runtime.js";
62
+ import { entryScript, parseScriptInvocation, readsHostUserConfig, runtimeOf, runtimePresent, scriptArgs, shellTokens } from "../runtime.js";
63
63
  import type { RuntimeKind } from "../runtime.js";
64
64
  import { pluginInstall, readOurHook } from "../host-wiring.js";
65
65
  import type { PluginInstallRead } from "../host-wiring.js";
@@ -577,6 +577,10 @@ export interface HostRead {
577
577
  readonly mcpName: string;
578
578
  readonly mcpFile: string;
579
579
  readonly mcpUnreadable: boolean;
580
+ /** False when this build does not open the MCP file at all
581
+ * (`runtime.ts#readsHostUserConfig`, the plugin directory's bundle): `mcp`
582
+ * is then "not looked", never "not registered". */
583
+ readonly mcpRead: boolean;
580
584
  /** The runtimes our hook commands and our MCP registration name, one row
581
585
  * per distinct executable (`adapters/runtime.ts`), and whether each is there. */
582
586
  readonly runtimes: readonly HostRuntime[];
@@ -763,6 +767,7 @@ export function readHost(
763
767
  home: string,
764
768
  cwd: string,
765
769
  env: Record<string, string | undefined> = process.env,
770
+ readsUserConfig: boolean = readsHostUserConfig(),
766
771
  ): HostRead {
767
772
  const base = hostConfigBase(home, env);
768
773
  const events = new Set<string>();
@@ -829,7 +834,8 @@ export function readHost(
829
834
  }
830
835
  }
831
836
  const mcpFile = hostMcpFile(base);
832
- const mcpRead = readJsonFile(mcpFile);
837
+ // Not opened by the plugin directory's build (`runtime.ts#readsHostUserConfig`).
838
+ const mcpRead: ReturnType<typeof readJsonFile> = readsUserConfig ? readJsonFile(mcpFile) : { state: "absent", value: {} };
833
839
  const servers = mcpRead.value["mcpServers"];
834
840
  const mcp =
835
841
  servers !== null &&
@@ -869,6 +875,7 @@ export function readHost(
869
875
  mcpName: MCP_SERVER_NAME,
870
876
  mcpFile,
871
877
  mcpUnreadable: mcpRead.state === "unreadable",
878
+ mcpRead: readsUserConfig,
872
879
  runtimes: [...runtimes.entries()].map(([exe, row]) => ({
873
880
  exe,
874
881
  kind: row.kind,
@@ -79,6 +79,7 @@ import type {
79
79
  // destruction path. It is reachable by importing the seam on purpose, never by
80
80
  // holding a `Store` (INTERFACE-GAPS §1, closed 2026-08-25).
81
81
  import { chaseRemoved } from "../../core/store/owner-op-seam.js";
82
+ import { chaseSidebarStatus } from "../sidebar-status.js";
82
83
  // The page has its own door out (`self-page --clear`), and removal is not it.
83
84
  import { isSelfPageRow } from "../../core/self/page.js";
84
85
 
@@ -1061,6 +1062,12 @@ export function ownerRemoval(
1061
1062
  // have already gone.
1062
1063
  chaseWriteAheadLog(store.dir, chased, unchased);
1063
1064
 
1065
+ // THE SIDEBAR'S STATUS FILE (2026-10-14) holds a few memories' words for the
1066
+ // Claude Code sidebar, beside the configuration: deleted when it names this
1067
+ // one, and written again without it (`adapters/sidebar-status.ts`).
1068
+ const sidebar = chaseSidebarStatus(store.dir, request.targetId);
1069
+ if (sidebar !== null) (sidebar.chased ? chased : unchased).push(sidebar.line);
1070
+
1064
1071
  // THE DURABLE RECORD MUST NOT CLAIM MORE THAN THE CONSOLE (third review's
1065
1072
  // open question). The record's stages carry no surface list, so `complete`
1066
1073
  // has always meant "the ceremony finished", not "everything was reached" —
@@ -25,6 +25,8 @@
25
25
  *
26
26
  * - the configuration file, and our own temp and backup siblings of it;
27
27
  * - `scopes.json` and its siblings;
28
+ * - `sidebar.json` (what the Claude Code sidebar shows, `sidebar-status.ts`)
29
+ * and its temp siblings — a file this package left;
28
30
  * - `snapshots/`, when it is the one this layout owns rather than a directory
29
31
  * the owner pointed at;
30
32
  * - the STORE — at `dataDir`, **wherever that is**, which is the other half of
@@ -91,6 +93,7 @@ import { basename, dirname, isAbsolute, join, parse as parsePath, resolve } from
91
93
  import { Store, assertSafeDataDir, dateOf, isWithin, storeExists } from "../../core/store/index.js";
92
94
  import { isJournal } from "../../core/sleep/index.js";
93
95
  import { SCOPES_FILE_NAME, shellWord } from "../scopes.js";
96
+ import { SIDEBAR_FILE_NAME } from "../sidebar-status.js";
94
97
  import { PLUGIN_ROOT_ENV, installRoute } from "../plugin.js";
95
98
  import { pluginInstall } from "../host-wiring.js";
96
99
  import { pluginConsoleWords } from "../runtime.js";
@@ -194,8 +197,10 @@ function removeProgramAfterGone(input: UninstallInput): void {
194
197
  const route = installRoute(input.env);
195
198
  if (route === "npm") {
196
199
  input.io.out(`To remove the program too: ${REMOVE_PACKAGE}`);
197
- // INSTALLED TWICE: the plugin stood down while this install's hooks were
198
- // live, and they are out now, so its next start is a first run too.
200
+ // INSTALLED TWICE: the plugin's launcher flavor stood down while this
201
+ // install's hooks were live, and the directory flavor (which never reads
202
+ // `~/.claude.json`) ran beside them; either way it is still on, and with
203
+ // the configuration gone its next start is a first run.
199
204
  const also = pluginInstall({ home: input.home, env: input.env, cwd: null });
200
205
  if (also === null || !also.enabled) return;
201
206
  input.io.out(`Claude Code also has the plugin: ${pluginUninstallCommand(also, input.home)}`);
@@ -294,6 +299,7 @@ export function ownedKind(name: string, owned: OwnedNames): OwnedKind | null {
294
299
  if (name === owned.scopes) return "scopes";
295
300
  if (owned.snapshots !== null && name === owned.snapshots) return "snapshots";
296
301
  if (owned.store !== null && name === owned.store) return "store";
302
+ if (name === SIDEBAR_FILE_NAME || /^sidebar\.json\.\d+\.tmp$/.test(name)) return "sidecar";
297
303
  const bases = [owned.config, owned.scopes, owned.snapshots, owned.store];
298
304
  for (const base of bases) {
299
305
  if (base === null || !name.startsWith(`${base}.`)) continue;
@@ -85,7 +85,7 @@ import { DATA_DIR_ENV, isWithin } from "../../core/store/index.js";
85
85
  import { CONFIG_ENV, CONFIG_FLAG } from "../config-path.js";
86
86
  import { isOurHookCommand } from "../host-wiring.js";
87
87
  import { claudeCodeEnvMarker } from "../hosts.js";
88
- import { parseScriptInvocation, scriptArgs, shellTokens } from "../runtime.js";
88
+ import { parseScriptInvocation, readsHostUserConfig, scriptArgs, shellTokens } from "../runtime.js";
89
89
  import { installedBuild, readServerRecords, sameBuild, serverBelieved } from "../sessions.js";
90
90
  import type { BuildStamp, ServerRecordRead } from "../sessions.js";
91
91
  import type { Io } from "./commands.js";
@@ -924,6 +924,10 @@ export interface McpReading {
924
924
  /** True when the file exists and could not be read — a different fact from
925
925
  * "no registration", and the one that must not read as "not installed". */
926
926
  readonly unreadable: boolean;
927
+ /** True when this build does not open the file at all (the plugin
928
+ * directory's, `runtime.ts#readsHostUserConfig`): `present` is then "not
929
+ * looked", and only `claude` itself can say what is registered. */
930
+ readonly notRead?: boolean;
927
931
  }
928
932
 
929
933
  /**
@@ -937,8 +941,10 @@ export function readMcp(
937
941
  custom: string | undefined,
938
942
  exe: string,
939
943
  serve: string = MCP_SCRIPT,
944
+ readsUserConfig: boolean = readsHostUserConfig(),
940
945
  ): McpReading {
941
946
  const file = hostMcpFile(hostConfigBase(home, env));
947
+ if (!readsUserConfig) return { file, present: false, matches: false, unreadable: false, notRead: true };
942
948
  if (!existsSync(file)) return { file, present: false, matches: false, unreadable: false };
943
949
  let raw: unknown;
944
950
  try {
@@ -1133,6 +1139,9 @@ export interface WireInput {
1133
1139
  readonly lister: ProcessLister;
1134
1140
  /** `install` prints its own step heading; a bare `wire` prints one here. */
1135
1141
  readonly heading?: boolean;
1142
+ /** Whether `unwire` may read `~/.claude.json`: `runtime.ts#readsHostUserConfig`
1143
+ * by default; a test's seam. */
1144
+ readonly readsUserConfig?: boolean;
1136
1145
  }
1137
1146
 
1138
1147
  export interface WireResult {
@@ -1642,12 +1651,14 @@ export async function unwire(input: WireInput): Promise<WireResult> {
1642
1651
  }
1643
1652
 
1644
1653
  const merged = mergeHooks(sight.value, "", "unwire");
1645
- const mcp = readMcp(home, env, input.store, input.custom, input.exe);
1654
+ const mcp = readMcp(home, env, input.store, input.custom, input.exe, MCP_SCRIPT, input.readsUserConfig);
1646
1655
 
1647
1656
  // `mcp.unreadable` is NOT "nothing there": that file is the host's own and a
1648
1657
  // read that failed is no evidence either way, which is the same stance the
1649
1658
  // removal below takes.
1650
- if (!merged.changed && !mcp.present && !mcp.unreadable) {
1659
+ // A file this build never opens (`notRead`) is no evidence either: the
1660
+ // removal below asks `claude`.
1661
+ if (!merged.changed && !mcp.present && !mcp.unreadable && mcp.notRead !== true) {
1651
1662
  u.ok("nothing to disconnect: no Counterparts hooks and no memory server were found.");
1652
1663
  // SAID EVEN HERE: a wrapper is exactly the case where "nothing of ours"
1653
1664
  // needs a sentence, because the person can see a hook that mentions us and
@@ -1760,6 +1771,8 @@ export async function unwire(input: WireInput): Promise<WireResult> {
1760
1771
  // `uninstall`'s two irreversible arms refuse on it: a server pointed at a
1761
1772
  // store that is no longer there fails at every session start with nothing on
1762
1773
  // screen, which is the same argument this file already makes for the hooks.
1774
+ // A build that does not read that file (the plugin directory's) with no
1775
+ // `claude` to ask has neither, and is false too.
1763
1776
  let mcpConfirmed = false;
1764
1777
  const res = input.spawner(mcpRemoveArgs());
1765
1778
  const notThere = /not found|no .*server|does not exist|not configured/i.test(`${res.out}\n${res.err}`);
@@ -1771,10 +1784,23 @@ export async function unwire(input: WireInput): Promise<WireResult> {
1771
1784
  // let the irreversible arm run. M2's own words are "a read of the
1772
1785
  // registration shows it ABSENT", and a read that failed shows nothing at all.
1773
1786
  const stillThere = (): boolean => {
1774
- const fresh = readMcp(home, env, input.store, input.custom, input.exe);
1775
- return fresh.present || fresh.unreadable;
1787
+ const fresh = readMcp(home, env, input.store, input.custom, input.exe, MCP_SCRIPT, input.readsUserConfig);
1788
+ // Not looked (`notRead`) is not "gone" either.
1789
+ return fresh.present || fresh.unreadable || fresh.notRead === true;
1776
1790
  };
1777
- if (res.missing) {
1791
+ if (res.missing && mcp.notRead === true) {
1792
+ // NOT LOOKED, AND NOBODY TO ASK (the plugin directory's build): that
1793
+ // build never registers a server there itself, but an npm install's may
1794
+ // be there, pointing at this same store, and nothing was looked at. Not
1795
+ // confirmed, so uninstall stops before deleting or moving the store (M2):
1796
+ // unknown is not absent (review of #481).
1797
+ mcpConfirmed = false;
1798
+ u.warn(
1799
+ "`claude` is not on this PATH and this version does not read Claude Code's own configuration, so whether a memory server is still registered (an npm install's, if there is one) could not be checked.",
1800
+ );
1801
+ u.hint(`Remove one if it is there: claude mcp remove ${MCP_SERVER_NAME} -s user — and run this again where \`claude\` is on PATH to have it checked.`);
1802
+ mcpWord = "printed";
1803
+ } else if (res.missing) {
1778
1804
  mcpConfirmed = !stillThere();
1779
1805
  if (mcpConfirmed) {
1780
1806
  u.hint(`no MCP registration named "${MCP_SERVER_NAME}" was there to remove.`);
@@ -1788,10 +1814,11 @@ export async function unwire(input: WireInput): Promise<WireResult> {
1788
1814
  u.ok("memory server removed");
1789
1815
  mcpWord = "removed";
1790
1816
  mcpConfirmed = true;
1791
- } else if (notThere || !mcp.present) {
1817
+ } else if (notThere || (!mcp.present && mcp.notRead !== true)) {
1792
1818
  // `claude` says there was nothing there. Believe it, and check the file
1793
- // too — this is the one place where two sources agreeing is cheap.
1794
- mcpConfirmed = !stillThere();
1819
+ // too — this is the one place where two sources agreeing is cheap. A
1820
+ // build that does not read the file has `claude`'s word alone, and takes it.
1821
+ mcpConfirmed = mcp.notRead === true || !stillThere();
1795
1822
  u.hint(`no MCP registration named "${MCP_SERVER_NAME}" was there to remove.`);
1796
1823
  mcpWord = "absent";
1797
1824
  } else {
@@ -10,7 +10,7 @@ step, no dependencies. `server.ts` serves them as files (see "Serving" below).
10
10
 
11
11
  | file | what it is |
12
12
  |---|---|
13
- | `server.ts` | `node:http` on 127.0.0.1, the Host allowlist, `router()` (GET: `/`, `/brain` (now a redirect to `/#home`), the favicon, `/api/*`, the static files), and the POST hand-off to `actions.ts`. A store waiting for its one-time upgrade (v6 met by v7, `../upgrade.ts`) gets one calm page instead, and is tried again on every request |
13
+ | `server.ts` | `node:http` on 127.0.0.1, the Host allowlist, `router()` (GET: `/`, `/brain` (now a redirect to `/#home`), the favicon (`favicon.svg`, a file beside it since 2026-10-14), `/api/*`, the static files), and the POST hand-off to `actions.ts`. A store waiting for its one-time upgrade (v6 met by v7, `../upgrade.ts`) gets one calm page instead, and is tried again on every request |
14
14
  | `actions.ts` | managing: `POST /api/action/<name>` — the same-origin + per-launch-token guard, argument validation, and the console's own `run()` (loaded lazily; never handed the observer source). `ACTIONS` lists them: `ask`, `note`, `remove`, `backup`, `export`, `scope`, `rebrief`, `verify`, and `doctor` (a read: the health tab's checklist, `doctor --json`) |
15
15
  | `ask-voice.ts` | `toMyVoice(question, ownerName)`: Ask is the owner talking to me, so `ask` turns his question into my voice before it searches ("do you remember what I said" → "do I remember what Mike said"; his I → "you" when the store knows no name). Pure; the rules are in its header and `test/dashboard-ask-voice.test.ts`. The server reads the name (`sleep#ownerNames`) and hands `actions.ts` the string |
16
16
  | `static.ts` | `resolveStatic()`: which URL paths are static files and where they live (pure; no fs) |
@@ -74,10 +74,12 @@ export function isActionName(name: string): name is ActionName {
74
74
  return (ACTIONS as readonly string[]).includes(name);
75
75
  }
76
76
 
77
- /** The header every action must echo the page's token in. */
78
- export const TOKEN_HEADER = "x-counterparts-token";
79
- /** The `<meta name>` the served page carries the token in. */
80
- export const TOKEN_META = "counterparts-action-token";
77
+ /** The NAME of the header every action must echo the page's per-launch token
78
+ * in (a guard against another page posting here, not a credential; renamed
79
+ * from TOKEN_HEADER 2026-10-14, the directory's validator read it as one). */
80
+ export const ACTION_HEADER_NAME = "x-counterparts-token";
81
+ /** The `<meta name>` the served page carries that token in (was TOKEN_META). */
82
+ export const ACTION_META_NAME = "counterparts-action-token";
81
83
 
82
84
  /** A request body larger than this is refused before it is parsed. */
83
85
  export const MAX_BODY_BYTES = 64 * 1024;
@@ -8,6 +8,9 @@
8
8
  <!-- The server fills this with a per-launch token; every management action
9
9
  echoes it (web/actions.ts). Empty means this page cannot act. -->
10
10
  <meta name="counterparts-action-token" content="">
11
+ <!-- The server turns this off when the brain picture's three.js is not
12
+ installed (server.ts#BRAIN_LIBRARY); the home tab then draws without it. -->
13
+ <meta name="counterparts-brain" content="on">
11
14
  <!--
12
15
  The shell. Styles, scripts and the two font faces are served beside this file
13
16
  (see README.md): no CDN, no network of any kind beyond this origin.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="13" fill="#0a0e14"/><path d="M14 46 L32 32 L50 18" stroke="#00e5ff" stroke-opacity=".35" stroke-width="2.5" fill="none" stroke-linecap="round"/><circle cx="14" cy="46" r="4.5" fill="#00bfa5"/><circle cx="32" cy="32" r="7" fill="#00e5ff"/><circle cx="50" cy="18" r="4.5" fill="#b388ff"/></svg>
@@ -18,6 +18,9 @@
18
18
  .home-row{display:grid;gap:24px;align-items:start}
19
19
  .home-row>*{min-width:0}
20
20
  .home-row-a{grid-template-columns:minmax(0,1fr) minmax(0,1.15fr);align-items:center;margin:0 0 18px}
21
+ /* No brain picture in this build (sections/brain.js#pictureServed): "Today" takes the row. */
22
+ .home-row-a.is-solo{grid-template-columns:minmax(0,1fr)}
23
+ .home-brain[hidden]{display:none}
21
24
  .home-row-b{grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:stretch}
22
25
  .home-card{display:flex;flex-direction:column;min-width:0}
23
26
  .home-card .card{flex:1;margin-bottom:8px}