counterparts 0.3.2 → 0.3.3

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 (66) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/package.json +1 -1
  3. package/src/adapters/claude-code/NOTES.md +12 -0
  4. package/src/adapters/claude-code/bin/hook.ts +85 -22
  5. package/src/adapters/claude-code/config.ts +7 -0
  6. package/src/adapters/claude-code/doctor.ts +20 -4
  7. package/src/adapters/claude-code/hooks.ts +157 -6
  8. package/src/adapters/claude-code/index.ts +3 -0
  9. package/src/adapters/cli/commands.ts +11 -0
  10. package/src/adapters/cli/mechanisms.ts +46 -21
  11. package/src/adapters/dashboard/registries.ts +4 -0
  12. package/src/adapters/dashboard/web/README.md +19 -11
  13. package/src/adapters/dashboard/web/flow.ts +2 -0
  14. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +9 -5
  15. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +6 -3
  16. package/src/adapters/dashboard/web/narrate.ts +8 -0
  17. package/src/adapters/dashboard/web/pages/health/sections/checks.js +17 -1
  18. package/src/adapters/dashboard/web/pages/self/index.js +55 -16
  19. package/src/adapters/dashboard/web/pages/self/sections/journal.js +75 -19
  20. package/src/adapters/dashboard/web/pages/self/sections/page.js +108 -65
  21. package/src/adapters/dashboard/web/pages/self/sections/settling.js +94 -99
  22. package/src/adapters/dashboard/web/pages/self/sections/wake.js +31 -15
  23. package/src/adapters/dashboard/web/pages/self/self.css +119 -59
  24. package/src/adapters/dashboard/web/pages/self/state.js +23 -0
  25. package/src/adapters/dashboard/web/pages/self/tips.js +50 -0
  26. package/src/adapters/dashboard/web/shared/memory-modal.js +9 -0
  27. package/src/adapters/dashboard/web/views/mechanisms.ts +85 -14
  28. package/src/adapters/dashboard/web/views/memory.ts +15 -1
  29. package/src/adapters/dashboard/web/views/mind.ts +130 -6
  30. package/src/adapters/feelings-line.ts +74 -0
  31. package/src/adapters/fired.ts +78 -18
  32. package/src/adapters/mcp/CONTRACT.md +8 -0
  33. package/src/adapters/mcp/NOTES.md +45 -0
  34. package/src/adapters/mcp/server.ts +165 -6
  35. package/src/adapters/mcp/tools.ts +51 -4
  36. package/src/core/bridge.ts +21 -16
  37. package/src/core/counterpart.ts +309 -6
  38. package/src/core/encode/CONTRACT.md +7 -1
  39. package/src/core/feelings-wheel.ts +171 -13
  40. package/src/core/mint.ts +9 -0
  41. package/src/core/physics/CONTRACT.md +43 -0
  42. package/src/core/physics/NOTES.md +94 -0
  43. package/src/core/physics/index.ts +98 -6
  44. package/src/core/prospective/CONTRACT.md +35 -6
  45. package/src/core/prospective/INTERFACE-GAPS.md +10 -5
  46. package/src/core/prospective/NOTES.md +175 -4
  47. package/src/core/prospective/derive.ts +32 -3
  48. package/src/core/prospective/index.ts +362 -39
  49. package/src/core/prospective/tunables.ts +18 -1
  50. package/src/core/prospective/windows.ts +104 -46
  51. package/src/core/recall/CONTRACT.md +28 -0
  52. package/src/core/recall/NOTES.md +39 -0
  53. package/src/core/recall/activate.ts +32 -5
  54. package/src/core/recall/gate.ts +7 -1
  55. package/src/core/recall/index.ts +19 -0
  56. package/src/core/recall/mood.ts +106 -0
  57. package/src/core/recall/tunables.ts +26 -0
  58. package/src/core/remember/index.ts +1 -0
  59. package/src/core/remember/proposals.ts +86 -3
  60. package/src/core/self/identity.ts +20 -1
  61. package/src/core/store/CONTRACT.md +9 -2
  62. package/src/core/store/NOTES.md +20 -0
  63. package/src/core/store/feelings.ts +23 -6
  64. package/src/core/store/index.ts +107 -10
  65. package/src/core/store/operational.ts +15 -1
  66. package/src/core/types.ts +9 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3 — 2026-09-26
4
+
5
+ Reminders with dates, and feelings start to matter. The store's format is unchanged (still
6
+ v7), so there is no upgrade step; close every Claude Code session before installing, and
7
+ run `/mcp` → Reconnect in any you missed.
8
+
9
+ Reminders work.
10
+
11
+ - **A memory can carry a date, and it comes back around then.** `note` and each
12
+ `session_end` memory take an optional `eventDate`: a day `2026-10-15`, a month
13
+ `2026-10`, or a range `2026-10-20..2026-10-31` (how to say "late October"). Claude writes
14
+ the date itself; nothing is read out of the text, and a date that cannot be read is
15
+ refused with the shapes that can. A year alone is kept but never comes back on its own.
16
+ - **Plain or quiet.** Beside the date, `remind: "plain"` for something that really has to
17
+ happen — a deadline, an important day, or anything you say not to forget. On its day
18
+ you see it in the terminal (`Today: pay your taxes`) and Claude has it in context, once;
19
+ a month or a range is said on its first day and again on its last. Everything else is
20
+ quiet, the default: it can come back as a footnote around the date, at most twice.
21
+ Giving a memory a date is what makes it eligible, however ordinary the memory; one that
22
+ has faded away or been archived still never comes back.
23
+ - **A plain line is spent only when you can see it.** If the morning's wake is too full
24
+ for the terminal line, it waits for your first prompt instead of being used up unseen,
25
+ and the update notice never pushes it out.
26
+ - **A quiet reminder is not repeated every turn.** A footnote that came back spends one of
27
+ its two mentions, at most one a day. Month and range dates spread their warmth over the
28
+ first week instead of all landing on the 1st, keep their second mention for after the
29
+ dates pass, and never take one of the wake's two "Arriving" lines — those are for
30
+ day-dated things, and a tie goes to the one happening sooner.
31
+ - **The gauge shows it.** `counterparts mechanisms` and the dashboard's Prospective light
32
+ count dated memories held and reminders that came back this week, plain and quiet apart
33
+ (the dashboard adds today's). Grey only when nothing is dated.
34
+ - **Revising a dated memory keeps its date.** A revision (`updates:`) that leaves the date
35
+ or `remind` out carries them over, and the older memory stops coming back, so one
36
+ reminder is never said twice; `eventDate: null` drops the date. The reminder is found
37
+ where it moved even when a later revision names the older memory, and what was already
38
+ said or used for the same window still counts after the move.
39
+ - **A date that has already passed is kept, and the reply says it won't come back**, so a
40
+ wrong year can be caught when it is written.
41
+
42
+ **Feelings start to matter.** No change to the store's format.
43
+
44
+ - **A memory's strongest feeling holds it higher and makes it fade more slowly** — yours or
45
+ Claude's, or its emotional score if that is stronger. This changes how existing memories
46
+ fade too: the ones that carry feeling now last longer (a strongly felt note about 1.7
47
+ times as long before it is let go). The first nightly cleanup after upgrading may move a
48
+ few felt memories up a band. Feeling does not count toward becoming core: what it takes
49
+ to reach identity is unchanged.
50
+ - **A recorded feeling softens faster than the memory it sits on.** The feeling is kept as
51
+ it was recorded; the softened strength is what recall and the displays read.
52
+ - **Mood-matching.** When a feeling was recorded in the last few hours, memories that
53
+ carried the same feeling for the same person come to mind more easily, and the other
54
+ person's matching feelings help a little. It only helps a memory the conversation
55
+ already reached — it never brings up one on its own.
56
+ - **An emotional score given on its own is no longer ignored by the memory gate.**
57
+ - **More words on the feelings wheel**, from real use: grateful, curious, tender,
58
+ sheepish, relieved, moved, wistful, bittersweet, fond and intrigued (marked as
59
+ additions, not the poster's), and "exposed" reads as vulnerable. Blends count under
60
+ both their feelings (tender: sad and happy). A word that is not on the wheel is kept as
61
+ your own, and the reply suggests a wheel word only for a near misspelling — "tender" is
62
+ no longer offered "despair".
63
+ - **Showing it.** The dashboard's memory view and `counterparts ask --full` / `--id` show a
64
+ memory's feelings as `you: … · me: …`. The Emotion light on the dashboard and in
65
+ `counterparts mechanisms` now counts memories carrying feeling and turns where a mood
66
+ brought memories closer.
67
+
68
+ **The dashboard's Self tab, round 2.** Lighter: one line on top, with the explanations
69
+ behind a small `?`. Beside the page, a side column says when it was last rewritten, what
70
+ the page writer did on its last night, the version dots and how much of the wake it
71
+ takes. A version's changes open on a click, settling is one compact chart, the journal is
72
+ a strip of days, and the tab refreshes itself while it is open. The Health row says how
73
+ many days since the page was rewritten.
74
+
3
75
  ## 0.3.2 — 2026-09-25
4
76
 
5
77
  Dates and times follow your clock, and the store's format moves to v7.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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": {
@@ -1593,3 +1593,15 @@ What the build settled, beyond the CONTRACT section:
1593
1593
  - **Review of #231, S1 (2026-09-25):** the evening of the upgrade no longer turns doctor
1594
1594
  RED. The store holds a one-day-back date as the same lived day, and the migration
1595
1595
  clamps `lastActiveDate`; details are in store NOTES.
1596
+
1597
+ ## 2026-09-26 — plain reminders are claimed only once the envelope carries them (PR #243 review)
1598
+
1599
+ Plain reminder lines ("Today: pay your taxes") now go FIRST among the terminal notices,
1600
+ ahead of the doctor's red line, and are claimed only after `bin/hook.ts#deliverTurn` has
1601
+ probed the envelope and found room for them — the update notice's "mark only what is
1602
+ certainly leaving". The priority order above still holds for the notices that follow them.
1603
+ The reason for going first: the doctor's line returns at the next start, while a plain
1604
+ beat is spent once. A full wake (the ~9 KB case above) therefore defers the plain lines —
1605
+ unclaimed, and stripped from the model's copy too (`hooks.ts#withoutPlain`) — to the first
1606
+ prompt, whose envelope is small. When a plain line and the update notice do not fit
1607
+ together at a prompt, the update notice waits. Details: `docs/adversarial-review-pr243-2026-09-26.md`.
@@ -34,12 +34,13 @@ import {
34
34
  stanceOfMode,
35
35
  } from "../../scopes.js";
36
36
  import type { ScopeRead, ScopeVerdict } from "../../scopes.js";
37
- import { canonicalScope, readSession } from "../../sessions.js";
37
+ import { PAGE_WRITER_ENV, canonicalScope, readSession } from "../../sessions.js";
38
38
  import { resolveZone, todayIn } from "../../../core/time.js";
39
39
  import { loadConfig, withEmbedderDefault } from "../config.js";
40
40
  import type { AdapterConfig } from "../config.js";
41
41
  import { HOOKS, openAdapter } from "../index.js";
42
- import { STOP_HUMAN_LINE } from "../hooks.js";
42
+ import { STOP_HUMAN_LINE, plainLine, withoutPlain } from "../hooks.js";
43
+ import type { PlainReminder } from "../../../core/counterpart.js";
43
44
  import type { HookInput, HookName } from "../hooks.js";
44
45
  import {
45
46
  CONFIG_REFUSED,
@@ -393,6 +394,9 @@ export function toHookInput(
393
394
  // nothing (`hooks.ts#askAtStop`).
394
395
  ...(payload["stop_hook_active"] === true ? { reFired: true } : {}),
395
396
  ...(typeof payload["prompt"] === "string" ? { prompt: payload["prompt"] } : {}),
397
+ // The host-mode page writer's headless child (`page-writer.ts` sets this):
398
+ // no one reads its terminal, so it must not spend a plain reminder's beat.
399
+ ...(((opts.env ?? process.env)[PAGE_WRITER_ENV] ?? "").trim().length > 0 ? { pageWriter: true } : {}),
396
400
  // THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
397
401
  // hook's rows, the wake preface, the prospective "today" and the date the
398
402
  // boundary hands the lived clock — which is why the lived clock can see a
@@ -739,6 +743,11 @@ async function runHook(
739
743
  // AND THE UPDATE NOTICE AT A PROMPT (roadmap E, 2026-09-23), fail-open
740
744
  // (`deliverTurn`): once per session, when the MCP server this session talks
741
745
  // to runs an older build than this installed one.
746
+ //
747
+ // AND PLAIN REMINDERS (2026-09-26), at both events, FIRST — `deliverTurn`
748
+ // adds them from `result.plain` and claims them only once the envelope is
749
+ // known to carry them (2026-09-26 review): a plain beat is spent once and
750
+ // never comes back, while the doctor's line returns at the next start.
742
751
  const delivery = deliverTurn(
743
752
  name,
744
753
  result,
@@ -783,38 +792,92 @@ async function runHook(
783
792
  export interface UpdateNoticeDoors {
784
793
  updateNotice(input: HookInput): string | null;
785
794
  markUpdateNotice(input: HookInput): boolean;
795
+ /**
796
+ * Claim plain reminders this delivery is certainly about to show, returning
797
+ * the ones claimed (`ClaudeCodeAdapter#claimPlain`). Absent: nothing can be
798
+ * claimed, so nothing is shown and every one waits for a later turn.
799
+ */
800
+ claimPlain?(input: HookInput, due: readonly PlainReminder[]): readonly PlainReminder[];
786
801
  }
787
802
 
788
803
  /**
789
- * THIS EVENT'S OUTPUT, WITH THE UPDATE NOTICE FOLDED IN FAIL-OPEN (roadmap E;
790
- * #187 re-review, N4).
804
+ * THIS EVENT'S OUTPUT, WITH PLAIN REMINDERS AND THE UPDATE NOTICE FOLDED IN
805
+ * FAIL-OPEN (roadmap E; #187 re-review, N4; 2026-09-26 review).
791
806
  *
792
- * The plain delivery is computed first and is the answer whenever anything
793
- * about the notice goes wrong: a door that throws, a mark that will not land.
794
- * The notice is MARKED only once it is certainly leaving — after the envelope
795
- * is known to carry it — and SHOWN only if the mark landed, so it never repeats
796
- * and is never marked-but-lost; a turn whose recall leaves no room drops it,
797
- * marks nothing, and tries again next turn. Every event but
798
- * `user-prompt-submit` is exactly `hostDelivery`.
807
+ * PLAIN REMINDERS FIRST, and under the update notice's own rule — MARK ONLY
808
+ * WHAT IS CERTAINLY LEAVING. A plain beat is spent once and never comes back,
809
+ * so it is claimed only after the envelope is known to carry its line to the
810
+ * terminal, and it goes ahead of every other notice (the doctor's red line
811
+ * returns at the next start; the beat would not). A turn with no room — a full
812
+ * wake at SessionStart — claims nothing and strips the lines from the model's
813
+ * context too (`withoutPlain`), so the first prompt, whose envelope is small,
814
+ * says them instead. A line whose claim is lost to another process is stripped
815
+ * the same way.
816
+ *
817
+ * Then the update notice: the delivery without it is the answer whenever
818
+ * anything about it goes wrong — a door that throws, a mark that will not
819
+ * land, an envelope with no room for it — so it can never cost a line that
820
+ * already fit. It is MARKED only once it is certainly leaving and SHOWN only if
821
+ * the mark landed, so it never repeats and is never marked-but-lost; a turn
822
+ * whose recall leaves no room marks nothing and tries again next turn.
799
823
  */
800
824
  export function deliverTurn(
801
825
  name: HookName,
802
- result: { injection: string | null; ask: string | null },
826
+ result: {
827
+ injection: string | null;
828
+ ask: string | null;
829
+ notices?: readonly string[];
830
+ plain?: readonly PlainReminder[];
831
+ },
803
832
  payload: Record<string, unknown>,
804
- sessionStartNotices: readonly (string | null)[] | null,
833
+ /** SessionStart's priority-ordered notices (after any plain reminders), or
834
+ * null. At a prompt, null: the plain lines come from `result.plain`. */
835
+ notices: readonly (string | null)[] | null,
805
836
  doors: UpdateNoticeDoors,
806
837
  input: HookInput,
807
838
  ): Delivery {
808
- const plain = hostDelivery(name, result, payload, sessionStartNotices);
809
- if (name !== "user-prompt-submit") return plain;
839
+ let r = result;
840
+ let ordered = notices;
841
+ let deferred: Delivery["dropped"] = null;
842
+ const due = result.plain ?? [];
843
+ if (due.length > 0) {
844
+ // The longest run, in order, whose lines the envelope carries: a day with
845
+ // more plain items than room says what fits and keeps the rest for later.
846
+ let fits = 0;
847
+ for (let k = due.length; k > 0; k--) {
848
+ const probe = hostDelivery(name, r, payload, [due.slice(0, k).map(plainLine).join("\n")]);
849
+ if (probe.dropped === null) {
850
+ fits = k;
851
+ break;
852
+ }
853
+ if (k === due.length) deferred = probe.dropped;
854
+ }
855
+ let claimed: readonly PlainReminder[] = [];
856
+ if (fits > 0) {
857
+ try {
858
+ claimed = doors.claimPlain?.(input, due.slice(0, fits)) ?? [];
859
+ } catch {
860
+ claimed = [];
861
+ }
862
+ }
863
+ // By the beat's identity, not the object's: a door may hand back copies.
864
+ const beat = (x: PlainReminder): string => `${x.memoryId} ${x.windowKey} ${x.beat}`;
865
+ const kept = new Set(claimed.map(beat));
866
+ const shownPlain = due.filter((d) => kept.has(beat(d)));
867
+ r = withoutPlain(r, due.filter((d) => !kept.has(beat(d))));
868
+ if (shownPlain.length > 0) ordered = [shownPlain.map(plainLine).join("\n"), ...(notices ?? [])];
869
+ }
870
+ const shown = hostDelivery(name, r, payload, ordered);
871
+ const base = shown.dropped === null && deferred !== null ? { ...shown, dropped: deferred } : shown;
872
+ if (name !== "user-prompt-submit") return base;
810
873
  try {
811
874
  const update = doors.updateNotice(input);
812
- if (update === null) return plain;
813
- const carried = hostDelivery(name, result, payload, update);
814
- if (carried.dropped !== null) return carried;
815
- return doors.markUpdateNotice(input) ? carried : plain;
875
+ if (update === null) return base;
876
+ const carried = hostDelivery(name, r, payload, [...(ordered ?? []), update]);
877
+ if (carried.dropped !== null) return { ...base, dropped: base.dropped ?? carried.dropped };
878
+ return doors.markUpdateNotice(input) ? carried : base;
816
879
  } catch {
817
- return plain;
880
+ return base;
818
881
  }
819
882
  }
820
883
 
@@ -890,7 +953,7 @@ export function hostDelivery(
890
953
  * each is added only while the envelope still fits, so a lower line can never
891
954
  * cost a higher one its place. At a prompt the lines are ALL OR NOTHING —
892
955
  * joined into one `systemMessage`, or all dropped — which is what lets
893
- * `deliverTurn` mark only an envelope that carried them; today there is one.
956
+ * `deliverTurn` mark only an envelope that carried them; since 2026-09-26 that is plain reminders and the update notice.
894
957
  */
895
958
  notice: string | null | readonly (string | null)[] = null,
896
959
  ): Delivery {
@@ -935,7 +998,7 @@ export function hostDelivery(
935
998
  // no notice prints what it always has — plain text, or nothing. More than
936
999
  // one line would be JOINED into the one `systemMessage` an object carries,
937
1000
  // never one replacing another, and dropped all together or not at all —
938
- // not SessionStart's priority order; today the update notice is the only one.
1001
+ // not SessionStart's priority order; since 2026-09-26 the plain reminders and the update notice (`deliverTurn` tries the two together and falls back to the first alone).
939
1002
  if (name === "user-prompt-submit" && notices.length > 0) {
940
1003
  const message = notices.join("\n");
941
1004
  const envelope = JSON.stringify({
@@ -80,6 +80,13 @@ export const TUNABLES = {
80
80
  * own — and nothing here is at the Stop, where §13 G3's one pacer lives.
81
81
  */
82
82
  WRITE_UP_ASKS_PER_DAY: 2,
83
+ /**
84
+ * A plain reminder's handle — the memory's title or first line — is clipped
85
+ * to this many characters in the line a person reads (2026-09-26). One
86
+ * glance's worth: a longer title is a paragraph, and the memory's id rides
87
+ * beside it in the model's copy.
88
+ */
89
+ PLAIN_WHAT_MAX_CHARS: 120,
83
90
  /**
84
91
  * The host's cap on a hook's whole output, in characters. The host's own
85
92
  * words: "Hook output strings, including `additionalContext`, `systemMessage`,
@@ -2376,7 +2376,17 @@ export function selfPageFindings(store: Store): Finding[] {
2376
2376
  const detail =
2377
2377
  `${page.bytes} bytes, version ${page.version}, last revised ${page.revisedOn === "" ? "(unrecorded)" : page.revisedOn}` +
2378
2378
  `${page.by === null ? "" : ` by ${page.by}`}`;
2379
- const data = { present: true, bytes: page.bytes, version: page.version, revisedOn: page.revisedOn, stale };
2379
+ // The day count and the limit ride along so a surface can say it in words
2380
+ // ("not rewritten in 16 days") without re-deriving either (dashboard health).
2381
+ const data = {
2382
+ present: true,
2383
+ bytes: page.bytes,
2384
+ version: page.version,
2385
+ revisedOn: page.revisedOn,
2386
+ stale,
2387
+ daysSince: calendarDaysSince(page.revisedOn, store.today()),
2388
+ staleAfter: SELF_TUNABLES.PAGE_STALE_DAYS,
2389
+ };
2380
2390
  return [
2381
2391
  stale
2382
2392
  ? finding(
@@ -2561,12 +2571,18 @@ function clearedPage(
2561
2571
  * two are asserted to agree.
2562
2572
  */
2563
2573
  function pageStaleOn(revisedOn: string, today: string, limit: number): boolean {
2574
+ const days = calendarDaysSince(revisedOn, today);
2575
+ return days === null ? true : days > limit;
2576
+ }
2577
+
2578
+ /** Calendar days from `revisedOn` to `today`; null when either does not read. */
2579
+ function calendarDaysSince(revisedOn: string, today: string): number | null {
2564
2580
  const on = revisedOn.trim();
2565
- if (!/^\d{4}-\d{2}-\d{2}$/.test(on) || !/^\d{4}-\d{2}-\d{2}$/.test(today)) return true;
2581
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(on) || !/^\d{4}-\d{2}-\d{2}$/.test(today)) return null;
2566
2582
  const a = Date.parse(`${on}T00:00:00Z`);
2567
2583
  const b = Date.parse(`${today}T00:00:00Z`);
2568
- if (!Number.isFinite(a) || !Number.isFinite(b)) return true;
2569
- return Math.round((b - a) / 86_400_000) > limit;
2584
+ if (!Number.isFinite(a) || !Number.isFinite(b)) return null;
2585
+ return Math.round((b - a) / 86_400_000);
2570
2586
  }
2571
2587
 
2572
2588
  /**
@@ -51,7 +51,7 @@ import {
51
51
  WAKE_DELIVERED_EVENT,
52
52
  WAKE_INJECTED_EVENT,
53
53
  } from "../../core/counterpart.js";
54
- import type { AdapterDurableEventName } from "../../core/counterpart.js";
54
+ import type { AdapterDurableEventName, PlainReminder } from "../../core/counterpart.js";
55
55
  import type {
56
56
  BoundaryKind,
57
57
  CaptureResult,
@@ -98,7 +98,7 @@ import {
98
98
  writerInstruction,
99
99
  writerInstructionOverhead,
100
100
  } from "../../core/self/index.js";
101
- import { localClock, localDate } from "../../core/time.js";
101
+ import { localClock, localDate, readableDate } from "../../core/time.js";
102
102
  import { capabilities, pageWriterMode } from "./config.js";
103
103
  import { TUNABLES } from "./config.js";
104
104
  import type { AdapterConfig, CapabilityReport } from "./config.js";
@@ -167,6 +167,13 @@ export interface HookInput {
167
167
  readonly model?: string;
168
168
  /** Today's calendar date, for the temporal channel and the horizon lane. */
169
169
  readonly at?: string;
170
+ /**
171
+ * This session is the host-mode NIGHTLY PAGE WRITER this package started
172
+ * (`page-writer.ts`, `COUNTERPARTS_PAGE_WRITER` in its environment): a
173
+ * headless `claude -p` nobody watches. A plain reminder is never claimed in
174
+ * it — its beat would be spent on a terminal no one reads (2026-09-26 review).
175
+ */
176
+ readonly pageWriter?: boolean;
170
177
  /**
171
178
  * THE HOST'S RE-FIRE. A blocked Stop comes back with `stop_hook_active`, and
172
179
  * that pass must ask nothing — v1's anti-loop, kept for the same reason. It is
@@ -220,6 +227,21 @@ export interface HookResult {
220
227
  readonly spansAppended: number;
221
228
  readonly spawn: SpawnOutcome | null;
222
229
  readonly observer: boolean;
230
+ /**
231
+ * Lines for the PERSON — the host's `systemMessage`, which their terminal
232
+ * shows (`bin/hook.ts#hostDelivery`). Today only plain reminders
233
+ * (`Counterpart.plainDueToday`, 2026-09-26), at SessionStart and at a
234
+ * prompt; absent when there are none. The same lines also ride in
235
+ * `injection` (`plainContextLine`), for the model, so it can raise them.
236
+ *
237
+ * NOT YET CLAIMED (2026-09-26 review): `plain` is the records behind these
238
+ * lines, in the same order, and the delivery claims them only once it knows
239
+ * the envelope carries them (`bin/hook.ts#deliverTurn` → `claimPlain`); what
240
+ * it cannot carry, or loses the race for, is stripped (`withoutPlain`) and
241
+ * waits for the next prompt.
242
+ */
243
+ readonly notices?: readonly string[];
244
+ readonly plain?: readonly PlainReminder[];
223
245
  }
224
246
 
225
247
  export interface AdapterEvent {
@@ -698,7 +720,13 @@ export class ClaudeCodeAdapter {
698
720
  // the delivery check finds its sentinels by prefix, not by line number.
699
721
  // It is counted wherever the host's ceiling is: the over-budget event
700
722
  // and the room an ask may take both measure `sent`, not `woke.bytes`.
701
- const lead = woke.text.length === 0 ? "" : `${this.nowLine()}\n`;
723
+ // PLAIN REMINDERS DUE TODAY (2026-09-26) ride right under the clock, outside
724
+ // the wake block like the clock itself, and go to the person too
725
+ // (`notices`). NOT claimed here: the delivery claims them once it knows
726
+ // the envelope carries them, and a full wake that leaves no room sends
727
+ // them to the first prompt instead (`bin/hook.ts#deliverTurn`).
728
+ const plain = this.plainFor(input);
729
+ const lead = `${woke.text.length === 0 && plain.context.length === 0 ? "" : `${this.nowLine()}\n`}${plain.context}`;
702
730
  const sent = woke.bytes + Buffer.byteLength(lead, "utf8");
703
731
  if (budget !== undefined && sent > budget) {
704
732
  // Exceeding a reported limit is an EVENT, never silent degradation. The
@@ -767,6 +795,7 @@ export class ClaudeCodeAdapter {
767
795
  bytes: woke.bytes,
768
796
  sentinel: woke.sentinel,
769
797
  ask: asks.length === 0 ? null : asks,
798
+ ...(plain.due.length === 0 ? {} : { notices: plain.notices, plain: plain.due }),
770
799
  };
771
800
  });
772
801
  }
@@ -1208,9 +1237,14 @@ export class ClaudeCodeAdapter {
1208
1237
  return { ...out, ok: true, reason: "primacy-standdown" };
1209
1238
  }
1210
1239
  this.checkWakeArrival(input);
1240
+ // A plain reminder whose day began while this session was already open —
1241
+ // the session that runs past midnight — or that SessionStart had no room
1242
+ // for, is said at the next prompt, once (claimed at delivery).
1243
+ const plain = this.plainFor(input);
1244
+ const told = plain.due.length === 0 ? {} : { notices: plain.notices, plain: plain.due };
1211
1245
  const text = input.prompt ?? "";
1212
1246
  if (text.trim().length === 0) {
1213
- return { ...out, ok: true, reason: "empty-prompt", injection: this.nowLine() };
1247
+ return { ...out, ok: true, reason: "empty-prompt", injection: `${this.nowLine()}${plain.context.length === 0 ? "" : `\n${plain.context.trimEnd()}`}`, ...told };
1214
1248
  }
1215
1249
  const result = this.counterpart.recallForTurn(
1216
1250
  {
@@ -1220,7 +1254,11 @@ export class ClaudeCodeAdapter {
1220
1254
  ? {}
1221
1255
  : { budgetBytes: this.config.injectionBudgetBytes }),
1222
1256
  },
1223
- { ...(input.at === undefined ? {} : { at: input.at }) },
1257
+ {
1258
+ ...(input.at === undefined ? {} : { at: input.at }),
1259
+ // Said outright this turn, so not ALSO handed over as a quiet cue.
1260
+ ...(plain.due.length === 0 ? {} : { withhold: new Set(plain.due.map((r) => r.memoryId)) }),
1261
+ },
1224
1262
  );
1225
1263
  const decision = result.decision;
1226
1264
  // The recall block states its own sentinel too, and nothing checks it: the
@@ -1251,13 +1289,17 @@ export class ClaudeCodeAdapter {
1251
1289
  // session can run for hours. One line ABOVE the recall note when there
1252
1290
  // is one, outside it like the wake's, so the note's byte count and
1253
1291
  // sentinel stand; alone when recall surfaced nothing.
1254
- injection: result.injection.length === 0 ? this.nowLine() : `${this.nowLine()}\n${result.injection}`,
1292
+ injection:
1293
+ result.injection.length === 0
1294
+ ? `${this.nowLine()}${plain.context.length === 0 ? "" : `\n${plain.context.trimEnd()}`}`
1295
+ : `${this.nowLine()}\n${plain.context}${result.injection}`,
1255
1296
  bytes: decision.bytes,
1256
1297
  sentinel: decision.sentinel,
1257
1298
  // The footnote tier is carried SEPARATELY from the loud one, because the
1258
1299
  // two mean different things to reinforcement: a footnote trains nothing.
1259
1300
  surfaced: decision.surfaced,
1260
1301
  footnotes: decision.footnotes,
1302
+ ...told,
1261
1303
  };
1262
1304
  });
1263
1305
  }
@@ -1267,6 +1309,58 @@ export class ClaudeCodeAdapter {
1267
1309
  return `Now: ${localClock(this.nowFn(), this.counterpart.store.zone())}`;
1268
1310
  }
1269
1311
 
1312
+ /**
1313
+ * PLAIN REMINDERS, in words (owner decision 2026-09-25/26): "Today: pay your
1314
+ * taxes". Two renderings of each, from the same record —
1315
+ *
1316
+ * - `notices`, for the PERSON, bare: the host shows them as the hook's
1317
+ * `systemMessage` in the terminal (`bin/hook.ts#hostDelivery`);
1318
+ * - `context`, for the MODEL, one line each ending in a newline, saying it
1319
+ * was asked for and naming the memory, so it can raise it and look it up.
1320
+ *
1321
+ * A READ (2026-09-26 review): nothing is claimed here. The delivery claims
1322
+ * what its envelope will certainly carry (`claimPlain`, from
1323
+ * `bin/hook.ts#deliverTurn`) and strips the rest, so a beat is never spent
1324
+ * on a line the person did not get. No date (`input.at` absent) means no
1325
+ * calendar, and so nothing; the host-mode page writer's headless child is
1326
+ * told nothing (`HookInput.pageWriter`). Never throws.
1327
+ */
1328
+ private plainFor(input: HookInput): { context: string; notices: string[]; due: PlainReminder[] } {
1329
+ const none = { context: "", notices: [], due: [] };
1330
+ if (input.at === undefined || input.pageWriter === true) return none;
1331
+ try {
1332
+ const due = this.counterpart.plainDueToday({ at: input.at });
1333
+ return {
1334
+ context: due.map((r) => `${plainContextLine(r)}\n`).join(""),
1335
+ notices: due.map(plainLine),
1336
+ due,
1337
+ };
1338
+ } catch {
1339
+ return none;
1340
+ }
1341
+ }
1342
+
1343
+ /**
1344
+ * CLAIM plain reminders the delivery is certainly about to show — the latch
1345
+ * (`Counterpart.claimPlainReminder`) decides, so of two processes racing for
1346
+ * one beat exactly one gets it back. Returns the ones this call claimed, in
1347
+ * order; the caller shows only those. Never throws.
1348
+ */
1349
+ claimPlain(input: HookInput, due: readonly PlainReminder[]): PlainReminder[] {
1350
+ if (input.at === undefined || due.length === 0) return [];
1351
+ const at = input.at;
1352
+ const claimed = due.filter((r) => {
1353
+ try {
1354
+ return this.counterpart.claimPlainReminder(r, { at });
1355
+ } catch {
1356
+ return false;
1357
+ }
1358
+ });
1359
+ if (claimed.length > 0) this.emit("adapter.plain.told", { count: claimed.length });
1360
+ if (claimed.length < due.length) this.emit("adapter.plain.lost", { count: due.length - claimed.length });
1361
+ return claimed;
1362
+ }
1363
+
1270
1364
  /**
1271
1365
  * "COUNTERPARTS WAS UPDATED" — the line this session's terminal gets, once,
1272
1366
  * when the MCP server it is talking to runs an older build than the one
@@ -2547,6 +2641,63 @@ export function wakeOutcome(expected: string | null, arrival: WakeArrival): Wake
2547
2641
  return "truncated";
2548
2642
  }
2549
2643
 
2644
+ /**
2645
+ * ONE PLAIN REMINDER, AS A PERSON READS IT (2026-09-26). The owner's example is
2646
+ * the whole spec — "Today: pay your taxes" — so each beat is the shortest
2647
+ * sentence that says when:
2648
+ *
2649
+ * day `Today: pay your taxes`
2650
+ * opens `This month: launch the beta` / `Until Sat 31 Oct 2026: book flights`
2651
+ * last-day `Last day today: file the extension`
2652
+ *
2653
+ * `what` is the memory's title or first line (`Counterpart.plainReminders`).
2654
+ */
2655
+ export function plainLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what">): string {
2656
+ const max = TUNABLES.PLAIN_WHAT_MAX_CHARS;
2657
+ const what = r.what.length <= max ? r.what : `${r.what.slice(0, max - 1).trimEnd()}…`;
2658
+ if (r.beat === "day") return `Today: ${what}`;
2659
+ if (r.beat === "last-day") return `Last day today: ${what}`;
2660
+ if (r.precision === "month") return `This month: ${what}`;
2661
+ return `Until ${readableDate(r.lastDay)}: ${what}`;
2662
+ }
2663
+
2664
+ /**
2665
+ * The MODEL's copy of one plain reminder: says it was asked for, and names the
2666
+ * memory so it can be looked up. One line, no newline — `what` is folded to
2667
+ * single spaces upstream — so `withoutPlain` can take it back out by line.
2668
+ */
2669
+ export function plainContextLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "memoryId">): string {
2670
+ return `Plain reminder (they asked to be told) — ${plainLine(r)} [${r.memoryId}]`;
2671
+ }
2672
+
2673
+ /**
2674
+ * A hook result WITHOUT the given plain reminders — their terminal lines, their
2675
+ * records and their context lines — for a delivery that could not carry them or
2676
+ * lost the race to claim them (`bin/hook.ts#deliverTurn`). They are not spent:
2677
+ * the next prompt reads them again. Everything else is untouched.
2678
+ */
2679
+ export function withoutPlain<R extends { injection: string | null; notices?: readonly string[]; plain?: readonly PlainReminder[] }>(
2680
+ result: R,
2681
+ drop: readonly PlainReminder[],
2682
+ ): R {
2683
+ if (drop.length === 0) return result;
2684
+ const keyOf = (r: PlainReminder): string => `${r.memoryId} ${r.windowKey} ${r.beat}`;
2685
+ const gone = new Set(drop.map(keyOf));
2686
+ const lines = new Set(drop.map(plainContextLine));
2687
+ const plain = (result.plain ?? []).filter((r) => !gone.has(keyOf(r)));
2688
+ const injection =
2689
+ result.injection === null
2690
+ ? null
2691
+ : result.injection
2692
+ .split("\n")
2693
+ .filter((l) => !lines.has(l))
2694
+ .join("\n");
2695
+ const rest: R = { ...result, injection };
2696
+ delete (rest as { notices?: unknown }).notices;
2697
+ delete (rest as { plain?: unknown }).plain;
2698
+ return plain.length === 0 ? rest : { ...rest, notices: plain.map(plainLine), plain };
2699
+ }
2700
+
2550
2701
  function codeOf(err: unknown): string {
2551
2702
  if (err !== null && typeof err === "object") {
2552
2703
  const code = (err as { code?: unknown }).code;
@@ -59,8 +59,11 @@ export {
59
59
  SPAWN_REFUSAL_PREFIX,
60
60
  SPAWN_START_COUNT_KEY,
61
61
  SPAWN_START_DATE_KEY,
62
+ plainContextLine,
63
+ plainLine,
62
64
  substanceOf,
63
65
  wakeOutcome,
66
+ withoutPlain,
64
67
  } from "./hooks.js";
65
68
  export type {
66
69
  AdapterEvent,
@@ -239,6 +239,7 @@ import type {
239
239
  import { humanBytes as humanDiskBytes, uninstall } from "./uninstall.js";
240
240
  import { NO_PAGE_VERSION } from "../../core/self/index.js";
241
241
  import { snapshot, snapshotName } from "./snapshot.js";
242
+ import { feelingsLine } from "../feelings-line.js";
242
243
  // The console's map and the paragraphs the old `usage()` carried. One
243
244
  // direction only: `help.ts` imports nothing but types back from this file.
244
245
  import { COMMAND_DETAIL, CONSOLE_FOOTER, advancedHelp, shortHelp } from "./help.js";
@@ -5193,6 +5194,16 @@ async function recallCommand(
5193
5194
  const journal = m.journal ? "[journal] " : "";
5194
5195
  io.out(` ${m.id} [${m.tier}] ${journal}${m.kind}${m.title === null ? "" : ` — ${m.title}`}`);
5195
5196
  for (const line of m.body.split("\n")) io.out(` ${line}`);
5197
+ // The feelings on it, `you: … · me: …` (emotion part A). Read-only, and
5198
+ // a store that cannot answer simply shows none.
5199
+ let felt = "";
5200
+ try {
5201
+ const born = counterpart.store.physicsOf(m.id).birthDay;
5202
+ felt = feelingsLine(counterpart.store.feelingsFor(m.id), counterpart.store.livedDay() - born);
5203
+ } catch {
5204
+ felt = "";
5205
+ }
5206
+ if (felt !== "") io.out(` feelings — ${felt}`);
5196
5207
  }
5197
5208
  // THE TIER LEGEND, and it is not decoration. `answered` means the question
5198
5209
  // reached something, never that the something is right, and the loudest