counterparts 0.3.27 → 0.3.28

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 (64) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/docs/README.md +3 -1
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +9 -2
  5. package/src/adapters/claude-code/bin/runner.ts +10 -0
  6. package/src/adapters/claude-code/doctor.ts +14 -2
  7. package/src/adapters/claude-code/hooks.ts +10 -5
  8. package/src/adapters/claude-code/night-run.ts +8 -0
  9. package/src/adapters/cli/CONTRACT.md +7 -0
  10. package/src/adapters/cli/commands-note.ts +8 -0
  11. package/src/adapters/cli/commands-self.ts +53 -1
  12. package/src/adapters/cli/commands.ts +18 -0
  13. package/src/adapters/cli/dream-core.ts +16 -6
  14. package/src/adapters/cli/help.ts +2 -0
  15. package/src/adapters/dashboard/CONTRACT.md +5 -2
  16. package/src/adapters/dashboard/web/narrate.ts +4 -0
  17. package/src/adapters/lifecycle.ts +34 -7
  18. package/src/adapters/mcp/CONTRACT.md +41 -0
  19. package/src/adapters/mcp/NOTES.md +42 -0
  20. package/src/adapters/mcp/deliberate.ts +25 -1
  21. package/src/adapters/mcp/facts.ts +176 -8
  22. package/src/adapters/mcp/nights.ts +283 -0
  23. package/src/adapters/mcp/server-args.ts +42 -2
  24. package/src/adapters/mcp/server-self-tools.ts +35 -9
  25. package/src/adapters/mcp/server-session-end.ts +5 -0
  26. package/src/adapters/mcp/server-words.ts +7 -1
  27. package/src/adapters/mcp/server.ts +90 -13
  28. package/src/adapters/mcp/tools.ts +39 -21
  29. package/src/adapters/snapshots.ts +101 -2
  30. package/src/adapters/store-id.ts +68 -1
  31. package/src/core/briefing.ts +19 -1
  32. package/src/core/counterpart-deposit.ts +83 -2
  33. package/src/core/counterpart-types.ts +56 -0
  34. package/src/core/counterpart.ts +396 -88
  35. package/src/core/dream/CONTRACT.md +45 -3
  36. package/src/core/dream/NOTES.md +119 -0
  37. package/src/core/dream/core-ask.ts +134 -0
  38. package/src/core/dream/index.ts +3 -1
  39. package/src/core/dream/reflect.ts +493 -65
  40. package/src/core/handoff/CONTRACT.md +28 -1
  41. package/src/core/handoff/NOTES.md +86 -0
  42. package/src/core/handoff/last-here.ts +267 -59
  43. package/src/core/mint.ts +11 -0
  44. package/src/core/onboarding.ts +2 -1
  45. package/src/core/prospective/CONTRACT.md +11 -2
  46. package/src/core/prospective/NOTES.md +64 -0
  47. package/src/core/prospective/index.ts +143 -4
  48. package/src/core/recall/CONTRACT.md +8 -1
  49. package/src/core/recall/NOTES.md +53 -0
  50. package/src/core/recall/time-ask.ts +36 -6
  51. package/src/core/self/CONTRACT.md +31 -4
  52. package/src/core/self/NOTES.md +113 -0
  53. package/src/core/self/briefing-delivery.ts +49 -0
  54. package/src/core/self/briefing.ts +20 -3
  55. package/src/core/self/identity.ts +23 -4
  56. package/src/core/self/index.ts +252 -5
  57. package/src/core/self/tunables.ts +24 -0
  58. package/src/core/self/writer.ts +20 -8
  59. package/src/core/sleep/CONTRACT.md +7 -1
  60. package/src/core/sleep/core-standing.ts +50 -3
  61. package/src/core/sleep/index.ts +1 -1
  62. package/src/core/sleep/tunables.ts +13 -0
  63. package/src/core/store/index.ts +31 -0
  64. package/src/core/store/reads-memories.ts +45 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.28 — 2026-10-20
4
+
5
+ The morning share now closes the open threads that are plainly done, and says which and why; say one isn't done and it is reopened. The session-start wake repeats nothing: each session is named once, and "Today, elsewhere" and a new "Here, also open" say by title what the other open sessions are working on. Saying "done" to a weekly reminder closes just this week; it comes back on its next date. Last night's dream and reflection open by their ids, and `counterparts night` reads them without changing anything. The nightly run keeps the self page within its 4,600-byte room, the reflection answers core memories that have waited a week for keep or retire, and facts list the next twenty matches by title. Most of these are experiments, to be checked in a few days. If you use the plugin, update it with this release: the wake's head is now one tag, and a plugin of 0.3.27 or earlier reads the meeting and the store as unknown until it is updated, so its sidebar footer offers the 5-minute intro again and it skips its store check. No store-format change (store v13, cache v7) and no wiring change: nothing to run after upgrading from 0.3.27, and `counterparts connect` is not needed.
6
+
7
+ - **The nightly reflection closes open threads that are plainly done, and tells you, as an
8
+ experiment.** When a memory shows a thing finished, it closes the thread itself and the
9
+ morning share names it with why; say it isn't done and it is reopened, and then only
10
+ ever asked about. Threads it is unsure of, and private ones, are still asked about, as
11
+ before.
12
+ - **Last night opens by its id.** Recall now reads a dream's id (`drm_…`) or a
13
+ reflection's (`rfl_…`) — the ids the morning wake and the share name — as a short,
14
+ read-only summary: what the dream did, the memories it touched and its gists; the
15
+ reflection's entry, its share and whether it was told, what it cited, and any closes.
16
+ Opening one changes nothing. A night that rests on a confidential memory is withheld from
17
+ a session that isn't yours, and says so.
18
+ - **`counterparts night` reads the nights and changes nothing.** The recent dreams and
19
+ reflections, `last`, `last-reflection`, or one by id — the same lines as `dream --show`,
20
+ from a command with no undo, so a session can run it with you. Undo stays on
21
+ `counterparts dream`.
22
+ - **A weekly reminder can be marked done for this week.** Saying a repeating reminder was done
23
+ (a memory that updates it with `status: "done"`) closes just this time: it stops coming up
24
+ today, the reminder keeps its date and repeat, and it comes back on its next date. The answer
25
+ says which day was closed and when it returns. Dropping the date (`eventDate: null`) still
26
+ ends the repeat.
27
+ - **A "done" note written on its own points at the reminder it answers.** When a memory saying
28
+ something was done (or that you said it) lands next to a reminder due now, the answer names
29
+ the reminder and how to close it.
30
+ - **A memory a session just replaced still counts as drawn on.** Naming in `drewOn` a memory the
31
+ same session had just updated with a newer one (or one replaced that day) no longer refuses it.
32
+ One put away by a correction is still refused.
33
+ - **The session-start wake names each session once.** The Yesterday line leaves the newest
34
+ chapter written in this folder to "Last here", and "Last here"'s "Before it" and "+N more
35
+ here" lines, and the chapter-about-me line, leave out what Yesterday already names. A
36
+ Yesterday chapter with no room for its title is counted ("and 3 more"), never printed as a
37
+ bare id.
38
+ - **One tag at the top of the wake.** The meeting's state and the store's id are now fields of
39
+ the wake's own opening comment (`<!-- counterparts:wake meet=done store=st_… elements=…
40
+ bytes=… -->`), or of one `<!-- counterparts:session … -->` tag when there is no wake to
41
+ carry them. The sidebar reads both forms. An older sidebar (plugin 0.3.27 or before) reads
42
+ them as unknown until the plugin is updated: it skips its store check and keeps the
43
+ "5-minute intro" line in its footer.
44
+ - **The chapter-about-me line says where it is from first**: "A chapter about me from
45
+ ~/site: session …, Oct 19 — "…" (epi_…)."
46
+ - **"Coming up" at a session start lists what is due today.** A plain reminder due tomorrow is
47
+ counted with the other dates, as the evening's bundle still lists it for the next morning.
48
+ Every "Coming up" item now carries its own id, beside any "(earlier: …)" pointer.
49
+ - **One backup a day, even when two background runs start at once.** The daily snapshot
50
+ claims the day before it copies, so two runs at one boundary no longer leave two copies.
51
+ - **The nightly page writer and reflection keep your self page within its 4,600-byte room,
52
+ as an experiment.** The night's first page past the room is sent back to be cut, with how
53
+ many bytes over, rather than kept with a short version. A second try is kept, and a page
54
+ that was never sent again is kept when the night ends, so a night's rewrite is never lost.
55
+ A page past the room that has a short version now shows the short version in the wake, so
56
+ the lists beside it keep their room. Pages you or a session write are not held.
57
+ - **A core memory that has waited a week for "keep or retire" gets answered, as an
58
+ experiment.** The nightly reflection is offered up to three that have waited 7 lived
59
+ days, decides the ones it can with a reason, and the morning share says which, in one
60
+ line. Say one was wrong and it is undone: a memory a reflection retired comes back into
61
+ the core with a keep (`counterparts core --reaffirm <id> --reason "..."`, or just say
62
+ so in a session). Agree with one instead (`counterparts core --demote <id>`) and it
63
+ is recorded as your retire, which no session can undo; your own `--reaffirm` still
64
+ can. The wake's "Still open" leads with a week-old one, and still says
65
+ "keep or retire it" when the memory is also unsettled. Doctor's Reflection line counts
66
+ the ones waiting.
67
+ - **Asking for facts also lists the next matches by title.** After the ten results, the next
68
+ twenty are listed one line each (title, id and date), so a memory ranked a little lower is in
69
+ sight and can be opened by its id without asking for page 2. Being listed doesn't strengthen
70
+ a memory; opening it does.
71
+ - **"Lately" and "recently" no longer hide older facts.** A facts question with "lately",
72
+ "recently", "these days" or "nowadays" ranks the past week's matches first instead of keeping
73
+ only those, and says so. "What happened lately?" on its own still means the past week, and
74
+ "last week" or "in September" still keep only that time.
75
+ - **The sidebar's fox stays up while Claude is working, as an experiment.** Any tool call,
76
+ including one waiting on a permission prompt, starts his idle clock over, so he no longer
77
+ lies down or naps in the middle of a long call; he lies down at 45 seconds and naps at 2
78
+ minutes after the last activity, as before. A memory saved from a session shows his
79
+ notepad once.
80
+ - **"Today, elsewhere" and "Since you started" say what the other sessions are working on.**
81
+ Beside each folder's memory count they name up to two of its memories by title and id,
82
+ work in progress first ("planned" or "done" marks, then work memories), newest first:
83
+ `~/random open since 08:33 (live), 8 memories: "Wake check 10-20" (mem_…), "Spans out of
84
+ backups" (mem_…)`. Other sessions open in the same folder get a clause of their own:
85
+ `Here, also open: session 25e12e7d on Fable 5 since 10:05: "…" (mem_…)`. Never from a
86
+ folder that is off, paused or observed, never a confidential memory, a dated one, one about
87
+ you, about the two of you or about your counterpart itself, or small talk. "Since you
88
+ started" names only what was written since it last told you. Both lines stay within their
89
+ old size.
90
+
3
91
  ## 0.3.27 — 2026-10-19
4
92
 
5
93
  Recall learns from use, and finds "baking" when you say "bake". The memories a session rates useful, draws on or opens count as used, memories found useful together get linked, and one rated noise twice comes up less for a while; what the conversation has been about, and what is open in its folder, gives related memories a head start. Recall matches word forms and counts everyday words for less, a session's first prompt is matched by meaning too, footnotes skip what this session wrote, and a newer memory stands in for the one it replaced. Most of these are experiments, to be checked in a few days. `counterparts doctor` gains a Feedback loop line. No store migration (store v13) and no wiring change, so `counterparts connect` is not needed; the word index re-indexes itself once in the background (cache v6 to v7, under a second on a typical store). Going back to 0.3.26 is not a plain reinstall: its memory tools refuse the newer cache, and its hooks miss word matches without saying so. To go back, delete `~/.counterparts/store/cache/cache.sqlite*`, then run `counterparts verify --rebuild --keep-vectors --dir ~/.counterparts/store` on 0.3.26 (recall by meaning comes back over the next few sessions, as the background worker re-reads the memories); `counterparts rollback` does not cover a cache change.
package/docs/README.md CHANGED
@@ -15,7 +15,9 @@ has it; every other page is a working default or a record of what happened.
15
15
 
16
16
  ## Where the work is going
17
17
 
18
- - [`ROADMAP.md`](ROADMAP.md) — the plan for the current round.
18
+ - [`ROADMAP.md`](ROADMAP.md) — the plan for the current round, one line per thing to do.
19
+ - [`WORKLIST.md`](WORKLIST.md) — the details behind the roadmap's to-do list.
20
+ - [`CHECK-AFTER.md`](CHECK-AFTER.md) — experiments in use, each with a date to check.
19
21
  - `HANDOFF.md` — the note one session leaves for the next. It is written locally and is not in
20
22
  the repository (ignored since 2026-10-02).
21
23
  - [`IMPROVEMENTS.md`](IMPROVEMENTS.md) — things noticed while living on it, as opposed to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
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": {
@@ -413,7 +413,9 @@ row, saying which source answered, existed until the keys were removed — §1a.
413
413
  **AND, AT A PROMPT, WHAT CHANGED SINCE (2026-10-11).** A session already open
414
414
  never reads a wake again, so `userPromptSubmit` may add one "Since you started"
415
415
  line for the model (`Lifecycle#sinceLine` → `Counterpart#sinceElsewhere`): another
416
- directory's session started or ended, a chapter, new memories, since this session
416
+ directory's session started or ended, a chapter, new memories (since 2026-10-20 up
417
+ to two by title, only ones written since the line last told; and another session
418
+ open in this same folder that started or wrote something), since this session
417
419
  last heard. The same gate as "Today, elsewhere" (`elsewhereGate`, one code path)
418
420
  and the same registry hand-over (`elsewhereHere`). At most once an hour, never at
419
421
  the first prompt after a wake; the state is the session record's `sinceSeen`
@@ -628,7 +630,12 @@ row, saying which source answered, existed until the keys were removed — §1a.
628
630
  as "delete them all"); and **a half-copy is never a snapshot** — the copy is
629
631
  written under a `.partial-…` name and renamed into place, so a worker killed
630
632
  mid-copy leaves something that is not counted toward `keep`, does not satisfy
631
- "today's exists", and is swept once it is too old to be a live run's.
633
+ "today's exists", and is swept once it is too old to be a live run's. **One copy
634
+ a day when two runs start together** (2026-10-20): a run claims the day first
635
+ (`.taking-<date>`, a file created exclusively), looks again under the claim, and
636
+ lets it go once its copy is in place or has failed; the run that finds the claim
637
+ held writes nothing (`already-today`). A killed run's claim is stale, and taken
638
+ over or swept, by the partials' bound.
632
639
 
633
640
  *For now:* the default directory applies only inside the layout this package
634
641
  creates (the store is the `store/` subdirectory of a base directory). A store
@@ -72,6 +72,7 @@ import { fileURLToPath } from "node:url";
72
72
 
73
73
  import { Counterpart, RUNNER_FAILED_EVENT } from "../../../core/counterpart.js";
74
74
  import { recordCoverage } from "../../../core/coverage/index.js";
75
+ import { PAGE_HELD_SETTLE_MS } from "../../../core/self/index.js";
75
76
  import { clearIdleCarries } from "../../../core/recall/index.js";
76
77
  import { RETENTION_EVENT, retentionRow, retentionRuns } from "../../../core/remember/index.js";
77
78
  import type { HostSessionEvidence, RetentionReport } from "../../../core/remember/index.js";
@@ -454,6 +455,15 @@ export async function runOnce(input: {
454
455
  // render re-renders it now, not at the next lived day. After the cycle, whose own render already caught up to what was
455
456
  // marked before it; nothing marked, nothing rendered.
456
457
  // Its own try: a render that fails costs the refresh, and the mark stays.
458
+ // First, A HELD PAGE NO RUN END KEPT (review of #541): a night launched
459
+ // from a session (the default `ask`) or a run killed after the hold never
460
+ // reaches `runNight`'s keep, so a boundary keeps it once it has settled —
461
+ // only while the page still stands where it was held.
462
+ try {
463
+ counterpart.self.keepHeldPage({ settledMs: PAGE_HELD_SETTLE_MS });
464
+ } catch {
465
+ /* the held page stays on its refusal row for the next boundary */
466
+ }
457
467
  try {
458
468
  const wake = counterpart.refreshWake({ at: today });
459
469
  if (wake.reason !== "current") emit("runner.wake", { reason: wake.reason, triggers: wake.triggers.join(","), bytes: wake.bytes });
@@ -74,7 +74,7 @@ import {
74
74
  } from "../../core/store/index.js";
75
75
  import { heldCorrections } from "../../core/reconsolidation.js";
76
76
  import { bundledModelDir } from "../runtime.js";
77
- import { acceptsReflectedFeeling, laterFeelingWasAwake, laterFeelingWasReflections, selfRelevantFeeling } from "../../core/sleep/index.js";
77
+ import { TUNABLES as SLEEP_TUNABLES, acceptsReflectedFeeling, laterFeelingWasAwake, laterFeelingWasReflections, selfRelevantFeeling } from "../../core/sleep/index.js";
78
78
  import { TUNABLES as ASSOCIATE_TUNABLES, isDead, pairKey } from "../../core/associate/index.js";
79
79
  import type { EventRow } from "../../core/store/index.js";
80
80
  // The ask allowance the amber hint names, read rather than retyped: a number in
@@ -84,7 +84,7 @@ import { WORK_OVERFLOW_EVENT } from "../../core/self/work.js";
84
84
  import { HANDOFF_REFUSED_EVENT } from "../../core/handoff/index.js";
85
85
  import { LAST_HERE_NOROOM_EVENT } from "../../core/handoff/last-here.js";
86
86
  import { TOOL_RESULT_CEILING } from "../../core/fit/index.js";
87
- import { awakeFeelingCounts, nightRunOf } from "../../core/dream/index.js";
87
+ import { awakeFeelingCounts, coreWaiting, nightRunOf } from "../../core/dream/index.js";
88
88
  import type { DreamingSetting } from "../../core/dream/index.js";
89
89
  import type { AskReason } from "../../core/self/episodes.js";
90
90
  // The what-fired reading, shared with the console's `fired` command and the
@@ -2280,7 +2280,18 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2280
2280
  last.entry_id === null ? "nothing much" : "an entry"
2281
2281
  }${last.page_version === null ? "" : ", the self page rewritten"}, ${share[last.share_state] ?? last.share_state}`;
2282
2282
  const byHow = `returns this week — awake ${String(returns.awake)}, reflection ${String(returns.reflection)}, dream ${String(returns.dream)}`;
2283
+ // CORE QUESTIONS THAT WAITED (2026-10-20, an experiment): flagged a week
2284
+ // or more ago with no decision since — what the reflection is offered.
2285
+ let coreWaited = 0;
2286
+ try {
2287
+ coreWaited = coreWaiting(store, store.livedDay()).length;
2288
+ } catch {
2289
+ coreWaited = 0;
2290
+ }
2283
2291
  const aloneLine =
2292
+ (coreWaited > 0
2293
+ ? `; ${String(coreWaited)} core ${coreWaited === 1 ? "memory has" : "memories have"} waited ${String(SLEEP_TUNABLES.CORE_WAITING_DAYS)}+ lived days for a keep or retire (counterparts core --list shows them)`
2294
+ : "") +
2284
2295
  (promotionsUnread
2285
2296
  ? `; how many became core on reflection alone is unknown: more than ${String(PROMOTED_ROWS)} promotions in the log, and only the newest ${String(PROMOTED_ROWS)} were read`
2286
2297
  : "") +
@@ -2325,6 +2336,7 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2325
2336
  awakeFeelings: awake.total,
2326
2337
  awakeFeelingsFast: awake.fast,
2327
2338
  awakeFeelingsOwner: awake.owner,
2339
+ coreWaited,
2328
2340
  },
2329
2341
  ),
2330
2342
  ];
@@ -82,7 +82,7 @@ import { nightRowTimeoutMs, planNightRunner } from "./night-run.js";
82
82
  import { NOTHING_OWED_BEFORE_KEY, catchUpOf, catchUpWords, owedBefore } from "./night-catch-up.js";
83
83
  import type { NightKind } from "./night-run.js";
84
84
  import { spawnDetached } from "../spawn.js";
85
- import { ONE_TAG_LINE, wakeTagLead } from "../store-id.js";
85
+ import { ONE_TAG_LINE, tagLead } from "../store-id.js";
86
86
  import type { SpawnOutcome } from "../spawn.js";
87
87
  import { NO_ARRIVAL, STOP_ASK_OPENER, readWakeArrival, startedByHost } from "./transcript.js";
88
88
  import type { WakeArrival } from "./transcript.js";
@@ -538,7 +538,7 @@ export const RESUME_WAKE_LINE =
538
538
  "Counterparts: this session was resumed; the wake it was handed when it started (above) still holds.";
539
539
 
540
540
  /** What `sessionStart` hands the host: a composed wake, or a resume's line. */
541
- type WokeHere = Pick<ReturnType<Lifecycle["composeWake"]>, "text" | "ok" | "bytes" | "sentinel" | "preface" | "lined"> & {
541
+ type WokeHere = Pick<ReturnType<Lifecycle["composeWake"]>, "text" | "ok" | "bytes" | "sentinel" | "preface" | "lined" | "tags" | "tagged"> & {
542
542
  readonly reason: string;
543
543
  };
544
544
 
@@ -642,7 +642,10 @@ export class ClaudeCodeAdapter extends Lifecycle {
642
642
  // the "Since you started" line says what changed elsewhere since it
643
643
  // last heard. No wake is composed, so no new expectation is written for
644
644
  // the delivery check, and the since-line's state is left to the line.
645
- const woke: WokeHere = resumed ? this.resumeWake(input) : this.composeWake(input, budget);
645
+ // The markers ride in the composed wake's head tag (2026-10-20, ONE
646
+ // TAG; `Lifecycle#composeWake`).
647
+ const markers = (): readonly string[] => [this.onboardingMarker(input), this.storeMarker()];
648
+ const woke: WokeHere = resumed ? this.resumeWake(input) : this.composeWake(input, budget, markers);
646
649
  // The wake has just said what the other directories did today, so the
647
650
  // prompt's "Since you started" line counts from here (2026-10-11).
648
651
  if (!resumed) this.noteSinceWoke(input);
@@ -701,8 +704,10 @@ export class ClaudeCodeAdapter extends Lifecycle {
701
704
  // says which store this session opened, so the mod can tell this
702
705
  // store's dashboard from another's. Since 2026-10-16 both ride on the
703
706
  // wake's own head line, just above its body (`wakeTagLead`, lightly
704
- // held); `ONE_TAG_LINE` off puts them back under the clock.
705
- const tags = wakeTagLead([this.onboardingMarker(input), this.storeMarker()], woke.text);
707
+ // held), and since 2026-10-20 inside its head tag (`ONE_TAG`), or as
708
+ // one tag of their own in front of a wake that has none (`tagLead`);
709
+ // `ONE_TAG_LINE` off puts them back under the clock.
710
+ const tags = tagLead(woke.tags ?? markers(), woke.text, woke.tagged === true);
706
711
  const lead = `${woke.text.length === 0 && plain.context.length === 0 && codeTab === null ? "" : `${this.nowLine()}\n`}${ONE_TAG_LINE ? "" : tags}${codeTab === null ? "" : `${codeTab}\n`}${plain.context}${ONE_TAG_LINE ? tags : ""}`;
707
712
  const sent = woke.bytes + Buffer.byteLength(lead, "utf8");
708
713
  const rides =
@@ -713,6 +713,14 @@ export async function runNight(input: NightRunInput): Promise<NightRun> {
713
713
  // usually rendered the morning's wake before the writer wrote. The
714
714
  // host's budget came with the store (`openNightCounterpart`); without
715
715
  // one the render refuses, as everywhere. Its own try: never the record.
716
+ // First, A PAGE HELD TO THE ROOM AND NOT SENT AGAIN IS KEPT (2026-10-20,
717
+ // `Self#keepHeldPage`), so the night never loses its rewrite to the hold.
718
+ // Bounded by this run's start, not the date: a run may cross midnight.
719
+ try {
720
+ c.self.keepHeldPage({ sinceAt: startedAt });
721
+ } catch {
722
+ /* the held page stays on its refusal row */
723
+ }
716
724
  try {
717
725
  c.refreshWake({ at: c.store.today(), trigger: "run-end" });
718
726
  } catch {
@@ -613,6 +613,13 @@ The standalone verb does not ask either: typing it is the yes.*
613
613
  again. Neither command is on `OWNER_OPS`: like `self-page`, reading works from an
614
614
  instrument, and the write refuses at the core's own seam under observer. Confidential
615
615
  rows print as `[confidential]`.
616
+ *Extended 2026-10-20.* `counterparts night` prints the same lines with no write at all:
617
+ the recent dreams and reflections, `last` (the newest dream and the reflection after
618
+ it), `last-reflection`, or one by id (`show <id>` means the same). It always opens the
619
+ store as an observer, so a session can run it to review the night with the owner — a
620
+ host's safety check refuses `dream`, which also undoes. `--undo` stays on `dream`.
621
+ A reflection's entry whose memory is marked confidential prints as `[confidential]`,
622
+ like any confidential row (review of #538), here and under `dream --show`.
616
623
 
617
624
  ## 6. Scars honored
618
625
 
@@ -22,6 +22,7 @@ import { withEmbedderDefault } from "../config.js";
22
22
  import { openEmbedder } from "../claude-code/embed-client.js";
23
23
  import type { LiveEmbedder } from "../claude-code/embed-client.js";
24
24
  import { exportStore } from "./export.js";
25
+ import { dreamShowLines } from "./dream-core.js";
25
26
  import { BIN } from "./install.js";
26
27
  // The console's shared manners (2026-09-21): is there a person here, ask them,
27
28
  // and say one marked line back.
@@ -369,6 +370,13 @@ export async function recallCommand(
369
370
  // number, and `status` prints the split.
370
371
  `${result.storeSize} live rows · returned ${result.memories.length}`,
371
372
  );
373
+ // A NIGHT BY ITS ID (2026-10-20): the console's own words for it, the
374
+ // ones `counterparts night` prints (read-only, like this whole path).
375
+ if (result.nights !== undefined && result.nights.length > 0) {
376
+ io.out("");
377
+ for (const line of dreamShowLines(counterpart, idFlag) ?? []) io.out(line);
378
+ return EXIT.ok;
379
+ }
372
380
  if (result.memories.length === 0) {
373
381
  io.out("");
374
382
  // NOTHING CAME, said as a sentence rather than as an absence. A blank
@@ -123,6 +123,52 @@ export function dreamCommand(dir: string, io: Io, parsed: Parsed, observer: bool
123
123
  }
124
124
  }
125
125
 
126
+ /**
127
+ * `night` — last night, read-only (2026-10-20). The same lines `dream`
128
+ * prints (`dream-core.ts`), behind a command with no write at all, so a
129
+ * session can run it to review the night with the owner: `dream` also undoes,
130
+ * and a host's safety check refuses a command that can change shared data.
131
+ * It always opens the store as an observer, so `--observer` changes nothing
132
+ * here. `last` is the newest dream (and the reflection after it); with no
133
+ * dream yet, the newest reflection. `last-reflection` is the newest reflection.
134
+ */
135
+ export function nightCommand(dir: string, io: Io, parsed: Parsed, namedDir: boolean): number {
136
+ if (!storeExists(dir)) {
137
+ io.err(`No store at ${dir}. Run 'counterparts init${namedDir ? ` --dir ${dir}` : ""}' to create one.`);
138
+ return EXIT.usage;
139
+ }
140
+ const words = parsed.positional[0] === "show" || parsed.positional[0] === "list" ? parsed.positional.slice(1) : parsed.positional;
141
+ const listing = parsed.positional[0] === "list" || words.length === 0;
142
+ if (parsed.positional[0] === "show" && words.length === 0) {
143
+ io.err("refused: show needs an id (drm_… or rfl_…) or last. counterparts night lists them.");
144
+ return EXIT.usage;
145
+ }
146
+ const counterpart = openCounterpart(dir, true);
147
+ try {
148
+ if (listing) {
149
+ for (const line of dreamListLines(counterpart, parsed.flags["all"] === true ? "all" : undefined, "night")) io.out(line);
150
+ return EXIT.ok;
151
+ }
152
+ const asked = (words[0] ?? "").trim();
153
+ let id: string | null = asked;
154
+ if (asked === "last") id = counterpart.dreams.list(1)[0]?.dream.id ?? counterpart.reflections.list(1)[0]?.id ?? null;
155
+ else if (asked === "last-reflection") id = counterpart.reflections.list(1)[0]?.id ?? null;
156
+ if (id === null) {
157
+ io.out(asked === "last-reflection" ? "No reflections yet." : "No dreams yet.");
158
+ return EXIT.ok;
159
+ }
160
+ const lines = id.startsWith("drm_") || id.startsWith("rfl_") ? dreamShowLines(counterpart, id) : null;
161
+ if (lines === null) {
162
+ io.err(`refused: no dream or reflection ${id} in this store. counterparts night lists them.`);
163
+ return EXIT.refused;
164
+ }
165
+ for (const line of lines) io.out(line);
166
+ return EXIT.ok;
167
+ } finally {
168
+ counterpart.close();
169
+ }
170
+ }
171
+
126
172
  /**
127
173
  * `settle` — contradictions, the owner's door (2026-09-29). The list reads
128
174
  * under any stance; a settle and an undo go through `Counterpart
@@ -368,7 +414,7 @@ export function coreCommand(dir: string, io: Io, parsed: Parsed, observer: boole
368
414
  io.err(`refused: ${why[out.reason] ?? out.reason}. Nothing was changed.`);
369
415
  return EXIT.refused;
370
416
  }
371
- io.out(`Kept ${keep} in the core.`);
417
+ io.out(out.reason === "restored" ? `Put ${keep} back in the core: it had been retired.` : `Kept ${keep} in the core.`);
372
418
  io.out(` Why, as recorded: ${reason.trim()}`);
373
419
  io.out(" It is no longer being reconsidered, and it is not flagged again for what it is — only if it stops coming back.");
374
420
  return EXIT.ok;
@@ -394,6 +440,12 @@ export function coreCommand(dir: string, io: Io, parsed: Parsed, observer: boole
394
440
  io.err(`refused: ${why[out.reason] ?? out.reason}. Nothing was changed.`);
395
441
  return EXIT.refused;
396
442
  }
443
+ if (out.reason === "confirmed") {
444
+ io.out(`A reflection had already retired ${demote}; it is now recorded as your retire.`);
445
+ io.out(` Why, as recorded: ${reason.trim()}`);
446
+ io.out(" It keeps fading, and no session can put it back in the core — only you can (counterparts core --reaffirm).");
447
+ return EXIT.ok;
448
+ }
397
449
  io.out(`Sent ${demote} back to ordinary fading, from today.`);
398
450
  io.out(` Why, as recorded: ${reason.trim()}`);
399
451
  io.out(" It fades like any other memory now, and the core's lanes will not promote it again.");
@@ -111,6 +111,7 @@ import {
111
111
  catchUpEntry,
112
112
  selfPageCommand,
113
113
  dreamCommand,
114
+ nightCommand,
114
115
  coreCommand,
115
116
  claimsEraCommand,
116
117
  settleCommand,
@@ -222,6 +223,10 @@ export const COMMANDS = [
222
223
  // each both reads and writes, so neither is on `OWNER_OPS`: reading works
223
224
  // under observer, and the write refuses at the core's own seam.
224
225
  "dream",
226
+ // Last night, read-only (2026-10-20): a dream or a reflection by id, or the
227
+ // newest. It has no write at all — `dream --undo` stays on `dream` — so a
228
+ // session can run it to review the night with the owner.
229
+ "night",
225
230
  "core",
226
231
  // Contradictions (2026-09-29): what is unsettled and what was settled, and
227
232
  // the owner's settle and undo. Reads and writes, like `dream`; the write
@@ -574,6 +579,7 @@ export const COMMAND_FLAGS: Record<Command, readonly string[]> = {
574
579
  // session does not belong there.
575
580
  "self-page": ["write", "file", "stdin", "short", "reason", "versions", "version", "restore", "clear", "if-version"],
576
581
  dream: ["list", "show", "undo", "all", "setting"],
582
+ night: ["all"],
577
583
  core: ["list", "demote", "reaffirm", "reason", "reflected-feeling"],
578
584
  settle: ["list", "pair", "holds", "against", "how", "why", "undo"],
579
585
  about: ["why"],
@@ -653,6 +659,8 @@ export const COMMAND_BLURB: Record<Command, string> = {
653
659
  "The written page the wake opens with. With no flags it prints the page, its date and its size; --write --file <path> or --write --stdin replaces it whole, keeping every earlier version; --short <file> beside them gives a page past its room the short version sessions read on a day the wake has no room for it whole (alone, with --write, it is added to the page as it stands); --versions lists those and --version <seq> prints one. Reading works under observer; writing refuses there.",
654
660
  dream:
655
661
  "What each dream did, and its undo — and what the waking self made of it. With no flags (or --list), the newest 20 dreams (--list --all for every one): date, state, title and what changed, then the recent reflections; --show <id> prints one dream's journal, every change it made and the reflection after it (--show <rfl_…> prints one reflection: its questions, entry, what it rests on and its morning share); --undo <id> reverses that dream's whole batch (merges come apart, links and gists go, replays and nominations are taken back) and keeps its journal, marked undone — a reflection is lived and stays. Reading works under observer; --undo refuses there.",
662
+ night:
663
+ "Last night, read-only: what a dream did and what the waking self made of it. It changes nothing — it opens the store as an observer, so it runs the same under --observer. With nothing after it (or list), the recent dreams and reflections, newest first (--all for every dream); last prints the newest dream — its journal, every change it made, and the reflection after it (last-reflection: the newest reflection); an id (drm_… or rfl_…) prints that one, and show <id|last> means the same. Undoing a dream stays on `counterparts dream`, the owner's door.",
656
664
  core:
657
665
  "The core — the memories about me and about us that do not fade. With no flags (or --list), what it holds and which lane carried each one there, what dreams have nominated, what is being reconsidered, and what was sent back; --demote <id> --reason \"...\" sends one back to ordinary fading from today, records why, and keeps the lanes from promoting it again; --reaffirm <id> --reason \"...\" keeps one that is being reconsidered (it is not flagged again for what it is); --reflected-feeling on|off opens or closes the core to reflection alone. On (the default): a feeling a reflection records later and a reflection citing a memory both count toward the fast lane, and a reflection may re-label what a memory is about either way — each re-label is recorded with its reason, and one into me, us or the owner is told in the next morning share. Off: nothing reaches the core on a reflection alone — the fast lane needs a feeling felt at the time (not one a reflection recorded later) and an ordinary use after a gap (not a reflection citing it), and a reflection may only move what a memory is about toward work or world. Reading works under observer; the changes refuse there.",
658
666
  settle:
@@ -688,6 +696,7 @@ const COMMAND_ARGS: Partial<Record<Command, string>> = {
688
696
  disconnect: " [claude-code]",
689
697
  help: " [advanced | <command>]",
690
698
  dream: " [--list [--all] | --show <id> | --undo <id>]",
699
+ night: " [list [--all] | last | last-reflection | [show] <drm_…|rfl_…>]",
691
700
  core: " [--demote <id> --reason \"...\" | --reaffirm <id> --reason \"...\" | --reflected-feeling on|off]",
692
701
  settle: " [--list | --pair <id> --holds <id> --how changed|corrected|open --why \"...\" | --undo <pair>]",
693
702
  about: " <id> [me|us|owner|work|world] [--why \"...\"]",
@@ -922,6 +931,11 @@ const DREAM_FLAG_HELP: Record<string, string> = {
922
931
  "auto, ask or off — the nightly run (page writer, dream, reflection). ask (the default): the first session of a day shows you the question in the terminal and waits for you to say \"dream\" (or \"dream on your own\", which turns on auto); auto: the first session of a day starts it by itself, in a separate windowless claude -p in the background, and says so in one line; off: no dreams. `counterparts dream` prints the setting.",
923
932
  };
924
933
 
934
+ /** `night`'s one flag (2026-10-20): `--all` means something else on other pages. */
935
+ const NIGHT_FLAG_HELP: Record<string, string> = {
936
+ all: "with the list: every dream the store holds, not only the newest 20",
937
+ };
938
+
925
939
  /** `settle`'s own seven (2026-09-29): `--list` and `--undo` mean something else on other pages. */
926
940
  const SETTLE_FLAG_HELP: Record<string, string> = {
927
941
  list: "what is unsettled, and what was settled lately — the default",
@@ -1015,6 +1029,8 @@ export function commandHelp(command: Command): string {
1015
1029
  ? HOST_FLAG_HELP
1016
1030
  : command === "dream"
1017
1031
  ? DREAM_FLAG_HELP
1032
+ : command === "night"
1033
+ ? NIGHT_FLAG_HELP
1018
1034
  : command === "core"
1019
1035
  ? CORE_FLAG_HELP
1020
1036
  : command === "claims-era"
@@ -1679,6 +1695,8 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
1679
1695
  );
1680
1696
  case "dream":
1681
1697
  return dreamCommand(dir, io, parsed, observer, typeof parsed.flags["dir"] === "string");
1698
+ case "night":
1699
+ return nightCommand(dir, io, parsed, typeof parsed.flags["dir"] === "string");
1682
1700
  case "core":
1683
1701
  return coreCommand(dir, io, parsed, observer, typeof parsed.flags["dir"] === "string");
1684
1702
  case "claims-era":
@@ -67,7 +67,7 @@ export const DREAM_LIST_LIMIT = 20;
67
67
  * (`limit: "all"`). The header says how many of how many, so a list that stops
68
68
  * is never read as all there is.
69
69
  */
70
- export function dreamListLines(counterpart: Counterpart, limit: number | "all" = DREAM_LIST_LIMIT): string[] {
70
+ export function dreamListLines(counterpart: Counterpart, limit: number | "all" = DREAM_LIST_LIMIT, via: "dream" | "night" = "dream"): string[] {
71
71
  const total = counterpart.store.dreamCount();
72
72
  const dreams = counterpart.dreams.list(limit === "all" ? Math.max(1, total) : limit);
73
73
  const setting = counterpart.dreams.setting();
@@ -79,7 +79,7 @@ export function dreamListLines(counterpart: Counterpart, limit: number | "all" =
79
79
  const out = [
80
80
  ...head,
81
81
  dreams.length < total
82
- ? `Dreams — newest first (${String(dreams.length)} of ${String(total)} shown; every one: counterparts dream --list --all)`
82
+ ? `Dreams — newest first (${String(dreams.length)} of ${String(total)} shown; every one: counterparts ${via === "night" ? "night --all" : "dream --list --all"})`
83
83
  : `Dreams — newest first (all ${String(dreams.length)})`,
84
84
  "",
85
85
  ];
@@ -88,12 +88,18 @@ export function dreamListLines(counterpart: Counterpart, limit: number | "all" =
88
88
  const title = dream.title === null || dream.title.length === 0 ? "(no journal)" : `"${dream.title}"`;
89
89
  out.push(`${dream.id} ${when} ${dream.state.padEnd(9)} ${title} — ${countsLine(counts)}`);
90
90
  }
91
- out.push("", "Read one: counterparts dream --show <id> Reverse one: counterparts dream --undo <id>");
91
+ // From `night` (2026-10-20), the read-only door, the pointer stays on it.
92
+ out.push(
93
+ "",
94
+ via === "night"
95
+ ? "Read one: counterparts night <id> (or last) Undo one (the owner's): counterparts dream --undo <id>"
96
+ : "Read one: counterparts dream --show <id> Reverse one: counterparts dream --undo <id>",
97
+ );
92
98
  const reflections = counterpart.reflections.list(10);
93
99
  if (reflections.length > 0) {
94
100
  out.push("", `Reflections — the waking self, newest first (${String(reflections.length)} shown)`, "");
95
101
  for (const r of reflections) out.push(`${r.id} ${r.date ?? `lived day ${String(r.day)}`} ${reflectionSummary(r)}`);
96
- out.push("", "Read one: counterparts dream --show <rfl_…>");
102
+ out.push("", via === "night" ? "Read one: counterparts night <rfl_…>" : "Read one: counterparts dream --show <rfl_…>");
97
103
  }
98
104
  return out;
99
105
  }
@@ -177,7 +183,11 @@ export function reflectionShowLines(counterpart: Counterpart, id: string): strin
177
183
  "",
178
184
  r.entry === null ? "Entry: (not written)" : "Entry:",
179
185
  ];
180
- if (r.entry !== null) for (const line of r.entry.split("\n")) out.push(` ${line}`);
186
+ // The entry is the body of the memory it became: marked confidential since,
187
+ // it prints as that row does (review of #538 — `night` is run by sessions).
188
+ const entryHidden = r.entry_id !== null && counterpart.store.row(r.entry_id)?.confidential === 1;
189
+ if (r.entry !== null && entryHidden) out.push(" [confidential]");
190
+ else if (r.entry !== null) for (const line of r.entry.split("\n")) out.push(` ${line}`);
181
191
  if (r.entry_id !== null) out.push(` (kept as memory ${r.entry_id})`);
182
192
  const cites = parseIdList(r.cites);
183
193
  if (cites.length > 0) {
@@ -236,7 +246,7 @@ export function coreListLines(counterpart: Counterpart): string[] {
236
246
  : `The core — ${String(core.length)} ${core.length === 1 ? "memory" : "memories"} that do not fade`,
237
247
  ];
238
248
  for (const m of core) {
239
- const how = m.lane === null ? "(before lanes, or by revision)" : `${m.lane} lane${m.day === null ? "" : `, lived day ${String(m.day)}`}`;
249
+ const how = m.lane === null ? "(before lanes, or by revision)" : m.lane === "restored" ? `restored after it was retired${m.day === null ? "" : `, lived day ${String(m.day)}`}` : `${m.lane} lane${m.day === null ? "" : `, lived day ${String(m.day)}`}`;
240
250
  const said = m.confidential ? "[confidential]" : (m.body ?? "(unreadable)");
241
251
  out.push(` ${m.id} ${m.kind.padEnd(6)} ${how} — ${said}`);
242
252
  }
@@ -130,6 +130,7 @@ export const SHORT: Record<string, string | readonly string[]> = {
130
130
  mechanisms: "Which parts of memory are working, one line each",
131
131
  log: "What happened today, in order, one line each (kept 7 days)",
132
132
  dream: "What each dream did — and undo one",
133
+ night: "Last night's dream and reflection, read-only",
133
134
  core: "What became part of who I am — and send one back",
134
135
  settle: "Two memories that disagree: which holds — and undo one",
135
136
  about: "What a memory is about — and change it",
@@ -185,6 +186,7 @@ export const ADVANCED: readonly string[] = [
185
186
  "mechanisms",
186
187
  "log",
187
188
  "dream",
189
+ "night",
188
190
  "core",
189
191
  "settle",
190
192
  "about",
@@ -72,8 +72,11 @@ it; `version` is `package.json#version`, or null when unreadable. `/api/onboardi
72
72
  the same `store` field. The dashboard only reads the salt (E7): `store` is null until a
73
73
  session-start wake has minted it. The id is stable across opens, differs between stores,
74
74
  and never carries the path; a store moved to another path reads as another store.
75
- **[M]** The session-start wake of a Claude Code hook carries the same id on the line under
76
- the onboarding marker: `<!-- counterparts:store id=st_… -->`. The sidebar mod compares the
75
+ **[M]** The session-start wake of a Claude Code hook carries the same id: since 2026-10-20 as
76
+ the `store=st_…` field of the wake's head tag (`<!-- counterparts:wake meet=… store=st_…
77
+ elements=… bytes=… -->`, or `<!-- counterparts:session … -->` before a wake with no head tag;
78
+ `adapters/store-id.ts#ONE_TAG`), before that as `<!-- counterparts:store id=st_… -->` beside
79
+ the onboarding marker. The sidebar mod reads every form, compares the
77
80
  two and trusts a dashboard only when they match. Nothing about which port is chosen changed.
78
81
 
79
82
  ## 6. Scars honored
@@ -942,6 +942,10 @@ export const NARRATORS = {
942
942
  : ` ${String(total)} more ${total === 1 ? "was" : "were"} kept out (most often ${worst[0]}).`;
943
943
  if (s(t, "path") === "handle") {
944
944
  const opened = n(t, "expanded") ?? 0;
945
+ const nights = n(t, "nights") ?? 0;
946
+ if (opened === 0 && nights > 0) {
947
+ return calm(`${nights === 1 ? "A dream or a reflection was" : `${String(nights)} dreams or reflections were`} read back by id.${stopped}`);
948
+ }
945
949
  return calm(
946
950
  opened === 0
947
951
  ? `Something was asked for by name and I had nothing at that address.${stopped}`