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
package/src/adapters/fired.ts
CHANGED
|
@@ -71,9 +71,15 @@ import {
|
|
|
71
71
|
} from "../core/prospective/index.js";
|
|
72
72
|
import { addDays, daysBetween as calendarDaysBetween, localDate, parseCalendarDate } from "../core/time.js";
|
|
73
73
|
import type { EventRow, ReadOnlyStore } from "../core/store/index.js";
|
|
74
|
-
import { rowToPhysics } from "../core/store/index.js";
|
|
74
|
+
import { SHORT_RETENTION_NAMES, rowToPhysics } from "../core/store/index.js";
|
|
75
|
+
import type { NameSpan, RolledDay } from "../core/event-rollup.js";
|
|
75
76
|
import { emotionalIntensity } from "../core/physics/index.js";
|
|
76
77
|
import { reminderHeldBack } from "../core/dream/slices.js";
|
|
78
|
+
import { PLAIN_CROSS_AFTER_LIVED_DAYS, PROSPECTIVE_PLAIN_CROSSED_EVENT } from "../core/prospective/index.js";
|
|
79
|
+
import { readPresence } from "./presence.js";
|
|
80
|
+
import type { Presence } from "./presence.js";
|
|
81
|
+
import { projectFolder, threadPlace } from "../core/self/work.js";
|
|
82
|
+
import type { Kind } from "../core/types.js";
|
|
77
83
|
import type { FolderOn } from "../core/dream/slices.js";
|
|
78
84
|
import { chapterMoments } from "../core/self/episodes.js";
|
|
79
85
|
import type { DurableEventName } from "./dashboard/registries.js";
|
|
@@ -644,6 +650,15 @@ export const MECHANISMS: readonly Mechanism[] = [
|
|
|
644
650
|
// 2026-10-21): the same mechanism standing aside, not a mechanism of its own.
|
|
645
651
|
covers: ["sleep.cycle.held"],
|
|
646
652
|
},
|
|
653
|
+
{
|
|
654
|
+
// FD1 step 2 (2026-11-07): the log's exit. Per-turn rows go at the short
|
|
655
|
+
// window, each lived day of them counted into one kept row first.
|
|
656
|
+
id: "log-sweep",
|
|
657
|
+
label: "old event rows let go, the per-turn ones counted a day at a time first",
|
|
658
|
+
module: "sleep/log.ts, store/",
|
|
659
|
+
evidence: { kind: "event", names: ["sleep.log.swept"] },
|
|
660
|
+
covers: ["events.rolled"],
|
|
661
|
+
},
|
|
647
662
|
{
|
|
648
663
|
id: "decay",
|
|
649
664
|
label: "memories weaken with time and drop to a lower band",
|
|
@@ -1059,7 +1074,8 @@ export const MECHANISMS: readonly Mechanism[] = [
|
|
|
1059
1074
|
label: "a reminder marked plain was said plainly on its day",
|
|
1060
1075
|
module: "prospective/, lifecycle.ts",
|
|
1061
1076
|
cadence: { kind: "occasion", when: "a reminder marked plain falls due on a day a session runs", check: "plain-due" },
|
|
1062
|
-
|
|
1077
|
+
// A crossing (SO1 step 3 fix round) is the same mechanism saying it late, elsewhere.
|
|
1078
|
+
evidence: { kind: "event", names: ["prospective.plain", "prospective.plain.crossed"] },
|
|
1063
1079
|
since: "2026-09-26",
|
|
1064
1080
|
},
|
|
1065
1081
|
|
|
@@ -1296,6 +1312,8 @@ export interface FiredReport {
|
|
|
1296
1312
|
* isn't known.
|
|
1297
1313
|
*/
|
|
1298
1314
|
readonly heldBack: number;
|
|
1315
|
+
/** Plain reminders due while their folder had no session, waiting to cross (SO1 step 3): info. */
|
|
1316
|
+
readonly homelessPlain: number;
|
|
1299
1317
|
/** The store's own clock — the number of days it has actually LIVED. */
|
|
1300
1318
|
readonly livedDay: number;
|
|
1301
1319
|
/** Calendar days between the oldest row this pass read and today, or null
|
|
@@ -1392,6 +1410,7 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
|
|
|
1392
1410
|
const notRead: string[] = [];
|
|
1393
1411
|
const missedOccasion: string[] = [];
|
|
1394
1412
|
let heldBack = 0;
|
|
1413
|
+
let homelessPlain = 0;
|
|
1395
1414
|
for (const m of MECHANISMS) {
|
|
1396
1415
|
if (m.evidence.kind === "probe" && probed === null) {
|
|
1397
1416
|
notRead.push(m.id);
|
|
@@ -1405,6 +1424,7 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
|
|
|
1405
1424
|
rows.push(row);
|
|
1406
1425
|
if (occasion !== null && occasion.missed > 0) missedOccasion.push(`${row.label} (${occasion.says})`);
|
|
1407
1426
|
heldBack += occasion?.held ?? 0;
|
|
1427
|
+
homelessPlain += occasion?.homeless ?? 0;
|
|
1408
1428
|
}
|
|
1409
1429
|
|
|
1410
1430
|
const counts = Object.fromEntries(FIRED_STATES.map((s) => [s, 0])) as Record<FiredState, number>;
|
|
@@ -1445,6 +1465,7 @@ export function firedReport(store: ReadOnlyStore, today: string, opts: FiredOpti
|
|
|
1445
1465
|
// than twice.
|
|
1446
1466
|
missedOccasion,
|
|
1447
1467
|
heldBack,
|
|
1468
|
+
homelessPlain,
|
|
1448
1469
|
wentQuiet: rows
|
|
1449
1470
|
.filter((r) => r.state === "quiet" && r.firedInPreviousWindow > 0 && r.occasionMissed === 0)
|
|
1450
1471
|
// A row whose table keeps only LIVED days was compared on the lived clock,
|
|
@@ -1808,8 +1829,22 @@ function emptyTally(): NameTally {
|
|
|
1808
1829
|
function readLog(store: ReadOnlyStore, w: Window): LogRead {
|
|
1809
1830
|
const byName = new Map<string, NameTally>();
|
|
1810
1831
|
const age: PassState = { oldest: null, presence: [], attended: new Map() };
|
|
1832
|
+
// THE DAILY SUMMARIES FIRST (FD1 step 2, roadmap ruling R2): the per-turn
|
|
1833
|
+
// rows the sweep let go are counted from their day's `events.rolled` row, so
|
|
1834
|
+
// a total and a last-fired date never shrink with the sweep. A rolled day's
|
|
1835
|
+
// rows still held (a capped sweep half-way through it) are in its summary
|
|
1836
|
+
// already, and skipped below.
|
|
1837
|
+
let rolledDays: ReadonlySet<number> = new Set();
|
|
1838
|
+
try {
|
|
1839
|
+
const rolled = store.rolledDays();
|
|
1840
|
+
rolledDays = rolled.days;
|
|
1841
|
+
for (const day of rolled.rows) tallyRolled(byName, day, w, age);
|
|
1842
|
+
} catch {
|
|
1843
|
+
// A store that cannot read its summaries is read off its rows alone.
|
|
1844
|
+
}
|
|
1845
|
+
const skip = (row: EventRow): boolean => rolledDays.has(row.day) && SHORT_RETENTION_NAMES.includes(row.name) && row.dedup_key === null;
|
|
1811
1846
|
const first = store.eventLog({ limit: EVENT_CEILING });
|
|
1812
|
-
for (const row of first) tallyRow(byName, row, w, age);
|
|
1847
|
+
for (const row of first) if (!skip(row)) tallyRow(byName, row, w, age);
|
|
1813
1848
|
if (first.length < EVENT_CEILING) {
|
|
1814
1849
|
return { byName, truncated: false, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
|
|
1815
1850
|
}
|
|
@@ -1821,7 +1856,7 @@ function readLog(store: ReadOnlyStore, w: Window): LogRead {
|
|
|
1821
1856
|
limit: EVENT_CEILING,
|
|
1822
1857
|
});
|
|
1823
1858
|
for (const row of recent) {
|
|
1824
|
-
if (row.seq <= lastSeq) continue;
|
|
1859
|
+
if (row.seq <= lastSeq || skip(row)) continue;
|
|
1825
1860
|
tallyRow(byName, row, w, age);
|
|
1826
1861
|
}
|
|
1827
1862
|
return { byName, truncated: true, oldestDate: age.oldest, presence: age.presence, attended: age.attended };
|
|
@@ -1874,19 +1909,42 @@ function countInto(
|
|
|
1874
1909
|
key: string,
|
|
1875
1910
|
date: string,
|
|
1876
1911
|
w: Window,
|
|
1912
|
+
n = 1,
|
|
1877
1913
|
): NameTally {
|
|
1878
1914
|
let t = byName.get(key);
|
|
1879
1915
|
if (t === undefined) {
|
|
1880
1916
|
t = emptyTally();
|
|
1881
1917
|
byName.set(key, t);
|
|
1882
1918
|
}
|
|
1883
|
-
t.total +=
|
|
1919
|
+
t.total += n;
|
|
1884
1920
|
if (t.lastDate === null || date > t.lastDate) t.lastDate = date;
|
|
1885
|
-
if (date >= w.from && date <= w.to) t.inWindow +=
|
|
1886
|
-
else if (date >= w.previousFrom && date <= w.previousTo) t.inPreviousWindow +=
|
|
1921
|
+
if (date >= w.from && date <= w.to) t.inWindow += n;
|
|
1922
|
+
else if (date >= w.previousFrom && date <= w.previousTo) t.inPreviousWindow += n;
|
|
1887
1923
|
return t;
|
|
1888
1924
|
}
|
|
1889
1925
|
|
|
1926
|
+
/**
|
|
1927
|
+
* ONE DAILY SUMMARY, TALLIED (FD1 step 2): each name's count on the last
|
|
1928
|
+
* calendar date its rows carried, and the filtered counts (`positive`) the
|
|
1929
|
+
* same way. A summary's rows are older than any window this reads, so the
|
|
1930
|
+
* windows see none of them; the totals, the last-fired dates and the store's
|
|
1931
|
+
* oldest date do.
|
|
1932
|
+
*/
|
|
1933
|
+
function tallyRolled(byName: Map<string, NameTally>, day: RolledDay, w: Window, age: PassState): void {
|
|
1934
|
+
const spanDate = (s: NameSpan, which: "first" | "last"): string =>
|
|
1935
|
+
(which === "first" ? s.firstDate : s.lastDate) ?? localDate(which === "first" ? s.firstAt : s.lastAt, w.zone);
|
|
1936
|
+
for (const [name, span] of Object.entries(day.spans)) {
|
|
1937
|
+
if (typeof span?.n !== "number") continue;
|
|
1938
|
+
const first = spanDate(span, "first");
|
|
1939
|
+
if (age.oldest === null || first < age.oldest) age.oldest = first;
|
|
1940
|
+
countInto(byName, name, spanDate(span, "last"), w, span.n);
|
|
1941
|
+
}
|
|
1942
|
+
for (const [key, span] of Object.entries(day.positive)) {
|
|
1943
|
+
if (typeof span?.n !== "number") continue;
|
|
1944
|
+
countInto(byName, key, spanDate(span, "last"), w, span.n);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1890
1948
|
/** The CALENDAR date a row is about: its own field, else the wall clock it was
|
|
1891
1949
|
* written at. `day` is the lived-day column and answers a different question. */
|
|
1892
1950
|
export function rowDate(row: EventRow, payload: Record<string, unknown>, zone: string): string {
|
|
@@ -2045,6 +2103,8 @@ export interface OccasionReading {
|
|
|
2045
2103
|
readonly says: string;
|
|
2046
2104
|
/** Not said because its folder is closed, and so not in `missed`. */
|
|
2047
2105
|
readonly held?: number;
|
|
2106
|
+
/** Another folder's work, due while its folder had no session and not yet past its crossing (SO1 step 3): info, not in `missed`. */
|
|
2107
|
+
readonly homeless?: number;
|
|
2048
2108
|
}
|
|
2049
2109
|
|
|
2050
2110
|
/** The checks, by `OccasionCheckId`. Each is a READ, and each may fail. */
|
|
@@ -2093,6 +2153,16 @@ function readOccasion(m: Mechanism, store: ReadOnlyStore, log: LogRead, w: Windo
|
|
|
2093
2153
|
* One not said because its folder is closed (`on`, `reminderHeldBack`) is no miss:
|
|
2094
2154
|
* the line says how many are waiting, and it counts in neither number. Read at
|
|
2095
2155
|
* today's setting: a folder turned on since reads as what it now is, due and unsaid.
|
|
2156
|
+
*
|
|
2157
|
+
* ANOTHER FOLDER'S WORK (SO1 step 3 fix round, 2026-11-07) is said only in its own
|
|
2158
|
+
* folder, so one due while its folder had no session is no miss either: an INFO
|
|
2159
|
+
* clause ("due while its folder had no session"), counted in neither number. It
|
|
2160
|
+
* crosses once `PLAIN_CROSS_AFTER_LIVED_DAYS` lived days have passed its last day
|
|
2161
|
+
* (`prospective.plain.crossed`), which reads as said; still unsaid once a session
|
|
2162
|
+
* ran on the day it should have crossed, it is a miss. Both read the session
|
|
2163
|
+
* starts' presence rows (`presence.ts#readPresence`), as the crossing does; a row
|
|
2164
|
+
* that names no folder (written before the field) could have been its folder's,
|
|
2165
|
+
* so it counts as one.
|
|
2096
2166
|
*/
|
|
2097
2167
|
function plainDueReading(store: ReadOnlyStore, log: LogRead, w: Window, on?: FolderOn): OccasionReading {
|
|
2098
2168
|
const lastDay = daysBefore(w.to, 1);
|
|
@@ -2104,6 +2174,9 @@ function plainDueReading(store: ReadOnlyStore, log: LogRead, w: Window, on?: Fol
|
|
|
2104
2174
|
let due = 0;
|
|
2105
2175
|
let missed = 0;
|
|
2106
2176
|
let held = 0;
|
|
2177
|
+
let homeless = 0;
|
|
2178
|
+
// When a person was there and in which folder: the presence rows the crossing reads too (`presence.ts`).
|
|
2179
|
+
let wakes: Presence | null = null;
|
|
2107
2180
|
for (const dated of store.datedMemories(w.from, lastDay)) {
|
|
2108
2181
|
if (denied.has(dated.id)) continue;
|
|
2109
2182
|
const row = store.row(dated.id);
|
|
@@ -2142,22 +2215,51 @@ function plainDueReading(store: ReadOnlyStore, log: LogRead, w: Window, on?: Fol
|
|
|
2142
2215
|
held += 1;
|
|
2143
2216
|
continue;
|
|
2144
2217
|
}
|
|
2218
|
+
if (untold && lineage.some((id) => store.eventLog({ name: PROSPECTIVE_PLAIN_CROSSED_EVENT, ref: id, order: "desc", limit: 50 }).some((e) => e.dedup_key === `${PROSPECTIVE_PLAIN_CROSSED_EVENT}:${id}:${key}`))) {
|
|
2219
|
+
// Crossed from its folder: said.
|
|
2220
|
+
due += 1;
|
|
2221
|
+
continue;
|
|
2222
|
+
}
|
|
2223
|
+
const home = row.origin_scope === null ? "" : projectFolder(row.origin_scope);
|
|
2224
|
+
const waits = home.length > 0 && threadPlace({ about: row.about ?? null, kind: row.kind as Kind, originScope: row.origin_scope, journal: false }, new Set()) === "out";
|
|
2225
|
+
if (untold && waits) {
|
|
2226
|
+
wakes ??= readPresence(store, w.from, w.to);
|
|
2227
|
+
const seen = wakes;
|
|
2228
|
+
const spanDays: string[] = [];
|
|
2229
|
+
for (let day = span.first > w.from ? span.first : w.from; day <= lastDay && day <= span.last; day = addDays(day, 1)) spanDays.push(day);
|
|
2230
|
+
// A row naming no folder (one written before the field), or a day a person was there with no
|
|
2231
|
+
// session start that day (a session carried past midnight), could have been its folder's.
|
|
2232
|
+
const atHome = spanDays.some((d) => (present?.has(d) === true && !seen.folders.has(d)) || [...(seen.folders.get(d) ?? [])].some((f) => f === "" || f === home));
|
|
2233
|
+
if (!atHome) {
|
|
2234
|
+
// Lived days past its last day, up to yesterday: the day it should have crossed has come and gone?
|
|
2235
|
+
const after = [...seen.lived].filter((d) => d > span.last && d <= lastDay).length;
|
|
2236
|
+
if (after < PLAIN_CROSS_AFTER_LIVED_DAYS) {
|
|
2237
|
+
homeless += 1;
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2145
2242
|
due += 1;
|
|
2146
2243
|
if (untold) missed += 1;
|
|
2147
2244
|
}
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2150
|
-
|
|
2245
|
+
const clauses = [
|
|
2246
|
+
held === 0 ? "" : `${String(held)} held back, ${held === 1 ? "its folder" : "their folders"} not on`,
|
|
2247
|
+
homeless === 0 ? "" : `${String(homeless)} due while ${homeless === 1 ? "its folder" : "their folders"} had no session (said elsewhere once ${String(PLAIN_CROSS_AFTER_LIVED_DAYS)} lived days pass)`,
|
|
2248
|
+
].filter((c) => c.length > 0);
|
|
2249
|
+
const waiting = clauses.length === 0 ? "" : `${due === 0 ? "" : "; "}${clauses.join("; ")}`;
|
|
2250
|
+
const heldCount = { ...(held === 0 ? {} : { held }), ...(homeless === 0 ? {} : { homeless }) };
|
|
2251
|
+
if (due === 0) return held === 0 && homeless === 0 ? none : { missed: 0, says: waiting, ...heldCount };
|
|
2151
2252
|
if (missed === 0) {
|
|
2152
2253
|
return { missed: 0, says: `${String(due)} fell due this week, and ${due === 1 ? "it was" : "each was"} said${waiting}`, ...heldCount };
|
|
2153
2254
|
}
|
|
2154
2255
|
return {
|
|
2155
2256
|
missed,
|
|
2156
|
-
says: `${String(missed)} plain ${missed === 1 ? "reminder was" : "reminders were"} due
|
|
2257
|
+
says: `${String(missed)} plain ${missed === 1 ? "reminder was" : "reminders were"} due where a session could say it, and not said${waiting}`,
|
|
2157
2258
|
...heldCount,
|
|
2158
2259
|
};
|
|
2159
2260
|
}
|
|
2160
2261
|
|
|
2262
|
+
|
|
2161
2263
|
/**
|
|
2162
2264
|
* THE DAYS A PERSON COULD HAVE BEEN TOLD SOMETHING, each with its newest such
|
|
2163
2265
|
* moment (review of #337). A session nobody attends — the headless nightly
|
|
@@ -250,7 +250,9 @@ function readObject(path: string): Record<string, unknown> | null {
|
|
|
250
250
|
/** A leading `~/` or `$HOME/` (`${HOME}/`) as the host's shell would expand
|
|
251
251
|
* it, from `env`'s HOME; anything else as it is. */
|
|
252
252
|
export function expandHome(path: string, env: Record<string, string | undefined>): string {
|
|
253
|
-
|
|
253
|
+
// Windows has no HOME as a rule; Git Bash, which runs a hook there, sets it
|
|
254
|
+
// from USERPROFILE (W1).
|
|
255
|
+
const home = (env["HOME"] ?? env["USERPROFILE"] ?? "").trim();
|
|
254
256
|
if (home.length === 0) return path;
|
|
255
257
|
const m = /^(~|\$HOME|\$\{HOME\})(?=[/\\])/.exec(path);
|
|
256
258
|
return m === null ? path : `${home}${path.slice(m[0].length)}`;
|
|
@@ -69,6 +69,9 @@ import { calendarDate } from "../core/self/index.js";
|
|
|
69
69
|
import { ONE_TAG, markerFields, storeMarker } from "./store-id.js";
|
|
70
70
|
import { ahaDue, ahaLine, markAha, meetPending, meetState, noteOffered, offerDue, offerLine, onboardingMarker, settleOffer } from "../core/onboarding.js";
|
|
71
71
|
import { localClock, localDate, readableDate } from "../core/time.js";
|
|
72
|
+
import { PLAIN_CROSS_LOOKBACK_DAYS } from "../core/prospective/index.js";
|
|
73
|
+
import { crossingWindow, readPresence } from "./presence.js";
|
|
74
|
+
import { isDirectoryScope } from "../core/self/work.js";
|
|
72
75
|
|
|
73
76
|
import { CONFIG_FILE_EVENT } from "./config-path.js";
|
|
74
77
|
import { capabilities, TUNABLES } from "./config.js";
|
|
@@ -367,7 +370,8 @@ export interface PlainLines {
|
|
|
367
370
|
/** The records behind them, in the same order — claimed only at delivery. */
|
|
368
371
|
readonly due: PlainReminder[];
|
|
369
372
|
/**
|
|
370
|
-
* What is due and this reader is not told, a closed folder's work
|
|
373
|
+
* What is due and this reader is not told, a closed folder's work or another
|
|
374
|
+
* folder's (`plainFor`):
|
|
371
375
|
* memory ids, so a turn doesn't hand over as a quiet cue what it held back.
|
|
372
376
|
*/
|
|
373
377
|
readonly held?: readonly string[];
|
|
@@ -954,11 +958,12 @@ export class Lifecycle implements HostLifecycle {
|
|
|
954
958
|
* means no calendar, and so nothing; the headless nightly run is told nothing
|
|
955
959
|
* (`SessionInput.nightRun`). A closed folder's work is held back, whichever road
|
|
956
960
|
* the wake takes (2026-10-30, `Counterpart#plainHeldBack`): not in these lines,
|
|
957
|
-
* not claimed, not spent.
|
|
961
|
+
* not claimed, not spent. So is another folder's work, which is told in its own
|
|
962
|
+
* folder (SO1 step 3, 2026-11-07, `Counterpart#plainAway`). The setting is read only when something is due: with
|
|
958
963
|
* no configuration named every folder is on, and one that won't read closes
|
|
959
964
|
* every folder (`writeUpFolders`). Never throws.
|
|
960
965
|
*/
|
|
961
|
-
plainFor(input: SessionInput): PlainLines {
|
|
966
|
+
plainFor(input: SessionInput, opts: { readonly cross?: boolean } = {}): PlainLines {
|
|
962
967
|
const none = { context: "", notices: [], due: [] };
|
|
963
968
|
if (input.at === undefined || input.nightRun === true) return none;
|
|
964
969
|
try {
|
|
@@ -969,11 +974,31 @@ export class Lifecycle implements HostLifecycle {
|
|
|
969
974
|
if (!("on" in read)) read.on = this.writeUpFolders();
|
|
970
975
|
return read.on;
|
|
971
976
|
};
|
|
972
|
-
const
|
|
973
|
-
|
|
977
|
+
const today = this.counterpart.plainDueToday({ at: input.at, scope: input.scope, folders });
|
|
978
|
+
// Another folder's work that went unsaid crosses once (SO1 step 3 fix round, `Counterpart#plainCrossing`):
|
|
979
|
+
// only where the caller says a person is starting (a session start, a wake the host says is attended),
|
|
980
|
+
// never per prompt (round 3: its cost), and never into a reader with no folder (rule a).
|
|
981
|
+
const at = input.at;
|
|
982
|
+
const crossing =
|
|
983
|
+
opts.cross === true && isDirectoryScope(input.scope)
|
|
984
|
+
? this.counterpart.plainCrossing({
|
|
985
|
+
at,
|
|
986
|
+
lived: () => {
|
|
987
|
+
const w = crossingWindow(at, PLAIN_CROSS_LOOKBACK_DAYS);
|
|
988
|
+
return readPresence(this.counterpart.store, w.from, w.to).lived;
|
|
989
|
+
},
|
|
990
|
+
})
|
|
991
|
+
: [];
|
|
992
|
+
if (today.length === 0 && crossing.length === 0) return none;
|
|
974
993
|
const on = folders();
|
|
975
|
-
const
|
|
976
|
-
|
|
994
|
+
const closed = on === undefined ? new Set<string>() : this.counterpart.plainHeldBack([...today, ...crossing].map((r) => r.memoryId), on, input.scope);
|
|
995
|
+
// Another folder's work waits for its own folder (SO1 step 3, `Counterpart#plainAway`): the same reader Coming up reads.
|
|
996
|
+
const away = this.counterpart.plainAway(today.map((r) => r.memoryId), input.scope, this.chapterExports());
|
|
997
|
+
const held = new Set([...closed, ...away]);
|
|
998
|
+
const told = today.filter((r) => !held.has(r.memoryId));
|
|
999
|
+
// A late beat told here (its own folder, in its grace) is the telling: no crossing beside it.
|
|
1000
|
+
const toldIds = new Set(told.map((r) => r.memoryId));
|
|
1001
|
+
const due = [...told, ...crossing.filter((r) => !closed.has(r.memoryId) && !toldIds.has(r.memoryId))];
|
|
977
1002
|
return {
|
|
978
1003
|
context: due.map((r) => `${plainContextLine(r)}\n`).join(""),
|
|
979
1004
|
notices: due.map(plainLine),
|
|
@@ -2147,9 +2172,11 @@ export function substanceOf(turns: readonly HostTurn[]): { turns: number; bytes:
|
|
|
2147
2172
|
*
|
|
2148
2173
|
* `what` is the memory's title or first line (`Counterpart.plainReminders`).
|
|
2149
2174
|
*/
|
|
2150
|
-
export function plainLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "late">): string {
|
|
2175
|
+
export function plainLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "late" | "crossFrom">): string {
|
|
2151
2176
|
const max = TUNABLES.PLAIN_WHAT_MAX_CHARS;
|
|
2152
2177
|
const what = r.what.length <= max ? r.what : `${r.what.slice(0, max - 1).trimEnd()}…`;
|
|
2178
|
+
// Crossed from its folder, unsaid there (SO1 step 3 fix round): the folder named, and when it was due.
|
|
2179
|
+
if (r.crossFrom !== undefined) return `${r.crossFrom}: ${what}, due ${r.precision === "day" ? readableDate(r.lastDay) : `by ${readableDate(r.lastDay)}`} (not said yet: no session there while it was due)`;
|
|
2153
2180
|
if (r.late === true) return `This was for ${readableDate(r.lastDay)}: ${what}`;
|
|
2154
2181
|
if (r.beat === "day") return `Today: ${what}`;
|
|
2155
2182
|
if (r.beat === "last-day") return `Last day today: ${what}`;
|
|
@@ -2162,7 +2189,7 @@ export function plainLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay
|
|
|
2162
2189
|
* memory so it can be looked up. One line, no newline — `what` is folded to
|
|
2163
2190
|
* single spaces upstream — so `withoutPlain` can take it back out by line.
|
|
2164
2191
|
*/
|
|
2165
|
-
export function plainContextLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "memoryId" | "late">): string {
|
|
2192
|
+
export function plainContextLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "memoryId" | "late" | "crossFrom">): string {
|
|
2166
2193
|
return `Plain reminder (they asked to be told) — ${plainLine(r)} [${r.memoryId}]`;
|
|
2167
2194
|
}
|
|
2168
2195
|
|
|
@@ -512,6 +512,21 @@ among the neighbours. Nothing else about the reply changes: the memory is stored
|
|
|
512
512
|
"earlier (now mem_…)"`, before its title (`recall/standing.ts#headOf`, `earlierMark`) — or
|
|
513
513
|
left out when the memory that holds now is already in view.
|
|
514
514
|
|
|
515
|
+
**[M] Open items a write looks like it settles are listed** (SO1 step 1b, 2026-11-07,
|
|
516
|
+
lightly held; `core/close-hint.ts`). A stored `remember` or `session_end` entry comes back
|
|
517
|
+
with `mayClose: [{id, title, folder, settlesWhen?, note?}]` and `mayCloseHint` when open
|
|
518
|
+
items from ANY folder share its subject: the same version series at or past the item's
|
|
519
|
+
(`interference.ts#subjectKeys`/`sameSubject`), the same pull request with a done verb
|
|
520
|
+
beside it (`prKeys`; items in the writer's own project only), or a version or PR the item's
|
|
521
|
+
`settlesWhen` names. Read in each memory's headline. Open only (unresolved, not parked, not
|
|
522
|
+
settled over, not protected), never a check or follow-up, never one in a folder the folder
|
|
523
|
+
setting has off, paused or observer; at most three, nearest first; none for an entry about
|
|
524
|
+
owner/us/me or a plan. One asked of the owner
|
|
525
|
+
carries `note: "asked of <name>: close only if this is <name>'s answer"`. Nothing is
|
|
526
|
+
closed here: the writing model decides. Counted: `open.close-hint.shown` (ref the entry:
|
|
527
|
+
ids, ms) and, for a close of a listed id through `updates` within seven lived days,
|
|
528
|
+
`open.close-hint.closed` (ref the item).
|
|
529
|
+
|
|
515
530
|
## 6c. Re-feeling while awake (2026-10-02, lane B)
|
|
516
531
|
|
|
517
532
|
**[M]** `note` takes `feelingsNow`: how memories this session was shown feel now, recorded
|
|
@@ -541,6 +556,12 @@ each over from the memory it revises unless one is sent (null: none); nothing mo
|
|
|
541
556
|
old memory (`counterpart-deposit.ts#carryFacts`). **[A]** The descriptions ask the writer to
|
|
542
557
|
resolve "last week" to a date at write time and keep `occurredOn` (when it happened) apart
|
|
543
558
|
from `eventDate` (a future date to be reminded on). Facts mode reads them (§6f).
|
|
559
|
+
**[M]** A done one dated today or earlier (SO1 step 2, 2026-11-07, lightly held): `status:
|
|
560
|
+
done` with an `eventDate` whose last day is on or before today, no `recurring` and no
|
|
561
|
+
`updates`, keeps the date as `occurredOn` (one sent too and different is kept instead), and
|
|
562
|
+
the eventDate is dropped and said in `facts.dropped` (`server-args.ts#doneDateAsOccurred`).
|
|
563
|
+
A date ending after today, a repeat and a revision are left as they were; `prospective/`
|
|
564
|
+
keeps a done row dated today or earlier out of Coming up whichever way it was written.
|
|
544
565
|
|
|
545
566
|
## 6d'. Tags (2026-10-21, schema v14, wave 2 lane B)
|
|
546
567
|
|
|
@@ -772,7 +793,7 @@ Working defaults, held lightly; the revisit (a few days of daily use) checks the
|
|
|
772
793
|
`feelings` (schema v7), each with its own `strength`; since emotion part A the
|
|
773
794
|
strongest of those and `emotional` is the memory's intensity, which lifts its height
|
|
774
795
|
and slows its decay (physics §5.10), and a recent one sets the mood recall matches
|
|
775
|
-
(recall G18). A lone `emotional` score was already kept on the row by `mint.ts`; the
|
|
796
|
+
(recall G18; off since 2026-10-10, both mood weights 0). A lone `emotional` score was already kept on the row by `mint.ts`; the
|
|
776
797
|
battery now reads it the same way (`bridge.ts#dimensionsFrom` pads a missing
|
|
777
798
|
dimension with 0 instead of dropping all three). The stated-emotion gate still
|
|
778
799
|
supplies no number, and still must not.
|
|
@@ -55,6 +55,9 @@ export interface RecallRowFields {
|
|
|
55
55
|
* bar can be calibrated on live use. Ids and numbers only.
|
|
56
56
|
*/
|
|
57
57
|
readonly dreams?: readonly { readonly id: string; readonly why: string; readonly score: number | null }[];
|
|
58
|
+
/** How long the recall took, ms (FD1 step 5, 2026-11-07): a question's mode
|
|
59
|
+
* answer (embedding left out), or an address's read. */
|
|
60
|
+
readonly elapsedMs?: number;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -139,6 +142,9 @@ export type ReminderRead =
|
|
|
139
142
|
readonly detail: string;
|
|
140
143
|
};
|
|
141
144
|
|
|
145
|
+
/** A `ReminderRead` that was not refused. */
|
|
146
|
+
export type ReminderFields = Exclude<ReminderRead, { readonly refused: unknown }>;
|
|
147
|
+
|
|
142
148
|
const EVENT_DATE_SHAPES =
|
|
143
149
|
'A day "2026-10-15", a month "2026-10", a year "2026", or a range of two days "2026-10-20..2026-10-31" (first day first). Convert "late October" or "before the 15th" into one of those yourself.';
|
|
144
150
|
|
|
@@ -354,6 +360,8 @@ export function readsLikeReminder(...parts: readonly (string | null | undefined)
|
|
|
354
360
|
export function undatedReminderWarning(deposit: DepositResult, dated: ReminderRead, title: unknown, text: unknown): Record<string, unknown> {
|
|
355
361
|
if ("refused" in dated || !deposit.deposited || deposit.memoryId === null) return {};
|
|
356
362
|
if ("eventDate" in dated.fields || deposit.reminder !== undefined) return {};
|
|
363
|
+
// A done memory is no reminder (SO1 step 2): its passed date may just have become occurredOn.
|
|
364
|
+
if (deposit.facts?.status === "done") return {};
|
|
357
365
|
if (!readsLikeReminder(typeof title === "string" ? title : null, typeof text === "string" ? text : null)) return {};
|
|
358
366
|
return {
|
|
359
367
|
reminderHint: `this reads like a reminder but has no eventDate, so it will never come back on a date; to make it fire, revise it with updates: ${deposit.memoryId} and an eventDate`,
|
|
@@ -500,6 +508,49 @@ export function readWriteFacts(rec: Record<string, unknown>, today: string): Fac
|
|
|
500
508
|
return { sent, dropped, notes };
|
|
501
509
|
}
|
|
502
510
|
|
|
511
|
+
/**
|
|
512
|
+
* A DONE MEMORY IS NEVER OVERDUE (SO1 step 2, 2026-11-07, lightly held): a
|
|
513
|
+
* `remember` or `session_end` entry with `status: "done"` and an `eventDate`
|
|
514
|
+
* today or already passed (its last day on or before `today`: a done dated
|
|
515
|
+
* today has happened, coordinator 11-07) says when the thing HAPPENED,
|
|
516
|
+
* so the date is kept as `occurredOn`, not as a reminder. When `occurredOn`
|
|
517
|
+
* was sent too and differs, it is kept and the eventDate is dropped. Either
|
|
518
|
+
* way it is dropped and said beside the memory, in the three fields' `dropped`.
|
|
519
|
+
*
|
|
520
|
+
* Left alone: a date ending after today (a done with a future date is ambiguous),
|
|
521
|
+
* a repeat (`recurring` sent: a done closes one occurrence), and a revision
|
|
522
|
+
* (`updates` sent: its target may repeat, and the deposit's own close decides
|
|
523
|
+
* it; the read side keeps a done one-off with a past date out of Coming up
|
|
524
|
+
* anyway, `prospective/derive.ts` "done"). Pure; returns new reads.
|
|
525
|
+
*/
|
|
526
|
+
export function doneDateAsOccurred(
|
|
527
|
+
rec: Record<string, unknown>,
|
|
528
|
+
dated: ReminderFields,
|
|
529
|
+
facts: FactsRead,
|
|
530
|
+
today: string,
|
|
531
|
+
): { dated: ReminderFields; facts: FactsRead } {
|
|
532
|
+
if (facts.sent.status !== "done" || typeof rec["updates"] === "string") return { dated, facts };
|
|
533
|
+
// `remind` shapes a reminder, and this is none: it goes with the date.
|
|
534
|
+
const { eventDate, remind: _remind, ...rest } = dated.fields;
|
|
535
|
+
if (typeof eventDate !== "string" || isRecurrence(rest.recurring)) return { dated, facts };
|
|
536
|
+
const read = parseCalendarDate(eventDate);
|
|
537
|
+
if (read === null || read.last > today) return { dated, facts };
|
|
538
|
+
const given = facts.sent.occurredOn;
|
|
539
|
+
const keepGiven = typeof given === "string" && given !== read.text;
|
|
540
|
+
const when = read.last !== today ? "has already passed" : read.first === today ? "is today" : "ends today";
|
|
541
|
+
const note = keepGiven
|
|
542
|
+
? `eventDate "${read.text}" ${when} and this memory is done, so it is not a reminder; occurredOn "${given}" was sent too, so that was kept and the eventDate dropped.`
|
|
543
|
+
: `eventDate "${read.text}" ${when} and this memory is done, so the date was kept as occurredOn (when it happened), not as a reminder: it won't come up as due or overdue.`;
|
|
544
|
+
return {
|
|
545
|
+
dated: { fields: rest, remindIgnored: false },
|
|
546
|
+
facts: {
|
|
547
|
+
sent: keepGiven ? facts.sent : { ...facts.sent, occurredOn: read.text },
|
|
548
|
+
dropped: [...facts.dropped, { field: "eventDate", note }],
|
|
549
|
+
notes: facts.notes,
|
|
550
|
+
},
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
503
554
|
/** The three fields' half of a deposit's answer (v12): what was RECORDED —
|
|
504
555
|
* after a revision's carry-over — what was carried and from where, and what
|
|
505
556
|
* was dropped and why. Nothing when nothing was sent, dropped or carried. */
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
readAbout,
|
|
15
15
|
readTraits,
|
|
16
16
|
readWriteFacts,
|
|
17
|
+
doneDateAsOccurred,
|
|
17
18
|
readTags,
|
|
18
19
|
MEMORY_KINDS,
|
|
19
20
|
reminderEcho,
|
|
@@ -265,14 +266,18 @@ export async function depositEntries(
|
|
|
265
266
|
if (Object.keys(entryDims).length > 0) draft["salience"] = entryDims;
|
|
266
267
|
// The reminder date (2026-09-26), per entry: an unreadable one refuses
|
|
267
268
|
// THIS entry below, by name, and its siblings still land.
|
|
268
|
-
|
|
269
|
+
// A done whose date has passed keeps it as occurredOn instead (SO1 step 2).
|
|
270
|
+
const datedRead = readReminder(rec);
|
|
271
|
+
const factsRead = readWriteFacts(rec, today);
|
|
272
|
+
const doneAt = "refused" in datedRead ? { dated: datedRead, facts: factsRead } : doneDateAsOccurred(rec, datedRead, factsRead, today);
|
|
273
|
+
const dated = doneAt.dated;
|
|
269
274
|
if (!("refused" in dated)) Object.assign(draft, dated.fields);
|
|
270
275
|
datedOf.push(dated);
|
|
271
276
|
entries.push(draft);
|
|
272
277
|
feelingsOf.push(readFeelings(rec["feelings"]));
|
|
273
278
|
aboutOf.push(readAbout(rec["about"]));
|
|
274
279
|
traitsOf.push(readTraits(rec["traits"]));
|
|
275
|
-
factsOf.push(
|
|
280
|
+
factsOf.push(doneAt.facts);
|
|
276
281
|
tagsOf.push(readTags(rec));
|
|
277
282
|
}
|
|
278
283
|
|
|
@@ -365,6 +370,7 @@ export async function depositEntries(
|
|
|
365
370
|
...(neighbours.length === 0 ? {} : { neighbours }),
|
|
366
371
|
...server["slotOf"](result),
|
|
367
372
|
...server["stillDatedNear"](result, dated, facts.sent.status, batch, session),
|
|
373
|
+
...server["mayCloseOf"](result, { title: draft["title"], text: draft["content"], status: facts.sent.status }, batch),
|
|
368
374
|
...server["answersReminder"](result, facts.sent, neighbours),
|
|
369
375
|
});
|
|
370
376
|
}
|
|
@@ -21,7 +21,7 @@ export const SERVER_NAME = "counterparts";
|
|
|
21
21
|
* host decides whether to trust what follows. Read from a constant rather than
|
|
22
22
|
* from disk so the server opens no file to answer its first message.
|
|
23
23
|
*/
|
|
24
|
-
export const SERVER_VERSION = "0.3.
|
|
24
|
+
export const SERVER_VERSION = "0.3.52";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* THE ONE LINE EVERY TOOL ANSWERS WITH when the store on disk is a schema AHEAD
|
|
@@ -308,6 +308,19 @@ export const STILL_DATED_SHOWN = 5;
|
|
|
308
308
|
export const STILL_DATED_HINT =
|
|
309
309
|
"These nearby memories still hold a date. If one is the same obligation as the one you just closed, close it too now: remember with updates: its id and eventDate: null (or status: done). If it is something else, leave it.";
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Beside a write whose subject an open item from any folder names (SO1 step
|
|
313
|
+
* 1b, 2026-11-07, `McpServer#mayCloseOf`, `core/close-hint.ts`).
|
|
314
|
+
*/
|
|
315
|
+
export const MAY_CLOSE_HINT =
|
|
316
|
+
"These open items look settled by what you just wrote. If one is, close it with updates: its id and unresolved: false; leave it if not.";
|
|
317
|
+
|
|
318
|
+
/** The note on a listed item that was asked of the owner (SO1 step 1b). */
|
|
319
|
+
export function mayCloseAskedNote(owner: string | null): string {
|
|
320
|
+
const who = owner === null || owner.trim() === "" ? "the owner" : owner.trim();
|
|
321
|
+
return `asked of ${who}: close only if this is ${who}'s answer`;
|
|
322
|
+
}
|
|
323
|
+
|
|
311
324
|
/** Beside a "done" or owner-said write that lands close to a reminder due now (`McpServer#answersReminder`, 2026-10-20). */
|
|
312
325
|
export const ANSWERS_HINT =
|
|
313
326
|
"This looks like it answers the reminder in `answers`, which is due now. If it does, close it: remember with updates: its id, status: done, and a short text (\"Done for this week\"). A repeating one closes for this time only and comes back on its next date; eventDate: null would end it. If it is something else, leave it.";
|