counterparts 0.3.13 → 0.3.14
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 +160 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/bin/hook.mjs +4 -2
- package/src/adapters/claude-code/bin/hook.ts +11 -4
- package/src/adapters/claude-code/bin/nightly.ts +5 -1
- package/src/adapters/claude-code/bin/runner.ts +11 -3
- package/src/adapters/claude-code/doctor.ts +69 -5
- package/src/adapters/claude-code/embed-client.ts +3 -0
- package/src/adapters/cli/bin/counterparts.mjs +4 -2
- package/src/adapters/cli/bin/counterparts.ts +11 -3
- package/src/adapters/cli/commands.ts +65 -23
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +22 -9
- package/src/adapters/cli/settle.ts +39 -2
- package/src/adapters/cli/wire.ts +4 -0
- package/src/adapters/config.ts +29 -1
- package/src/adapters/dashboard/NOTES.md +33 -0
- package/src/adapters/dashboard/bin/dashboard.mjs +4 -2
- package/src/adapters/dashboard/bin/dashboard.ts +11 -3
- package/src/adapters/dashboard/index.ts +14 -0
- package/src/adapters/dashboard/source.ts +0 -8
- package/src/adapters/dashboard/web/fired.ts +8 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -1
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +7 -10
- package/src/adapters/dashboard/web/pages/memories/memories.css +3 -0
- package/src/adapters/dashboard/web/pages/memories/row.js +5 -2
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +2 -1
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +19 -3
- package/src/adapters/dashboard/web/server.ts +16 -4
- package/src/adapters/dashboard/web/shared/dates.js +6 -16
- package/src/adapters/dashboard/web/shared/memory-modal.js +21 -8
- package/src/adapters/dashboard/web/views/health.ts +11 -0
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +8 -5
- package/src/adapters/dashboard/web/views/memories.ts +26 -7
- package/src/adapters/dashboard/web/views/memory-words.ts +16 -0
- package/src/adapters/dashboard/web/views/memory.ts +51 -2
- package/src/adapters/dashboard/web/views/mind.ts +31 -6
- package/src/adapters/empty-bunfig.toml +5 -0
- package/src/adapters/fired.ts +6 -2
- package/src/adapters/host-wiring.ts +4 -3
- package/src/adapters/log/index.ts +2 -2
- package/src/adapters/mcp/CONTRACT.md +16 -2
- package/src/adapters/mcp/INTERFACE-GAPS.md +15 -1
- package/src/adapters/mcp/NOTES.md +243 -0
- package/src/adapters/mcp/bin/serve.mjs +4 -2
- package/src/adapters/mcp/bin/serve.ts +11 -4
- package/src/adapters/mcp/facts.ts +72 -4
- package/src/adapters/mcp/meaning.ts +218 -15
- package/src/adapters/mcp/server.ts +1 -1
- package/src/adapters/mcp/tools.ts +81 -57
- package/src/adapters/plugin-run.sh +405 -33
- package/src/adapters/plugin.ts +14 -2
- package/src/adapters/runtime.ts +192 -17
- package/src/adapters/sessions.ts +2 -2
- package/src/core/associate/NOTES.md +10 -0
- package/src/core/bridge.ts +1 -1
- package/src/core/briefing.ts +20 -3
- package/src/core/contradictions.ts +56 -20
- package/src/core/counterpart.ts +39 -17
- package/src/core/dream/CONTRACT.md +4 -12
- package/src/core/dream/INTERFACE-GAPS.md +3 -2
- package/src/core/dream/NOTES.md +10 -0
- package/src/core/dream/index.ts +10 -52
- package/src/core/embed/static.ts +5 -1
- package/src/core/encode/INTERFACE-GAPS.md +2 -1
- package/src/core/encode/NOTES.md +12 -0
- package/src/core/encode/chunk.ts +6 -30
- package/src/core/encode/index.ts +0 -1
- package/src/core/encode/types.ts +1 -13
- package/src/core/handoff/last-here.ts +18 -2
- package/src/core/physics/CONTRACT.md +6 -0
- package/src/core/physics/NOTES.md +33 -2
- package/src/core/physics/index.ts +22 -7
- package/src/core/prospective/CONTRACT.md +3 -1
- package/src/core/prospective/NOTES.md +15 -0
- package/src/core/recall/time-ask.ts +154 -19
- package/src/core/self/CONTRACT.md +23 -3
- package/src/core/self/NOTES.md +64 -0
- package/src/core/self/behind.ts +6 -3
- package/src/core/self/briefing.ts +272 -11
- package/src/core/self/index.ts +50 -4
- package/src/core/sleep/NOTES.md +32 -0
- package/src/core/store/NOTES.md +16 -0
- package/src/core/time.ts +15 -0
|
@@ -14,7 +14,8 @@ import { filters, onFilter, toggle } from "../state.js";
|
|
|
14
14
|
* [key, words, what it means]. True to the forgetting rules (`views/memories.ts#holdOf`,
|
|
15
15
|
* `physics`): firm is still settled into what I know 30 lived days on if unused
|
|
16
16
|
* (and a lived day is never shorter than a calendar day); fading is what prune
|
|
17
|
-
* could let go within 14 lived days, unless a revision still leans on it.
|
|
17
|
+
* could let go within 14 lived days, unless a revision still leans on it. A
|
|
18
|
+
* date that still repeats is kept by prune, so it is never fading (2026-10-09).
|
|
18
19
|
*/
|
|
19
20
|
export const PARTS = [
|
|
20
21
|
["firm", "firm", "I'll still know these a month from now, even if they're never used."],
|
|
@@ -293,12 +293,21 @@ export function factLines(m) {
|
|
|
293
293
|
parts.push(/^(mem|epi|sch)_/.test(m.now || "") ? "an earlier version — now " + withIdMarks(m.now) : "an earlier version — a later one holds now");
|
|
294
294
|
}
|
|
295
295
|
for (const s of m.standing || []) parts.push(withIdMarks(s));
|
|
296
|
-
|
|
296
|
+
// Corrected versions were wrong: each named and linked like an earlier one,
|
|
297
|
+
// labelled so (`facts.ts#itemLines`); the rest counted.
|
|
298
|
+
const wrong = m.correctedShown || [];
|
|
299
|
+
const unnamed = (m.corrected || 0) - wrong.length;
|
|
300
|
+
if (unnamed > 0 && wrong.length === 0) parts.push(esc(plural(unnamed, "corrected version") + " hidden"));
|
|
297
301
|
const earlier = (m.earlier || []).map((e) =>
|
|
298
302
|
'<div class="mearlier">earlier: “' + esc(e.text) + "”" +
|
|
299
303
|
esc((e.learned ? " (learned " + dateOr(e.learned) + ")" : "") + (e.changed ? ", changed " + dateOr(e.changed) : "")) +
|
|
300
304
|
(e.id ? " " + withIdMarks(e.id) : "") + "</div>").join("") +
|
|
301
|
-
(m.earlierMore > 0 ? '<div class="mearlier">+' + m.earlierMore + " more earlier</div>" : "")
|
|
305
|
+
(m.earlierMore > 0 ? '<div class="mearlier">+' + m.earlierMore + " more earlier</div>" : "") +
|
|
306
|
+
wrong.map((e) =>
|
|
307
|
+
'<div class="mearlier">corrected (was wrong): “' + esc(e.text) + "”" +
|
|
308
|
+
esc((e.learned ? " (learned " + dateOr(e.learned) + ")" : "") + (e.corrected ? ", corrected " + dateOr(e.corrected) : "")) +
|
|
309
|
+
" " + withIdMarks(e.id) + "</div>").join("") +
|
|
310
|
+
(unnamed > 0 && wrong.length > 0 ? '<div class="mearlier">+' + unnamed + " more corrected (was wrong)</div>" : "");
|
|
302
311
|
if (parts.length === 0 && !earlier) return "";
|
|
303
312
|
return '<div class="mfacts">' + (parts.length > 0 ? "<div>" + parts.join(" · ") + "</div>" : "") + earlier + "</div>";
|
|
304
313
|
}
|
|
@@ -331,8 +340,15 @@ export function factsRows(r, q) {
|
|
|
331
340
|
return rows + faded;
|
|
332
341
|
}
|
|
333
342
|
|
|
334
|
-
/** A
|
|
343
|
+
/** A name asked about that has no card (`MeaningResult.noCard`), said first, on its own line. */
|
|
344
|
+
const leadLine = (r) => (r.noCard ? '<span class="find-lead">' + esc(r.noCard) + ".</span>" : "");
|
|
345
|
+
|
|
346
|
+
/** A meaning answer's head: a name with no card first, then what it is about, how much holds it, then the quieter notes. Markup. */
|
|
335
347
|
export function meaningHead(r) {
|
|
348
|
+
return leadLine(r) + meaningHeadLine(r);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function meaningHeadLine(r) {
|
|
336
352
|
if (r.lens === null) return esc("nothing came");
|
|
337
353
|
const c = r.counts;
|
|
338
354
|
const parts = [r.lens.name];
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
import { readFileSync } from "node:fs";
|
|
61
61
|
import { createServer } from "node:http";
|
|
62
62
|
import type { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
63
|
-
import {
|
|
64
|
-
import { fileURLToPath } from "node:url";
|
|
63
|
+
import { join } from "node:path";
|
|
65
64
|
|
|
66
65
|
import { ownerNames } from "../../../core/sleep/index.js";
|
|
67
66
|
import { dataDir, isStoreError } from "../../../core/store/index.js";
|
|
67
|
+
import { zoneBeside, zoneOfConfig } from "../../config.js";
|
|
68
68
|
import { Dashboard } from "../index.js";
|
|
69
69
|
import { upgradePending, upgradePendingSentence } from "../upgrade.js";
|
|
70
70
|
import type { DashboardSource } from "../source.js";
|
|
@@ -82,6 +82,7 @@ import { mechanismPanel } from "./views/mechanism-panel.js";
|
|
|
82
82
|
import { mechanismsView } from "./views/mechanisms.js";
|
|
83
83
|
import { DREAM_LIMIT, dreamsView } from "./views/dreams.js";
|
|
84
84
|
import { resolveStatic } from "./static.js";
|
|
85
|
+
import { packagePath } from "../../runtime.js";
|
|
85
86
|
import {
|
|
86
87
|
activityView,
|
|
87
88
|
eventDetail,
|
|
@@ -102,7 +103,9 @@ import {
|
|
|
102
103
|
export const DEFAULT_PORT = 4747;
|
|
103
104
|
export const PORT_ENV = "COUNTERPARTS_DASHBOARD_PORT";
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
// From the package root rather than `import.meta.url`, which in the single
|
|
107
|
+
// binary is the binary's own path, not this module's (adapters/runtime.ts).
|
|
108
|
+
const HERE = packagePath("src/adapters/dashboard/web");
|
|
106
109
|
const APP_PATH = join(HERE, "app.html");
|
|
107
110
|
|
|
108
111
|
const NO_STORE = { "cache-control": "no-store" } as const;
|
|
@@ -384,7 +387,16 @@ function resolvePort(opts: ServeOptions): number {
|
|
|
384
387
|
* for 0 — and closing it closes the store.
|
|
385
388
|
*/
|
|
386
389
|
export function startDashboard(opts: ServeOptions = {}): Promise<RunningDashboard> {
|
|
387
|
-
|
|
390
|
+
// THE ZONE THE HOOKS USE (review of #335, 2026-10-09): the named
|
|
391
|
+
// configuration's `timeZone`, else the one beside the store, else the
|
|
392
|
+
// machine's. Every date the server sends is read in it, already local.
|
|
393
|
+
const timeZone =
|
|
394
|
+
(opts.config === undefined ? undefined : zoneOfConfig(opts.config)) ??
|
|
395
|
+
(opts.dir === undefined ? undefined : zoneBeside(opts.dir));
|
|
396
|
+
const openOpts = {
|
|
397
|
+
...(opts.dir === undefined ? {} : { dir: opts.dir }),
|
|
398
|
+
...(timeZone === undefined ? {} : { timeZone }),
|
|
399
|
+
};
|
|
388
400
|
// A store waiting for its upgrade is not an error to the owner: the server
|
|
389
401
|
// still starts, says so on every page, and tries the store again on each
|
|
390
402
|
// request, so a reload after a session has upgraded it shows the dashboard.
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
9
9
|
const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
10
|
-
const ISO = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
11
10
|
|
|
12
11
|
/** 1 → "1st", 2 → "2nd", 11 → "11th", 23 → "23rd". */
|
|
13
12
|
export function ordinal(n) {
|
|
@@ -38,18 +37,9 @@ export function dateOr(value, opts) {
|
|
|
38
37
|
return dateWords(value, opts) || String(value || "");
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return day ? day + (t ? ", " + t[1] + " UTC" : "") : s;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** A clock reading (ms) → the day it falls on HERE, as `YYYY-MM-DD`. */
|
|
51
|
-
export function localIso(ms) {
|
|
52
|
-
const d = new Date(ms);
|
|
53
|
-
const two = (n) => String(n).padStart(2, "0");
|
|
54
|
-
return d.getFullYear() + "-" + two(d.getMonth() + 1) + "-" + two(d.getDate());
|
|
55
|
-
}
|
|
40
|
+
/* No moment is turned into a day in here (2026-10-09). `stampWords` (a UTC
|
|
41
|
+
minute) and `localIso` (the browser's calendar) were removed: the server
|
|
42
|
+
dates every moment in the person's zone, the one the hooks use
|
|
43
|
+
(`views/memory.ts#writtenWhen`, `views/health.ts`'s `cycle.on`), and the
|
|
44
|
+
page prints the day it is handed. A browser's own zone can differ from the
|
|
45
|
+
configured one, and one page then showed two days for one moment. */
|
|
@@ -13,7 +13,7 @@ import { emptyBox } from "./absence.js";
|
|
|
13
13
|
import { esc } from "./dom.js";
|
|
14
14
|
import { headline, n2, n3, said } from "./format.js";
|
|
15
15
|
import { coreRoadLine, curveStart, versionRows } from "./memory-card-words.js";
|
|
16
|
-
import { dateOr,
|
|
16
|
+
import { dateOr, dateWords } from "./dates.js";
|
|
17
17
|
import { FEELING_COLOURS, feelingName, feelingWord, kindMark, kindOf } from "./memory-marks.js";
|
|
18
18
|
import { openModal } from "./modal.js";
|
|
19
19
|
import { confirmTyped } from "./widgets/confirm.js";
|
|
@@ -48,12 +48,19 @@ export function memoryCard(d) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** The day it was written, once: "Written Sep 28th, 2026" — the moment it entered
|
|
51
|
-
* the store (v7 `created_at`) on
|
|
52
|
-
* it was recorded.
|
|
53
|
-
*
|
|
51
|
+
* the store (v7 `created_at`) on the person's calendar, else the calendar day
|
|
52
|
+
* it was recorded. The server dates it (`views/memory.ts#writtenWhen`), in the
|
|
53
|
+
* zone the hooks use, so the card agrees with every other date the dashboard
|
|
54
|
+
* prints. It read the UTC day until 2026-10-09, then the browser's. */
|
|
54
55
|
export function writtenOn(d) {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(String(d.writtenOn || "")) ? d.writtenOn : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The details row's "written": its day and its clock, named — "Sep 30th, 2026, 11:47 MDT". */
|
|
60
|
+
export function writtenStamp(d) {
|
|
61
|
+
const day = writtenOn(d);
|
|
62
|
+
if (!day || !d.writtenClock) return null;
|
|
63
|
+
return (dateWords(day, FULL) || day) + ", " + d.writtenClock;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
/** The card is read on its own, so its dates always carry their year. */
|
|
@@ -97,9 +104,15 @@ function curvePart(d) {
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
/** The one plain sentence under the chart (round 4): "I remember this at 41%.
|
|
100
|
-
* If nobody uses it, I'll put it away around day 67." `c` is the card's curve.
|
|
107
|
+
* If nobody uses it, I'll put it away around day 67." `c` is the card's curve.
|
|
108
|
+
* The prune never lets a protected memory go (review of #343): "It's protected, so
|
|
109
|
+
* I'll keep it even if nobody uses it." A date that still repeats is kept for
|
|
110
|
+
* its next time (2026-10-09), however faint: "It comes round every May 14, so
|
|
111
|
+
* I'll keep it while it does." Both come before "soon": neither is. */
|
|
101
112
|
export function rememberLine(now, c) {
|
|
102
113
|
const head = "I remember this at " + pct(now) + ". ";
|
|
114
|
+
if (c.protected) return head + "It's protected, so I'll keep it even if nobody uses it.";
|
|
115
|
+
if (c.repeats) return head + "It comes round " + c.repeats + ", so I'll keep it while it does.";
|
|
103
116
|
if (c.archiveDay !== null) return head + "If nobody uses it, I'll put it away around day " + c.archiveDay + ".";
|
|
104
117
|
if (now < c.archiveLine) return head + "That's low enough that I could put it away soon.";
|
|
105
118
|
const ahead = c.to - c.day;
|
|
@@ -266,7 +279,7 @@ function footer(d) {
|
|
|
266
279
|
kv("lived", "born day " + d.bornDay + " · used " + d.uses + "× over " + d.reinforcedDays + " days · last used day " + d.lastUsedDay) +
|
|
267
280
|
kv("standing", (d.consolidated ? "consolidated" : "not consolidated") + " · " + (d.promoted ? "promoted" : "not promoted") +
|
|
268
281
|
" · " + (d.protected ? "protected" : "revisable") + " · pressure " + n3(d.pressure) + (d.bar === null ? "" : " / bar " + n3(d.bar))) +
|
|
269
|
-
(d
|
|
282
|
+
(writtenStamp(d) ? kv("written", esc(writtenStamp(d))) : "") +
|
|
270
283
|
(d.archived ? kv("archived", esc(d.archived)) : "") +
|
|
271
284
|
d.points.map((p) => kv(p.role, esc(p.id))).join("") +
|
|
272
285
|
d.removal.map((r) => kv("removal", esc(r.stage) + " by " + esc(r.actor) + " — " + esc(r.reason || "no reason recorded"))).join("") +
|
|
@@ -11,6 +11,7 @@ import { MARKER_UNSET, MERGE_ARCHIVE_REASON, PRUNE_ARCHIVE_REASON, readMarker }
|
|
|
11
11
|
import { cadenceFor, markerDue } from "../../../../core/sleep/markers.js";
|
|
12
12
|
import type { Phase } from "../../../../core/sleep/types.js";
|
|
13
13
|
import type { Kind } from "../../../../core/types.js";
|
|
14
|
+
import { localDate } from "../../../../core/time.js";
|
|
14
15
|
import { NEVER, NONE } from "../../layout.js";
|
|
15
16
|
import { CYCLE_PHASES, DURABLE_EVENTS, DURABLE_EVENT_NAMES, KINDS } from "../../registries.js";
|
|
16
17
|
import type { DurableEventName } from "../../registries.js";
|
|
@@ -64,6 +65,13 @@ export interface HealthView {
|
|
|
64
65
|
readonly cycle: {
|
|
65
66
|
readonly day: number | null;
|
|
66
67
|
readonly at: number | null;
|
|
68
|
+
/**
|
|
69
|
+
* `at`'s calendar day in the person's zone (`store.zone()`), and whether it
|
|
70
|
+
* is today there — dated by the server, so the line agrees with every
|
|
71
|
+
* other date on the page (review of #335, 2026-10-09). Null with `at`.
|
|
72
|
+
*/
|
|
73
|
+
readonly on: string | null;
|
|
74
|
+
readonly today: boolean;
|
|
67
75
|
readonly ran: number;
|
|
68
76
|
/** Phases that did not run because their cadence had not come round: not a problem. */
|
|
69
77
|
readonly waiting: number;
|
|
@@ -388,9 +396,12 @@ export function healthView(src: DashboardSource): HealthView {
|
|
|
388
396
|
const nextInDays = state === "waiting" && p.day !== null ? Math.max(0, p.day + cadence - day) : null;
|
|
389
397
|
return { phase: p.phase, gloss: PHASE_GLOSS[p.phase] ?? p.phase, state, day: p.day, nextInDays };
|
|
390
398
|
});
|
|
399
|
+
const cycleOn = lastCycleRow === undefined ? null : localDate(lastCycleRow.at, store.zone()) || null;
|
|
391
400
|
const cycle = {
|
|
392
401
|
day: newest,
|
|
393
402
|
at: lastCycleRow === undefined ? null : lastCycleRow.at,
|
|
403
|
+
on: cycleOn,
|
|
404
|
+
today: cycleOn !== null && cycleOn === store.today(),
|
|
394
405
|
ran: cyclePhases.filter((p) => p.state === "ran").length,
|
|
395
406
|
waiting: cyclePhases.filter((p) => p.state === "waiting").length,
|
|
396
407
|
total: cyclePhases.length,
|
|
@@ -773,15 +773,18 @@ export function fadeCurve(
|
|
|
773
773
|
/**
|
|
774
774
|
* The first lived day within `horizon` days ahead on which prune's own verdict
|
|
775
775
|
* (`physics#pruneVerdict`: under the floor, long enough unused, episodic, not
|
|
776
|
-
* protected) would let this memory go if nobody
|
|
777
|
-
*
|
|
778
|
-
*
|
|
776
|
+
* protected, not a date that still repeats) would let this memory go if nobody
|
|
777
|
+
* used it — or null. `recurring` is the row's own repeat (`store#recurrenceOfRow`
|
|
778
|
+
* !== null), passed the way `sleep/prune.ts` passes it, so a live repeat never
|
|
779
|
+
* has a let-go day (2026-10-09). The revision-chain gate is not checked here
|
|
780
|
+
* (it needs the store), so this can only say "sooner than it will be", never
|
|
781
|
+
* "later".
|
|
779
782
|
*/
|
|
780
|
-
export function letGoDay(physics: MemoryPhysics, day: number, horizon: number): number | null {
|
|
783
|
+
export function letGoDay(physics: MemoryPhysics, day: number, horizon: number, recurring = false): number | null {
|
|
781
784
|
// Unused, strength only falls: still over the floor at the horizon means never inside it.
|
|
782
785
|
if (strength(physics, day + horizon) >= TUNABLES.PHI_PRUNE) return null;
|
|
783
786
|
for (let d = day; d <= day + horizon; d++) {
|
|
784
|
-
if (pruneVerdict(physics, d, { inLiveRevisionChain: false }).prune) return d;
|
|
787
|
+
if (pruneVerdict(physics, d, { inLiveRevisionChain: false, recurring }).prune) return d;
|
|
785
788
|
}
|
|
786
789
|
return null;
|
|
787
790
|
}
|
|
@@ -18,7 +18,7 @@ import { displayName } from "../ask-voice.js";
|
|
|
18
18
|
import { WITHHELD, revealHere } from "../reveal.js";
|
|
19
19
|
import { archiveWords } from "./archive-words.js";
|
|
20
20
|
import { letGoDay } from "./mechanism-panel.js";
|
|
21
|
-
import { feelingsShown, firstSentence, isChapterMemory, shownOf } from "./memory-words.js";
|
|
21
|
+
import { feelingsShown, firstSentence, isChapterMemory, repeatsOf, shownOf } from "./memory-words.js";
|
|
22
22
|
import type { DateFrom, FeelingShown } from "./memory-words.js";
|
|
23
23
|
import { absenceFor, census, countMap } from "./shared.js";
|
|
24
24
|
import { todayView } from "./today.js";
|
|
@@ -107,12 +107,15 @@ export const FIRM_AHEAD_DAYS = 30;
|
|
|
107
107
|
* Firm, settling or fading. Core and protected memories are firm (neither is
|
|
108
108
|
* pruned). Fading is prune's own verdict within `NEAR_LET_GO_DAYS` (`letGoDay`);
|
|
109
109
|
* an entity card is faded by `schemas/`, not by prune, so it is never fading
|
|
110
|
-
* here.
|
|
111
|
-
*
|
|
110
|
+
* here. Nor is a memory whose date still repeats (`opts.recurring`, the row's
|
|
111
|
+
* `recurrenceOfRow` — 2026-10-09): the prune keeps it for its next occurrence,
|
|
112
|
+
* so it is firm or settling by its strength like any other, and the row says
|
|
113
|
+
* how often it comes round (`ListRow.repeats`). Firm is still settled
|
|
114
|
+
* `FIRM_AHEAD_DAYS` from now if unused. The rest are settling.
|
|
112
115
|
*/
|
|
113
|
-
export function holdOf(physics: MemoryPhysics, day: number, opts: { prunable: boolean }): Hold {
|
|
116
|
+
export function holdOf(physics: MemoryPhysics, day: number, opts: { prunable: boolean; recurring?: boolean }): Hold {
|
|
114
117
|
if (physics.promotedIdentity === true || physics.protected === true) return "firm";
|
|
115
|
-
if (opts.prunable && letGoDay(physics, day, NEAR_LET_GO_DAYS) !== null) return "fading";
|
|
118
|
+
if (opts.prunable && letGoDay(physics, day, NEAR_LET_GO_DAYS, opts.recurring === true) !== null) return "fading";
|
|
116
119
|
if (strengthOf(physics, day + FIRM_AHEAD_DAYS) >= PHYSICS.THETA_SEM) return "firm";
|
|
117
120
|
return "settling";
|
|
118
121
|
}
|
|
@@ -177,7 +180,12 @@ export function memoriesView(src: DashboardSource, opts: { limit?: number } = {}
|
|
|
177
180
|
else if (m.unreadable) hold.settling += 1;
|
|
178
181
|
else {
|
|
179
182
|
try {
|
|
180
|
-
hold[
|
|
183
|
+
hold[
|
|
184
|
+
holdOf(store.physicsOf(m.id), day, {
|
|
185
|
+
prunable: row === undefined || !isEntityCard(row),
|
|
186
|
+
recurring: row !== undefined && repeatsOf(row) !== null,
|
|
187
|
+
})
|
|
188
|
+
] += 1;
|
|
181
189
|
} catch {
|
|
182
190
|
hold.settling += 1;
|
|
183
191
|
}
|
|
@@ -329,6 +337,10 @@ export interface ListRow {
|
|
|
329
337
|
readonly createdAt: number | null;
|
|
330
338
|
/** How firmly it is held (`holdOf`); null for an archived row or a journal chapter. */
|
|
331
339
|
readonly hold: Hold | null;
|
|
340
|
+
/** A live row whose date still repeats: how often, as a person says it
|
|
341
|
+
* (`every May 14`, `repeatsOf`) — kept for its next occurrence, so never
|
|
342
|
+
* "fading" (2026-10-09). Null otherwise, and on a withheld row. */
|
|
343
|
+
readonly repeats: string | null;
|
|
332
344
|
/** Put-away rows only: how many put-away versions of the same memory this
|
|
333
345
|
* one row stands for (itself included) — 1 for most. See `versionKey`. */
|
|
334
346
|
readonly versions: number;
|
|
@@ -483,6 +495,7 @@ export function memoryListView(
|
|
|
483
495
|
core: boolean;
|
|
484
496
|
journal: boolean;
|
|
485
497
|
hold: Hold | null;
|
|
498
|
+
repeats: string | null;
|
|
486
499
|
/** Put-away rows only: the key its other versions share, or null. */
|
|
487
500
|
group: string | null;
|
|
488
501
|
versions: number;
|
|
@@ -503,11 +516,13 @@ export function memoryListView(
|
|
|
503
516
|
let s = 0;
|
|
504
517
|
const chapter = isChapterMemory(row);
|
|
505
518
|
let hold: Hold | null = null;
|
|
519
|
+
// Kept while it repeats (the prune's `recurring` gate): live rows only.
|
|
520
|
+
const repeats = isArchived || chapter ? null : repeatsOf(row);
|
|
506
521
|
try {
|
|
507
522
|
const physics = rowToPhysics(row);
|
|
508
523
|
b = bandOf(physics, day);
|
|
509
524
|
s = strengthOf(physics, day);
|
|
510
|
-
if (!isArchived && !chapter) hold = holdOf(physics, day, { prunable: !isEntityCard(row) });
|
|
525
|
+
if (!isArchived && !chapter) hold = holdOf(physics, day, { prunable: !isEntityCard(row), recurring: repeats !== null });
|
|
511
526
|
} catch {
|
|
512
527
|
/* a row whose physics will not compute still lists, at zero */
|
|
513
528
|
if (!isArchived && !chapter) hold = "settling";
|
|
@@ -524,6 +539,7 @@ export function memoryListView(
|
|
|
524
539
|
core: row.promoted_identity === 1,
|
|
525
540
|
journal: chapter,
|
|
526
541
|
hold,
|
|
542
|
+
repeats,
|
|
527
543
|
group: isArchived ? versionKey(store, row) : null,
|
|
528
544
|
versions: 1,
|
|
529
545
|
cores: new Set(feelingsShown(store, id).map((f) => f.core)),
|
|
@@ -621,6 +637,9 @@ export function memoryListView(
|
|
|
621
637
|
feelings: feelingsShown(store, r.id),
|
|
622
638
|
createdAt: r.createdAt,
|
|
623
639
|
hold: r.hold,
|
|
640
|
+
// A withheld row shows no date of its own in the list, so not how often
|
|
641
|
+
// its date comes round either; it is still never "fading".
|
|
642
|
+
repeats: here.confidential || !here.present ? null : r.repeats,
|
|
624
643
|
versions: r.versions,
|
|
625
644
|
};
|
|
626
645
|
});
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { wheelEntry } from "../../../../core/feelings-wheel.js";
|
|
11
11
|
import { readChapterLead } from "../../../../core/self/index.js";
|
|
12
|
+
import { recurrenceOfRow } from "../../../../core/store/index.js";
|
|
12
13
|
import type { MemoryRow, ReadOnlyStore } from "../../../../core/store/index.js";
|
|
14
|
+
import { readableRecurrence } from "../../../../core/time.js";
|
|
13
15
|
|
|
14
16
|
/** Where the date shown beside a row came from. */
|
|
15
17
|
export type DateFrom = "text" | "chapter" | "recorded";
|
|
@@ -30,6 +32,20 @@ export interface FeelingShown {
|
|
|
30
32
|
readonly strength: number;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* How often a row's date comes round, as a person says it — `every May 14`,
|
|
37
|
+
* `every Monday` (`time#readableRecurrence`) — or null for a date that happens
|
|
38
|
+
* once. The same predicate the prune's `recurring` gate reads
|
|
39
|
+
* (`store#recurrenceOfRow`, 2026-10-09), so a row that says it repeats is one
|
|
40
|
+
* the prune keeps for its next occurrence.
|
|
41
|
+
*/
|
|
42
|
+
export function repeatsOf(row: Pick<MemoryRow, "event_date" | "meta">): string | null {
|
|
43
|
+
const rule = recurrenceOfRow(row);
|
|
44
|
+
if (rule === null || row.event_date === null) return null;
|
|
45
|
+
const words = readableRecurrence(row.event_date, rule);
|
|
46
|
+
return words === "" ? null : words;
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
/**
|
|
34
50
|
* A JOURNAL-CHAPTER MEMORY: a `memory` row minted from a chapter of the journal
|
|
35
51
|
* (`source = episode`, `meta.episodeId`). Its text is the chapter as written,
|
|
@@ -14,10 +14,11 @@ import type { DashboardSource } from "../../source.js";
|
|
|
14
14
|
import { WITHHELD, gistOfDoc, reveal, revealHere } from "../reveal.js";
|
|
15
15
|
import { archiveWords } from "./archive-words.js";
|
|
16
16
|
import { fadeCurve } from "./mechanism-panel.js";
|
|
17
|
-
import { chapterDate, feelingsShown, isChapterMemory, liftDate, stripChapterLead } from "./memory-words.js";
|
|
17
|
+
import { chapterDate, feelingsShown, isChapterMemory, liftDate, repeatsOf, stripChapterLead } from "./memory-words.js";
|
|
18
18
|
import { readChapterLead } from "../../../../core/self/index.js";
|
|
19
19
|
import type { FeelingShown } from "./memory-words.js";
|
|
20
20
|
import { LOG_CEILING } from "./shared.js";
|
|
21
|
+
import { isDay, localClockZone, localDate } from "../../../../core/time.js";
|
|
21
22
|
|
|
22
23
|
/** One step in a memory's lineage, as the card's timeline draws it. */
|
|
23
24
|
export interface TimelineStep {
|
|
@@ -95,9 +96,19 @@ export interface MemoryCurve {
|
|
|
95
96
|
readonly from: number;
|
|
96
97
|
readonly to: number;
|
|
97
98
|
readonly points: readonly (readonly [number, number])[];
|
|
99
|
+
/** The first lived day ahead on which it falls below the archive line if
|
|
100
|
+
* unused — the day the prune could put it away. Null for a date that still
|
|
101
|
+
* repeats: the prune keeps it for its next occurrence (2026-10-09). Null for
|
|
102
|
+
* a protected memory too: the prune never lets one go (review of #343). */
|
|
98
103
|
readonly archiveDay: number | null;
|
|
99
104
|
readonly archiveLine: number;
|
|
100
105
|
readonly semanticFloor: number;
|
|
106
|
+
/** Its date still repeats: how often, as a person says it (`every May 14`,
|
|
107
|
+
* `repeatsOf`), else null. The card says this instead of a let-go day. */
|
|
108
|
+
readonly repeats: string | null;
|
|
109
|
+
/** Protected (`physics.protected`): the prune refuses it however faint it
|
|
110
|
+
* grows, so the card says that instead of a let-go day (review of #343). */
|
|
111
|
+
readonly protected: boolean;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -193,6 +204,16 @@ export interface MemoryDetail {
|
|
|
193
204
|
readonly model: string | null;
|
|
194
205
|
readonly eventDate: string | null;
|
|
195
206
|
readonly createdAt: number | null;
|
|
207
|
+
/**
|
|
208
|
+
* The day it was written, `YYYY-MM-DD`, in the person's zone (`store.zone()`:
|
|
209
|
+
* the configuration's `timeZone`, else the machine's) — the local date of
|
|
210
|
+
* `createdAt`, else the recorded calendar day. Dated HERE, not by the
|
|
211
|
+
* browser, so the card agrees with every other date the dashboard prints
|
|
212
|
+
* (review of #335, 2026-10-09). Null when nothing dates it.
|
|
213
|
+
*/
|
|
214
|
+
readonly writtenOn: string | null;
|
|
215
|
+
/** The clock it was written at, in the same zone and named: `17:47 MDT`. Null without `createdAt`. */
|
|
216
|
+
readonly writtenClock: string | null;
|
|
196
217
|
/** Why it was archived, in plain words; null while it is live. */
|
|
197
218
|
readonly archivedWords: string | null;
|
|
198
219
|
/** Its lineage, oldest first: what it replaced or corrects, its own rewrites, what it became. */
|
|
@@ -267,6 +288,8 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
|
|
|
267
288
|
model: null,
|
|
268
289
|
eventDate: null,
|
|
269
290
|
createdAt: null,
|
|
291
|
+
writtenOn: null,
|
|
292
|
+
writtenClock: null,
|
|
270
293
|
archivedWords: null,
|
|
271
294
|
timeline: [],
|
|
272
295
|
shownText: "",
|
|
@@ -302,7 +325,20 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
|
|
|
302
325
|
else if (physics.promotedIdentity === true) curveNote = "in the core — it doesn't fade";
|
|
303
326
|
else {
|
|
304
327
|
const c = fadeCurve(physics, day);
|
|
305
|
-
|
|
328
|
+
// A date that still repeats is kept (the prune's `recurring` gate), and so
|
|
329
|
+
// is a protected memory (its `protected` gate, review of #343): neither has
|
|
330
|
+
// a let-go day. A put-away row is past the question.
|
|
331
|
+
const repeats = row === undefined || row.archived === 1 ? null : repeatsOf(row);
|
|
332
|
+
const kept = physics.protected === true;
|
|
333
|
+
curve = {
|
|
334
|
+
day,
|
|
335
|
+
...c,
|
|
336
|
+
archiveDay: repeats === null && !kept ? c.archiveDay : null,
|
|
337
|
+
archiveLine: TUNABLES.PHI_PRUNE,
|
|
338
|
+
semanticFloor: TUNABLES.THETA_SEM,
|
|
339
|
+
repeats,
|
|
340
|
+
protected: kept,
|
|
341
|
+
};
|
|
306
342
|
}
|
|
307
343
|
|
|
308
344
|
const points: { role: string; id: string; text: string }[] = [];
|
|
@@ -391,12 +427,25 @@ export function memoryDetail(src: DashboardSource, id: string): MemoryDetail {
|
|
|
391
427
|
model: row?.model ?? null,
|
|
392
428
|
eventDate: row?.event_date ?? null,
|
|
393
429
|
createdAt: row?.created_at ?? null,
|
|
430
|
+
...writtenWhen(row?.created_at ?? null, doc.learnedOn, store.zone()),
|
|
394
431
|
archivedWords: row?.archived === 1 ? archiveWords(row.archived_reason ?? null, row.superseded_by !== null) : null,
|
|
395
432
|
timeline: timelineOf(src, headId, doc.meta["updates"]),
|
|
396
433
|
...cardWords(doc.body.trim(), chapter, g.confidential),
|
|
397
434
|
};
|
|
398
435
|
}
|
|
399
436
|
|
|
437
|
+
/** The card's "Written" day and the details row's clock, both in `zone` (`MemoryDetail.writtenOn`). */
|
|
438
|
+
export function writtenWhen(
|
|
439
|
+
createdAt: number | null,
|
|
440
|
+
learnedOn: string,
|
|
441
|
+
zone: string,
|
|
442
|
+
): { writtenOn: string | null; writtenClock: string | null } {
|
|
443
|
+
if (createdAt !== null && createdAt > 0) {
|
|
444
|
+
return { writtenOn: localDate(createdAt, zone) || null, writtenClock: localClockZone(createdAt, zone) || null };
|
|
445
|
+
}
|
|
446
|
+
return { writtenOn: isDay(learnedOn) ? learnedOn : null, writtenClock: null };
|
|
447
|
+
}
|
|
448
|
+
|
|
400
449
|
/** The lived days the log shows this memory being credited for use (`recall.credit`'s `ids`). */
|
|
401
450
|
function useDaysOf(src: DashboardSource, id: string): number[] {
|
|
402
451
|
const days = new Set<number>();
|
|
@@ -10,6 +10,7 @@ import { isConfidential } from "../../../../core/recall/index.js";
|
|
|
10
10
|
import {
|
|
11
11
|
FRAMING,
|
|
12
12
|
LANE_ORDER,
|
|
13
|
+
collapsedLane,
|
|
13
14
|
SELF_PAGE_REVISED_EVENT,
|
|
14
15
|
chapterModels,
|
|
15
16
|
dayBefore,
|
|
@@ -716,13 +717,17 @@ function pageHistory(src: DashboardSource, page: ReturnType<DashboardSource["sel
|
|
|
716
717
|
const pageId = page?.id ?? null;
|
|
717
718
|
const zone = src.store.zone();
|
|
718
719
|
try {
|
|
720
|
+
// NEWEST first (2026-10-09, audit #1's last caller): past `LOG_LIMIT` an
|
|
721
|
+
// ascending read kept the oldest rows, and the newest versions — the ones
|
|
722
|
+
// the timeline ends on — lost their dates. The first row seen for a version
|
|
723
|
+
// is its newest, as the last one seen was when this read ascended.
|
|
719
724
|
const rows = pageId === null
|
|
720
|
-
? src.store.eventLog({ name: SELF_PAGE_REVISED_EVENT, limit: LOG_LIMIT })
|
|
721
|
-
: src.store.eventLog({ name: SELF_PAGE_REVISED_EVENT, ref: pageId, limit: LOG_LIMIT });
|
|
725
|
+
? src.store.eventLog({ name: SELF_PAGE_REVISED_EVENT, order: "desc", limit: LOG_LIMIT })
|
|
726
|
+
: src.store.eventLog({ name: SELF_PAGE_REVISED_EVENT, ref: pageId, order: "desc", limit: LOG_LIMIT });
|
|
722
727
|
for (const row of rows) {
|
|
723
728
|
const payload = JSON.parse(row.payload ?? "{}") as Record<string, unknown>;
|
|
724
729
|
const v = payload["version"];
|
|
725
|
-
if (typeof v === "number") {
|
|
730
|
+
if (typeof v === "number" && !at.has(v)) {
|
|
726
731
|
at.set(v, row.at);
|
|
727
732
|
onDay.set(v, row.day);
|
|
728
733
|
}
|
|
@@ -762,7 +767,8 @@ function pageHistory(src: DashboardSource, page: ReturnType<DashboardSource["sel
|
|
|
762
767
|
return steps;
|
|
763
768
|
}
|
|
764
769
|
|
|
765
|
-
|
|
770
|
+
/** Rows the page's history and its day strip read per event name, newest first. */
|
|
771
|
+
export const LOG_LIMIT = 2_000;
|
|
766
772
|
|
|
767
773
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
768
774
|
// the page's history as one strip of lived days (round 3b, item 1)
|
|
@@ -839,9 +845,12 @@ function pageDays(src: DashboardSource, history: readonly PageStep[]): { pageDay
|
|
|
839
845
|
// records the calendar date it closed.
|
|
840
846
|
const cycleDate = new Map<number, string>();
|
|
841
847
|
try {
|
|
842
|
-
|
|
848
|
+
// NEWEST first, so past `LOG_LIMIT` it is the oldest days that go undated,
|
|
849
|
+
// not today's (one row per session end; 2026-10-09). Each day keeps its
|
|
850
|
+
// OLDEST row's date, as before: the last one seen wins.
|
|
851
|
+
for (const row of src.store.eventLog({ name: "sleep.cycle", sinceDay: first, order: "desc", limit: LOG_LIMIT })) {
|
|
843
852
|
const date = (JSON.parse(row.payload ?? "{}") as Record<string, unknown>)["date"];
|
|
844
|
-
if (typeof date === "string" && isIsoDay(date)
|
|
853
|
+
if (typeof date === "string" && isIsoDay(date)) cycleDate.set(row.day, date);
|
|
845
854
|
}
|
|
846
855
|
} catch {
|
|
847
856
|
/* undated days stay undated */
|
|
@@ -1125,6 +1134,14 @@ export function wakeParts(text: string, hasPage: boolean): WakePart[] {
|
|
|
1125
1134
|
add("furniture", n);
|
|
1126
1135
|
return;
|
|
1127
1136
|
}
|
|
1137
|
+
// A lane that listed nothing is ONE line, its heading inside it
|
|
1138
|
+
// (`self/briefing.ts#collapsedLine`, 2026-10-09): it is that lane's.
|
|
1139
|
+
const collapsed = collapsedLane(line);
|
|
1140
|
+
if (collapsed !== null) {
|
|
1141
|
+
current = collapsed;
|
|
1142
|
+
add(collapsed, n);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1128
1145
|
if (line.startsWith("<!--") || line === FRAMING.context) {
|
|
1129
1146
|
add("furniture", n);
|
|
1130
1147
|
return;
|
|
@@ -1435,6 +1452,14 @@ export function wakeLanes(text: string): WakeLane[] {
|
|
|
1435
1452
|
if (line.startsWith("<!--")) continue;
|
|
1436
1453
|
if (line.length === 0) continue;
|
|
1437
1454
|
const lane = headings.get(line);
|
|
1455
|
+
// A lane that listed nothing is one line with its heading inside it
|
|
1456
|
+
// (`self/briefing.ts#collapsedLine`, 2026-10-09): that lane, that one item.
|
|
1457
|
+
const collapsed = collapsedLane(line);
|
|
1458
|
+
if (collapsed !== null) {
|
|
1459
|
+
if (current.items.length > 0) lanes.push(current);
|
|
1460
|
+
current = { heading: FRAMING[collapsed], lane: collapsed, items: [line.slice(FRAMING[collapsed].length).trim()] };
|
|
1461
|
+
continue;
|
|
1462
|
+
}
|
|
1438
1463
|
// A markdown heading counts too, so a future briefing that uses one still
|
|
1439
1464
|
// splits rather than collapsing into a single block.
|
|
1440
1465
|
const mdHeading = /^#{1,6}\s+(.*)$/.exec(line);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Deliberately empty. Every Bun launch Counterparts makes passes
|
|
2
|
+
# --config=<this file>, so Bun reads this instead of the bunfig.toml in the
|
|
3
|
+
# folder it starts in (the person's project), whose `preload` would otherwise
|
|
4
|
+
# run inside the hooks and the memory server. adapters/runtime.ts says why.
|
|
5
|
+
# Installed commands name this path: it must stay, and stay empty.
|
package/src/adapters/fired.ts
CHANGED
|
@@ -723,8 +723,12 @@ export const MECHANISMS: readonly Mechanism[] = [
|
|
|
723
723
|
// reminder date that still comes round, kept for its next occurrence —
|
|
724
724
|
// and physics names it only where the floor would otherwise have let the
|
|
725
725
|
// memory go (review of #341), or every pill reminder would read as a
|
|
726
|
-
// refusal every night.
|
|
727
|
-
//
|
|
726
|
+
// refusal every night. `protected` is named on the same terms (2026-10-09):
|
|
727
|
+
// the self page is born protected, and counting it every night read
|
|
728
|
+
// "BLOCKED: protected ×8" on a store too young for anything to be at the
|
|
729
|
+
// floor. `in-live-revision-chain` too (review of #343): a row under challenge
|
|
730
|
+
// pressure was counted every night it stayed so. All three are a rule
|
|
731
|
+
// refusing a memory that qualified, and only that. `above-floor`,
|
|
728
732
|
// `dwell-too-short` and `band-not-episodic`
|
|
729
733
|
// are the ordinary condition of almost every memory on almost every night —
|
|
730
734
|
// the reviewer measured `dwell-too-short ×240` on a healthy forty-memory
|
|
@@ -79,10 +79,11 @@ export function isOurHookCommand(command: string): boolean {
|
|
|
79
79
|
const first = tokens[0] ?? "";
|
|
80
80
|
// The installed shim, by itself.
|
|
81
81
|
if (/(^|[/\\])counterparts-hook$/.test(first)) return tail(1);
|
|
82
|
-
// `<runtime> run <our hook script>`,
|
|
83
|
-
// `<runtime> --import <node-hooks.mjs> <our hook script
|
|
82
|
+
// `<runtime> run <our hook script>`, Node's
|
|
83
|
+
// `<runtime> --import <node-hooks.mjs> <our hook script>`, or the single
|
|
84
|
+
// binary's `<binary> hook` (`runtime.ts`).
|
|
84
85
|
const run = parseScriptInvocation(tokens);
|
|
85
|
-
if (run !== null && /claude-code[/\\]bin[/\\]hook\.ts$/.test(run.script)) {
|
|
86
|
+
if (run !== null && (run.mode === "hook" || (run.mode === undefined && /claude-code[/\\]bin[/\\]hook\.ts$/.test(run.script)))) {
|
|
86
87
|
return tail(tokens.length - run.rest.length);
|
|
87
88
|
}
|
|
88
89
|
return false;
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
*/
|
|
41
41
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
42
42
|
import { join, relative, resolve } from "node:path";
|
|
43
|
-
import { fileURLToPath } from "node:url";
|
|
44
43
|
|
|
45
44
|
import { assertSafeDataDir } from "../../core/store/index.js";
|
|
46
45
|
import { daysBetween, isDay, isoInstant, localDate, resolveZone } from "../../core/time.js";
|
|
47
46
|
import { SESSIONS_DIR } from "../sessions.js";
|
|
47
|
+
import { packagePath } from "../runtime.js";
|
|
48
48
|
|
|
49
49
|
/** The directory, inside `sessions/`. */
|
|
50
50
|
export const LOG_DIR = "log";
|
|
@@ -179,7 +179,7 @@ export function clean(data: Record<string, unknown> | undefined): Record<string,
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/** This package's `src/`, for an error's top frame. */
|
|
182
|
-
const SRC_ROOT = resolve(
|
|
182
|
+
const SRC_ROOT = resolve(packagePath("src"));
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* An error as the log may write it: its class, its code, and the top source
|