counterparts 0.3.20 → 0.3.21

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +4 -1
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +2 -2
  5. package/src/adapters/claude-code/bin/hook.ts +7 -1
  6. package/src/adapters/claude-code/bin/runner.ts +31 -14
  7. package/src/adapters/claude-code/doctor.ts +24 -11
  8. package/src/adapters/cli/commands-delete.ts +273 -0
  9. package/src/adapters/cli/commands-note.ts +1 -1
  10. package/src/adapters/cli/commands.ts +22 -3
  11. package/src/adapters/cli/help.ts +2 -0
  12. package/src/adapters/cli/removal.ts +1 -1
  13. package/src/adapters/config.ts +74 -0
  14. package/src/adapters/dashboard/web/actions.ts +21 -2
  15. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +73 -3
  16. package/src/adapters/fired.ts +1 -1
  17. package/src/adapters/log/index.ts +21 -0
  18. package/src/adapters/mcp/server-words.ts +1 -1
  19. package/src/adapters/plugin.ts +31 -0
  20. package/src/adapters/sessions.ts +5 -2
  21. package/src/adapters/snapshots.ts +90 -1
  22. package/src/core/onboarding.ts +9 -6
  23. package/src/core/recall/CONTRACT.md +3 -1
  24. package/src/core/recall/INTERFACE-GAPS.md +1 -1
  25. package/src/core/recall/NOTES.md +14 -0
  26. package/src/core/recall/session.ts +40 -1
  27. package/src/core/remember/CONTRACT.md +14 -8
  28. package/src/core/remember/owes.ts +68 -28
  29. package/src/core/remember/owner-strike-seam.ts +6 -3
  30. package/src/core/remember/spans.ts +3 -2
  31. package/src/core/remember/tunables.ts +18 -5
  32. package/src/core/remember/write-up-seam.ts +2 -1
  33. package/src/core/store/index.ts +39 -0
  34. package/src/core/store/paths.ts +9 -2
@@ -127,6 +127,7 @@ import { dashboardCommand } from "./commands-dashboard.js";
127
127
  import { startFreshCommand, rollbackCommand } from "./commands-start-fresh.js";
128
128
  import { noteCommand, recallCommand, backupCommand, exportCommand } from "./commands-note.js";
129
129
  import { removeCommand } from "./commands-remove.js";
130
+ import { deleteCommand } from "./commands-delete.js";
130
131
  import {
131
132
  verifyCommand,
132
133
  migrateCacheCommand,
@@ -186,6 +187,9 @@ export const COMMANDS = [
186
187
  "export",
187
188
  "backup",
188
189
  "remove",
190
+ // Delete ONE kind of data — conversation text, backups or the activity log —
191
+ // and nothing else (2026-10-13). `commands-delete.ts`.
192
+ "delete",
189
193
  "verify",
190
194
  "migrate-cache",
191
195
  "backfill-claims",
@@ -284,6 +288,7 @@ export const OWNER_OPS: readonly Command[] = [
284
288
  // has no owner ruling behind it and this change is not the place to make one.
285
289
  "backup",
286
290
  "remove",
291
+ "delete",
287
292
  "verify",
288
293
  // Box 3 is rebuildable, and rewriting it is still a WRITE: an instrument does
289
294
  // not migrate the store it is reading.
@@ -527,6 +532,9 @@ export const COMMAND_FLAGS: Record<Command, readonly string[]> = {
527
532
  // across every project on the machine is how one removal reaches into work
528
533
  // nobody named. The dry run lists what it WOULD match; this flag performs it.
529
534
  remove: ["confirm", "reason", "strike-by-content-across-scopes", "echo-scan"],
535
+ // `--yes` is the door for anything that cannot be asked — a script, the
536
+ // dashboard (which asks in the browser first).
537
+ delete: ["yes"],
530
538
  verify: ["rebuild", "drop-vectors", "prune-index", "keep-vectors", "retry-skipped"],
531
539
  "migrate-cache": ["apply", "batch", "yes"],
532
540
  "backfill-claims": ["apply"],
@@ -613,9 +621,11 @@ export const COMMAND_BLURB: Record<Command, string> = {
613
621
  ask: "Ask memory a question. Read-only.",
614
622
  recall: "Ask memory a question — the same command as `ask`, under its older name. Read-only.",
615
623
  export: "A portable copy of the store, encrypted unless you say otherwise.",
616
- backup: "Snapshot: prose plus the canonical DB via VACUUM INTO. The cache is excluded.",
624
+ backup: "Snapshot: the canonical DB via VACUUM INTO. The cache is excluded, and so is conversation text: backups never hold it.",
617
625
  remove:
618
626
  "The loud removal. With nothing after it, at a terminal, it asks for a memory id or for words to search for, numbers what it finds, lets you pick one or several (or name several ids outright), shows the plan for each, and asks once before it deletes them. --confirm is the scripted door: that exact id, confirmed by typing it back. Anywhere a person cannot be asked — a pipe, a redirect, a CI job — and without --confirm, it prints the plan and changes nothing.",
627
+ delete:
628
+ "Delete one kind of data, and nothing else: conversation-text (every word of conversation still held — sessions still owed a write-up lose theirs, and it says how many first), backups (every daily copy and every copy taken before an upgrade — rollback then has nothing to go back to) or activity-log (what the processes did, never what was said). Memories are not touched; start-fresh is their door. It prints what it would delete, then asks once at a terminal; anywhere else it changes nothing without --yes. Refuses under observer.",
619
629
  verify:
620
630
  "Census of the cache against canonical state. Read-only unless --rebuild, --prune-index or --retry-skipped. --rebuild, --prune-index, --retry-skipped and --drop-vectors require --dir.",
621
631
  "migrate-cache":
@@ -650,7 +660,7 @@ export const COMMAND_BLURB: Record<Command, string> = {
650
660
  about:
651
661
  "What a memory is about — me (who I am), us (the two of us), owner (you, as a person), work (the craft) or world (anything else). With an id alone, its mark and who set it; with an id and a mark, it changes the mark as you, keeps --why with it, and records it the way a nightly reflection's re-mark is recorded. Unmarked, a fact written in a project (or a skill) counts as that project's work and is shown only there; me, us and owner are shown everywhere and can become part of who I am. An archived memory can be marked too (the mark counts if it comes back); an earlier version's id marks the current one. Reading works under observer; the change refuses there.",
652
662
  coverage:
653
- "What is written up, and what is not yet, for one date (default today): each session that captured something that day, how much of it is written up, and what is not yet written up — how many pieces, over how long, since when — and whether that is owed (the nightly run catches it up, or counterparts catch-up does now), lapsed (let go unwritten after fourteen days of use — lost to memory; nothing is deleted), under the floor, or still at work. Read-only.",
663
+ "What is written up, and what is not yet, for one date (default today): each session that captured something that day, how much of it is written up, and what is not yet written up — how many pieces, over how long, since when — and whether that is owed (the nightly run catches it up, or counterparts catch-up does now), lapsed (let go unwritten after fourteen days of use — lost to memory; its text is deleted with the rest, never more than 14 days after the session), under the floor, or still at work. Read-only.",
654
664
  "catch-up":
655
665
  "Write up, now, every session that ended before it was written up — what the nightly run does each morning, on demand. Oldest first, in batches, each a windowless claude -p of its own allowed one tool (session_end); it prints each batch, then what it caught up and what is left. Sessions may be open meanwhile: one still at work is left for later, one being written up elsewhere is passed over. It uses your Claude subscription like any session. At most 400 parts and an hour a run; what is left stays owed. A part whose every word the session's own chapters or notes already wrote up is passed over, and a part answered with nothing kept and no reason why stays owed. --reowe <run> owes again the parts a run (cup_… or nrn_…) closed with nothing kept, when their words were not yet written up: it prints the plan, then asks for the run's id typed back (--yes skips that, --dry-run stops at the plan); it reads the run from the log, which keeps a week, and refuses by name what it cannot do. Refuses under observer.",
656
666
  dashboard:
@@ -668,6 +678,7 @@ const COMMAND_ARGS: Partial<Record<Command, string>> = {
668
678
  // Three shapes, and the bare one is the door a person uses: an id, the words
669
679
  // to find one by, or nothing at all and it asks.
670
680
  remove: " [<id>… | <words>]",
681
+ delete: " conversation-text|backups|activity-log",
671
682
  scope: " <path|.>",
672
683
  // The host is OPTIONAL and there is one of them: `counterparts connect` and
673
684
  // `counterparts connect claude-code` are the same command, and any other name
@@ -961,6 +972,10 @@ const CATCH_UP_FLAG_HELP: Record<string, string> = {
961
972
  yes: "with --reowe: skip typing the run's id back, for a script or a pipe",
962
973
  };
963
974
 
975
+ const DELETE_FLAG_HELP: Record<string, string> = {
976
+ yes: "delete without asking — for a script or a pipe, which otherwise get the counts and nothing changed",
977
+ };
978
+
964
979
  const DASHBOARD_FLAG_HELP: Record<string, string> = {
965
980
  dir: "a store to look at instead of the one your configuration names",
966
981
  };
@@ -1008,7 +1023,9 @@ export function commandHelp(command: Command): string {
1008
1023
  ? SETTLE_FLAG_HELP
1009
1024
  : command === "about"
1010
1025
  ? ABOUT_FLAG_HELP
1011
- : {};
1026
+ : command === "delete"
1027
+ ? DELETE_FLAG_HELP
1028
+ : {};
1012
1029
  const flagLine = (name: string): string => {
1013
1030
  const shown = `--${name}${VALUED_FLAGS.includes(name) ? " <value>" : ""}`;
1014
1031
  return ` ${shown.padEnd(20)} ${override[name] ?? FLAG_HELP[name] ?? "(undocumented)"}`;
@@ -1628,6 +1645,8 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
1628
1645
  // gate key` is three of them. `env` rides along because the door test is
1629
1646
  // `isInteractive`, which reads `CI` out of it.
1630
1647
  return await removeCommand(dir, io, env, parsed.positional, parsed.flags, now);
1648
+ case "delete":
1649
+ return await deleteCommand(dir, io, env, parsed.positional, parsed.flags);
1631
1650
  case "backfill-claims":
1632
1651
  return backfillClaimsCommand(dir, io, parsed.flags);
1633
1652
  case "repair-dates":
@@ -122,6 +122,7 @@ export const SHORT: Record<string, string | readonly string[]> = {
122
122
  export: "A copy of your memory you can take anywhere, encrypted by default",
123
123
  backup: "Save a snapshot of your memory to a folder",
124
124
  remove: "Delete one memory for good",
125
+ delete: "Delete one kind of data: conversation text, backups or the activity log",
125
126
  // ── advanced: the maintenance shelf, in a person's words rather than the
126
127
  // build's. Finding #18 is exactly this list read by somebody who had just
127
128
  // installed the package.
@@ -190,6 +191,7 @@ export const ADVANCED: readonly string[] = [
190
191
  "coverage",
191
192
  "catch-up",
192
193
  "init",
194
+ "delete",
193
195
  "start-fresh",
194
196
  "rollback",
195
197
  "verify",
@@ -535,7 +535,7 @@ export function spanResidue(
535
535
  const echoNote =
536
536
  echoes === 0
537
537
  ? ""
538
- : ` ${echoes} line${echoes === 1 ? "" : "s"} of conversation under ${named} quote${echoes === 1 ? "s" : ""} these words — transcript, not this memory's own capture, and left alone here; retention deletes a session's captured text 7 days after it ends, unless it is still waiting to be written up, so ${echoes === 1 ? "it goes" : "they go"} then (the daily snapshots keep a copy up to 14 days longer).`;
538
+ : ` ${echoes} line${echoes === 1 ? "" : "s"} of conversation under ${named} quote${echoes === 1 ? "s" : ""} these words — transcript, not this memory's own capture, and left alone here; retention deletes a session's captured text 3 days after it is written up and ended, and never keeps it more than 14 days, so ${echoes === 1 ? "it goes" : "they go"} then (backups made since 2026-10-13 hold none of it).`;
539
539
 
540
540
  if (first !== null) {
541
541
  const where = count === 1 ? first : `${first} (and ${count - 1} more line${count === 2 ? "" : "s"})`;
@@ -28,6 +28,7 @@ import { isAbsolute, join } from "node:path";
28
28
 
29
29
  import { isZone } from "../core/time.js";
30
30
 
31
+ import { TUNABLES as REMEMBER_TUNABLES } from "../core/remember/tunables.js";
31
32
  import { PAGE_HOST_BUDGET_BYTES, PAGE_WRITER_MODES } from "../core/self/index.js";
32
33
  import type { PageWriterMode } from "../core/self/index.js";
33
34
  import { DEFAULT_KEEP as SNAPSHOT_DEFAULT_KEEP } from "./snapshots.js";
@@ -333,6 +334,20 @@ export interface AdapterConfig {
333
334
  * Whether the run is headless at all is the dreaming SETTING (`auto`), which
334
335
  * lives in the store, not here.
335
336
  */
337
+ /**
338
+ * HOW LONG CONVERSATION TEXT IS KEPT (Mike, 2026-10-13). Both optional:
339
+ * `afterWriteUpDays` — days after a session was written up and ended
340
+ * (default 3); `maxDays` — the ceiling, days after its last activity, owed
341
+ * or not (default 14). Whichever comes first. Read leniently, like
342
+ * `snapshots`: a bad field costs that field, falls back to its default, and
343
+ * is named in `ignored`. `retentionClocks` turns it into what
344
+ * `remember/owes.ts` reads.
345
+ */
346
+ readonly retention?: {
347
+ readonly afterWriteUpDays?: number;
348
+ readonly maxDays?: number;
349
+ readonly ignored?: readonly string[];
350
+ };
336
351
  readonly dreaming?: {
337
352
  readonly model?: string;
338
353
  readonly timeoutMs?: number;
@@ -407,6 +422,7 @@ export function loadConfig(raw: unknown): LoadedConfig {
407
422
  snapshots?: { dir?: string; keep?: number; mirror?: string; ignored?: string[] };
408
423
  pageWriter?: { mode: PageWriterMode; ignored?: string[] };
409
424
  dreaming?: { model?: string; timeoutMs?: number; maxTurns?: number; ignored?: string[] };
425
+ retention?: { afterWriteUpDays?: number; maxDays?: number; ignored?: string[] };
410
426
  retired?: string[];
411
427
  owner?: boolean;
412
428
  timeZone?: string;
@@ -577,6 +593,11 @@ export function loadConfig(raw: unknown): LoadedConfig {
577
593
  if (snapshots !== undefined) {
578
594
  out.snapshots = readSnapshots(snapshots);
579
595
  }
596
+ // THE FOURTH LENIENT BLOCK (2026-10-13): how long conversation text is kept.
597
+ const retention = rec["retention"];
598
+ if (retention !== undefined) {
599
+ out.retention = readRetention(retention);
600
+ }
580
601
  const identity = rec["identity"];
581
602
  if (identity !== undefined) {
582
603
  const i = identity as Record<string, unknown>;
@@ -695,6 +716,59 @@ function readDreaming(raw: unknown): { model?: string; timeoutMs?: number; maxTu
695
716
  return done();
696
717
  }
697
718
 
719
+ /**
720
+ * The `retention` block, read leniently. Whole days, at least one: a value
721
+ * that is not one is named and its default used, so a typo never means
722
+ * "delete today" and never means "keep forever".
723
+ */
724
+ function readRetention(raw: unknown): { afterWriteUpDays?: number; maxDays?: number; ignored?: string[] } {
725
+ const raws: string[] = [];
726
+ const out: { afterWriteUpDays?: number; maxDays?: number } = {};
727
+ const done = (): typeof out & { ignored?: string[] } => (raws.length === 0 ? out : { ...out, ignored: tidy(raws) });
728
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
729
+ raws.push(`"retention" was not an object; the defaults are used`);
730
+ return done();
731
+ }
732
+ const r = raw as Record<string, unknown>;
733
+ const defaults = retentionDefaults();
734
+ for (const key of ["afterWriteUpDays", "maxDays"] as const) {
735
+ const value = r[key];
736
+ if (value === undefined) continue;
737
+ if (typeof value === "number" && Number.isInteger(value) && value > 0) out[key] = value;
738
+ else raws.push(`"retention.${key}" was ${JSON.stringify(value)}; using ${String(defaults[key])}`);
739
+ }
740
+ for (const key of Object.keys(r)) {
741
+ if (key !== "afterWriteUpDays" && key !== "maxDays") raws.push(`"retention.${key}" is not a setting this reads; it was ignored`);
742
+ }
743
+ return done();
744
+ }
745
+
746
+ const DAY_MS = 86_400_000;
747
+
748
+ /** The two retention defaults, in days — `remember/tunables.ts`'s, never retyped. */
749
+ export function retentionDefaults(): { afterWriteUpDays: number; maxDays: number } {
750
+ return {
751
+ afterWriteUpDays: Math.round(REMEMBER_TUNABLES.RETENTION_MS / DAY_MS),
752
+ maxDays: Math.round(REMEMBER_TUNABLES.RETENTION_MAX_MS / DAY_MS),
753
+ };
754
+ }
755
+
756
+ /**
757
+ * THE TWO CLOCKS THIS CONFIGURATION SETS, in days and in the milliseconds
758
+ * `remember/owes.ts#RetentionSources` reads. Absent fields are the defaults.
759
+ */
760
+ export function retentionClocks(config: AdapterConfig): {
761
+ afterWriteUpDays: number;
762
+ maxDays: number;
763
+ retentionMs: number;
764
+ maxMs: number;
765
+ } {
766
+ const d = retentionDefaults();
767
+ const afterWriteUpDays = config.retention?.afterWriteUpDays ?? d.afterWriteUpDays;
768
+ const maxDays = config.retention?.maxDays ?? d.maxDays;
769
+ return { afterWriteUpDays, maxDays, retentionMs: afterWriteUpDays * DAY_MS, maxMs: maxDays * DAY_MS };
770
+ }
771
+
698
772
  /**
699
773
  * The `snapshots` block, read leniently — the FIRST place in this file that
700
774
  * never stands the configuration down.
@@ -39,7 +39,8 @@
39
39
  *
40
40
  * ## Which commands
41
41
  *
42
- * `note`, `remove`, `about` (what a memory is about, 2026-10-11), `backup`,
42
+ * `note`, `remove`, `delete` (one kind of data, 2026-10-13), `about` (what a
43
+ * memory is about, 2026-10-11), `backup`,
43
44
  * `export`, `scope`, `rebrief`, `verify`, and the
44
45
  * read-only `ask` and `doctor` (the health tab's checklist: `doctor --json`,
45
46
  * the console's own reading, so the page and the terminal cannot disagree
@@ -62,9 +63,13 @@ import { toMyVoice } from "./ask-voice.js";
62
63
  export const NO_CONFIG_HOME = "/nonexistent/counterparts-dashboard-bare-store";
63
64
 
64
65
  /** The actions, in the order a reader meets them. */
65
- export const ACTIONS = ["ask", "note", "remove", "about", "backup", "export", "scope", "rebrief", "verify", "doctor"] as const;
66
+ export const ACTIONS = ["ask", "note", "remove", "delete", "about", "backup", "export", "scope", "rebrief", "verify", "doctor"] as const;
66
67
  export type ActionName = (typeof ACTIONS)[number];
67
68
 
69
+ /** The kinds `delete` takes — `cli/commands-delete.ts#DELETE_KINDS`, spelled
70
+ * again so this file imports nothing of the console up front. */
71
+ const DELETE_KINDS: readonly string[] = ["conversation-text", "backups", "activity-log"];
72
+
68
73
  export function isActionName(name: string): name is ActionName {
69
74
  return (ACTIONS as readonly string[]).includes(name);
70
75
  }
@@ -84,6 +89,8 @@ export const TIMEOUT_MS: Record<ActionName, number> = {
84
89
  ask: 120_000,
85
90
  note: 120_000,
86
91
  remove: 120_000,
92
+ // Deleting backups takes every copy apart file by file.
93
+ delete: 10 * 60_000,
87
94
  about: 30_000,
88
95
  scope: 30_000,
89
96
  rebrief: 120_000,
@@ -430,6 +437,18 @@ function argvFor(name: ActionName, body: Body, ctx: ActionContext): Built {
430
437
  }
431
438
  return { argv: [...argv, "--confirm", "--", id], answer: typed };
432
439
  }
440
+ case "delete": {
441
+ // ONE KIND OF DATA (2026-10-13): the console's `delete <kind>`. WITHOUT
442
+ // `confirm` it is the console's own dry run — the counts, and "Nothing
443
+ // has changed"; WITH it, `--yes`, after the page asked plainly. The
444
+ // kinds are spelled here, not imported: this file loads nothing of the
445
+ // console until an action runs, and the console refuses any other word.
446
+ const kind = body["kind"];
447
+ if (typeof kind !== "string" || !DELETE_KINDS.includes(kind)) {
448
+ throw new Invalid(`kind is one of ${DELETE_KINDS.join(", ")}`);
449
+ }
450
+ return { argv: ["delete", ...dir, ...(flag(body, "confirm") ? ["--yes"] : []), "--", kind] };
451
+ }
433
452
  case "about": {
434
453
  // WHAT A MEMORY IS ABOUT (2026-10-11): the console's `about`, as the
435
454
  // owner — one store function behind both doors (`Counterpart.markAbout`).
@@ -1,5 +1,6 @@
1
1
  /* The page's own buttons: add a memory (a note the owner writes, the same as
2
- `counterparts note`), back up, export. Each runs the
2
+ `counterparts note`), back up, export, and delete one kind of data (the
3
+ same as `counterparts delete <kind>`, 2026-10-13). Each runs the
3
4
  console's own command through `shared/actions.js` and says what it said.
4
5
  (Remove lives on the memory card, where the memory is.) */
5
6
  import { act, resultHtml } from "../../../shared/actions.js";
@@ -12,6 +13,7 @@ export const markup = `
12
13
  <button class="mbtn primary" id="note-open" type="button" aria-expanded="false">+ Add a memory</button>
13
14
  <button class="mbtn" id="backup-open" type="button">Back up…</button>
14
15
  <button class="mbtn" id="export-open" type="button">Export…</button>
16
+ <button class="mbtn" id="delete-open" type="button">Delete data…</button>
15
17
  </div>`;
16
18
 
17
19
  export const notePanel = `
@@ -57,6 +59,74 @@ export function mount() {
57
59
  });
58
60
  $("backup-open").addEventListener("click", () => folderDialog("backup"));
59
61
  $("export-open").addEventListener("click", () => folderDialog("export"));
62
+ $("delete-open").addEventListener("click", deleteDialog);
63
+ }
64
+
65
+ // ── delete one kind of data ─────────────────────────────────────────────────
66
+
67
+ const KINDS = [
68
+ { kind: "conversation-text", label: "Conversation text",
69
+ what: "Every word of conversation still kept, waiting to be written up or to age out. Memories already made from it stay." },
70
+ { kind: "backups", label: "Backups",
71
+ what: "Every daily copy, and the copies taken before an upgrade. Rollback then has nothing to go back to." },
72
+ { kind: "activity-log", label: "Activity log",
73
+ what: "What the background processes did, one line each. Never what was said." },
74
+ ];
75
+
76
+ /* Each kind: "Delete…" asks the console what it would delete (its dry run,
77
+ counts only), shows that, and offers one plain "Yes, delete", which runs the
78
+ console's own `delete <kind> --yes`. */
79
+ function deleteDialog() {
80
+ const back = document.createElement("div");
81
+ back.className = "confirm-back";
82
+ back.innerHTML =
83
+ '<div class="confirm mdialog" role="dialog" aria-modal="true" aria-labelledby="dd-title">' +
84
+ '<h3 id="dd-title">Delete one kind of data</h3>' +
85
+ '<p class="fd-lede">Each deletes that kind and nothing else. Memories are not touched.</p>' +
86
+ KINDS.map((k) =>
87
+ '<div class="fd-set" data-kind="' + esc(k.kind) + '">' +
88
+ "<b>" + esc(k.label) + "</b> — " + esc(k.what) +
89
+ ' <button class="mbtn dd-ask" type="button">Delete…</button>' +
90
+ '<div class="dd-out"></div>' +
91
+ "</div>").join("") +
92
+ '<div class="confirm-buttons"><button class="fd-cancel" type="button">Close</button></div>' +
93
+ "</div>";
94
+ const close = () => {
95
+ removeEventListener("keydown", onKey, true);
96
+ if (back.parentNode) back.parentNode.removeChild(back);
97
+ };
98
+ const onKey = (e) => { if (e.key === "Escape") { e.stopPropagation(); close(); } };
99
+ back.querySelectorAll(".fd-set[data-kind]").forEach((row) => {
100
+ const kind = row.getAttribute("data-kind");
101
+ const out = row.querySelector(".dd-out");
102
+ const ask = row.querySelector(".dd-ask");
103
+ ask.addEventListener("click", async () => {
104
+ ask.disabled = true;
105
+ out.innerHTML = '<div class="act-out">counting…</div>';
106
+ const plan = await act("delete", { kind });
107
+ ask.disabled = false;
108
+ if (!plan || !plan.ok) { out.innerHTML = resultHtml(plan); return; }
109
+ const said = (plan.out || []).filter((l) => l.trim().length > 0);
110
+ const nothing = said.some((l) => /nothing to delete/i.test(l));
111
+ const lines = said.filter((l) => !/^Nothing has changed/.test(l));
112
+ out.innerHTML = '<div class="act-out">' + lines.map((l) => "<div>" + esc(l) + "</div>").join("") +
113
+ (nothing ? "" : '<div class="confirm-buttons"><button class="dd-no" type="button">Keep it</button>' +
114
+ '<button class="dd-yes" type="button">Yes, delete</button></div>') + "</div>";
115
+ if (nothing) return;
116
+ out.querySelector(".dd-no").addEventListener("click", () => { out.innerHTML = ""; });
117
+ out.querySelector(".dd-yes").addEventListener("click", async (e) => {
118
+ e.target.disabled = true;
119
+ out.innerHTML = '<div class="act-out">deleting…</div>';
120
+ const r = await act("delete", { kind, confirm: true });
121
+ out.innerHTML = plainResult(r);
122
+ if (r && r.ok) changed();
123
+ });
124
+ });
125
+ });
126
+ back.querySelector(".fd-cancel").addEventListener("click", close);
127
+ back.addEventListener("click", (e) => { if (e.target === back) close(); });
128
+ addEventListener("keydown", onKey, true);
129
+ document.body.appendChild(back);
60
130
  }
61
131
 
62
132
  // ── the folder dialog (back up / export) ────────────────────────────────────
@@ -64,8 +134,8 @@ export function mount() {
64
134
  const COPY = {
65
135
  backup: {
66
136
  title: "Back up this memory",
67
- lede: "A dated snapshot of the whole store — the database and the conversation it is still " +
68
- "writing up — into a new folder inside the one you name. Nothing in the store changes.",
137
+ lede: "A dated snapshot of your memories — the database, never conversation text — " +
138
+ "into a new folder inside the one you name. Nothing in the store changes.",
69
139
  go: "Back up",
70
140
  },
71
141
  export: {
@@ -1121,7 +1121,7 @@ export const MECHANISMS: readonly Mechanism[] = [
1121
1121
  // pass that has not written its result — so a row is evidence the pass RAN;
1122
1122
  // what it found is doctor's `Raw transcripts` line.
1123
1123
  id: "retention",
1124
- label: "the raw transcript of a session that owes nothing was let go a week after it ended",
1124
+ label: "the raw transcript of a session that owes nothing was let go a few days after it ended (never more than 14 days after its last activity)",
1125
1125
  module: "remember/retention.ts (run by the worker)",
1126
1126
  evidence: { kind: "event", names: ["remember.prune"] },
1127
1127
  since: "2026-09-23",
@@ -415,6 +415,27 @@ export function pruneLog(dataDir: string, today: string, days: number = LOG_DAYS
415
415
  return removed;
416
416
  }
417
417
 
418
+ /**
419
+ * Delete EVERY dated file — the owner's "delete the activity log"
420
+ * (`cli/commands-delete.ts`, 2026-10-13). Named files only, the same ones
421
+ * `pruneLog` would take in time: a name that is not a date is left alone.
422
+ * Today's file is a file like the others; the next line written makes it
423
+ * again. Never throws. Returns how many went and how many would not.
424
+ */
425
+ export function clearLog(dataDir: string): { removed: number; failed: number } {
426
+ let removed = 0;
427
+ let failed = 0;
428
+ for (const date of logDates(dataDir)) {
429
+ try {
430
+ rmSync(logFile(dataDir, date), { force: true });
431
+ removed += 1;
432
+ } catch {
433
+ failed += 1;
434
+ }
435
+ }
436
+ return { removed, failed };
437
+ }
438
+
418
439
  /** What doctor says in one line: where, how many days, how many failures today. */
419
440
  export interface LogReading {
420
441
  readonly dir: string;
@@ -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.20";
22
+ export const SERVER_VERSION = "0.3.21";
23
23
 
24
24
  /**
25
25
  * THE ONE LINE EVERY TOOL ANSWERS WITH when the store on disk is a schema AHEAD
@@ -379,6 +379,37 @@ export function takeFirstRunNotice(noticePath: string): boolean {
379
379
  }
380
380
  }
381
381
 
382
+ /**
383
+ * "INSTALLED TWICE" IS SAID ONCE (2026-10-13, Mike's first session with the
384
+ * plugin beside his npm install: the stand-down line at every session start
385
+ * read as an error). The stand-down itself is unchanged and needs nothing
386
+ * done; doctor's Claude Code row keeps saying it (`doctor-host.ts`). The mark
387
+ * lives in the plugin's own data directory, which outlasts a reboot and goes
388
+ * with the plugin at uninstall (so a reinstall says it once more); without
389
+ * one, the system temp directory, beside the first-run notice and for its
390
+ * reasons. Keyed by the configuration path, like the notice. The line for a
391
+ * dead npm entry is not this: it asks for something, and says so every time.
392
+ */
393
+ export function twiceNoticePath(configPath: string, env: Record<string, string | undefined>, tmp: string = tmpdir()): string {
394
+ const data = (env[PLUGIN_DATA_ENV] ?? "").trim();
395
+ return join(data.length > 0 ? data : tmp, `counterparts-installed-twice-${firstRunKey(configPath)}.said`);
396
+ }
397
+
398
+ /**
399
+ * Mark it said: true for the first caller only (`wx` either makes the file or
400
+ * finds one there). A mark that cannot be written for any other reason is
401
+ * true, so the line is said, as it was before there was a mark.
402
+ */
403
+ export function markTwiceSaid(markPath: string): boolean {
404
+ try {
405
+ mkdirSync(dirname(markPath), { recursive: true });
406
+ writeFileSync(markPath, `${new Date().toISOString()}\n`, { encoding: "utf8", mode: 0o600, flag: "wx" });
407
+ return true;
408
+ } catch (err) {
409
+ return (err as { code?: string }).code !== "EEXIST";
410
+ }
411
+ }
412
+
382
413
  /**
383
414
  * The line a new install is announced with, for the configuration at
384
415
  * `configPath`. ONE LINE (2026-10-12, Mike's fresh-user trial: the three-line
@@ -1677,8 +1677,11 @@ function registryFacts(dir: string, session: string): HostSessionEvidence {
1677
1677
  * deleted" and "what the next session is asked to write" are read off one set
1678
1678
  * of facts (B3's rule, kept by construction).
1679
1679
  */
1680
- export function writeUpSources(store: Store): RetentionSources {
1681
- return retentionSources(store, { host: hostSessionEvidence(store) });
1680
+ export function writeUpSources(store: Store, clocks: { retentionMs?: number; maxMs?: number } = {}): RetentionSources {
1681
+ // The clocks change only WHEN text goes, never what is owed — so the
1682
+ // write-up's readers may leave them at the defaults, and the retention pass
1683
+ // hands over the configuration's (`config.ts#retentionClocks`).
1684
+ return retentionSources(store, { host: hostSessionEvidence(store), ...clocks });
1682
1685
  }
1683
1686
 
1684
1687
  /** Every session the store holds text for, judged by `remember/owes.ts`. Read-only. */
@@ -52,7 +52,7 @@
52
52
  * directory, a failed copy, a failed rename, an aborted run — is a
53
53
  * `snapshot.failed` row carrying its `reason` and the `step` it died at.
54
54
  */
55
- import { cpSync, readdirSync, renameSync, rmSync, statSync } from "node:fs";
55
+ import { cpSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync } from "node:fs";
56
56
  import { homedir } from "node:os";
57
57
  import { basename, dirname, join, parse, resolve } from "node:path";
58
58
 
@@ -775,6 +775,89 @@ export function rotate(
775
775
  };
776
776
  }
777
777
 
778
+ // ── the owner's "delete every backup" (2026-10-13) ──────────────────────────
779
+
780
+ /** What deleting every copy in one directory did. Names and counts. */
781
+ export interface DeleteCopiesReport {
782
+ /** The copies deleted — daily and pre-migration — by name. */
783
+ readonly deleted: readonly string[];
784
+ /** Files and directories removed inside them, one by one. */
785
+ readonly entries: number;
786
+ /** Copies of a pre-rows store, and correctly-named directories that are not
787
+ * ours: left, exactly as rotation leaves them. */
788
+ readonly left: readonly string[];
789
+ readonly errors: readonly string[];
790
+ }
791
+
792
+ /**
793
+ * DELETE EVERY COPY THIS PACKAGE WROTE in one snapshots directory — the
794
+ * owner's "delete backups" (`cli/commands-delete.ts`), not rotation. It
795
+ * deletes what rotation may delete and nothing more: the directory must pass
796
+ * `assertRotatableDir` (it throws otherwise), the copies are the ones
797
+ * `readSnapshotsDir` counts as ours (daily names and pre-migration names that
798
+ * hold a classified store), and everything else — a pre-rows copy, a folder
799
+ * that only wears the name, a `.partial-…` a live run may be writing — is left.
800
+ *
801
+ * Each copy is taken apart BY NAME (`removeCopy`), never by a recursive
802
+ * force-delete of a computed path.
803
+ */
804
+ export function deleteAllCopies(storeDir: string, dir: string): DeleteCopiesReport {
805
+ const real = assertRotatableDir(storeDir, dir);
806
+ const read = readSnapshotsDir(real);
807
+ const deleted: string[] = [];
808
+ const errors: string[] = [];
809
+ let entries = 0;
810
+ for (const name of [...read.names, ...read.preMigration]) {
811
+ const removed = removeCopy(join(real, name), errors);
812
+ entries += removed.entries;
813
+ if (removed.ok) deleted.push(name);
814
+ }
815
+ return { deleted, entries, left: [...read.preRows, ...read.unrecognised], errors };
816
+ }
817
+
818
+ /**
819
+ * Take one copy apart: list it, unlink each file (a symlink is unlinked as
820
+ * itself, never followed), descend only into real directories, then remove
821
+ * each directory once it is empty. A file that will not go is named in
822
+ * `errors` and its directory stays.
823
+ */
824
+ function removeCopy(path: string, errors: string[]): { ok: boolean; entries: number } {
825
+ let entries = 0;
826
+ let ok = true;
827
+ let listing;
828
+ try {
829
+ listing = readdirSync(path, { withFileTypes: true });
830
+ } catch (err) {
831
+ errors.push(`could not read ${basename(path)}: ${messageOf(err)}`);
832
+ return { ok: false, entries };
833
+ }
834
+ for (const entry of listing) {
835
+ const child = join(path, entry.name);
836
+ if (entry.isDirectory()) {
837
+ const inner = removeCopy(child, errors);
838
+ entries += inner.entries;
839
+ if (!inner.ok) ok = false;
840
+ continue;
841
+ }
842
+ try {
843
+ unlinkSync(child);
844
+ entries += 1;
845
+ } catch (err) {
846
+ ok = false;
847
+ errors.push(`could not remove ${entry.name}: ${messageOf(err)}`);
848
+ }
849
+ }
850
+ if (!ok) return { ok, entries };
851
+ try {
852
+ rmdirSync(path);
853
+ entries += 1;
854
+ } catch (err) {
855
+ errors.push(`could not remove ${basename(path)}: ${messageOf(err)}`);
856
+ return { ok: false, entries };
857
+ }
858
+ return { ok: true, entries };
859
+ }
860
+
778
861
  /**
779
862
  * The pre-migration copies rotation may remove: older than
780
863
  * `PRE_MIGRATION_KEEP_DAYS` by the date in their name, with at least `keep`
@@ -935,6 +1018,12 @@ function fewOf(names: readonly string[], limit = 3): string {
935
1018
  * whatever else it holds. It is not "unrecognised" either — it is a copy, of a
936
1019
  * floor this build cannot open — and it gets its own channel so the sentence
937
1020
  * the owner reads can say which it is.
1021
+ *
1022
+ * **Since 2026-10-13 a new copy holds the database and nothing else** —
1023
+ * `spans/` left the backup set (backups never hold conversation text). The
1024
+ * database entry matches by prefix, so such a copy is "ours"; one taken
1025
+ * before, which still holds `spans/`, is "ours" by either name and rotates out
1026
+ * as it always did.
938
1027
  */
939
1028
  function copyKind(path: string): "ours" | "pre-rows" | "not-a-copy" {
940
1029
  let entries: string[];
@@ -506,13 +506,16 @@ export const PRONOUN_RULE = "Until they say their pronouns, use their name or \"
506
506
 
507
507
  /**
508
508
  * WHAT IS KEPT, word for word (D): Claude is never to paraphrase retention, so
509
- * the script hands the exact line, for when they ask. Its facts: a week is
510
- * `remember/tunables.ts#RETENTION_MS` from the latest of last activity, write-up
511
- * and session end (`remember/owes.ts`); two weeks is `coverage/tunables.ts#
512
- * LAPSE_DAYS_OF_USE`; 14 days is the daily snapshots' `DEFAULT_KEEP`.
509
+ * the script hands the exact line, for when they ask. Its facts (Mike,
510
+ * 2026-10-13), the DEFAULTS: 3 days is `remember/tunables.ts#RETENTION_MS`
511
+ * from the latest of last activity, write-up and session end
512
+ * (`remember/owes.ts`); 14 days is `RETENTION_MAX_MS`, the ceiling from the
513
+ * last activity, owed or not; backups never copy `spans/`
514
+ * (`store/paths.ts#LAYOUT`). A configuration may set other numbers
515
+ * (`retention` in claude-code.json); this line says the defaults.
513
516
  */
514
517
  export const RETENTION_LINE =
515
- "Session text is kept until I've written it up and the session has ended, then deleted a week later. If a write-up is still owed, the text is let go after about two weeks of use. Backups hold it about 14 days longer.";
518
+ "Our conversation text is kept only so I can turn it into memories: it's deleted 3 days after I've written it up, and never kept more than 14 days. Backups never include it. Memories stay until they fade or you remove them, and you can delete the conversation text, the backups or the activity log on their own at any time.";
516
519
 
517
520
  /** The first dream, true to the dreaming setting: never today (`meetingDay`). Empty when dreaming is off. */
518
521
  function firstDream(dreaming: MeetContext["dreaming"]): string {
@@ -595,7 +598,7 @@ export function finishText(ctx: Pick<MeetContext, "name" | "dreaming" | "plugin"
595
598
  `1) The write-up: hand back anything from the meeting that a meet step did not already save, one idea each, with the counterparts session_end tool, session: ${ctx.session} (the answers and the style are saved already: don't repeat them; often there is nothing more). Then write the first chapter with the counterparts chapter tool, session: ${ctx.session}: a short, true page about meeting them. ${PRONOUN_RULE}`,
596
599
  `2) Show memory working: two or three short lines of what you'll carry from today, in your words — "Here's what I'll remember: …".${dream.length === 0 ? "" : ` Then: "${dream}"`}`,
597
600
  "3) Close, close to this, and nothing about retention or uninstalling unless they ask:",
598
- ...(ctx.plugin ? [" \"/counterparts shows the memory sidebar (off, quiet and pause are at its bottom)."] : []),
601
+ ...(ctx.plugin ? [" \"/counterparts shows the memory sidebar on the right, once this window is wide enough. Off, quiet and pause are at its bottom."] : []),
599
602
  ` ${ctx.plugin ? "" : "\""}Ask me anything about Counterparts, any time.`,
600
603
  ` Great meeting you, ${name}! What would you like to work on today? Or we can keep chatting — what's been on your mind lately?"`,
601
604
  ].join("\n");
@@ -170,7 +170,9 @@ reply actually used reconsolidates, where in humans every retrieval does.
170
170
  cross-session cue carry-over were all inert on the live path** — specified, implemented,
171
171
  tested, unreachable. The spec's instruction is to pick one and say so; this contract
172
172
  persists it (a few rows under the storage rescope) and marks the call. **Generalized: a
173
- pure function over caller-owned state is only as real as its caller.**
173
+ pure function over caller-owned state is only as real as its caller.** The one piece of
174
+ it that is the person's own words, the carried cue tokens, is emptied in any session idle
175
+ past the retention ceiling (`clearIdleCarries`, run by the worker; NOTES §6, 2026-10-13).
174
176
  - **The activation graph's edge arithmetic may belong in `physics/` and the traversal here** —
175
177
  `associate/CONTRACT.md` open question 1, the module map's standing check-in question. Not
176
178
  resolved by this contract.