counterparts 0.3.1 → 0.3.2
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 +49 -1
- package/docs/module-map.md +2 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/NOTES.md +32 -0
- package/src/adapters/claude-code/bin/hook.ts +15 -2
- package/src/adapters/claude-code/bin/runner.ts +3 -1
- package/src/adapters/claude-code/config.ts +23 -0
- package/src/adapters/claude-code/doctor.ts +39 -20
- package/src/adapters/claude-code/hooks.ts +32 -12
- package/src/adapters/claude-code/index.ts +1 -0
- package/src/adapters/cli/commands.ts +178 -59
- package/src/adapters/cli/export.ts +27 -3
- package/src/adapters/cli/help.ts +22 -8
- package/src/adapters/cli/install.ts +3 -5
- package/src/adapters/cli/mechanisms.ts +295 -0
- package/src/adapters/cli/repair-dates.ts +3 -1
- package/src/adapters/dashboard/CONTRACT.md +13 -9
- package/src/adapters/dashboard/NOTES.md +3 -2
- package/src/adapters/dashboard/activity.ts +2 -1
- package/src/adapters/dashboard/bin/dashboard.ts +18 -3
- package/src/adapters/dashboard/upgrade.ts +23 -0
- package/src/adapters/dashboard/web/README.md +153 -0
- package/src/adapters/dashboard/web/actions.ts +631 -0
- package/src/adapters/dashboard/web/app.html +40 -1703
- package/src/adapters/dashboard/web/app.js +55 -0
- package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
- package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
- package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
- package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
- package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
- package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
- package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
- package/src/adapters/dashboard/web/narrate.ts +10 -10
- package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
- package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
- package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
- package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
- package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
- package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
- package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
- package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
- package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
- package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
- package/src/adapters/dashboard/web/pages/health/health.css +93 -0
- package/src/adapters/dashboard/web/pages/health/index.js +41 -0
- package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
- package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
- package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
- package/src/adapters/dashboard/web/pages/home/home.css +134 -0
- package/src/adapters/dashboard/web/pages/home/index.js +84 -0
- package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
- package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
- package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
- package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
- package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
- package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
- package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
- package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
- package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
- package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
- package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
- package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
- package/src/adapters/dashboard/web/pages/self/index.js +43 -0
- package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
- package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
- package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
- package/src/adapters/dashboard/web/pages/self/self.css +182 -0
- package/src/adapters/dashboard/web/server.ts +305 -28
- package/src/adapters/dashboard/web/shared/absence.js +14 -0
- package/src/adapters/dashboard/web/shared/actions.js +48 -0
- package/src/adapters/dashboard/web/shared/api.js +17 -0
- package/src/adapters/dashboard/web/shared/base.css +34 -0
- package/src/adapters/dashboard/web/shared/canvas.js +68 -0
- package/src/adapters/dashboard/web/shared/colors.js +6 -0
- package/src/adapters/dashboard/web/shared/dom.js +4 -0
- package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/format.js +31 -0
- package/src/adapters/dashboard/web/shared/layout.css +32 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
- package/src/adapters/dashboard/web/shared/modal.css +24 -0
- package/src/adapters/dashboard/web/shared/modal.js +22 -0
- package/src/adapters/dashboard/web/shared/state.js +12 -0
- package/src/adapters/dashboard/web/shared/tip.css +4 -0
- package/src/adapters/dashboard/web/shared/tip.js +12 -0
- package/src/adapters/dashboard/web/shared/tokens.css +50 -0
- package/src/adapters/dashboard/web/shared/type.css +52 -0
- package/src/adapters/dashboard/web/shared/utilities.css +5 -0
- package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
- package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
- package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
- package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
- package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
- package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
- package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
- package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
- package/src/adapters/dashboard/web/shell/pages.js +15 -0
- package/src/adapters/dashboard/web/shell/pulse.js +86 -0
- package/src/adapters/dashboard/web/shell/tabs.js +49 -0
- package/src/adapters/dashboard/web/static.ts +76 -0
- package/src/adapters/dashboard/web/views/activity.ts +80 -0
- package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
- package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
- package/src/adapters/dashboard/web/views/health.ts +328 -0
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
- package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
- package/src/adapters/dashboard/web/views/memories.ts +342 -0
- package/src/adapters/dashboard/web/views/memory.ts +210 -0
- package/src/adapters/dashboard/web/views/meta.ts +64 -0
- package/src/adapters/dashboard/web/views/mind.ts +729 -0
- package/src/adapters/dashboard/web/views/overview.ts +282 -0
- package/src/adapters/dashboard/web/views/pulse.ts +19 -0
- package/src/adapters/dashboard/web/views/rows.ts +207 -0
- package/src/adapters/dashboard/web/views/search.ts +62 -0
- package/src/adapters/dashboard/web/views/shared.ts +161 -0
- package/src/adapters/dashboard/web/views.ts +34 -1724
- package/src/adapters/fired.ts +28 -17
- package/src/adapters/mcp/NOTES.md +43 -0
- package/src/adapters/mcp/bin/serve.ts +5 -1
- package/src/adapters/mcp/index.ts +3 -0
- package/src/adapters/mcp/server.ts +163 -6
- package/src/adapters/mcp/tools.ts +42 -0
- package/src/adapters/mcp/write-up.ts +1 -1
- package/src/core/counterpart.ts +30 -1
- package/src/core/feelings-wheel.ts +218 -0
- package/src/core/mint.ts +14 -2
- package/src/core/prospective/INTERFACE-GAPS.md +10 -0
- package/src/core/prospective/windows.ts +10 -48
- package/src/core/self/NOTES.md +17 -0
- package/src/core/self/calendar.ts +7 -78
- package/src/core/self/episodes.ts +7 -8
- package/src/core/self/index.ts +32 -11
- package/src/core/self/writer.ts +22 -22
- package/src/core/sleep/cycle.ts +8 -2
- package/src/core/store/CONTRACT.md +26 -7
- package/src/core/store/NOTES.md +142 -0
- package/src/core/store/errors.ts +15 -0
- package/src/core/store/feelings.ts +182 -0
- package/src/core/store/index.ts +297 -45
- package/src/core/store/operational.ts +133 -11
- package/src/core/store/owner-op-seam.ts +13 -3
- package/src/core/store/pre-migration.ts +3 -1
- package/src/core/store/prose.ts +8 -1
- package/src/core/store/render.ts +3 -0
- package/src/core/time.ts +374 -0
- package/src/core/types.ts +13 -0
- package/src/adapters/dashboard/web/brain.html +0 -463
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* is testable against a temp dir with a faked console.
|
|
28
28
|
*/
|
|
29
29
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
30
|
+
import { localDate, resolveZone, todayIn } from "../../core/time.js";
|
|
30
31
|
import { homedir, tmpdir } from "node:os";
|
|
31
32
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
32
33
|
import { spawn } from "node:child_process";
|
|
@@ -131,6 +132,8 @@ import { OBSERVER_ENV, observerFromEnv, unreadableStanceLine } from "../stance-e
|
|
|
131
132
|
// so the three surfaces cannot disagree about what "silent" means.
|
|
132
133
|
import { STATE_MEANING, STATE_ORDER, firedReport } from "../fired.js";
|
|
133
134
|
import type { FiredReport, FiredState } from "../fired.js";
|
|
135
|
+
// The short view over the same reading: one line per memory mechanism.
|
|
136
|
+
import { mechanismsLines } from "./mechanisms.js";
|
|
134
137
|
// The two snapshot readers `status` shares with doctor: the DIRECTORY is what
|
|
135
138
|
// says how many copies you have, and a row only says what a run once wrote.
|
|
136
139
|
import { readSnapshotsDir, resolveSnapshotsDir } from "../snapshots.js";
|
|
@@ -283,6 +286,10 @@ export const COMMANDS = [
|
|
|
283
286
|
"probe-oq4",
|
|
284
287
|
// Constitution 11's last sentence as a command: which mechanisms fired this
|
|
285
288
|
// week, which have gone quiet, and which record nothing at all. Read-only.
|
|
289
|
+
// ONE COMMAND, TWO NAMES (2026-09-25): `mechanisms` is the listed spelling
|
|
290
|
+
// and prints one line per memory mechanism; `fired` is its older name and
|
|
291
|
+
// dispatches for good. `--all` on either prints the full `fired` report.
|
|
292
|
+
"mechanisms",
|
|
286
293
|
"fired",
|
|
287
294
|
// I32's reading: whether the background half is alive. (Its partner, the
|
|
288
295
|
// `credentials` command, went with the API keys on 2026-09-24.)
|
|
@@ -452,6 +459,16 @@ export interface RunOptions {
|
|
|
452
459
|
* pass it and get `realDashboard()`, which loads the server module lazily.
|
|
453
460
|
*/
|
|
454
461
|
dashboard?: DashboardSeam;
|
|
462
|
+
/**
|
|
463
|
+
* WHERE A NOTE IS FILED — the scope `note` stamps on what it writes. Real
|
|
464
|
+
* terminal runs pass nothing and get the working directory, which is where
|
|
465
|
+
* the person typing is. The dashboard passes its store's own directory: a
|
|
466
|
+
* note written in the browser was not written from any project, and the
|
|
467
|
+
* server's working directory is only wherever it happened to be launched.
|
|
468
|
+
* (The store dir is the same "no project" answer `mcp/server.ts#resolveScope`
|
|
469
|
+
* falls back to.)
|
|
470
|
+
*/
|
|
471
|
+
scope?: string;
|
|
455
472
|
}
|
|
456
473
|
|
|
457
474
|
/**
|
|
@@ -670,14 +687,15 @@ export const COMMAND_FLAGS: Record<Command, readonly string[]> = {
|
|
|
670
687
|
rebrief: ["budget", "config"],
|
|
671
688
|
// Read-only, like `status`: rows in, a table out.
|
|
672
689
|
"probe-oq4": [],
|
|
690
|
+
mechanisms: ["all"],
|
|
673
691
|
fired: ["all"],
|
|
674
692
|
// `doctor` takes `--config` for the same reason `rebrief` does: it reports on
|
|
675
693
|
// the host configuration, and on a machine with two of them the reading is
|
|
676
694
|
// about whichever one the hooks read.
|
|
677
695
|
// `--all` unfolds the screen: on a terminal `doctor` folds every green
|
|
678
696
|
// worker-internal line into one, and this prints them all. Shared with
|
|
679
|
-
// `fired
|
|
680
|
-
//
|
|
697
|
+
// `mechanisms` (and its older name `fired`), whose `--all` means the same
|
|
698
|
+
// thing — every mechanism and every part, in full.
|
|
681
699
|
doctor: ["config", "json", "all"],
|
|
682
700
|
// `--config` because the registry sits BESIDE the configuration, so the flag
|
|
683
701
|
// that says which configuration also says which registry. `--observer` is
|
|
@@ -743,8 +761,10 @@ export const COMMAND_BLURB: Record<Command, string> = {
|
|
|
743
761
|
rebrief: "Re-render and republish the wake bundle NOW, through the boundary's own renderer.",
|
|
744
762
|
"probe-oq4":
|
|
745
763
|
"The OQ4 probe: footnotes delivered vs. later expanded, by calendar date, from recall.decision and recall.credit rows. Read-only.",
|
|
764
|
+
mechanisms:
|
|
765
|
+
"Is each memory mechanism working? One line per mechanism, with a light (● working this week, ◐ built but not firing, ○ not built yet) and the count from the store behind it, then the plumbing in one line that names only what is failing. --all prints the full report: every part, silent first, when it last fired, how often in the last 7 days, what it turned away, and why the store cannot tell for the ones nothing records. Read-only.",
|
|
746
766
|
fired:
|
|
747
|
-
"
|
|
767
|
+
"The older name of `mechanisms` — the same command, the same output. --all prints the full report. Read-only.",
|
|
748
768
|
doctor:
|
|
749
769
|
"Is the background half alive? The config, the two clocks, the newest sweep, sleep, backfill and credit rows, the spawn refusals and the vector coverage — worst first, each with the line that fixes it. Read-only; exit 1 if anything is red.",
|
|
750
770
|
scope:
|
|
@@ -752,7 +772,7 @@ export const COMMAND_BLURB: Record<Command, string> = {
|
|
|
752
772
|
"self-page":
|
|
753
773
|
"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.",
|
|
754
774
|
dashboard:
|
|
755
|
-
"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.
|
|
775
|
+
"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.",
|
|
756
776
|
version: "The version of Counterparts you have. It opens nothing.",
|
|
757
777
|
help:
|
|
758
778
|
"The console's own map. With no argument, the commands a person reaches for, one short line each; with 'advanced', the maintenance shelf and the three flags every command takes; with a command name, that command's whole page.",
|
|
@@ -856,11 +876,11 @@ const FLAG_HELP: Record<string, string> = {
|
|
|
856
876
|
apply: "actually do it — without this, it is a dry run",
|
|
857
877
|
layout:
|
|
858
878
|
"also print which directories the store keeps and which of them a backup carries",
|
|
859
|
-
// TRUE OF
|
|
860
|
-
//
|
|
861
|
-
// every line including the green ones a terminal folds away.
|
|
879
|
+
// TRUE OF EVERY COMMAND THAT TAKES IT, as the table requires: `mechanisms
|
|
880
|
+
// --all` (and `fired --all`) prints the full report of every part, `doctor
|
|
881
|
+
// --all` prints every line including the green ones a terminal folds away.
|
|
862
882
|
all:
|
|
863
|
-
"print every line, including the
|
|
883
|
+
"print every line in full, including the parts a store this new has had nothing to do with yet",
|
|
864
884
|
config:
|
|
865
885
|
"an absolute path to the host configuration, instead of ~/.counterparts/claude-code.json ($COUNTERPARTS_CONFIG says the same); install WRITES it there, rebrief reads it, ask and note read whether recall by meaning is on from it, and counterparts-hook and counterparts-mcp take the same flag (the server, the same variable)",
|
|
866
886
|
batch: "rows per transaction while converting (default 500)",
|
|
@@ -1656,14 +1676,16 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
|
|
|
1656
1676
|
dir,
|
|
1657
1677
|
io,
|
|
1658
1678
|
typeof parsed.flags["dir"] === "string",
|
|
1659
|
-
|
|
1679
|
+
// The person's day, in the zone the config beside this store names,
|
|
1680
|
+
// else this machine's (docs/time.md; UTC before 2026-09-25).
|
|
1681
|
+
localDate(now(), zoneBeside(dir)),
|
|
1660
1682
|
parsed.flags["layout"] === true,
|
|
1661
1683
|
env,
|
|
1662
1684
|
);
|
|
1663
1685
|
case "init":
|
|
1664
1686
|
return initCommand(dir, io, opts.home, typeof parsed.flags["name"] === "string" ? parsed.flags["name"] : undefined);
|
|
1665
1687
|
case "note":
|
|
1666
|
-
return await noteCommand(dir, io, parsed, env, opts.home ?? homedir());
|
|
1688
|
+
return await noteCommand(dir, io, parsed, env, opts.home ?? homedir(), opts.scope);
|
|
1667
1689
|
// ONE COMMAND, TWO NAMES — the same function, not a forwarding shim, so
|
|
1668
1690
|
// there is no arm where one spelling can behave differently from the other.
|
|
1669
1691
|
case "ask":
|
|
@@ -1697,6 +1719,7 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
|
|
|
1697
1719
|
return rebriefCommand(dir, io, parsed.flags["budget"], now, opts.home, named);
|
|
1698
1720
|
case "probe-oq4":
|
|
1699
1721
|
return probeCommand(dir, io, typeof parsed.flags["dir"] === "string");
|
|
1722
|
+
case "mechanisms":
|
|
1700
1723
|
case "fired":
|
|
1701
1724
|
return firedCommand(
|
|
1702
1725
|
dir,
|
|
@@ -1716,7 +1739,7 @@ export async function run(argv: readonly string[], opts: RunOptions): Promise<nu
|
|
|
1716
1739
|
);
|
|
1717
1740
|
}
|
|
1718
1741
|
} catch (err) {
|
|
1719
|
-
io.err(`${command} failed: ${describeDirRefusal(err)}`);
|
|
1742
|
+
io.err(upgradePending(err) ?? `${command} failed: ${describeDirRefusal(err)}`);
|
|
1720
1743
|
return EXIT.failed;
|
|
1721
1744
|
}
|
|
1722
1745
|
}
|
|
@@ -1761,10 +1784,37 @@ function describeDirRefusal(err: unknown, dir?: string): string {
|
|
|
1761
1784
|
describeGuardRefusal(err, `Name the store: --dir <path>, or ${DATA_DIR_ENV}.`) ??
|
|
1762
1785
|
describePreRowsRefusal(err, `Name a store with --dir <path>.`) ??
|
|
1763
1786
|
preRowsInDisguise(err, dir) ??
|
|
1787
|
+
upgradePending(err) ??
|
|
1764
1788
|
String((err as Error).message ?? err)
|
|
1765
1789
|
);
|
|
1766
1790
|
}
|
|
1767
1791
|
|
|
1792
|
+
/**
|
|
1793
|
+
* A store on an OLDER schema, met by a read-only door (review N1, 2026-09-25).
|
|
1794
|
+
* `STORE_UNINITIALIZED` with a `found` version below this build's reads, to an
|
|
1795
|
+
* observer, like an empty store; it is not — it is waiting for the first
|
|
1796
|
+
* session, which copies it and upgrades it. Doctor's sentence, said here too.
|
|
1797
|
+
*/
|
|
1798
|
+
function upgradePending(err: unknown): string | null {
|
|
1799
|
+
if (!isStoreError(err, "STORE_UNINITIALIZED")) return null;
|
|
1800
|
+
const found = Number.parseInt(String(err.detail["found"] ?? ""), 10);
|
|
1801
|
+
// Only a store this build can migrate: v6 up. Below the floor is the
|
|
1802
|
+
// pre-rows refusal's sentence, never "the next session upgrades it".
|
|
1803
|
+
if (!Number.isFinite(found) || found < 6 || found >= SCHEMA_VERSION) return null;
|
|
1804
|
+
return (
|
|
1805
|
+
`this store is on schema v${String(found)}; the next Claude Code session copies it and upgrades it ` +
|
|
1806
|
+
`to v${String(SCHEMA_VERSION)}. Nothing to do: start a session, then run this again.`
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
/** The line a read-only door prints when its open was refused. */
|
|
1811
|
+
function openRefusalLine(err: unknown, dir?: string): string {
|
|
1812
|
+
if (dir !== undefined && preRowsInDisguise(err, dir) !== null) {
|
|
1813
|
+
return `could not open the store: ${describeDirRefusal(err, dir)}`;
|
|
1814
|
+
}
|
|
1815
|
+
return upgradePending(err) ?? `could not open the store: ${describeDirRefusal(err, dir)}`;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1768
1818
|
/**
|
|
1769
1819
|
* The shape-lock shape, wearing `STORE_UNINITIALIZED`'s clothes.
|
|
1770
1820
|
*
|
|
@@ -1815,9 +1865,9 @@ function probeCommand(dir: string, io: Io, namedDir: boolean): number {
|
|
|
1815
1865
|
}
|
|
1816
1866
|
let store: Store;
|
|
1817
1867
|
try {
|
|
1818
|
-
store =
|
|
1868
|
+
store = openStoreAt({ dir, observer: true });
|
|
1819
1869
|
} catch (err) {
|
|
1820
|
-
io.err(
|
|
1870
|
+
io.err(openRefusalLine(err, dir));
|
|
1821
1871
|
return EXIT.failed;
|
|
1822
1872
|
}
|
|
1823
1873
|
try {
|
|
@@ -1842,13 +1892,18 @@ function probeCommand(dir: string, io: Io, namedDir: boolean): number {
|
|
|
1842
1892
|
}
|
|
1843
1893
|
|
|
1844
1894
|
/**
|
|
1845
|
-
* `
|
|
1895
|
+
* `mechanisms` (and its older name `fired`) — which mechanisms have actually
|
|
1896
|
+
* fired, and which have not.
|
|
1897
|
+
*
|
|
1898
|
+
* Two views over ONE reading. The default is the short one a regular user
|
|
1899
|
+
* reads: a line per memory mechanism the site names, and the plumbing in one
|
|
1900
|
+
* line (`mechanisms.ts`). `--all` is the full report below, unchanged.
|
|
1846
1901
|
*
|
|
1847
1902
|
* Read-only, and the same store-absent and open rules as `status`: it opens the
|
|
1848
1903
|
* store in OBSERVER stance whatever the console's own stance is, because reading
|
|
1849
1904
|
* what fired must not be able to change it.
|
|
1850
1905
|
*
|
|
1851
|
-
* SILENT FIRST is the whole shape of the
|
|
1906
|
+
* SILENT FIRST is the whole shape of the full report. A page that opened with
|
|
1852
1907
|
* everything that worked would bury the one thing worth acting on — constitution
|
|
1853
1908
|
* 11's "one that stays silent is diagnosed and fixed" needs the silences on the
|
|
1854
1909
|
* first screen, and every group carries the one line that says what its state
|
|
@@ -1867,13 +1922,14 @@ function firedCommand(
|
|
|
1867
1922
|
}
|
|
1868
1923
|
let store: Store;
|
|
1869
1924
|
try {
|
|
1870
|
-
store =
|
|
1925
|
+
store = openStoreAt({ dir, observer: true });
|
|
1871
1926
|
} catch (err) {
|
|
1872
|
-
io.err(
|
|
1927
|
+
io.err(openRefusalLine(err, dir));
|
|
1873
1928
|
return EXIT.failed;
|
|
1874
1929
|
}
|
|
1875
1930
|
try {
|
|
1876
|
-
|
|
1931
|
+
const report = firedReport(store, localDate(now(), store.zone()));
|
|
1932
|
+
for (const line of all ? firedLines(report, true) : mechanismsLines(report)) io.out(line);
|
|
1877
1933
|
return EXIT.ok;
|
|
1878
1934
|
} finally {
|
|
1879
1935
|
store.close();
|
|
@@ -1980,7 +2036,7 @@ async function selfPageCommand(
|
|
|
1980
2036
|
try {
|
|
1981
2037
|
counterpart = openCounterpart(dir, observer);
|
|
1982
2038
|
} catch (err) {
|
|
1983
|
-
io.err(
|
|
2039
|
+
io.err(openRefusalLine(err, dir));
|
|
1984
2040
|
return EXIT.failed;
|
|
1985
2041
|
}
|
|
1986
2042
|
try {
|
|
@@ -2080,7 +2136,7 @@ const YOUNG_STATES: readonly FiredState[] = ["firing", "blocked", "quiet"];
|
|
|
2080
2136
|
/** The report as plain text: one mechanism per line, grouped by state. */
|
|
2081
2137
|
export function firedLines(report: FiredReport, all = false): string[] {
|
|
2082
2138
|
const lines = [
|
|
2083
|
-
`what has fired — ${report.from}→${report.today}
|
|
2139
|
+
`what has fired — ${report.from}→${report.today}, against ${report.previousFrom}→${report.previousTo}`,
|
|
2084
2140
|
"",
|
|
2085
2141
|
];
|
|
2086
2142
|
const young = report.young && !all;
|
|
@@ -2099,7 +2155,7 @@ export function firedLines(report: FiredReport, all = false): string[] {
|
|
|
2099
2155
|
`This store is on lived day ${String(report.livedDay)} — ${age}. Most mechanisms have had ` +
|
|
2100
2156
|
`nothing to do yet, so below is only what HAS fired and anything that was stopped. The ` +
|
|
2101
2157
|
`full roll-call of ${String(report.rows.length)} comes back on its own once the store is ` +
|
|
2102
|
-
"old enough for silence to mean something — or run `counterparts
|
|
2158
|
+
"old enough for silence to mean something — or run `counterparts mechanisms --all` now.",
|
|
2103
2159
|
"",
|
|
2104
2160
|
);
|
|
2105
2161
|
}
|
|
@@ -2167,7 +2223,7 @@ function newestBoundary(store: Store, livedDay: number): string | null {
|
|
|
2167
2223
|
if (last === undefined) return null;
|
|
2168
2224
|
const payload = JSON.parse(last.payload ?? "{}") as Record<string, unknown>;
|
|
2169
2225
|
const date = payload["date"];
|
|
2170
|
-
return typeof date === "string" && date.length === 10 ? date :
|
|
2226
|
+
return typeof date === "string" && date.length === 10 ? date : localDate(last.at, store.zone());
|
|
2171
2227
|
} catch {
|
|
2172
2228
|
return null;
|
|
2173
2229
|
}
|
|
@@ -2246,9 +2302,9 @@ function statusCommand(
|
|
|
2246
2302
|
}
|
|
2247
2303
|
let store: Store;
|
|
2248
2304
|
try {
|
|
2249
|
-
store =
|
|
2305
|
+
store = openStoreAt({ dir, observer: true });
|
|
2250
2306
|
} catch (err) {
|
|
2251
|
-
io.err(
|
|
2307
|
+
io.err(openRefusalLine(err, dir));
|
|
2252
2308
|
return EXIT.failed;
|
|
2253
2309
|
}
|
|
2254
2310
|
try {
|
|
@@ -2414,7 +2470,7 @@ function statusCommand(
|
|
|
2414
2470
|
if (beganSaid !== null) say(`Began: ${beganSaid}`);
|
|
2415
2471
|
const asides = [
|
|
2416
2472
|
"Memories is the number the wake preface states; the journal does not decay.",
|
|
2417
|
-
"counterparts doctor grades all of this; counterparts
|
|
2473
|
+
"counterparts doctor grades all of this; counterparts mechanisms says which mechanisms are working.",
|
|
2418
2474
|
];
|
|
2419
2475
|
say("");
|
|
2420
2476
|
for (const aside of asides) say(` ${aside}`);
|
|
@@ -2423,7 +2479,7 @@ function statusCommand(
|
|
|
2423
2479
|
if (removals.length > 0) {
|
|
2424
2480
|
// Owner side: the id and the date, no body and no content hash — ever.
|
|
2425
2481
|
const rows = removals.map(
|
|
2426
|
-
(row) => ` ${
|
|
2482
|
+
(row) => ` ${localDate(row.at, store.zone())} ${row.memory_id} by ${row.actor}`,
|
|
2427
2483
|
);
|
|
2428
2484
|
tail.push({ title: "Removed:", lines: rows });
|
|
2429
2485
|
say("");
|
|
@@ -2659,7 +2715,7 @@ function installCommand(
|
|
|
2659
2715
|
const existed = storeExists(layout.store);
|
|
2660
2716
|
let store: Store;
|
|
2661
2717
|
try {
|
|
2662
|
-
store =
|
|
2718
|
+
store = openStoreAt({ dir: layout.store });
|
|
2663
2719
|
} catch (err) {
|
|
2664
2720
|
io.err(prefixedRefusal(describeDirRefusal(err, layout.store)));
|
|
2665
2721
|
return EXIT.refused;
|
|
@@ -3028,6 +3084,15 @@ async function installConversation(
|
|
|
3028
3084
|
io.out(`Nice to meet you, ${answer}.`);
|
|
3029
3085
|
}
|
|
3030
3086
|
}
|
|
3087
|
+
// THE ZONE, SAID ONCE AND NOT ASKED (docs/time.md rule 2, 2026-09-25): times
|
|
3088
|
+
// follow the computer, so there is nothing to answer — but a person should
|
|
3089
|
+
// see which clock their memory will read, and how to pin another.
|
|
3090
|
+
const zoneSet = hostConfigFor(layout.config).config.timeZone;
|
|
3091
|
+
u.hint(
|
|
3092
|
+
zoneSet === undefined
|
|
3093
|
+
? `Times read in ${resolveZone(undefined)}, this computer's zone — "timeZone" in the config pins another.`
|
|
3094
|
+
: `Times read in ${zoneSet}, as the config's "timeZone" says.`,
|
|
3095
|
+
);
|
|
3031
3096
|
u.blank();
|
|
3032
3097
|
|
|
3033
3098
|
// ── the store and the configuration — SILENTLY ────────────────────────────
|
|
@@ -3578,6 +3643,8 @@ export interface RunningView {
|
|
|
3578
3643
|
readonly url: string;
|
|
3579
3644
|
/** The store it opened, resolved — printed, so it is never a guess. */
|
|
3580
3645
|
readonly dir: string;
|
|
3646
|
+
/** The store waits for its one-time upgrade; the page says so, and so does this. */
|
|
3647
|
+
readonly upgradePending?: boolean;
|
|
3581
3648
|
stop(): Promise<void>;
|
|
3582
3649
|
}
|
|
3583
3650
|
|
|
@@ -3595,7 +3662,7 @@ export interface RunningView {
|
|
|
3595
3662
|
* dashboard's own server, named in `test/claude-code.test.ts`.)
|
|
3596
3663
|
*/
|
|
3597
3664
|
export interface DashboardSeam {
|
|
3598
|
-
start(opts: { readonly dir: string; readonly port?: number }): Promise<RunningView>;
|
|
3665
|
+
start(opts: { readonly dir: string; readonly port?: number; readonly config?: string }): Promise<RunningView>;
|
|
3599
3666
|
/** Open the person's browser. Never throws: a machine with no opener, or a
|
|
3600
3667
|
* desktop that refuses, is not a reason for the dashboard to fail. */
|
|
3601
3668
|
open?(url: string): void;
|
|
@@ -3673,7 +3740,19 @@ async function dashboardCommand(
|
|
|
3673
3740
|
const seam = opts.dashboard ?? realDashboard(env);
|
|
3674
3741
|
let running: RunningView;
|
|
3675
3742
|
try {
|
|
3676
|
-
|
|
3743
|
+
// THE CONFIGURATION rides along for the dashboard's management actions
|
|
3744
|
+
// (`scope` and `rebrief` read one) — when this command resolved the store
|
|
3745
|
+
// through it, or when one was named outright. A bare `--dir` names a store
|
|
3746
|
+
// and no configuration, and the dashboard then offers no `scope`.
|
|
3747
|
+
const config =
|
|
3748
|
+
typeof parsed.flags["dir"] !== "string" || (named !== undefined && named.source !== "default")
|
|
3749
|
+
? configPath
|
|
3750
|
+
: undefined;
|
|
3751
|
+
running = await seam.start({
|
|
3752
|
+
dir,
|
|
3753
|
+
...(port === undefined ? {} : { port }),
|
|
3754
|
+
...(config === undefined ? {} : { config }),
|
|
3755
|
+
});
|
|
3677
3756
|
} catch (err) {
|
|
3678
3757
|
if ((err as { code?: string }).code === "EADDRINUSE") {
|
|
3679
3758
|
io.err(
|
|
@@ -3691,6 +3770,12 @@ async function dashboardCommand(
|
|
|
3691
3770
|
// changed: a whole memory is being served, and "which one" must never be a
|
|
3692
3771
|
// guess (constitution 16).
|
|
3693
3772
|
io.out(`reading ${tilde(running.dir, home_)}`);
|
|
3773
|
+
if (running.upgradePending === true) {
|
|
3774
|
+
io.out(
|
|
3775
|
+
`this store is on an older schema; the next Claude Code session copies it and upgrades it to ` +
|
|
3776
|
+
`v${String(SCHEMA_VERSION)}. The page says so until then; reload it after.`,
|
|
3777
|
+
);
|
|
3778
|
+
}
|
|
3694
3779
|
if (parsed.flags["no-open"] !== true) seam.open?.(running.url);
|
|
3695
3780
|
|
|
3696
3781
|
await (seam.until ?? untilInterrupted)();
|
|
@@ -3711,8 +3796,9 @@ function realDashboard(env: Record<string, string | undefined>): DashboardSeam {
|
|
|
3711
3796
|
const up = await startDashboard({
|
|
3712
3797
|
dir: o.dir,
|
|
3713
3798
|
...(o.port === undefined ? {} : { port: o.port }),
|
|
3799
|
+
...(o.config === undefined ? {} : { config: o.config }),
|
|
3714
3800
|
});
|
|
3715
|
-
return { url: up.url, dir: up.dir, stop: (): Promise<void> => up.stop() };
|
|
3801
|
+
return { url: up.url, dir: up.dir, upgradePending: up.upgradePending, stop: (): Promise<void> => up.stop() };
|
|
3716
3802
|
},
|
|
3717
3803
|
open(url: string): void {
|
|
3718
3804
|
openInBrowser(url, env);
|
|
@@ -3781,7 +3867,7 @@ function initCommand(dir: string, io: Io, home = homedir(), name?: string): numb
|
|
|
3781
3867
|
const existed = storeExists(dir);
|
|
3782
3868
|
let store: Store;
|
|
3783
3869
|
try {
|
|
3784
|
-
store =
|
|
3870
|
+
store = openStoreAt({ dir });
|
|
3785
3871
|
} catch (err) {
|
|
3786
3872
|
io.err(prefixedRefusal(describeDirRefusal(err, dir)));
|
|
3787
3873
|
return EXIT.refused;
|
|
@@ -4329,7 +4415,7 @@ async function startFreshCommand(
|
|
|
4329
4415
|
const previous = parkedStore ?? soleParked(final);
|
|
4330
4416
|
if (!existedBefore) {
|
|
4331
4417
|
try {
|
|
4332
|
-
const store =
|
|
4418
|
+
const store = openStoreAt({ dir: created });
|
|
4333
4419
|
try {
|
|
4334
4420
|
const entries: [string, string][] = [
|
|
4335
4421
|
[STORE_STARTED_KEY, final.date],
|
|
@@ -4447,7 +4533,7 @@ async function startFreshUndo(
|
|
|
4447
4533
|
// path, of the NEW store, as an observer.
|
|
4448
4534
|
const readRecord = (): string | null => {
|
|
4449
4535
|
try {
|
|
4450
|
-
const store =
|
|
4536
|
+
const store = openStoreAt({ dir: storeDir, observer: true });
|
|
4451
4537
|
try {
|
|
4452
4538
|
return store.getMeta(STORE_PREVIOUS_PARKED_KEY) ?? null;
|
|
4453
4539
|
} finally {
|
|
@@ -4820,6 +4906,7 @@ async function noteCommand(
|
|
|
4820
4906
|
parsed: Parsed,
|
|
4821
4907
|
env: Record<string, string | undefined>,
|
|
4822
4908
|
home: string,
|
|
4909
|
+
filedUnder?: string,
|
|
4823
4910
|
): Promise<number> {
|
|
4824
4911
|
const text = parsed.positional.join(" ").trim();
|
|
4825
4912
|
if (text.length === 0) {
|
|
@@ -4850,7 +4937,7 @@ async function noteCommand(
|
|
|
4850
4937
|
// printed was that something had been remembered.
|
|
4851
4938
|
io.out(`Store: ${counterpart.store.dir}`);
|
|
4852
4939
|
const session = "console";
|
|
4853
|
-
const scope = process.cwd();
|
|
4940
|
+
const scope = filedUnder ?? process.cwd();
|
|
4854
4941
|
// Step 1 of 2, and the ORDER is the rule (see the docblock above).
|
|
4855
4942
|
const captured = counterpart.captureJot({ session, scope, text });
|
|
4856
4943
|
const ownSpanHash = captured.spans[0]?.hash ?? null;
|
|
@@ -5022,8 +5109,15 @@ async function recallCommand(
|
|
|
5022
5109
|
// Opened WITH the embedder's identity, the way `mcp/index.ts#openServer`
|
|
5023
5110
|
// opens the server's store: the store reconciles box 3's tag at open, so a
|
|
5024
5111
|
// held or mismatched meaning index ranks nothing rather than a cosine across
|
|
5025
|
-
// two models.
|
|
5026
|
-
|
|
5112
|
+
// two models.
|
|
5113
|
+
//
|
|
5114
|
+
// AND IN OBSERVER STANCE (owner, 2026-09-25: asking is looking, and looking
|
|
5115
|
+
// changes nothing). A writable open here backfilled the meaning index — on a
|
|
5116
|
+
// fresh store, one `ask` embedded and wrote every row's vector into box 3 —
|
|
5117
|
+
// and asking from the dashboard runs this same function. Under observer the
|
|
5118
|
+
// question is still embedded and answered; nothing is written, the cache
|
|
5119
|
+
// included. The backfill is the worker's and the hooks' job.
|
|
5120
|
+
const counterpart = openCounterpart(dir, true, undefined, embedder?.embed);
|
|
5027
5121
|
try {
|
|
5028
5122
|
// Same rule as `note` and `status`: say which store answered.
|
|
5029
5123
|
if (parsed.flags["json"] !== true) io.out(`Store: ${counterpart.store.dir}`);
|
|
@@ -5471,7 +5565,7 @@ function verifyCommand(dir: string, io: Io, flags: Record<string, string | boole
|
|
|
5471
5565
|
* not be paid for with `--rebuild`, which drops every embedding.
|
|
5472
5566
|
*/
|
|
5473
5567
|
function verifyPruneIndex(dir: string, io: Io): number {
|
|
5474
|
-
const store =
|
|
5568
|
+
const store = openStoreAt({ dir });
|
|
5475
5569
|
try {
|
|
5476
5570
|
const removed = store.pruneDeadIndex();
|
|
5477
5571
|
io.out(`Store: ${dir}`);
|
|
@@ -5504,7 +5598,7 @@ function verifyPruneIndex(dir: string, io: Io): number {
|
|
|
5504
5598
|
* lose nothing.
|
|
5505
5599
|
*/
|
|
5506
5600
|
function verifyRetrySkipped(dir: string, io: Io): number {
|
|
5507
|
-
const store =
|
|
5601
|
+
const store = openStoreAt({ dir });
|
|
5508
5602
|
try {
|
|
5509
5603
|
const skipped = store.skippedVectorIds();
|
|
5510
5604
|
const held = store.metaWithPrefix(EMBED_FAILED_PREFIX);
|
|
@@ -5537,13 +5631,13 @@ function verifyRetrySkipped(dir: string, io: Io): number {
|
|
|
5537
5631
|
* which is what this read-only line is for. The cap is the sleep budget itself,
|
|
5538
5632
|
* imported rather than restated, so the number printed is the number in force.
|
|
5539
5633
|
*/
|
|
5540
|
-
export function eventLogLines(log: EventLogCensus): string[] {
|
|
5634
|
+
export function eventLogLines(log: EventLogCensus, zone?: string): string[] {
|
|
5541
5635
|
const cap = SLEEP_TUNABLES.BUDGETS.log;
|
|
5542
5636
|
const wouldDelete = Math.min(log.eligible, cap);
|
|
5543
5637
|
const oldest =
|
|
5544
5638
|
log.oldestDay === null || log.oldestAt === null
|
|
5545
5639
|
? "oldest: none"
|
|
5546
|
-
: `oldest: lived day ${log.oldestDay} (${
|
|
5640
|
+
: `oldest: lived day ${log.oldestDay} (${localDate(log.oldestAt, zone)})`;
|
|
5547
5641
|
return [
|
|
5548
5642
|
`Events: ${log.rows} held (${log.latched} latched records) ${oldest} ` +
|
|
5549
5643
|
`window: ${log.retentionDays} lived days (cutoff day ${log.cutoffDay})`,
|
|
@@ -5559,7 +5653,7 @@ export function eventLogLines(log: EventLogCensus): string[] {
|
|
|
5559
5653
|
* out of date — dashboard INTERFACE-GAPS §1 — which is box 3's business.)
|
|
5560
5654
|
*/
|
|
5561
5655
|
function verifyCensus(dir: string, io: Io): number {
|
|
5562
|
-
const store =
|
|
5656
|
+
const store = openStoreAt({ dir, observer: true });
|
|
5563
5657
|
let canonical: string[];
|
|
5564
5658
|
let live: string[];
|
|
5565
5659
|
let denied: string[];
|
|
@@ -5634,7 +5728,7 @@ function verifyCensus(dir: string, io: Io): number {
|
|
|
5634
5728
|
"and let sessions start again.",
|
|
5635
5729
|
);
|
|
5636
5730
|
}
|
|
5637
|
-
for (const line of eventLogLines(log)) io.out(line);
|
|
5731
|
+
for (const line of eventLogLines(log, store.zone())) io.out(line);
|
|
5638
5732
|
|
|
5639
5733
|
// The unreadable half of this is narrow by construction: `Store.open` builds
|
|
5640
5734
|
// box 3 on the way in, so a cache this process cannot read usually fails the
|
|
@@ -5733,7 +5827,7 @@ function verifyRebuild(dir: string, io: Io, dropVectors: boolean, keepVectors: b
|
|
|
5733
5827
|
// longer a reason to refuse, because the count it could not take was only
|
|
5734
5828
|
// ever the count of what would be LOST.
|
|
5735
5829
|
if (keepVectors) {
|
|
5736
|
-
const store =
|
|
5830
|
+
const store = openStoreAt({ dir });
|
|
5737
5831
|
try {
|
|
5738
5832
|
const canonical = store.list().length;
|
|
5739
5833
|
const report = store.rebuildCache({ keepVectors: true });
|
|
@@ -5772,7 +5866,7 @@ function verifyRebuild(dir: string, io: Io, dropVectors: boolean, keepVectors: b
|
|
|
5772
5866
|
);
|
|
5773
5867
|
return EXIT.refused;
|
|
5774
5868
|
}
|
|
5775
|
-
const store =
|
|
5869
|
+
const store = openStoreAt({ dir });
|
|
5776
5870
|
try {
|
|
5777
5871
|
const canonical = store.list().length;
|
|
5778
5872
|
const report = store.rebuildCache();
|
|
@@ -6264,10 +6358,10 @@ function backupCommand(
|
|
|
6264
6358
|
// is now an ordinary failure report with an exit code.
|
|
6265
6359
|
let store: Store;
|
|
6266
6360
|
try {
|
|
6267
|
-
store =
|
|
6361
|
+
store = openStoreAt({ dir, observer: true });
|
|
6268
6362
|
} catch (err) {
|
|
6269
6363
|
io.out(`Snapshot: none — nothing was copied.`);
|
|
6270
|
-
io.err(`
|
|
6364
|
+
io.err(` ${openRefusalLine(err, dir)}`);
|
|
6271
6365
|
return EXIT.failed;
|
|
6272
6366
|
}
|
|
6273
6367
|
try {
|
|
@@ -6318,7 +6412,7 @@ function exportCommand(
|
|
|
6318
6412
|
// the store it is reading, the durable row included).
|
|
6319
6413
|
let store: Store;
|
|
6320
6414
|
try {
|
|
6321
|
-
store =
|
|
6415
|
+
store = openStoreAt({ dir, observer });
|
|
6322
6416
|
} catch (err) {
|
|
6323
6417
|
io.err(`export refused: ${describeDirRefusal(err, dir)}`);
|
|
6324
6418
|
return EXIT.refused;
|
|
@@ -6481,7 +6575,7 @@ async function removeByIdCommand(
|
|
|
6481
6575
|
const planOpts = removalPlanOptions(flags);
|
|
6482
6576
|
|
|
6483
6577
|
// THE PLAN, made read-only and with no lock held (scar E5).
|
|
6484
|
-
const planning =
|
|
6578
|
+
const planning = openStoreAt({ dir, observer: true });
|
|
6485
6579
|
let plan;
|
|
6486
6580
|
try {
|
|
6487
6581
|
plan = planRemoval(planning, targetId, planOpts);
|
|
@@ -6512,7 +6606,7 @@ async function removeByIdCommand(
|
|
|
6512
6606
|
|
|
6513
6607
|
// RELOAD AND RE-PLAN under the writing store: the human took time, and the
|
|
6514
6608
|
// store may not be the store the plan was made against.
|
|
6515
|
-
const store =
|
|
6609
|
+
const store = openStoreAt({ dir });
|
|
6516
6610
|
try {
|
|
6517
6611
|
const outcome = removeOne(store, io, targetId, flags, now, planOpts, "scripted");
|
|
6518
6612
|
return outcome === "removed" ? EXIT.ok : outcome === "refused" ? EXIT.refused : EXIT.failed;
|
|
@@ -6758,7 +6852,7 @@ async function removeInteractively(
|
|
|
6758
6852
|
// ONE writing store for the whole selection, and each memory re-planned under
|
|
6759
6853
|
// it on its own — the human took time, and the store may have moved since the
|
|
6760
6854
|
// lines above were printed.
|
|
6761
|
-
const store =
|
|
6855
|
+
const store = openStoreAt({ dir });
|
|
6762
6856
|
let removed = 0;
|
|
6763
6857
|
let refused = 0;
|
|
6764
6858
|
let failed = 0;
|
|
@@ -6925,7 +7019,7 @@ function searchForRemoval(
|
|
|
6925
7019
|
query: string,
|
|
6926
7020
|
): { candidates: RemovalCandidate[]; truncated: boolean } {
|
|
6927
7021
|
const fetch = REMOVE_SEARCH_LIMIT * 2;
|
|
6928
|
-
const store =
|
|
7022
|
+
const store = openStoreAt({ dir, observer: true });
|
|
6929
7023
|
try {
|
|
6930
7024
|
const out: RemovalCandidate[] = [];
|
|
6931
7025
|
const hits = store.search(query, fetch);
|
|
@@ -6962,7 +7056,7 @@ function inspectForRemoval(
|
|
|
6962
7056
|
refused: { id: string; reason: RemovalPlan["reason"] } | null;
|
|
6963
7057
|
entries: { line: string; plan: RemovalPlan }[];
|
|
6964
7058
|
} {
|
|
6965
|
-
const store =
|
|
7059
|
+
const store = openStoreAt({ dir, observer: true });
|
|
6966
7060
|
try {
|
|
6967
7061
|
const entries: { line: string; plan: RemovalPlan }[] = [];
|
|
6968
7062
|
for (const id of chosen) {
|
|
@@ -7088,7 +7182,7 @@ function backfillClaimsCommand(
|
|
|
7088
7182
|
const floor = TUNABLES.AUTHORED_DEFAULT_CLAIM;
|
|
7089
7183
|
|
|
7090
7184
|
// The plan is made read-only, as every plan here is (scar E5).
|
|
7091
|
-
const planning =
|
|
7185
|
+
const planning = openStoreAt({ dir, observer: true });
|
|
7092
7186
|
let targets: { id: string; kind: string; dims: string }[];
|
|
7093
7187
|
try {
|
|
7094
7188
|
targets = backfillTargets(planning);
|
|
@@ -7112,7 +7206,7 @@ function backfillClaimsCommand(
|
|
|
7112
7206
|
return EXIT.ok;
|
|
7113
7207
|
}
|
|
7114
7208
|
|
|
7115
|
-
const store =
|
|
7209
|
+
const store = openStoreAt({ dir });
|
|
7116
7210
|
let written = 0;
|
|
7117
7211
|
const failures: string[] = [];
|
|
7118
7212
|
try {
|
|
@@ -7327,7 +7421,7 @@ function repairMergedBeliefsCommand(
|
|
|
7327
7421
|
}
|
|
7328
7422
|
|
|
7329
7423
|
// The plan is made read-only, as every plan here is (scar E5).
|
|
7330
|
-
const planning =
|
|
7424
|
+
const planning = openStoreAt({ dir, observer: true });
|
|
7331
7425
|
let targets: MergedBelief[];
|
|
7332
7426
|
try {
|
|
7333
7427
|
targets = mergedBeliefs(planning);
|
|
@@ -7373,7 +7467,7 @@ function repairMergedBeliefsCommand(
|
|
|
7373
7467
|
return EXIT.ok;
|
|
7374
7468
|
}
|
|
7375
7469
|
|
|
7376
|
-
const store =
|
|
7470
|
+
const store = openStoreAt({ dir });
|
|
7377
7471
|
let restored = 0;
|
|
7378
7472
|
const failures: string[] = [];
|
|
7379
7473
|
try {
|
|
@@ -7549,7 +7643,7 @@ function rebriefCommand(
|
|
|
7549
7643
|
try {
|
|
7550
7644
|
// The horizon lane asks about a calendar date; the console's own clock is
|
|
7551
7645
|
// the only one in the room, and tests inject it.
|
|
7552
|
-
const at =
|
|
7646
|
+
const at = localDate(now(), counterpart.store.zone());
|
|
7553
7647
|
const report = counterpart.rebrief({ budgetBytes: ceiling.bytes, at });
|
|
7554
7648
|
if (!report.rendered) {
|
|
7555
7649
|
io.err(`refused: the render declined (${report.reason}).`);
|
|
@@ -7958,9 +8052,11 @@ export function openCounterpart(
|
|
|
7958
8052
|
// `embed` likewise: the option every composition root hands its embedder's
|
|
7959
8053
|
// sync face through (`ask`, 2026-09-24).
|
|
7960
8054
|
const snapshotsDir = observer ? undefined : snapshotsDirBeside(dir);
|
|
8055
|
+
const timeZone = zoneBeside(dir);
|
|
7961
8056
|
return Counterpart.open({
|
|
7962
8057
|
dir,
|
|
7963
8058
|
observer,
|
|
8059
|
+
...(timeZone === undefined ? {} : { timeZone }),
|
|
7964
8060
|
...(identity === undefined ? {} : { identity }),
|
|
7965
8061
|
...(embed === undefined ? {} : { embed }),
|
|
7966
8062
|
...(snapshotsDir === undefined ? {} : { snapshotsDir }),
|
|
@@ -7973,6 +8069,28 @@ export function openCounterpart(
|
|
|
7973
8069
|
* console runs puts its copy where the worker's rotation and doctor look.
|
|
7974
8070
|
* Absent, unreadable or unset: undefined, and the store's default applies.
|
|
7975
8071
|
*/
|
|
8072
|
+
/**
|
|
8073
|
+
* `timeZone` from the host configuration beside the store — the same file
|
|
8074
|
+
* `snapshotsDirBeside` reads — so a console command names the person's day in
|
|
8075
|
+
* the zone the hooks use (docs/time.md, 2026-09-25). Absent or unreadable:
|
|
8076
|
+
* undefined, and the store follows the machine's zone.
|
|
8077
|
+
*/
|
|
8078
|
+
export function zoneBeside(dir: string): string | undefined {
|
|
8079
|
+
const beside = join(dir, "..", "claude-code.json");
|
|
8080
|
+
if (!existsSync(beside)) return undefined;
|
|
8081
|
+
try {
|
|
8082
|
+
return loadConfig(JSON.parse(readFileSync(beside, "utf8"))).config.timeZone;
|
|
8083
|
+
} catch {
|
|
8084
|
+
return undefined;
|
|
8085
|
+
}
|
|
8086
|
+
}
|
|
8087
|
+
|
|
8088
|
+
/** `Store.open` for the console: the config's zone beside the store rides along. */
|
|
8089
|
+
function openStoreAt(opts: { dir: string; observer?: boolean }): Store {
|
|
8090
|
+
const timeZone = zoneBeside(opts.dir);
|
|
8091
|
+
return Store.open({ ...opts, ...(timeZone === undefined ? {} : { timeZone }) });
|
|
8092
|
+
}
|
|
8093
|
+
|
|
7976
8094
|
export function snapshotsDirBeside(dir: string): string | undefined {
|
|
7977
8095
|
const beside = join(dir, "..", "claude-code.json");
|
|
7978
8096
|
if (!existsSync(beside)) return undefined;
|
|
@@ -8170,7 +8288,8 @@ function doctorCommand(
|
|
|
8170
8288
|
return EXIT.refused;
|
|
8171
8289
|
}
|
|
8172
8290
|
|
|
8173
|
-
|
|
8291
|
+
// The person's day: the config's zone, else the machine's (docs/time.md).
|
|
8292
|
+
const today = todayIn(resolveZone(config.timeZone));
|
|
8174
8293
|
let store: Store | null = null;
|
|
8175
8294
|
try {
|
|
8176
8295
|
// WOULD A SESSION OPEN THIS STORE — asked FIRST, and closed again inside the
|
|
@@ -8183,7 +8302,7 @@ function doctorCommand(
|
|
|
8183
8302
|
const open = storeExists(dir) ? readCounterpartOpen(dir, undefined, config.snapshots?.dir) : undefined;
|
|
8184
8303
|
if (storeExists(dir)) {
|
|
8185
8304
|
try {
|
|
8186
|
-
store = Store.open({ dir, observer: true });
|
|
8305
|
+
store = Store.open({ dir, observer: true, ...(config.timeZone === undefined ? {} : { timeZone: config.timeZone }) });
|
|
8187
8306
|
} catch (err) {
|
|
8188
8307
|
// A store BEHIND this build refuses an observer until a session has
|
|
8189
8308
|
// upgraded it; the Store open line already grades that, so the rest of
|