counterparts 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +197 -0
- package/docs/module-map.md +3 -2
- package/package.json +1 -1
- package/src/adapters/claude-code/NOTES.md +29 -0
- package/src/adapters/claude-code/doctor.ts +272 -0
- package/src/adapters/claude-code/hooks.ts +46 -3
- package/src/adapters/claude-code/index.ts +2 -0
- package/src/adapters/claude-code/transcript.ts +7 -0
- package/src/adapters/cli/CONTRACT.md +11 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +16 -0
- package/src/adapters/cli/NOTES.md +37 -0
- package/src/adapters/cli/commands.ts +202 -4
- package/src/adapters/cli/dream-core.ts +193 -0
- package/src/adapters/cli/export.ts +21 -2
- package/src/adapters/cli/help.ts +20 -0
- package/src/adapters/cli/mechanisms.ts +175 -101
- package/src/adapters/dashboard/CONTRACT.md +5 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +12 -0
- package/src/adapters/dashboard/NOTES.md +38 -0
- package/src/adapters/dashboard/registries.ts +31 -1
- package/src/adapters/dashboard/source.ts +8 -0
- package/src/adapters/dashboard/web/README.md +144 -38
- package/src/adapters/dashboard/web/actions.ts +45 -3
- package/src/adapters/dashboard/web/app.html +2 -0
- package/src/adapters/dashboard/web/ask-voice.ts +364 -0
- package/src/adapters/dashboard/web/flow.ts +12 -0
- package/src/adapters/dashboard/web/lanes.ts +171 -0
- package/src/adapters/dashboard/web/mechanisms/association/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/association/panel.js +1 -3
- package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +9 -5
- package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +31 -17
- package/src/adapters/dashboard/web/mechanisms/decay/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/decay/panel.js +1 -3
- package/src/adapters/dashboard/web/mechanisms/dreaming/index.js +20 -0
- package/src/adapters/dashboard/web/mechanisms/dreaming/panel.js +20 -0
- package/src/adapters/dashboard/web/mechanisms/emotional/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/emotional/panel.js +24 -0
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +5 -5
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/panel.js +11 -0
- package/src/adapters/dashboard/web/mechanisms/index.js +19 -6
- package/src/adapters/dashboard/web/mechanisms/interference/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/prospective/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/prospective/panel.js +18 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +1 -3
- package/src/adapters/dashboard/web/mechanisms/regions.js +1 -1
- package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +54 -15
- package/src/adapters/dashboard/web/mechanisms/salience/index.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/salience/panel.js +1 -2
- package/src/adapters/dashboard/web/mechanisms/schema/index.js +2 -2
- package/src/adapters/dashboard/web/narrate.ts +118 -13
- package/src/adapters/dashboard/web/pages/health/health.css +14 -0
- package/src/adapters/dashboard/web/pages/health/index.js +5 -1
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +8 -5
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +49 -0
- package/src/adapters/dashboard/web/pages/home/home.css +137 -39
- package/src/adapters/dashboard/web/pages/home/index.js +10 -6
- package/src/adapters/dashboard/web/pages/home/sections/explorer.js +129 -38
- package/src/adapters/dashboard/web/pages/home/sections/hero.js +20 -4
- package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +18 -9
- package/src/adapters/dashboard/web/pages/home/sections/tiles.js +28 -18
- package/src/adapters/dashboard/web/pages/home/sections/tonight.js +74 -0
- package/src/adapters/dashboard/web/pages/home/sections/written.js +76 -0
- package/src/adapters/dashboard/web/pages/memories/fold.js +48 -0
- package/src/adapters/dashboard/web/pages/memories/index.js +30 -36
- package/src/adapters/dashboard/web/pages/memories/memories.css +102 -72
- package/src/adapters/dashboard/web/pages/memories/row.js +57 -0
- package/src/adapters/dashboard/web/pages/memories/sections/feel.js +176 -0
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +67 -0
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +65 -43
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +73 -30
- package/src/adapters/dashboard/web/pages/memories/state.js +12 -5
- package/src/adapters/dashboard/web/pages/self/index.js +19 -13
- package/src/adapters/dashboard/web/pages/self/sections/dreams.js +77 -0
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -13
- package/src/adapters/dashboard/web/pages/self/sections/map.js +217 -0
- package/src/adapters/dashboard/web/pages/self/sections/page.js +121 -62
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +68 -48
- package/src/adapters/dashboard/web/pages/self/sections/traits.js +101 -0
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +46 -53
- package/src/adapters/dashboard/web/pages/self/self.css +128 -92
- package/src/adapters/dashboard/web/pages/self/state.js +4 -2
- package/src/adapters/dashboard/web/server.ts +29 -1
- package/src/adapters/dashboard/web/shared/absence.js +1 -3
- package/src/adapters/dashboard/web/shared/memory-card-words.js +96 -0
- package/src/adapters/dashboard/web/shared/memory-marks.css +17 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +81 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +231 -62
- package/src/adapters/dashboard/web/shared/modal.css +67 -0
- package/src/adapters/dashboard/web/shared/tip.js +1 -1
- package/src/adapters/dashboard/web/shared/widgets/feed.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.js +93 -14
- package/src/adapters/dashboard/web/shared/widgets/light.css +1 -0
- package/src/adapters/dashboard/web/shared/widgets/light.js +7 -5
- package/src/adapters/dashboard/web/shared/widgets/tips.css +19 -0
- package/src/adapters/dashboard/web/{pages/self → shared/widgets}/tips.js +15 -9
- package/src/adapters/dashboard/web/views/activity.ts +49 -3
- package/src/adapters/dashboard/web/views/archive-words.ts +27 -10
- package/src/adapters/dashboard/web/views/core-road.ts +56 -0
- package/src/adapters/dashboard/web/views/dreams.ts +199 -0
- package/src/adapters/dashboard/web/views/health.ts +61 -9
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +447 -77
- package/src/adapters/dashboard/web/views/mechanisms.ts +181 -325
- package/src/adapters/dashboard/web/views/memories.ts +245 -43
- package/src/adapters/dashboard/web/views/memory-words.ts +133 -0
- package/src/adapters/dashboard/web/views/memory.ts +280 -7
- package/src/adapters/dashboard/web/views/mind.ts +708 -102
- package/src/adapters/dashboard/web/views/overview.ts +77 -46
- package/src/adapters/dashboard/web/views/search.ts +80 -3
- package/src/adapters/dashboard/web/views/self-map.ts +124 -0
- package/src/adapters/dashboard/web/views/shared.ts +14 -0
- package/src/adapters/dashboard/web/views/tonight.ts +158 -0
- package/src/adapters/dashboard/web/views/traits.ts +197 -0
- package/src/adapters/dashboard/web/views/written-returned.ts +93 -0
- package/src/adapters/dashboard/web/views.ts +8 -4
- package/src/adapters/fired.ts +107 -5
- package/src/adapters/mcp/CONTRACT.md +3 -0
- package/src/adapters/mcp/NOTES.md +51 -0
- package/src/adapters/mcp/bin/serve.ts +6 -1
- package/src/adapters/mcp/index.ts +4 -0
- package/src/adapters/mcp/server.ts +343 -3
- package/src/adapters/mcp/tools.ts +324 -1
- package/src/adapters/mechanism-evidence.ts +488 -0
- package/src/core/counterpart.ts +198 -5
- package/src/core/dream/CONTRACT.md +227 -0
- package/src/core/dream/INTERFACE-GAPS.md +49 -0
- package/src/core/dream/NOTES.md +190 -0
- package/src/core/dream/index.ts +1197 -0
- package/src/core/dream/mark.ts +14 -0
- package/src/core/dream/mind.ts +110 -0
- package/src/core/dream/reflect.ts +1154 -0
- package/src/core/dream/tunables.ts +56 -0
- package/src/core/physics/CONTRACT.md +114 -24
- package/src/core/physics/NOTES.md +187 -0
- package/src/core/physics/index.ts +438 -68
- package/src/core/recall/NOTES.md +16 -0
- package/src/core/recall/index.ts +9 -2
- package/src/core/remember/CONTRACT.md +5 -0
- package/src/core/remember/spans.ts +11 -1
- package/src/core/self/CONTRACT.md +11 -1
- package/src/core/self/INTERFACE-GAPS.md +11 -0
- package/src/core/self/NOTES.md +45 -0
- package/src/core/self/identity.ts +95 -5
- package/src/core/self/index.ts +17 -0
- package/src/core/self/tunables.ts +17 -0
- package/src/core/sleep/CONTRACT.md +18 -1
- package/src/core/sleep/INTERFACE-GAPS.md +19 -0
- package/src/core/sleep/NOTES.md +87 -0
- package/src/core/sleep/consolidate.ts +270 -96
- package/src/core/sleep/decay.ts +11 -0
- package/src/core/sleep/index.ts +14 -1
- package/src/core/sleep/tunables.ts +9 -0
- package/src/core/sleep/types.ts +34 -0
- package/src/core/sleep/upgrade.ts +168 -0
- package/src/core/store/CONTRACT.md +27 -0
- package/src/core/store/NOTES.md +137 -0
- package/src/core/store/errors.ts +12 -0
- package/src/core/store/feelings.ts +16 -0
- package/src/core/store/index.ts +1100 -15
- package/src/core/store/operational.ts +662 -7
- package/src/core/store/owner-op-seam.ts +188 -1
- package/src/core/store/traits.ts +161 -0
- package/src/core/types.ts +43 -0
- package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +0 -13
- package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +0 -178
- package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +0 -42
- package/src/adapters/dashboard/web/shared/widgets/chapters.js +0 -15
|
@@ -90,6 +90,7 @@ import {
|
|
|
90
90
|
statSync,
|
|
91
91
|
} from "node:fs";
|
|
92
92
|
|
|
93
|
+
import { carriesDreamMark } from "../../core/dream/mark.js";
|
|
93
94
|
import type { Turn, TurnSource } from "../../core/remember/index.js";
|
|
94
95
|
|
|
95
96
|
/**
|
|
@@ -547,6 +548,12 @@ function pieceOf(text: string, role: "user" | "assistant", author: EntryAuthor):
|
|
|
547
548
|
// metadata says: an `isMeta` Stop-hook block read as `injected` would ENTER
|
|
548
549
|
// capture, which is G11 broken by a step meant only to keep it out of pacing.
|
|
549
550
|
if (source === "foreign" || source === "ritual") return { text, source };
|
|
551
|
+
// A DREAM'S WORDS (2026-09-26): the bundle a dreamer was shown, or the
|
|
552
|
+
// hand-back its background agent sends home — which this host delivers into
|
|
553
|
+
// the parent's transcript user-role (`isMeta`, origin `peer`) and would read
|
|
554
|
+
// as `injected`, kept. Refused by the mark, whoever wrote the entry and in
|
|
555
|
+
// either role, so a dream never reaches the sweep (`core/dream/mark.ts`).
|
|
556
|
+
if (carriesDreamMark(text)) return { text, source: "dream" };
|
|
550
557
|
// THE ASSISTANT'S TEXT IS NEVER RECLASSIFIED BY A MARKER (review m2): its own
|
|
551
558
|
// replies add pacing bytes and earn recall credit exactly as on master. The one change is
|
|
552
559
|
// an entry the host SYNTHESISED as the assistant (an API error), which the
|
|
@@ -581,6 +581,17 @@ The standalone verb does not ask either: typing it is the yes.*
|
|
|
581
581
|
treats it as foreign (never moved, never deleted, and named with one sentence saying
|
|
582
582
|
what it is), and `start-fresh` leaves it byte for byte. `doctor` has no Credentials
|
|
583
583
|
line; the configuration's retired settings are one green `Old settings` note.
|
|
584
|
+
43. **[M] The owner's windows onto dreaming and the core (2026-09-26).** `counterparts
|
|
585
|
+
dream` lists the dreams, `--show <id>` prints one dream's journal and every change it
|
|
586
|
+
made (undone rows marked), and `--undo <id>` reverses its whole batch through
|
|
587
|
+
`Counterpart.dreams.undo` — the console decides nothing about what an undo does.
|
|
588
|
+
`counterparts core` lists the core with the lane that carried each memory there, the
|
|
589
|
+
dreams' nominations and the owner's demotions, and `--demote <id> --reason "…"` sends
|
|
590
|
+
one back to ordinary fading through `Counterpart.demoteCore`, which requires the
|
|
591
|
+
reason, records it, restarts fading from today and keeps the lanes from promoting it
|
|
592
|
+
again. Neither command is on `OWNER_OPS`: like `self-page`, reading works from an
|
|
593
|
+
instrument, and the write refuses at the core's own seam under observer. Confidential
|
|
594
|
+
rows print as `[confidential]`.
|
|
584
595
|
|
|
585
596
|
## 6. Scars honored
|
|
586
597
|
|
|
@@ -395,3 +395,19 @@ and says how much of the number is log (NOTES, 2026-09-23), which is this module
|
|
|
395
395
|
SQL string and finalize the cache in `close()` — so a clean close is a real close. Worth
|
|
396
396
|
measuring the hooks' per-turn cost before and after, since they open and close the store
|
|
397
397
|
on every turn.
|
|
398
|
+
|
|
399
|
+
## Dreaming and the core (2026-09-26)
|
|
400
|
+
|
|
401
|
+
- **`counterparts mechanisms` does not yet say "became core by the fast/slow lane"
|
|
402
|
+
or count a dream's changes.** The short view reads only `fired.ts`'s rows, which
|
|
403
|
+
count rows, not payloads; the lane is on each `band.promoted` row's payload and a
|
|
404
|
+
dream's change count is on `dream.changed`'s. The builder is moving the lights into
|
|
405
|
+
the shared `adapters/mechanism-evidence.ts` (master ef37eb1); that is where the
|
|
406
|
+
Consolidation / Dreaming / Gist lines belong.
|
|
407
|
+
- **A dream's journal cannot be removed from the console.** `remove` takes memory ids,
|
|
408
|
+
and a journal is not a memory (it lives in the `dreams` table). An owner who wants a
|
|
409
|
+
journal gone has `dream --undo`, which keeps it marked undone. A `dream --forget <id>`
|
|
410
|
+
would need a store write that blanks the journal text; not built.
|
|
411
|
+
- **`export --markdown` does not carry the dreams table** (the journals, the change
|
|
412
|
+
logs): it walks memories. The database export and `backup` copy the whole file, so
|
|
413
|
+
they do.
|
|
@@ -1800,6 +1800,31 @@ tier is primary while Voyage is frozen (ROADMAP §"Amendments"). What the build
|
|
|
1800
1800
|
binding in `bin/counterparts.ts`. Its only caller was `credentials set`; it is a small,
|
|
1801
1801
|
tested primitive, and removing it was not part of this round.
|
|
1802
1802
|
|
|
1803
|
+
## `dream` and `core` (2026-09-26, dreaming + consolidation)
|
|
1804
|
+
|
|
1805
|
+
Two small commands over the core's own answers (`cli/dream-core.ts` renders, the core
|
|
1806
|
+
decides). Choices made here:
|
|
1807
|
+
|
|
1808
|
+
- **`--undo` is a boolean with the id after it** (`dream --undo drm_…`), because
|
|
1809
|
+
`start-fresh --undo` already declares `undo` as a boolean and the parser's option table
|
|
1810
|
+
is shared by every command; `--undo=<id>` works too. `--show` and `--demote` are new
|
|
1811
|
+
and are valued flags.
|
|
1812
|
+
- **Both are on the advanced page, not the first one.** The first page is what a person
|
|
1813
|
+
reads thirty seconds after installing; dreams and the core are what they look at a week
|
|
1814
|
+
later. `counterparts help dream` / `help core` are the full pages.
|
|
1815
|
+
- **A demotion needs `--reason`**, and `--reason` without `--demote` is refused rather
|
|
1816
|
+
than ignored: the reason is the one thing the record keeps that the store cannot
|
|
1817
|
+
reconstruct.
|
|
1818
|
+
- **`fired` gained eight rows** (`returns`, `dream`, `dream-changes`, `dream-ask`,
|
|
1819
|
+
`dream-replays`, `core-demote`, `upgrade-census`, and `gist` now backed by dreamed
|
|
1820
|
+
memories instead of "not built"). `returns` and `dream-replays` are table probes over
|
|
1821
|
+
the new `returns` table (dated by each row's moment); `gist` is a probe over live
|
|
1822
|
+
memories of source `dreamed`.
|
|
1823
|
+
- **Doctor gained two lines**: `Upgrade` (the v8 upgrade's census — green when nothing
|
|
1824
|
+
moved down, amber until the first sleep measures it, red if anything did; no line on a
|
|
1825
|
+
store born at v8) and `Dreaming` (informational: last dreamed, and today's ask). Both
|
|
1826
|
+
fold into `Background` while green.
|
|
1827
|
+
|
|
1803
1828
|
## `ask` by meaning, and short (2026-09-24)
|
|
1804
1829
|
|
|
1805
1830
|
**By meaning.** `ask` passed `vector: null, semantic: "embedder-off"` since the days
|
|
@@ -1849,3 +1874,15 @@ found a paraphrase only by the words it shared. It now opens its store with the
|
|
|
1849
1874
|
the store's own, at open: a store whose box 3 holds another model's vectors withdraws
|
|
1850
1875
|
the embedder, and the note lands with words only. Missing weights: the note lands with
|
|
1851
1876
|
words only and prints nothing about it — doctor and the backfill name a missing table.
|
|
1877
|
+
|
|
1878
|
+
## 2026-09-27 — trait nudges in the export and `fired` (working defaults)
|
|
1879
|
+
|
|
1880
|
+
- **`export --markdown` carries a memory's nudges** as a `## Traits` list after its
|
|
1881
|
+
`## Feelings` (`1. agreeable-candid → candid · 0.6 — carried by: …`). The row is only
|
|
1882
|
+
there when it is not confidential or the owner passed `--include-confidential`, so the
|
|
1883
|
+
section reads with its words.
|
|
1884
|
+
- **`fired` gained one row, `traits`** ("a memory that showed how I acted was given a
|
|
1885
|
+
trait nudge"), a probe over live memories dated by the newest nudge. It is plumbing in
|
|
1886
|
+
`counterparts mechanisms` (no mechanism line of its own: traits feed nothing), so it
|
|
1887
|
+
shows in the plumbing count and in `mechanisms --all`. No doctor line: nothing there
|
|
1888
|
+
fits without forcing it.
|
|
@@ -133,7 +133,7 @@ import { OBSERVER_ENV, observerFromEnv, unreadableStanceLine } from "../stance-e
|
|
|
133
133
|
import { STATE_MEANING, STATE_ORDER, firedReport } from "../fired.js";
|
|
134
134
|
import type { FiredReport, FiredState } from "../fired.js";
|
|
135
135
|
// The short view over the same reading: one line per memory mechanism.
|
|
136
|
-
import { mechanismsLines } from "./mechanisms.js";
|
|
136
|
+
import { consoleVerdicts, mechanismsLines } from "./mechanisms.js";
|
|
137
137
|
// The two snapshot readers `status` shares with doctor: the DIRECTORY is what
|
|
138
138
|
// says how many copies you have, and a row only says what a run once wrote.
|
|
139
139
|
import { readSnapshotsDir, resolveSnapshotsDir } from "../snapshots.js";
|
|
@@ -197,6 +197,8 @@ import type { RemovalPlan } from "./removal.js";
|
|
|
197
197
|
import { repairDates } from "./repair-dates.js";
|
|
198
198
|
import type { Confidence } from "./repair-dates.js";
|
|
199
199
|
import { NO_PAGE_LINES, bodyFrom, pageLines, versionLines, writeLines } from "./self-page.js";
|
|
200
|
+
import { coreListLines, dreamListLines, dreamShowLines } from "./dream-core.js";
|
|
201
|
+
import { REFLECTED_FEELING_KEY } from "../../core/sleep/index.js";
|
|
200
202
|
// The console's shared manners (2026-09-21): is there a person here, ask them,
|
|
201
203
|
// and say one marked line back.
|
|
202
204
|
import { ask, confirm, isInteractive, isPromptAborted, paint, typed, ui } from "./ui.js";
|
|
@@ -299,6 +301,12 @@ export const COMMANDS = [
|
|
|
299
301
|
// The written page the wake leads with: read it, write it whole, and read
|
|
300
302
|
// back what it used to say (2026-09-18, S1).
|
|
301
303
|
"self-page",
|
|
304
|
+
// Dreaming + consolidation (2026-09-26): what each dream did, and its undo;
|
|
305
|
+
// what the core holds, and the owner's door out of it. Like `self-page`,
|
|
306
|
+
// each both reads and writes, so neither is on `OWNER_OPS`: reading works
|
|
307
|
+
// under observer, and the write refuses at the core's own seam.
|
|
308
|
+
"dream",
|
|
309
|
+
"core",
|
|
302
310
|
// The owner's window, started on the store the CONFIGURATION names — no
|
|
303
311
|
// `--dir` to get wrong, and the browser opened for you (2026-09-22, item 4).
|
|
304
312
|
// `counterparts-dashboard serve` is still there and still refuses an unnamed
|
|
@@ -709,6 +717,8 @@ export const COMMAND_FLAGS: Record<Command, readonly string[]> = {
|
|
|
709
717
|
// line is a page in shell history, and prose that is injected into every
|
|
710
718
|
// session does not belong there.
|
|
711
719
|
"self-page": ["write", "file", "stdin", "reason", "versions", "version", "restore", "clear", "if-version"],
|
|
720
|
+
dream: ["list", "show", "undo"],
|
|
721
|
+
core: ["list", "demote", "reason", "reflected-feeling"],
|
|
712
722
|
// `--config` because the store it opens is the one the CONFIGURATION names —
|
|
713
723
|
// that is the whole point of the command over `counterparts-dashboard serve`,
|
|
714
724
|
// which refuses until you name a store. `--dir` still parses (it is common)
|
|
@@ -772,6 +782,10 @@ export const COMMAND_BLURB: Record<Command, string> = {
|
|
|
772
782
|
"Which directories this memory is for: on, observer, off, or paused until you resume it. It writes the host's own registry beside claude-code.json, opens no store, and needs no --dir. A subdirectory inherits its nearest ancestor's entry. On this one command --observer names the MODE, not the console's stance.",
|
|
773
783
|
"self-page":
|
|
774
784
|
"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; --versions lists those and --version <seq> prints one. Reading works under observer; writing refuses there.",
|
|
785
|
+
dream:
|
|
786
|
+
"What each dream did, and its undo — and what the waking self made of it. With no flags (or --list), the recent dreams: 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.",
|
|
787
|
+
core:
|
|
788
|
+
"The core — the memories about me, about us and about the owner that do not fade. With no flags (or --list), what it holds and which lane carried each one there, what dreams have nominated, and what you sent back; --demote <id> --reason \"...\" sends one back to ordinary fading from today, records why, and keeps the lanes from promoting it again; --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 two changes refuse there.",
|
|
775
789
|
dashboard:
|
|
776
790
|
"Open the dashboard in your browser: the web view of the store your configuration names, served on 127.0.0.1 and nowhere else. Ctrl-C stops it. Looking is read-only — it strengthens nothing and deposits nothing. What you do there on purpose (write a note, remove a memory, back up, …) runs through these same commands, and a removal asks you to type the id back.",
|
|
777
791
|
version: "The version of Counterparts you have. It opens nothing.",
|
|
@@ -795,6 +809,8 @@ const COMMAND_ARGS: Partial<Record<Command, string>> = {
|
|
|
795
809
|
connect: " [claude-code]",
|
|
796
810
|
disconnect: " [claude-code]",
|
|
797
811
|
help: " [advanced | <command>]",
|
|
812
|
+
dream: " [--show <id> | --undo <id>]",
|
|
813
|
+
core: " [--demote <id> --reason \"...\" | --reflected-feeling on|off]",
|
|
798
814
|
};
|
|
799
815
|
|
|
800
816
|
/**
|
|
@@ -1002,6 +1018,21 @@ const START_FRESH_FLAG_HELP: Record<string, string> = {
|
|
|
1002
1018
|
* and it is the one the hooks and the memory tools open. Printing the shared
|
|
1003
1019
|
* sentence would describe a resolution this command does not use.
|
|
1004
1020
|
*/
|
|
1021
|
+
/** `dream`'s own three: `--list` and `--undo` mean something else on other pages. */
|
|
1022
|
+
const DREAM_FLAG_HELP: Record<string, string> = {
|
|
1023
|
+
list: "the recent dreams, newest first — the default",
|
|
1024
|
+
show: "one dream, by id: its journal and every change it made",
|
|
1025
|
+
undo: "reverse one dream's whole batch, by id (the id follows the flag); its journal is kept, marked undone",
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
/** `core`'s own four. */
|
|
1029
|
+
const CORE_FLAG_HELP: Record<string, string> = {
|
|
1030
|
+
list: "what the core holds, with lanes, nominations and demotions — the default",
|
|
1031
|
+
demote: "send one core memory back to ordinary fading from today, by id; needs --reason",
|
|
1032
|
+
reason: "why — recorded with the demotion, and shown by --list",
|
|
1033
|
+
"reflected-feeling": "on or off — can a memory reach the core on 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.",
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1005
1036
|
const DASHBOARD_FLAG_HELP: Record<string, string> = {
|
|
1006
1037
|
dir: "a store to look at instead of the one your configuration names",
|
|
1007
1038
|
};
|
|
@@ -1035,7 +1066,11 @@ export function commandHelp(command: Command): string {
|
|
|
1035
1066
|
? DASHBOARD_FLAG_HELP
|
|
1036
1067
|
: command === "connect" || command === "disconnect" || command === "uninstall"
|
|
1037
1068
|
? HOST_FLAG_HELP
|
|
1038
|
-
:
|
|
1069
|
+
: command === "dream"
|
|
1070
|
+
? DREAM_FLAG_HELP
|
|
1071
|
+
: command === "core"
|
|
1072
|
+
? CORE_FLAG_HELP
|
|
1073
|
+
: {};
|
|
1039
1074
|
const flagLine = (name: string): string => {
|
|
1040
1075
|
const shown = `--${name}${VALUED_FLAGS.includes(name) ? " <value>" : ""}`;
|
|
1041
1076
|
return ` ${shown.padEnd(20)} ${override[name] ?? FLAG_HELP[name] ?? "(undocumented)"}`;
|
|
@@ -1092,6 +1127,8 @@ const VALUED_FLAGS: readonly string[] = [
|
|
|
1092
1127
|
"version",
|
|
1093
1128
|
"restore",
|
|
1094
1129
|
"if-version",
|
|
1130
|
+
"show",
|
|
1131
|
+
"demote",
|
|
1095
1132
|
];
|
|
1096
1133
|
|
|
1097
1134
|
/** Levenshtein, small and local. Only ever used to say "did you mean". */
|
|
@@ -1281,6 +1318,14 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
1281
1318
|
restore: { type: "string" },
|
|
1282
1319
|
clear: { type: "boolean" },
|
|
1283
1320
|
"if-version": { type: "string" },
|
|
1321
|
+
// `dream --show <id>` and `core --demote <id>`: strings, so a trailing
|
|
1322
|
+
// flag is a refusal rather than a `true` read as "no id named". `dream
|
|
1323
|
+
// --undo` reuses `start-fresh`'s boolean and takes the id positionally.
|
|
1324
|
+
show: { type: "string" },
|
|
1325
|
+
demote: { type: "string" },
|
|
1326
|
+
// `core --reflected-feeling on|off` (2026-09-27): a string, so a bare
|
|
1327
|
+
// flag is a refusal rather than a `true` read as a choice.
|
|
1328
|
+
"reflected-feeling": { type: "string" },
|
|
1284
1329
|
observer: { type: "boolean" },
|
|
1285
1330
|
help: { type: "boolean" },
|
|
1286
1331
|
// `scope`'s five. Declared as booleans for the same reason `rebuild` is:
|
|
@@ -1738,6 +1783,10 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
|
|
|
1738
1783
|
typeof parsed.flags["dir"] === "string",
|
|
1739
1784
|
opts.stdin,
|
|
1740
1785
|
);
|
|
1786
|
+
case "dream":
|
|
1787
|
+
return dreamCommand(dir, io, parsed, observer, typeof parsed.flags["dir"] === "string");
|
|
1788
|
+
case "core":
|
|
1789
|
+
return coreCommand(dir, io, parsed, observer, typeof parsed.flags["dir"] === "string");
|
|
1741
1790
|
}
|
|
1742
1791
|
} catch (err) {
|
|
1743
1792
|
io.err(upgradePending(err) ?? `${command} failed: ${describeDirRefusal(err)}`);
|
|
@@ -1929,14 +1978,163 @@ function firedCommand(
|
|
|
1929
1978
|
return EXIT.failed;
|
|
1930
1979
|
}
|
|
1931
1980
|
try {
|
|
1932
|
-
const
|
|
1933
|
-
|
|
1981
|
+
const today = localDate(now(), store.zone());
|
|
1982
|
+
const report = firedReport(store, today);
|
|
1983
|
+
for (const line of all ? firedLines(report, true) : mechanismsLines(report, consoleVerdicts(store, today))) io.out(line);
|
|
1934
1984
|
return EXIT.ok;
|
|
1935
1985
|
} finally {
|
|
1936
1986
|
store.close();
|
|
1937
1987
|
}
|
|
1938
1988
|
}
|
|
1939
1989
|
|
|
1990
|
+
/**
|
|
1991
|
+
* `dream` — what each dream did, and its undo (2026-09-26). The rules are the
|
|
1992
|
+
* core's (`core/dream/`); this picks one of three modes and prints lines
|
|
1993
|
+
* (`dream-core.ts`). Reading opens the store as an instrument; `--undo` opens
|
|
1994
|
+
* it in the console's stance and the core refuses it under observer.
|
|
1995
|
+
*/
|
|
1996
|
+
function dreamCommand(dir: string, io: Io, parsed: Parsed, observer: boolean, namedDir: boolean): number {
|
|
1997
|
+
if (!storeExists(dir)) {
|
|
1998
|
+
io.err(`No store at ${dir}. Run 'counterparts init${namedDir ? ` --dir ${dir}` : ""}' to create one.`);
|
|
1999
|
+
return EXIT.usage;
|
|
2000
|
+
}
|
|
2001
|
+
const show = parsed.flags["show"];
|
|
2002
|
+
const undo = parsed.flags["undo"] === true;
|
|
2003
|
+
const undoId = typeof parsed.flags["undo"] === "string" ? parsed.flags["undo"] : parsed.positional[0];
|
|
2004
|
+
if (typeof show === "string" && undo) {
|
|
2005
|
+
io.err("refused: --show and --undo are two different things to do. Pass one.");
|
|
2006
|
+
return EXIT.usage;
|
|
2007
|
+
}
|
|
2008
|
+
if (undo) {
|
|
2009
|
+
if (undoId === undefined || undoId.length === 0) {
|
|
2010
|
+
io.err("refused: --undo needs the dream's id after it (counterparts dream --list shows them).");
|
|
2011
|
+
return EXIT.usage;
|
|
2012
|
+
}
|
|
2013
|
+
const counterpart = openCounterpart(dir, observer);
|
|
2014
|
+
try {
|
|
2015
|
+
if (counterpart.store.dream(undoId) === undefined) {
|
|
2016
|
+
io.err(`refused: no dream ${undoId} in this store. counterparts dream --list shows them.`);
|
|
2017
|
+
return EXIT.refused;
|
|
2018
|
+
}
|
|
2019
|
+
const out = counterpart.dreams.undo(undoId);
|
|
2020
|
+
if (!out.ok) {
|
|
2021
|
+
io.err(
|
|
2022
|
+
out.reason === "observer"
|
|
2023
|
+
? "refused: this console is an observer; it reads and changes nothing. Nothing was undone."
|
|
2024
|
+
: `refused: ${out.reason}. Nothing was undone.`,
|
|
2025
|
+
);
|
|
2026
|
+
return EXIT.refused;
|
|
2027
|
+
}
|
|
2028
|
+
io.out(
|
|
2029
|
+
out.reversed === 0
|
|
2030
|
+
? `Dream ${undoId} had nothing left to reverse; it is marked undone.`
|
|
2031
|
+
: `Undid dream ${undoId}: ${String(out.reversed)} ${out.reversed === 1 ? "change" : "changes"} reversed.`,
|
|
2032
|
+
);
|
|
2033
|
+
io.out(" Merged memories are back as they were, its links and gists are gone, and its replays and nominations were taken back.");
|
|
2034
|
+
if (out.kept > 0) {
|
|
2035
|
+
io.out(
|
|
2036
|
+
` ${String(out.kept)} ${out.kept === 1 ? "merge was" : "merges were"} left as ${out.kept === 1 ? "it is" : "they are"}: the merged memory has changed since (revised, merged again, or removed), and bringing its originals back would duplicate it.`,
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
io.out(" Its journal is kept, marked undone: counterparts dream --show " + undoId);
|
|
2040
|
+
return EXIT.ok;
|
|
2041
|
+
} finally {
|
|
2042
|
+
counterpart.close();
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
const counterpart = openCounterpart(dir, true);
|
|
2046
|
+
try {
|
|
2047
|
+
if (typeof show === "string") {
|
|
2048
|
+
const lines = dreamShowLines(counterpart, show);
|
|
2049
|
+
if (lines === null) {
|
|
2050
|
+
io.err(`refused: no dream ${show} in this store. counterparts dream --list shows them.`);
|
|
2051
|
+
return EXIT.refused;
|
|
2052
|
+
}
|
|
2053
|
+
for (const line of lines) io.out(line);
|
|
2054
|
+
return EXIT.ok;
|
|
2055
|
+
}
|
|
2056
|
+
for (const line of dreamListLines(counterpart)) io.out(line);
|
|
2057
|
+
return EXIT.ok;
|
|
2058
|
+
} finally {
|
|
2059
|
+
counterpart.close();
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* `core` — what the core holds, and the owner's door out of it (2026-09-26).
|
|
2065
|
+
* `--demote` opens the store in the console's stance; `Counterpart.demoteCore`
|
|
2066
|
+
* decides everything and refuses under observer.
|
|
2067
|
+
*/
|
|
2068
|
+
function coreCommand(dir: string, io: Io, parsed: Parsed, observer: boolean, namedDir: boolean): number {
|
|
2069
|
+
if (!storeExists(dir)) {
|
|
2070
|
+
io.err(`No store at ${dir}. Run 'counterparts init${namedDir ? ` --dir ${dir}` : ""}' to create one.`);
|
|
2071
|
+
return EXIT.usage;
|
|
2072
|
+
}
|
|
2073
|
+
const demote = parsed.flags["demote"];
|
|
2074
|
+
const reason = parsed.flags["reason"];
|
|
2075
|
+
const reflected = parsed.flags["reflected-feeling"];
|
|
2076
|
+
if (reflected !== undefined) {
|
|
2077
|
+
if (reflected !== "on" && reflected !== "off") {
|
|
2078
|
+
io.err("refused: --reflected-feeling takes on or off.");
|
|
2079
|
+
return EXIT.usage;
|
|
2080
|
+
}
|
|
2081
|
+
if (observer) {
|
|
2082
|
+
io.err("refused: this console is an observer; it reads and changes nothing. Nothing was changed.");
|
|
2083
|
+
return EXIT.refused;
|
|
2084
|
+
}
|
|
2085
|
+
const counterpart = openCounterpart(dir, observer);
|
|
2086
|
+
try {
|
|
2087
|
+
counterpart.store.setMeta(REFLECTED_FEELING_KEY, reflected);
|
|
2088
|
+
io.out(
|
|
2089
|
+
reflected === "on"
|
|
2090
|
+
? "On: 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."
|
|
2091
|
+
: "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.",
|
|
2092
|
+
);
|
|
2093
|
+
io.out(" It takes effect at the next consolidation. Nothing already in the core moves.");
|
|
2094
|
+
return EXIT.ok;
|
|
2095
|
+
} finally {
|
|
2096
|
+
counterpart.close();
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
if (reason !== undefined && typeof demote !== "string") {
|
|
2100
|
+
io.err("refused: --reason goes with a --demote. Pass one, or leave it out.");
|
|
2101
|
+
return EXIT.usage;
|
|
2102
|
+
}
|
|
2103
|
+
if (typeof demote === "string") {
|
|
2104
|
+
if (typeof reason !== "string" || reason.trim().length === 0) {
|
|
2105
|
+
io.err('refused: a demotion needs a reason — --reason "why" — and it is kept with the record.');
|
|
2106
|
+
return EXIT.usage;
|
|
2107
|
+
}
|
|
2108
|
+
const counterpart = openCounterpart(dir, observer);
|
|
2109
|
+
try {
|
|
2110
|
+
const out = counterpart.demoteCore(demote, { reason, actor: "owner" });
|
|
2111
|
+
if (!out.ok) {
|
|
2112
|
+
const why: Record<string, string> = {
|
|
2113
|
+
observer: "this console is an observer; it reads and changes nothing",
|
|
2114
|
+
"unknown-id": `no memory ${demote} in this store`,
|
|
2115
|
+
"not-core": `${demote} is not in the core (counterparts core --list shows what is)`,
|
|
2116
|
+
"reason-required": "a demotion needs a reason",
|
|
2117
|
+
};
|
|
2118
|
+
io.err(`refused: ${why[out.reason] ?? out.reason}. Nothing was changed.`);
|
|
2119
|
+
return EXIT.refused;
|
|
2120
|
+
}
|
|
2121
|
+
io.out(`Sent ${demote} back to ordinary fading, from today.`);
|
|
2122
|
+
io.out(` Why, as recorded: ${reason.trim()}`);
|
|
2123
|
+
io.out(" It fades like any other memory now, and the core's lanes will not promote it again.");
|
|
2124
|
+
return EXIT.ok;
|
|
2125
|
+
} finally {
|
|
2126
|
+
counterpart.close();
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
const counterpart = openCounterpart(dir, true);
|
|
2130
|
+
try {
|
|
2131
|
+
for (const line of coreListLines(counterpart)) io.out(line);
|
|
2132
|
+
return EXIT.ok;
|
|
2133
|
+
} finally {
|
|
2134
|
+
counterpart.close();
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
|
|
1940
2138
|
/**
|
|
1941
2139
|
* `self-page` — the owner's door to the written page (2026-09-18, S1).
|
|
1942
2140
|
*
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dream` and `core` — the owner's two windows onto the dreaming +
|
|
3
|
+
* consolidation mechanism (2026-09-26), rendered as plain lines.
|
|
4
|
+
*
|
|
5
|
+
* The console decides nothing here. What a dream did, how to undo it, what the
|
|
6
|
+
* core holds and how a memory leaves it are the core's (`core/dream/`,
|
|
7
|
+
* `Counterpart.coreList` / `demoteCore`); this file only turns their answers
|
|
8
|
+
* into lines a person reads. Pure over its inputs, like `self-page.ts`, so the
|
|
9
|
+
* tests can check the words without a store.
|
|
10
|
+
*/
|
|
11
|
+
import type { Counterpart } from "../../core/counterpart.js";
|
|
12
|
+
import { acceptsReflectedFeeling } from "../../core/sleep/index.js";
|
|
13
|
+
import type { ReflectionRow } from "../../core/store/index.js";
|
|
14
|
+
|
|
15
|
+
/** How a memory id reads in a list: its first line, or why it is not shown. */
|
|
16
|
+
export function memoryWords(counterpart: Counterpart, id: string | null, max = 80): string {
|
|
17
|
+
if (id === null) return "(removed by the owner)";
|
|
18
|
+
const row = counterpart.store.row(id);
|
|
19
|
+
if (row === undefined) return "(no such memory)";
|
|
20
|
+
if (row.confidential === 1) return "[confidential]";
|
|
21
|
+
if (row.body === "") return "(removed by the owner)";
|
|
22
|
+
const line = ((row.title ?? "").trim() || (row.body.split("\n").find((l) => l.trim().length > 0) ?? "")).replace(/\s+/g, " ").trim();
|
|
23
|
+
const said = line.length > max ? `${line.slice(0, max - 1)}…` : line;
|
|
24
|
+
return row.archived === 1 ? `${said} (archived: ${row.archived_reason ?? "archived"})` : said;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function countsLine(counts: Readonly<Record<string, number>>): string {
|
|
28
|
+
const parts = Object.entries(counts)
|
|
29
|
+
.filter(([, n]) => n > 0)
|
|
30
|
+
.map(([k, n]) => `${String(n)} ${k}`);
|
|
31
|
+
return parts.length === 0 ? "no changes" : parts.join(", ");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `counterparts dream --list`: newest first, one line each. */
|
|
35
|
+
export function dreamListLines(counterpart: Counterpart, limit = 20): string[] {
|
|
36
|
+
const dreams = counterpart.dreams.list(limit);
|
|
37
|
+
if (dreams.length === 0) {
|
|
38
|
+
return [
|
|
39
|
+
"No dreams yet.",
|
|
40
|
+
"A session is asked, at most once a day, whether it may dream; the owner says yes or not today.",
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
const out = [`Dreams — newest first (${String(dreams.length)} shown)`, ""];
|
|
44
|
+
for (const { dream, counts } of dreams) {
|
|
45
|
+
const when = dream.date ?? `lived day ${String(dream.day)}`;
|
|
46
|
+
const title = dream.title === null || dream.title.length === 0 ? "(no journal)" : `"${dream.title}"`;
|
|
47
|
+
out.push(`${dream.id} ${when} ${dream.state.padEnd(9)} ${title} — ${countsLine(counts)}`);
|
|
48
|
+
}
|
|
49
|
+
out.push("", "Read one: counterparts dream --show <id> Reverse one: counterparts dream --undo <id>");
|
|
50
|
+
const reflections = counterpart.reflections.list(10);
|
|
51
|
+
if (reflections.length > 0) {
|
|
52
|
+
out.push("", `Reflections — the waking self, newest first (${String(reflections.length)} shown)`, "");
|
|
53
|
+
for (const r of reflections) out.push(`${r.id} ${r.date ?? `lived day ${String(r.day)}`} ${reflectionSummary(r)}`);
|
|
54
|
+
out.push("", "Read one: counterparts dream --show <rfl_…>");
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function parseIdList(json: string): string[] {
|
|
60
|
+
try {
|
|
61
|
+
const v: unknown = JSON.parse(json);
|
|
62
|
+
return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
|
|
63
|
+
} catch {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** One line: after which dream, what it did, and what became of the share. */
|
|
69
|
+
function reflectionSummary(r: ReflectionRow): string {
|
|
70
|
+
const parts: string[] = [];
|
|
71
|
+
parts.push(r.dream_id === null ? "on its own" : `after ${r.dream_id}`);
|
|
72
|
+
if (r.state !== "reflected") return `${parts.join(", ")} — begun, not finished`;
|
|
73
|
+
if (r.entry_id === null) parts.push("nothing much");
|
|
74
|
+
if (r.page_version !== null) parts.push("rewrote the page");
|
|
75
|
+
const share: Record<string, string> = { none: "no share", offered: "share not told yet", carried: "share carried to a later session", told: "share told" };
|
|
76
|
+
parts.push(share[r.share_state] ?? r.share_state);
|
|
77
|
+
return parts.join(", ");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** `counterparts dream --show <rfl_…>`: one reflection, whole. */
|
|
81
|
+
export function reflectionShowLines(counterpart: Counterpart, id: string): string[] | null {
|
|
82
|
+
const r = counterpart.reflections.show(id);
|
|
83
|
+
if (r === null) return null;
|
|
84
|
+
const out = [
|
|
85
|
+
`Reflection ${r.id} — ${r.date ?? `lived day ${String(r.day)}`}, ${reflectionSummary(r)}`,
|
|
86
|
+
...(r.session === null ? [] : [` for session ${r.session}`]),
|
|
87
|
+
"",
|
|
88
|
+
"Asked:",
|
|
89
|
+
...parseIdList(r.questions).map((q) => ` - ${q}`),
|
|
90
|
+
"",
|
|
91
|
+
r.entry === null ? "Entry: (not written)" : "Entry:",
|
|
92
|
+
];
|
|
93
|
+
if (r.entry !== null) for (const line of r.entry.split("\n")) out.push(` ${line}`);
|
|
94
|
+
if (r.entry_id !== null) out.push(` (kept as memory ${r.entry_id})`);
|
|
95
|
+
const cites = parseIdList(r.cites);
|
|
96
|
+
if (cites.length > 0) {
|
|
97
|
+
out.push("", "It rests on:");
|
|
98
|
+
for (const c of cites) out.push(` ${c} "${memoryWords(counterpart, c)}"`);
|
|
99
|
+
}
|
|
100
|
+
if (r.share !== null) {
|
|
101
|
+
out.push("", "Morning share:", ` ${r.share}`);
|
|
102
|
+
}
|
|
103
|
+
if (r.page_version !== null) out.push("", `It rewrote the self page (version ${String(r.page_version)}): counterparts self-page --versions`);
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** `counterparts dream --show <id>`: the journal, then every change, undone ones marked — and the reflection after it. */
|
|
108
|
+
export function dreamShowLines(counterpart: Counterpart, id: string): string[] | null {
|
|
109
|
+
if (id.startsWith("rfl_")) return reflectionShowLines(counterpart, id);
|
|
110
|
+
const shown = counterpart.dreams.show(id);
|
|
111
|
+
if (shown === null) return null;
|
|
112
|
+
const { dream, changes } = shown;
|
|
113
|
+
const out = [
|
|
114
|
+
`Dream ${dream.id} — ${dream.date ?? `lived day ${String(dream.day)}`}, ${dream.state}`,
|
|
115
|
+
...(dream.session === null ? [] : [` for session ${dream.session}`]),
|
|
116
|
+
"",
|
|
117
|
+
dream.title === null ? "Journal: (not written)" : `Journal: "${dream.title}"`,
|
|
118
|
+
];
|
|
119
|
+
if (dream.journal !== null && dream.journal.length > 0) {
|
|
120
|
+
for (const line of dream.journal.split("\n")) out.push(` ${line}`);
|
|
121
|
+
}
|
|
122
|
+
out.push("", changes.length === 0 ? "Changes: none." : `Changes (${String(changes.length)}):`);
|
|
123
|
+
for (const c of changes) {
|
|
124
|
+
const mark = c.undone === 1 ? " [undone] " : " ";
|
|
125
|
+
const a = c.ref === null ? null : c.ref;
|
|
126
|
+
const b = c.ref2;
|
|
127
|
+
const words = (x: string | null): string => (x === null ? "(removed by the owner)" : `${x} "${memoryWords(counterpart, x)}"`);
|
|
128
|
+
switch (c.action) {
|
|
129
|
+
case "link":
|
|
130
|
+
case "contradiction":
|
|
131
|
+
out.push(`${mark}${c.action}: ${words(a)} ↔ ${words(b)}`);
|
|
132
|
+
break;
|
|
133
|
+
case "merge": {
|
|
134
|
+
let from: string[] = [];
|
|
135
|
+
try {
|
|
136
|
+
const d = JSON.parse(c.detail) as { from?: unknown };
|
|
137
|
+
if (Array.isArray(d.from)) from = d.from.filter((x): x is string => typeof x === "string");
|
|
138
|
+
} catch {
|
|
139
|
+
from = [];
|
|
140
|
+
}
|
|
141
|
+
out.push(`${mark}merge into ${words(a)}`);
|
|
142
|
+
for (const f of from) out.push(`${mark} from ${words(f)}`);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
default:
|
|
146
|
+
out.push(`${mark}${c.action}: ${words(a)}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (dream.state !== "undone") out.push("", `Reverse all of it: counterparts dream --undo ${dream.id}`);
|
|
150
|
+
// What the waking self made of it — lived, so an undo of the dream leaves it.
|
|
151
|
+
for (const r of counterpart.store.reflections({ dreamId: dream.id, limit: 3 })) {
|
|
152
|
+
const lines = reflectionShowLines(counterpart, r.id);
|
|
153
|
+
if (lines !== null) out.push("", ...lines);
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** `counterparts core --list`: the core with lanes, then nominations and demotions. */
|
|
159
|
+
export function coreListLines(counterpart: Counterpart): string[] {
|
|
160
|
+
const { core, nominated, demoted } = counterpart.coreList();
|
|
161
|
+
const out = [
|
|
162
|
+
core.length === 0
|
|
163
|
+
? "The core is empty: nothing has become part of who I am yet."
|
|
164
|
+
: `The core — ${String(core.length)} ${core.length === 1 ? "memory" : "memories"} that do not fade`,
|
|
165
|
+
];
|
|
166
|
+
for (const m of core) {
|
|
167
|
+
const how = m.lane === null ? "(before lanes, or by revision)" : `${m.lane} lane${m.day === null ? "" : `, lived day ${String(m.day)}`}`;
|
|
168
|
+
const said = m.confidential ? "[confidential]" : (m.body ?? "(unreadable)");
|
|
169
|
+
out.push(` ${m.id} ${m.kind.padEnd(6)} ${how} — ${said}`);
|
|
170
|
+
}
|
|
171
|
+
out.push(
|
|
172
|
+
"",
|
|
173
|
+
"Only a memory about me, about us or about the owner becomes core — what it is about is marked by",
|
|
174
|
+
"meaning, by the writer or by a reflection (work and world are not candidates). Then: strongly felt",
|
|
175
|
+
"and back after a gap (fast lane), or back on several separate days over weeks (slow lane). A",
|
|
176
|
+
"reflection that cites a memory counts as it coming back. At most a few a night.",
|
|
177
|
+
acceptsReflectedFeeling(counterpart.store)
|
|
178
|
+
? "Open to reflection alone: a feeling a reflection records later and a reflection citing a memory count toward the fast lane, and a reflection may re-label either way (counterparts core --reflected-feeling off to close it)."
|
|
179
|
+
: "Closed to reflection alone: the fast lane needs a feeling felt at the time and an ordinary use after a gap, and a reflection may only move a memory toward work or world (counterparts core --reflected-feeling on to open it).",
|
|
180
|
+
);
|
|
181
|
+
if (nominated.length > 0) {
|
|
182
|
+
out.push("", "Nominated by a dream (a lane still has to promote it):");
|
|
183
|
+
for (const n of nominated.slice(0, 20)) {
|
|
184
|
+
out.push(` ${n.id} lived day ${String(n.day)}${n.reason === null ? "" : ` — ${n.reason}`}${n.dream === null ? "" : ` (${n.dream})`}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (demoted.length > 0) {
|
|
188
|
+
out.push("", "Sent back to ordinary fading by you:");
|
|
189
|
+
for (const d of demoted.slice(0, 20)) out.push(` ${d.id} lived day ${String(d.day)}${d.reason === null ? "" : ` — ${d.reason}`}`);
|
|
190
|
+
}
|
|
191
|
+
if (core.length > 0) out.push("", 'Send one back: counterparts core --demote <id> --reason "..."');
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
@@ -260,7 +260,9 @@ function collectMarkdown(store: Store, opts: ExportOptions): { bundle: Bundle; c
|
|
|
260
260
|
// THE MEMORY'S FEELINGS TRAVEL WITH IT (schema v7, review N7): a short
|
|
261
261
|
// section after the body, one line each, so the readable copy says what the
|
|
262
262
|
// database does. The database export carries the table whole.
|
|
263
|
-
|
|
263
|
+
// Its trait nudges too (v9), the same way. The row is here, so it was
|
|
264
|
+
// either not confidential or the owner asked for confidential ones.
|
|
265
|
+
const text = rendered + feelingsSection(store, id) + traitsSection(store, id);
|
|
264
266
|
put(pathFor(store, row, doc), text);
|
|
265
267
|
counts.rows += 1;
|
|
266
268
|
if (row.type === "episode") counts.journal += 1;
|
|
@@ -316,6 +318,22 @@ function feelingsSection(store: Store, id: string): string {
|
|
|
316
318
|
return `\n\n## Feelings\n\n${lines.join("\n")}\n`;
|
|
317
319
|
}
|
|
318
320
|
|
|
321
|
+
/** `\n## Traits\n\n1. agreeable-candid → candid · 0.6 — carried by …`, or "" when none. */
|
|
322
|
+
function traitsSection(store: Store, id: string): string {
|
|
323
|
+
let rows;
|
|
324
|
+
try {
|
|
325
|
+
rows = store.traitsFor(id, { includeConfidential: true });
|
|
326
|
+
} catch {
|
|
327
|
+
return "";
|
|
328
|
+
}
|
|
329
|
+
if (rows.length === 0) return "";
|
|
330
|
+
const lines = rows.map((r, i) => {
|
|
331
|
+
const by = r.carried_by.length === 0 ? "" : ` — carried by: ${r.carried_by.replace(/\r?\n/g, " ")}`;
|
|
332
|
+
return `${String(i + 1)}. ${r.axis} → ${r.toward} · ${String(r.strength)}${by}`;
|
|
333
|
+
});
|
|
334
|
+
return `\n\n## Traits\n\n${lines.join("\n")}\n`;
|
|
335
|
+
}
|
|
336
|
+
|
|
319
337
|
function pathFor(store: Store, row: MemoryRow, doc: ProseDoc): string {
|
|
320
338
|
if (row.type === "episode") return journalRelativePath(doc);
|
|
321
339
|
if (row.type === "schema") {
|
|
@@ -734,7 +752,8 @@ function markdownReadme(census: MarkdownCensus, opts: ExportOptions): string {
|
|
|
734
752
|
"",
|
|
735
753
|
"- `memories/<kind>/<id>.md` — one file per memory, grouped by kind. The file name is",
|
|
736
754
|
" the memory's id; the title, dates and everything else are in the frontmatter, and",
|
|
737
|
-
" any feelings recorded on it are a `## Feelings` list after the words
|
|
755
|
+
" any feelings recorded on it are a `## Feelings` list after the words, and any trait",
|
|
756
|
+
" nudges a `## Traits` list after those.",
|
|
738
757
|
census.archived === 0
|
|
739
758
|
? " None of them is archived: every memory here is a live one."
|
|
740
759
|
: ` ${String(census.archived)} of them ${census.archived === 1 ? "is" : "are"} ARCHIVED — faded, superseded or merged.` +
|