counterparts 0.3.49 → 0.3.52
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 +96 -0
- package/README.md +18 -10
- package/docs/QUICKSTART.md +46 -12
- package/docs/manual.md +2 -1
- package/docs/module-map.md +3 -0
- package/package.json +3 -2
- package/src/adapters/claude-code/NOTES.md +43 -0
- package/src/adapters/claude-code/child.ts +23 -2
- package/src/adapters/claude-code/doctor-growth.ts +269 -0
- package/src/adapters/claude-code/doctor-host.ts +19 -1
- package/src/adapters/claude-code/doctor-recall-steps.ts +84 -0
- package/src/adapters/claude-code/doctor.ts +26 -3
- package/src/adapters/claude-code/hooks.ts +7 -1
- package/src/adapters/cli/INTERFACE-GAPS.md +18 -0
- package/src/adapters/cli/NOTES.md +24 -0
- package/src/adapters/cli/commands-dashboard.ts +9 -1
- package/src/adapters/cli/commands-project.ts +2 -1
- package/src/adapters/cli/commands-readings.ts +19 -8
- package/src/adapters/cli/commands-verify.ts +1 -1
- package/src/adapters/cli/commands.ts +4 -2
- package/src/adapters/cli/export.ts +2 -1
- package/src/adapters/cli/install.ts +14 -6
- package/src/adapters/cli/mechanisms.ts +1 -1
- package/src/adapters/cli/wire.ts +22 -6
- package/src/adapters/dashboard/activity.ts +6 -3
- package/src/adapters/dashboard/registries.ts +11 -0
- package/src/adapters/dashboard/web/flow.ts +3 -0
- package/src/adapters/dashboard/web/lanes.ts +4 -0
- package/src/adapters/dashboard/web/narrate.ts +23 -0
- package/src/adapters/dashboard/web/views/activity.ts +4 -2
- package/src/adapters/dashboard/web/views/flow-view.ts +6 -0
- package/src/adapters/dashboard/web/views/memory.ts +13 -0
- package/src/adapters/dashboard/web/views/shared.ts +2 -1
- package/src/adapters/fired.ts +113 -11
- package/src/adapters/host-wiring.ts +3 -1
- package/src/adapters/lifecycle.ts +36 -9
- package/src/adapters/mcp/CONTRACT.md +22 -1
- package/src/adapters/mcp/server-args.ts +51 -0
- package/src/adapters/mcp/server-session-end.ts +8 -2
- package/src/adapters/mcp/server-words.ts +14 -1
- package/src/adapters/mcp/server.ts +117 -7
- package/src/adapters/mcp/tools.ts +4 -3
- package/src/adapters/plugin.ts +1 -0
- package/src/adapters/presence.ts +74 -0
- package/src/adapters/runtime.ts +258 -8
- package/src/adapters/scopes.ts +3 -2
- package/src/adapters/spawn.ts +3 -0
- package/src/adapters/update-check.ts +1 -1
- package/src/adapters/windows-shims.mjs +102 -0
- package/src/core/close-hint.ts +297 -0
- package/src/core/counterpart-boundary.ts +15 -0
- package/src/core/counterpart-deposit.ts +24 -3
- package/src/core/counterpart-events.ts +14 -0
- package/src/core/counterpart-types.ts +6 -0
- package/src/core/counterpart-wake-shape.ts +88 -19
- package/src/core/counterpart.ts +143 -7
- package/src/core/dream/index.ts +1 -1
- package/src/core/dream/reflect.ts +54 -34
- package/src/core/encode/NOTES.md +55 -0
- package/src/core/encode/secrets.ts +477 -3
- package/src/core/event-rollup.ts +175 -0
- package/src/core/handoff/CONTRACT.md +7 -0
- package/src/core/interference.ts +496 -0
- package/src/core/open-close.ts +583 -0
- package/src/core/prospective/CONTRACT.md +24 -0
- package/src/core/prospective/derive.ts +22 -1
- package/src/core/prospective/index.ts +115 -1
- package/src/core/recall/CONTRACT.md +9 -2
- package/src/core/recall/NOTES.md +99 -0
- package/src/core/recall/activate.ts +83 -6
- package/src/core/recall/index.ts +75 -5
- package/src/core/recall/probe.ts +134 -0
- package/src/core/recall/steps.ts +84 -0
- package/src/core/recall/tunables.ts +11 -0
- package/src/core/reconsolidation.ts +14 -4
- package/src/core/remember/CONTRACT.md +2 -1
- package/src/core/remember/NOTES.md +15 -0
- package/src/core/remember/spans.ts +44 -6
- package/src/core/self/NOTES.md +21 -0
- package/src/core/self/work.ts +9 -5
- package/src/core/sleep/CONTRACT.md +36 -2
- package/src/core/sleep/NOTES.md +35 -0
- package/src/core/sleep/close.ts +77 -0
- package/src/core/sleep/cycle.ts +44 -0
- package/src/core/sleep/index.ts +4 -0
- package/src/core/sleep/interfere.ts +73 -0
- package/src/core/sleep/log.ts +27 -2
- package/src/core/sleep/tunables.ts +19 -0
- package/src/core/sleep/types.ts +20 -0
- package/src/core/store/index.ts +157 -10
- package/src/core/store/operational.ts +22 -0
- package/src/core/store/owner-op-seam.ts +16 -0
- package/src/core/store/reads-history.ts +173 -7
- package/src/core/store/reads-memories.ts +253 -4
- package/src/core/store/shapes.ts +8 -0
|
@@ -4,7 +4,7 @@ import { isDay, localDate, localTime, resolveZone, todayIn } from "../../core/ti
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { delimiter, join } from "node:path";
|
|
6
6
|
import { BOUNDARY_EVENT, MCP_RECALL_EVENT, RECALL_CREDIT_EVENT, RECALL_DECISION_EVENT, RECALL_RATED_EVENT } from "../../core/counterpart.js";
|
|
7
|
-
import { PROBE_ROW_CEILING, probeOQ4, probeRatings, renderProbe, renderRatings } from "../../core/recall/probe.js";
|
|
7
|
+
import { PROBE_ROW_CEILING, mergeProbe, mergeRatings, probeOQ4, probeRatings, renderProbe, renderRatings } from "../../core/recall/probe.js";
|
|
8
8
|
// `band` is imported rather than mirrored: the dashboard computes the live
|
|
9
9
|
// band with this exact function, and two implementations of "which band is this
|
|
10
10
|
// row in today" is how the two surfaces disagreed in the first place.
|
|
@@ -17,6 +17,7 @@ import { isJournal } from "../../core/sleep/index.js";
|
|
|
17
17
|
// `export.ts` make, and filed as INTERFACE-GAPS §5. `verify`'s census needs the
|
|
18
18
|
// number of vectors box 3 holds, and `Store` exposes no read for it.
|
|
19
19
|
import { journalModeOf } from "../../core/store/db.js";
|
|
20
|
+
import type { EventRow } from "../../core/store/index.js";
|
|
20
21
|
import {
|
|
21
22
|
LAYOUT,
|
|
22
23
|
REQUIRE_EXPLICIT_DIR_ENV,
|
|
@@ -68,7 +69,7 @@ import type { CheckoutReading } from "../claude-code/doctor.js";
|
|
|
68
69
|
import { readHost, mcpCommand } from "./install.js";
|
|
69
70
|
import { coverageLines } from "./coverage.js";
|
|
70
71
|
import { readDesktop } from "./desktop.js";
|
|
71
|
-
import { runtimeLabel } from "../runtime.js";
|
|
72
|
+
import { runtimeLabel, whichOnPath } from "../runtime.js";
|
|
72
73
|
import { npmMarkerReading } from "../npm-live.js";
|
|
73
74
|
import { installRoute } from "../plugin.js";
|
|
74
75
|
// The terminal layouts for the two readings a person checks an install with.
|
|
@@ -117,17 +118,25 @@ export function probeCommand(dir: string, io: Io, namedDir: boolean): number {
|
|
|
117
118
|
// Explicit ceiling, read NEWEST first and turned back to oldest first: an
|
|
118
119
|
// ascending read with a limit drops the newest rows — the side of the
|
|
119
120
|
// table the probe exists to read.
|
|
121
|
+
// THE DAILY SUMMARIES (FD1 step 2, roadmap ruling R2): the per-turn rows
|
|
122
|
+
// the sweep let go were read by these same two reports before they went,
|
|
123
|
+
// and those reports are merged with the ones over the rows still held. A
|
|
124
|
+
// rolled day's rows still held are in its summary, so they are skipped.
|
|
125
|
+
const rolled = store.rolledDays();
|
|
126
|
+
const held = (r: EventRow): boolean => !rolled.days.has(r.day);
|
|
120
127
|
const decisions = store.eventLog({ name: RECALL_DECISION_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
|
|
121
128
|
const credits = store.eventLog({ name: RECALL_CREDIT_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
|
|
122
|
-
const rows = [...decisions, ...credits].map((r) => ({ name: r.name, day: r.day, payload: r.payload }));
|
|
123
|
-
|
|
129
|
+
const rows = [...decisions, ...credits].filter(held).map((r) => ({ name: r.name, day: r.day, payload: r.payload }));
|
|
130
|
+
const rolledProbes = rolled.rows.flatMap((d) => (d.probe === null ? [] : [{ ...d.probe, sessions: [] }]));
|
|
131
|
+
for (const line of renderProbe(mergeProbe([probeOQ4(rows), ...rolledProbes]))) io.out(line);
|
|
124
132
|
// THE RATINGS (2026-10-14; Mike's call; counted as use since 2026-10-19): what sessions
|
|
125
133
|
// scored of what they were shown, beside the hit rate above.
|
|
126
|
-
const ratings = store.eventLog({ name: RECALL_RATED_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
|
|
127
|
-
const lookups = store.eventLog({ name: MCP_RECALL_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
|
|
134
|
+
const ratings = store.eventLog({ name: RECALL_RATED_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse().filter(held);
|
|
135
|
+
const lookups = store.eventLog({ name: MCP_RECALL_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse().filter(held);
|
|
128
136
|
io.out("");
|
|
129
137
|
const rated = [...rows, ...[...ratings, ...lookups].map((r) => ({ name: r.name, day: r.day, payload: r.payload }))];
|
|
130
|
-
|
|
138
|
+
const rolledRatings = rolled.rows.flatMap((d) => (d.ratings === null ? [] : [d.ratings]));
|
|
139
|
+
for (const line of renderRatings(mergeRatings([probeRatings(rated), ...rolledRatings]))) io.out(line);
|
|
131
140
|
for (const [name, got] of [
|
|
132
141
|
[RECALL_DECISION_EVENT, decisions.length],
|
|
133
142
|
[RECALL_CREDIT_EVENT, credits.length],
|
|
@@ -820,8 +829,10 @@ export const DOCTOR_RED_EXIT = 1;
|
|
|
820
829
|
* when there is no PATH to search, which the fix line reads as "not looked".
|
|
821
830
|
*/
|
|
822
831
|
function claudeOnPath(env: Record<string, string | undefined>): boolean | null {
|
|
823
|
-
const path = env["PATH"];
|
|
832
|
+
const path = env["PATH"] ?? env["Path"];
|
|
824
833
|
if (path === undefined || path.trim().length === 0) return null;
|
|
834
|
+
// Windows: `claude.exe` or npm's `claude.cmd`, and no exec bit to read (W1).
|
|
835
|
+
if (process.platform === "win32") return whichOnPath("claude", env) !== null;
|
|
825
836
|
for (const dir of path.split(delimiter)) {
|
|
826
837
|
if (dir.length === 0) continue;
|
|
827
838
|
try {
|
|
@@ -404,7 +404,7 @@ export function eventLogLines(log: EventLogCensus, zone?: string): string[] {
|
|
|
404
404
|
: `oldest: lived day ${log.oldestDay} (${localDate(log.oldestAt, zone)})`;
|
|
405
405
|
return [
|
|
406
406
|
`Events: ${log.rows} held (${log.latched} latched records) ${oldest} ` +
|
|
407
|
-
`window: ${log.retentionDays} lived days (cutoff day ${log.cutoffDay})`,
|
|
407
|
+
`window: ${log.retentionDays} lived days (cutoff day ${log.cutoffDay}); per-turn rows ${log.shortRetentionDays} (cutoff day ${log.shortCutoffDay}, rolled up a day at a time first)`,
|
|
408
408
|
` past the window: ${log.eligible} unlatched (the next sleep pass deletes ${wouldDelete}, cap ${cap} per pass)` +
|
|
409
409
|
`, ${log.latchedPastCutoff} latched records kept`,
|
|
410
410
|
];
|
|
@@ -83,7 +83,7 @@ import { confirm, isInteractive, isPromptAborted } from "./ui.js";
|
|
|
83
83
|
import type { Ui } from "./ui.js";
|
|
84
84
|
import type { UndoPlan } from "./start-fresh.js";
|
|
85
85
|
import type { DesktopRepair } from "./desktop.js";
|
|
86
|
-
import { BINARY, packagePath } from "../runtime.js";
|
|
86
|
+
import { BINARY, builtVersionOf, packagePath } from "../runtime.js";
|
|
87
87
|
import { installRoute } from "../plugin.js";
|
|
88
88
|
import type { Binary } from "../runtime.js";
|
|
89
89
|
import { DESKTOP_HOST } from "../hosts.js";
|
|
@@ -402,7 +402,9 @@ export function packageVersion(): string {
|
|
|
402
402
|
const said = (JSON.parse(raw) as Record<string, unknown>)["version"];
|
|
403
403
|
readVersion = typeof said === "string" && said.length > 0 ? said : VERSION_UNKNOWN;
|
|
404
404
|
} catch {
|
|
405
|
-
|
|
405
|
+
// The single binary on Windows can't open its embedded package.json; its
|
|
406
|
+
// build handed the same version in (`runtime.ts#setBuiltVersion`, W1).
|
|
407
|
+
readVersion = builtVersionOf() ?? VERSION_UNKNOWN;
|
|
406
408
|
}
|
|
407
409
|
return readVersion;
|
|
408
410
|
}
|
|
@@ -580,7 +580,8 @@ export function sweepStaleExportScratch(now = Date.now()): string[] {
|
|
|
580
580
|
try {
|
|
581
581
|
const st = statSync(full);
|
|
582
582
|
if (!st.isDirectory()) continue;
|
|
583
|
-
|
|
583
|
+
// Windows has no uids (`getuid` is absent): the temp folder is per-user there (W1).
|
|
584
|
+
if (process.getuid !== undefined && st.uid !== process.getuid()) continue;
|
|
584
585
|
if (now - st.mtimeMs < EXPORT_SCRATCH_STALE_MS) continue;
|
|
585
586
|
rmSync(full, { recursive: true, force: true });
|
|
586
587
|
swept.push(name);
|
|
@@ -59,7 +59,7 @@ export const DEFAULT_STORE_DIR = "store";
|
|
|
59
59
|
import { EMBEDDER_KINDS } from "../config.js";
|
|
60
60
|
import type { EmbedderKind } from "../config.js";
|
|
61
61
|
import { CONFIG_ENV, CONFIG_FLAG, defaultConfigPath } from "../config-path.js";
|
|
62
|
-
import { entryScript, parseScriptInvocation, readsHostUserConfig, runtimeOf, runtimePresent,
|
|
62
|
+
import { entryScript, hostInvocation, hostPath, parseScriptInvocation, readsHostUserConfig, runtimeOf, runtimePresent, shellTokens, windowsHookWord } from "../runtime.js";
|
|
63
63
|
import type { RuntimeKind } from "../runtime.js";
|
|
64
64
|
import { pluginInstall, readOurHook, sidebarPluginRecorded } from "../host-wiring.js";
|
|
65
65
|
import type { PluginInstallRead } from "../host-wiring.js";
|
|
@@ -144,9 +144,16 @@ export function shellQuote(path: string): string {
|
|
|
144
144
|
* the Bun shape was `<runtime> run <script>`; those commands still read as
|
|
145
145
|
* ours, so `connect` repairs them in place.
|
|
146
146
|
*/
|
|
147
|
-
export function runCommand(script: string, exe: string = process.execPath): string {
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
export function runCommand(script: string, exe: string = process.execPath, platform: string = process.platform): string {
|
|
148
|
+
// On win32 the runtime by its bare name when PATH finds this one, and `/`
|
|
149
|
+
// paths (`runtime.ts#hostInvocation`, "Windows"): a line Git Bash and
|
|
150
|
+
// PowerShell both run. Elsewhere exactly what it always was.
|
|
151
|
+
const { command, args } = hostInvocation(script, exe, platform);
|
|
152
|
+
const words = args.map((a) => (/^[A-Za-z-]+$/.test(a) ? a : shellQuote(a)));
|
|
153
|
+
// On win32 the first word in a form Claude Code's shell there runs
|
|
154
|
+
// (`runtime.ts#windowsHookWord`: by name, a plain path, or quoted for the
|
|
155
|
+
// one shell present).
|
|
156
|
+
return [platform === "win32" ? windowsHookWord(command).word : shellQuote(command), ...words].join(" ");
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
/**
|
|
@@ -164,7 +171,7 @@ export function hookCommand(configPath?: string, exe: string = process.execPath)
|
|
|
164
171
|
const base = runCommand(HOOK_SCRIPT, exe);
|
|
165
172
|
return configPath === undefined || configPath.length === 0
|
|
166
173
|
? base
|
|
167
|
-
: `${base} ${CONFIG_FLAG} ${shellQuote(configPath)}`;
|
|
174
|
+
: `${base} ${CONFIG_FLAG} ${shellQuote(hostPath(configPath))}`;
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
export const CONFIG_FILE = "claude-code.json";
|
|
@@ -694,7 +701,8 @@ export function hookTargetPath(command: string): string | null {
|
|
|
694
701
|
const tokens = command.trim().split(/\s+/);
|
|
695
702
|
for (const raw of tokens) {
|
|
696
703
|
const token = raw.replace(/^["']|["']$/g, "");
|
|
697
|
-
|
|
704
|
+
// Absolute: `/…`, or a Windows `C:/…` / `C:\…` (W1).
|
|
705
|
+
if (!token.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(token)) continue;
|
|
698
706
|
// Node's loader (`--import …/node-hooks.mjs`) is not the hook either.
|
|
699
707
|
if (/node-hooks\.mjs$/.test(token)) continue;
|
|
700
708
|
// The runtime itself (…/bin/bun) is not the hook; keep looking for the
|
|
@@ -272,7 +272,7 @@ export const MEMORY_MECHANISMS: readonly MemoryMechanism[] = [
|
|
|
272
272
|
// occasion check, so "nothing due this week" is never said of a week
|
|
273
273
|
// when something was due and went unsaid.
|
|
274
274
|
const missed = rows("prospective-plain")?.occasionMissed ?? 0;
|
|
275
|
-
const unsaid = missed > 0 ? `; ${plural(missed, "plain reminder")} due
|
|
275
|
+
const unsaid = missed > 0 ? `; ${plural(missed, "plain reminder")} due where a session could say it, and not said` : "";
|
|
276
276
|
if (v.fired) {
|
|
277
277
|
const parts: string[] = [];
|
|
278
278
|
if (plain > 0) parts.push(`${String(plain)} said plainly`);
|
package/src/adapters/cli/wire.ts
CHANGED
|
@@ -103,7 +103,7 @@ import { PACKAGE_ROOT, PLUGIN_DATA_ENV, PLUGIN_ROOT_ENV } from "../plugin.js";
|
|
|
103
103
|
import { claudeCodeEnvMarker } from "../hosts.js";
|
|
104
104
|
import { withHostUmask } from "../private-umask.js";
|
|
105
105
|
import { tightenInstallBase } from "../private-base.js";
|
|
106
|
-
import { parseScriptInvocation, readsHostUserConfig,
|
|
106
|
+
import { hostExe, hostInvocation, parseScriptInvocation, readsHostUserConfig, shellTokens, windowsHookFit, windowsHookWord, windowsLaunch } from "../runtime.js";
|
|
107
107
|
import { installedBuild, installedVersion, readServerRecords, sameBuild, serverBelieved } from "../sessions.js";
|
|
108
108
|
import type { BuildStamp, ServerRecordRead } from "../sessions.js";
|
|
109
109
|
import type { Io } from "./commands.js";
|
|
@@ -1022,7 +1022,11 @@ export function realSpawner(env: Record<string, string | undefined>): Spawner {
|
|
|
1022
1022
|
// it. `spawnSync` with an array passes each one through whole.
|
|
1023
1023
|
// Under the umask this process was started with: `claude` writes its own
|
|
1024
1024
|
// files, and they keep the modes they always had (`private-umask.ts`).
|
|
1025
|
-
|
|
1025
|
+
// On Windows an npm-installed `claude` is `claude.cmd`, which Node will not
|
|
1026
|
+
// start without a shell: `runtime.ts#windowsLaunch` reads its target (W1).
|
|
1027
|
+
const how = process.platform === "win32" ? windowsLaunch(CLAUDE_BIN, args, env) : { file: CLAUDE_BIN, args: [...args] };
|
|
1028
|
+
if (how === null) return { missing: true, code: null, out: "", err: "" };
|
|
1029
|
+
const res = withHostUmask(() => spawnSync(how.file, how.args, {
|
|
1026
1030
|
encoding: "utf8",
|
|
1027
1031
|
timeout: CLAUDE_TIMEOUT_MS,
|
|
1028
1032
|
windowsHide: true,
|
|
@@ -1057,6 +1061,10 @@ export function mcpAddArgs(
|
|
|
1057
1061
|
exe: string,
|
|
1058
1062
|
serve: string = MCP_SCRIPT,
|
|
1059
1063
|
): string[] {
|
|
1064
|
+
// `hostInvocation`: on win32 `node` by name and `/` paths, the same words the
|
|
1065
|
+
// hook line carries (`runtime.ts`, "Windows"); elsewhere `exe` and
|
|
1066
|
+
// `scriptArgs` as they always were.
|
|
1067
|
+
const { command, args } = hostInvocation(serve, exe);
|
|
1060
1068
|
return [
|
|
1061
1069
|
"mcp",
|
|
1062
1070
|
"add",
|
|
@@ -1067,8 +1075,8 @@ export function mcpAddArgs(
|
|
|
1067
1075
|
`${DATA_DIR_ENV}=${store}`,
|
|
1068
1076
|
...(custom === undefined || custom.length === 0 ? [] : ["-e", `${CONFIG_ENV}=${custom}`]),
|
|
1069
1077
|
"--",
|
|
1070
|
-
|
|
1071
|
-
...
|
|
1078
|
+
command,
|
|
1079
|
+
...args,
|
|
1072
1080
|
];
|
|
1073
1081
|
}
|
|
1074
1082
|
|
|
@@ -1119,9 +1127,9 @@ export function readMcp(
|
|
|
1119
1127
|
if (!isRecord(entry)) return { file, present: false, matches: false, unreadable: false };
|
|
1120
1128
|
const args = entry["args"];
|
|
1121
1129
|
const serverEnv = entry["env"];
|
|
1122
|
-
const want =
|
|
1130
|
+
const { command: wantCommand, args: want } = hostInvocation(serve, exe);
|
|
1123
1131
|
const matches =
|
|
1124
|
-
entry["command"] ===
|
|
1132
|
+
entry["command"] === wantCommand &&
|
|
1125
1133
|
Array.isArray(args) &&
|
|
1126
1134
|
args.length === want.length &&
|
|
1127
1135
|
want.every((a, i) => args[i] === a) &&
|
|
@@ -1395,6 +1403,14 @@ export async function wire(input: WireInput): Promise<WireResult> {
|
|
|
1395
1403
|
return { outcome: "refused", hooks: "refused", mcp: "skipped", backup: null, mcpConfirmed: false };
|
|
1396
1404
|
}
|
|
1397
1405
|
|
|
1406
|
+
// WINDOWS: a hook line that names Node by a path only one of Claude Code's
|
|
1407
|
+
// two shells there can run is said out loud, every connect (W1 review).
|
|
1408
|
+
if (process.platform === "win32") {
|
|
1409
|
+
const exe = hostExe(input.exe);
|
|
1410
|
+
const fit = windowsHookFit(windowsHookWord(exe, env).form, exe);
|
|
1411
|
+
if (fit !== null) u.warn(fit);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1398
1414
|
const plan = planSettings(sight.value, command, "wire");
|
|
1399
1415
|
const merged = plan.hooks;
|
|
1400
1416
|
const mcp = readMcp(home, env, input.store, input.custom, input.exe);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* without saying that would be quietly claiming six things ever happened.
|
|
19
19
|
*/
|
|
20
20
|
import { localClock } from "../../core/time.js";
|
|
21
|
+
import { EVENTS_ROLLED_EVENT, SHORT_RETENTION_DAYS } from "../../core/store/index.js";
|
|
21
22
|
import { PLAIN } from "./ansi.js";
|
|
22
23
|
import type { Style } from "./ansi.js";
|
|
23
24
|
import { NEVER, NONE, heading, indent, plural, stack, subheading, table, truncate } from "./layout.js";
|
|
@@ -50,7 +51,8 @@ export function renderActivity(src: DashboardSource, opts: ActivityOptions = {})
|
|
|
50
51
|
// Newest first is what "lately" means, and it has to be asked of the store:
|
|
51
52
|
// an ascending read with a limit is the OLDEST rows, so past the ceiling the
|
|
52
53
|
// feed printed last month as lately.
|
|
53
|
-
|
|
54
|
+
// The daily summaries (FD1 step 2) are the log's own bookkeeping: counted, not narrated.
|
|
55
|
+
const all = store.eventLog(filter).filter((r) => r.name !== EVENTS_ROLLED_EVENT);
|
|
54
56
|
const shown = all.slice(0, limit);
|
|
55
57
|
// How many the log holds, counted in SQL where it can be; a `ref` filter has
|
|
56
58
|
// no grouped count, so its read is the count and a full one says "at least".
|
|
@@ -64,7 +66,7 @@ export function renderActivity(src: DashboardSource, opts: ActivityOptions = {})
|
|
|
64
66
|
const atLeast = opts.ref !== undefined && all.length >= FEED_CEILING;
|
|
65
67
|
|
|
66
68
|
const bound =
|
|
67
|
-
`I keep events for ${plural(store.retentionDays, "day of use", "days of use")}; older ones are swept unless ` +
|
|
69
|
+
`I keep events for ${plural(store.retentionDays, "day of use", "days of use")} (the per-turn ones for ${plural(Math.min(SHORT_RETENTION_DAYS, store.retentionDays), "day", "days")}, counted a day at a time before they go); older ones are swept unless ` +
|
|
68
70
|
"a replay latch holds them. This is what I still have, not everything that ever happened.";
|
|
69
71
|
|
|
70
72
|
if (shown.length === 0) {
|
|
@@ -103,7 +105,8 @@ export function renderActivity(src: DashboardSource, opts: ActivityOptions = {})
|
|
|
103
105
|
function vocabulary(src: DashboardSource, style: Style): string {
|
|
104
106
|
// One grouped query for every name (INTERFACE-GAPS §5), exact rather than
|
|
105
107
|
// capped at a read ceiling; a name with no rows is absent from it.
|
|
106
|
-
|
|
108
|
+
// All-time (FD1 step 2): the rows held plus the per-turn rows' daily summaries.
|
|
109
|
+
const counts = new Map(src.store.eventCountsAllTime().map((c) => [c.name, c.count]));
|
|
107
110
|
const rows = DURABLE_EVENT_NAMES.map((name) => {
|
|
108
111
|
const count = counts.get(name) ?? 0;
|
|
109
112
|
return [
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* array so this workaround can be deleted.
|
|
20
20
|
* - `PHASES` is `sleep/`'s own exported tuple, imported, never restated.
|
|
21
21
|
*/
|
|
22
|
+
import { LOG_SWEEP_EVENT } from "../../core/sleep/log.js";
|
|
23
|
+
import { EVENTS_ROLLED_EVENT } from "../../core/store/operational.js";
|
|
22
24
|
import { TUNABLES as PHYSICS } from "../../core/physics/index.js";
|
|
23
25
|
import type { PromotionCrossing, PruneRecord } from "../../core/physics/index.js";
|
|
24
26
|
import { PHASES } from "../../core/sleep/index.js";
|
|
@@ -80,6 +82,7 @@ import { BAND_TRANSITION_EVENT } from "../../core/sleep/index.js";
|
|
|
80
82
|
import {
|
|
81
83
|
PROSPECTIVE_FIRE_EVENT,
|
|
82
84
|
PROSPECTIVE_PLAIN_EVENT,
|
|
85
|
+
PROSPECTIVE_PLAIN_CROSSED_EVENT,
|
|
83
86
|
PROSPECTIVE_REFUSED_EVENT,
|
|
84
87
|
} from "../../core/prospective/index.js";
|
|
85
88
|
// The self page's two, from `self/` itself (2026-09-18, S1): a written page is
|
|
@@ -183,6 +186,8 @@ export type DurableEventName =
|
|
|
183
186
|
| typeof SWEEP_WAKE_EVENT
|
|
184
187
|
| typeof SLEEP_CYCLE_EVENT
|
|
185
188
|
| typeof SLEEP_CYCLE_HELD_EVENT
|
|
189
|
+
| typeof LOG_SWEEP_EVENT
|
|
190
|
+
| typeof EVENTS_ROLLED_EVENT
|
|
186
191
|
| typeof SELF_BRIEFING_EVENT
|
|
187
192
|
| typeof SELF_PAGE_REVISED_EVENT
|
|
188
193
|
| typeof SELF_PAGE_REFUSED_EVENT
|
|
@@ -232,6 +237,7 @@ export type DurableEventName =
|
|
|
232
237
|
| typeof PROSPECTIVE_FIRE_EVENT
|
|
233
238
|
| typeof PROSPECTIVE_REFUSED_EVENT
|
|
234
239
|
| typeof PROSPECTIVE_PLAIN_EVENT
|
|
240
|
+
| typeof PROSPECTIVE_PLAIN_CROSSED_EVENT
|
|
235
241
|
| typeof JOURNAL_COPY_WRITTEN_EVENT
|
|
236
242
|
| typeof JOURNAL_COPY_FAILED_EVENT
|
|
237
243
|
| typeof STORE_EXPORT_EVENT
|
|
@@ -316,6 +322,9 @@ export const DURABLE_EVENTS = {
|
|
|
316
322
|
// cycle run today, did every phase succeed, what did the wake trim" could not
|
|
317
323
|
// be answered from the store at all.
|
|
318
324
|
"sleep.cycle": "the consolidation cycle ran (every phase by name, with its status, and the run's counts)",
|
|
325
|
+
// FD1 step 2 (2026-11-07): the log sweep's own record, and its daily roll-up.
|
|
326
|
+
"sleep.log.swept": "the nightly log sweep deleted event rows past their window (how many, how many wait, the days it rolled up)",
|
|
327
|
+
"events.rolled": "one lived day's per-turn rows summed before the sweep let them go: counts by name, the memories credited for use and the sessions (no memory's words), kept",
|
|
319
328
|
"sleep.cycle.held": "a boundary's cycle stood aside for another holding the store, at the start (its flush ran, no phase did) or part-way when its lease was taken over (the holder's pid, how long it had held)",
|
|
320
329
|
"self.briefing": "the wake briefing was re-rendered (what rendered per lane, which ids each kept, how many the trim dropped and, but for a refresh, which)",
|
|
321
330
|
// The page's two (2026-09-18, S1). The refusal has a row of its own because a
|
|
@@ -361,6 +370,8 @@ export const DURABLE_EVENTS = {
|
|
|
361
370
|
"prospective.fire": "a future date arrived and the reminder was offered into the turn (which window, and how much of its budget is left)",
|
|
362
371
|
"prospective.fire.refused": "a reminder was NOT offered (which brake held — one row per window per reason per day of use)",
|
|
363
372
|
"prospective.plain": "a reminder its author marked plain was told to the person on its day (which window, which beat — its day, a month or range opening, or its last day — and the date; `late` when a day passed untold was told within its week after)",
|
|
373
|
+
// SO1 step 3 fix round (2026-11-07): another folder's work reminder unsaid past its day, told once wherever the person was.
|
|
374
|
+
"prospective.plain.crossed": "a plain reminder from another folder went unsaid past its day, because its folder had no session, and was told once in the session the person was in, with its folder named (which window, and the date)",
|
|
364
375
|
// The journal's markdown copy and the hand export (2026-09-20, F6 and F7):
|
|
365
376
|
// the two places the constitution's "prose the owner can view" is kept now
|
|
366
377
|
// that every body is a column.
|
|
@@ -366,6 +366,8 @@ export const EVENT_NODE = {
|
|
|
366
366
|
// to "who did this" is the phase that ran, and the run is the whole of sleep.
|
|
367
367
|
"sleep.cycle": "sleep",
|
|
368
368
|
"sleep.cycle.held": "sleep",
|
|
369
|
+
"sleep.log.swept": "sleep",
|
|
370
|
+
"events.rolled": "sleep",
|
|
369
371
|
// The wake render's record. It is `self/`'s composition and `sleep/`'s order,
|
|
370
372
|
// but what the row DESCRIBES is the bundle — what rendered, what was trimmed —
|
|
371
373
|
// so it lights the node the owner will actually read it against.
|
|
@@ -449,6 +451,7 @@ export const EVENT_NODE = {
|
|
|
449
451
|
"prospective.fire.refused": "prospective",
|
|
450
452
|
// A plain item told on its day (2026-09-26) is the same node's, by request.
|
|
451
453
|
"prospective.plain": "prospective",
|
|
454
|
+
"prospective.plain.crossed": "prospective",
|
|
452
455
|
// Which checkout was live at a session start. It belongs to the SESSION node:
|
|
453
456
|
// it is a fact about the process the host started, recorded on the way in,
|
|
454
457
|
// before anything was read or written.
|
|
@@ -87,8 +87,11 @@ export const LANES = {
|
|
|
87
87
|
// A boundary that left the sleep to a cycle already running: housekeeping,
|
|
88
88
|
// like a check that found nothing due.
|
|
89
89
|
"sleep.cycle.held": "flow",
|
|
90
|
+
"sleep.log.swept": "flow",
|
|
91
|
+
"events.rolled": "flow",
|
|
90
92
|
"prospective.fire": "home",
|
|
91
93
|
"prospective.plain": "home",
|
|
94
|
+
"prospective.plain.crossed": "home",
|
|
92
95
|
// Dreaming and the core (2026-09-26): a dream that wrote its journal, what
|
|
93
96
|
// it changed, and the owner sending a memory back out of the core are
|
|
94
97
|
// things that happened to memories.
|
|
@@ -195,6 +198,7 @@ export function iconOf(name: string, p: Payload): Icon | null {
|
|
|
195
198
|
return "faded";
|
|
196
199
|
case "prospective.fire":
|
|
197
200
|
case "prospective.plain":
|
|
201
|
+
case "prospective.plain.crossed":
|
|
198
202
|
return "reminder";
|
|
199
203
|
default:
|
|
200
204
|
return null;
|
|
@@ -615,6 +615,24 @@ export const NARRATORS = {
|
|
|
615
615
|
* was already running on this store. Calm: it is the ordinary case of a
|
|
616
616
|
* session's two closing hooks, and the other cycle's own row says what ran.
|
|
617
617
|
*/
|
|
618
|
+
/** FD1 step 2 (2026-11-07): the log sweep's own record, and a day's roll-up. Calm: forgetting telemetry on purpose. */
|
|
619
|
+
"sleep.log.swept": (t) => {
|
|
620
|
+
const count = n(t, "count") ?? 0;
|
|
621
|
+
const rolled = n(t, "rolled") ?? 0;
|
|
622
|
+
return calm(
|
|
623
|
+
`I let ${num(count, 0)} old event row${count === 1 ? "" : "s"} go` +
|
|
624
|
+
(rolled > 0 ? `, after counting ${rolled} day${rolled === 1 ? "" : "s"} of per-turn rows` : "") +
|
|
625
|
+
".",
|
|
626
|
+
);
|
|
627
|
+
},
|
|
628
|
+
"events.rolled": (t) => {
|
|
629
|
+
const counts = t.p["counts"];
|
|
630
|
+
const total =
|
|
631
|
+
counts !== null && typeof counts === "object"
|
|
632
|
+
? Object.values(counts as Record<string, unknown>).reduce<number>((s, v) => s + (typeof v === "number" ? v : 0), 0)
|
|
633
|
+
: 0;
|
|
634
|
+
return calm(`I counted a day's per-turn rows (${num(total, 0)}) before letting them go.`);
|
|
635
|
+
},
|
|
618
636
|
"sleep.cycle.held": (t) => {
|
|
619
637
|
if (String(t.p["reason"] ?? "") === "lease-lost") {
|
|
620
638
|
return calm("My sleep stalled partway and another took over; that one finishes the night.");
|
|
@@ -1059,6 +1077,8 @@ export const NARRATORS = {
|
|
|
1059
1077
|
: "on the day";
|
|
1060
1078
|
return notable(`I told you plainly about ${subject(t)} ${when}, as it was asked to be.`);
|
|
1061
1079
|
},
|
|
1080
|
+
// Crossed from its folder (SO1 step 3 fix round): unsaid there, told once elsewhere.
|
|
1081
|
+
"prospective.plain.crossed": (t) => notable(`I told you about ${subject(t)} from its own folder, which had no session while it was due, so it wouldn't go unsaid.`),
|
|
1062
1082
|
|
|
1063
1083
|
// ── the worker that did start ──────────────────────────────────────────────
|
|
1064
1084
|
//
|
|
@@ -1298,6 +1318,7 @@ export const REF_KIND = {
|
|
|
1298
1318
|
"prospective.fire": "memory",
|
|
1299
1319
|
"prospective.fire.refused": "memory",
|
|
1300
1320
|
"prospective.plain": "memory",
|
|
1321
|
+
"prospective.plain.crossed": "memory",
|
|
1301
1322
|
"adapter.checkout": "none",
|
|
1302
1323
|
"adapter.wake.delivered": "none",
|
|
1303
1324
|
"adapter.wake.injected": "none",
|
|
@@ -1338,6 +1359,8 @@ export const REF_KIND = {
|
|
|
1338
1359
|
// BUNDLE. The ids they do carry (the trimmed elements) ride in the payload.
|
|
1339
1360
|
"sleep.cycle": "none",
|
|
1340
1361
|
"sleep.cycle.held": "none",
|
|
1362
|
+
"sleep.log.swept": "none",
|
|
1363
|
+
"events.rolled": "none",
|
|
1341
1364
|
"self.briefing": "none",
|
|
1342
1365
|
// The revision points at the PAGE's own row, which is a real id in the store
|
|
1343
1366
|
// and resolves like any other; a refusal wrote nothing, so it points at
|
|
@@ -10,6 +10,7 @@ import { DURABLE_EVENTS, DURABLE_EVENT_NAMES } from "../../registries.js";
|
|
|
10
10
|
import type { DurableEventName } from "../../registries.js";
|
|
11
11
|
import type { DashboardSource } from "../../source.js";
|
|
12
12
|
import type { EventRow } from "../../../../core/store/index.js";
|
|
13
|
+
import { EVENTS_ROLLED_EVENT, SHORT_RETENTION_DAYS } from "../../../../core/store/index.js";
|
|
13
14
|
import { payloadOf } from "../../../mechanism-evidence.js";
|
|
14
15
|
import { FLOW_NODES, eventsOfNode } from "../flow.js";
|
|
15
16
|
import { laneOf } from "../lanes.js";
|
|
@@ -50,7 +51,8 @@ export function activityView(
|
|
|
50
51
|
// NEWEST `LOG_CEILING`, turned back to oldest first. An ascending read with a
|
|
51
52
|
// limit is the OLDEST rows: past the ceiling the feed showed last month as
|
|
52
53
|
// "lately" and `lastSeq` froze, so the pulse never saw a new row again.
|
|
53
|
-
|
|
54
|
+
// The daily summaries (FD1 step 2) are the log's own bookkeeping: counted, not narrated.
|
|
55
|
+
const all = store.eventLog(filter).reverse().filter((r) => r.name !== EVENTS_ROLLED_EVENT);
|
|
54
56
|
const since = opts.sinceSeq;
|
|
55
57
|
const lane = opts.lane;
|
|
56
58
|
const inLane = (r: EventRow): boolean => lane === undefined || laneOf(r.name, payloadOf(r)) === lane;
|
|
@@ -72,7 +74,7 @@ export function activityView(
|
|
|
72
74
|
lastSeq,
|
|
73
75
|
retentionDays: store.retentionDays,
|
|
74
76
|
bound:
|
|
75
|
-
`I keep events for ${store.retentionDays} days of use; older ones are swept unless a replay latch holds them. ` +
|
|
77
|
+
`I keep events for ${store.retentionDays} days of use (the per-turn ones for ${Math.min(SHORT_RETENTION_DAYS, store.retentionDays)}, counted a day at a time before they go); older ones are swept unless a replay latch holds them. ` +
|
|
76
78
|
"This is what I still have, not everything that ever happened.",
|
|
77
79
|
absent: events.length === 0 ? (everLived ? NONE : NEVER) : null,
|
|
78
80
|
vocabulary: DURABLE_EVENT_NAMES.map((name) => {
|
|
@@ -137,6 +137,12 @@ function nodeState(src: DashboardSource, key: NodeKey, count: number, memories:
|
|
|
137
137
|
for (const row of store.eventLog({ name: "recall.decision", order: "desc", limit: LOG_CEILING })) {
|
|
138
138
|
if (row.ref !== null) sessions.add(row.ref);
|
|
139
139
|
}
|
|
140
|
+
// And the ones whose turns the sweep let go (FD1 step 2): their day's summary named them.
|
|
141
|
+
try {
|
|
142
|
+
for (const r of store.rolledDays().rows) for (const s of r.sessions) sessions.add(s);
|
|
143
|
+
} catch {
|
|
144
|
+
/* the rows alone */
|
|
145
|
+
}
|
|
140
146
|
return sessions.size === 0 ? (day === 0 ? NEVER : NONE) : `${sessions.size} sessions seen`;
|
|
141
147
|
}
|
|
142
148
|
case "remember":
|
|
@@ -540,7 +540,20 @@ function useDaysOf(src: DashboardSource, id: string): number[] {
|
|
|
540
540
|
} catch {
|
|
541
541
|
return [];
|
|
542
542
|
}
|
|
543
|
+
// THE DAILY SUMMARIES (FD1 step 2, roadmap ruling R2): a lived day whose
|
|
544
|
+
// credit rows the sweep let go kept the ids it credited (`used`), so the
|
|
545
|
+
// strip still reaches back past the 30 lived days the rows keep. A rolled
|
|
546
|
+
// day's rows still held are in its summary already.
|
|
547
|
+
let rolledDays: ReadonlySet<number> = new Set();
|
|
548
|
+
try {
|
|
549
|
+
const rolled = src.store.rolledDays();
|
|
550
|
+
rolledDays = rolled.days;
|
|
551
|
+
for (const r of rolled.rows) for (const d of r.used[id] ?? []) if (typeof d === "number") days.add(d);
|
|
552
|
+
} catch {
|
|
553
|
+
/* read off the rows alone */
|
|
554
|
+
}
|
|
543
555
|
for (const e of rows) {
|
|
556
|
+
if (rolledDays.has(e.day)) continue;
|
|
544
557
|
if (e.payload === null || !e.payload.includes(id)) continue;
|
|
545
558
|
try {
|
|
546
559
|
const p = JSON.parse(e.payload) as Record<string, unknown>;
|
|
@@ -174,5 +174,6 @@ export function memoriesLive(src: DashboardSource): number {
|
|
|
174
174
|
* no rows; the caller reads the miss as 0.
|
|
175
175
|
*/
|
|
176
176
|
export function eventCountsByName(src: DashboardSource): ReadonlyMap<string, number> {
|
|
177
|
-
|
|
177
|
+
// All-time (FD1 step 2): the rows held plus the per-turn rows' daily summaries, so a count never shrinks with the sweep.
|
|
178
|
+
return new Map(src.store.eventCountsAllTime().map((c) => [c.name, c.count]));
|
|
178
179
|
}
|