counterparts 0.3.11 → 0.3.13
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 +326 -0
- package/docs/QUICKSTART.md +5 -0
- package/docs/README.md +2 -2
- package/docs/module-map.md +3 -3
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +36 -10
- package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
- package/src/adapters/claude-code/NOTES.md +182 -0
- package/src/adapters/claude-code/bin/hook.ts +46 -12
- package/src/adapters/claude-code/bin/runner.ts +7 -1
- package/src/adapters/claude-code/doctor.ts +632 -18
- package/src/adapters/claude-code/hooks.ts +61 -16
- package/src/adapters/claude-code/index.ts +11 -0
- package/src/adapters/claude-code/night-run.ts +150 -14
- package/src/adapters/claude-code/transcript.ts +268 -1
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
- package/src/adapters/cli/NOTES.md +111 -0
- package/src/adapters/cli/commands.ts +134 -92
- package/src/adapters/cli/dream-core.ts +57 -42
- package/src/adapters/cli/export.ts +320 -21
- package/src/adapters/cli/help.ts +2 -1
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +39 -7
- package/src/adapters/cli/mechanisms.ts +7 -1
- package/src/adapters/cli/uninstall.ts +13 -5
- package/src/adapters/cli/wire.ts +189 -63
- package/src/adapters/config.ts +2 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
- package/src/adapters/dashboard/NOTES.md +79 -0
- package/src/adapters/dashboard/registries.ts +34 -2
- package/src/adapters/dashboard/web/README.md +19 -14
- package/src/adapters/dashboard/web/actions.ts +23 -1
- package/src/adapters/dashboard/web/flow.ts +14 -0
- package/src/adapters/dashboard/web/lanes.ts +10 -0
- package/src/adapters/dashboard/web/narrate.ts +88 -2
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
- package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
- package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
- package/src/adapters/dashboard/web/server.ts +0 -5
- package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
- package/src/adapters/dashboard/web/views/health.ts +21 -3
- package/src/adapters/dashboard/web/views/search.ts +4 -45
- package/src/adapters/dashboard/web/views.ts +2 -2
- package/src/adapters/fired.ts +430 -28
- package/src/adapters/host-wiring.ts +300 -0
- package/src/adapters/hosts.ts +11 -0
- package/src/adapters/lifecycle.ts +42 -2
- package/src/adapters/log/index.ts +9 -0
- package/src/adapters/mcp/CONTRACT.md +151 -11
- package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
- package/src/adapters/mcp/NOTES.md +313 -1
- package/src/adapters/mcp/bin/serve.ts +74 -1
- package/src/adapters/mcp/deliberate.ts +169 -651
- package/src/adapters/mcp/facts.ts +1094 -0
- package/src/adapters/mcp/index.ts +25 -7
- package/src/adapters/mcp/meaning.ts +1610 -0
- package/src/adapters/mcp/server.ts +835 -150
- package/src/adapters/mcp/stdio.ts +3 -1
- package/src/adapters/mcp/stood-down.ts +51 -0
- package/src/adapters/mcp/tools.ts +167 -41
- package/src/adapters/plugin-run.sh +133 -0
- package/src/adapters/plugin.ts +329 -0
- package/src/adapters/sessions.ts +18 -4
- package/src/core/associate/CONTRACT.md +2 -1
- package/src/core/associate/INTERFACE-GAPS.md +6 -1
- package/src/core/associate/NOTES.md +45 -0
- package/src/core/briefing.ts +12 -3
- package/src/core/contradictions.ts +184 -0
- package/src/core/counterpart.ts +797 -51
- package/src/core/dream/CONTRACT.md +36 -4
- package/src/core/dream/INTERFACE-GAPS.md +29 -6
- package/src/core/dream/NOTES.md +107 -0
- package/src/core/dream/feeling-weeks.ts +198 -0
- package/src/core/dream/index.ts +109 -18
- package/src/core/dream/reflect.ts +346 -87
- package/src/core/dream/tunables.ts +24 -4
- package/src/core/encode/INTERFACE-GAPS.md +3 -1
- package/src/core/encode/NOTES.md +7 -0
- package/src/core/encode/words.ts +45 -0
- package/src/core/fit/INTERFACE-GAPS.md +8 -2
- package/src/core/fit/NOTES.md +39 -1
- package/src/core/fit/index.ts +40 -0
- package/src/core/handoff/CONTRACT.md +37 -2
- package/src/core/handoff/INTERFACE-GAPS.md +10 -0
- package/src/core/handoff/NOTES.md +72 -0
- package/src/core/handoff/index.ts +214 -12
- package/src/core/handoff/last-here.ts +6 -4
- package/src/core/mint.ts +12 -2
- package/src/core/physics/CONTRACT.md +14 -2
- package/src/core/physics/NOTES.md +33 -1
- package/src/core/physics/index.ts +28 -5
- package/src/core/prospective/CONTRACT.md +45 -6
- package/src/core/prospective/INTERFACE-GAPS.md +4 -0
- package/src/core/prospective/NOTES.md +138 -0
- package/src/core/prospective/derive.ts +33 -5
- package/src/core/prospective/index.ts +90 -5
- package/src/core/prospective/windows.ts +72 -1
- package/src/core/recall/CONTRACT.md +31 -12
- package/src/core/recall/INTERFACE-GAPS.md +28 -4
- package/src/core/recall/NOTES.md +70 -1
- package/src/core/recall/feeling-ask.ts +10 -1
- package/src/core/recall/index.ts +3 -1
- package/src/core/recall/probe.ts +58 -0
- package/src/core/recall/session.ts +46 -2
- package/src/core/recall/time-ask.ts +487 -0
- package/src/core/remember/CONTRACT.md +4 -1
- package/src/core/remember/INTERFACE-GAPS.md +9 -1
- package/src/core/remember/NOTES.md +8 -0
- package/src/core/remember/proposals.ts +47 -5
- package/src/core/revision.ts +18 -1
- package/src/core/schemas/CONTRACT.md +21 -1
- package/src/core/schemas/INTERFACE-GAPS.md +20 -2
- package/src/core/schemas/NOTES.md +144 -0
- package/src/core/schemas/aliases.ts +55 -5
- package/src/core/schemas/index.ts +93 -1
- package/src/core/schemas/types.ts +2 -0
- package/src/core/self/CONTRACT.md +32 -5
- package/src/core/self/INTERFACE-GAPS.md +7 -2
- package/src/core/self/NOTES.md +102 -1
- package/src/core/self/behind.ts +43 -3
- package/src/core/self/briefing.ts +12 -2
- package/src/core/self/chapter-address.ts +254 -0
- package/src/core/self/episodes.ts +27 -0
- package/src/core/self/index.ts +83 -8
- package/src/core/self/page.ts +88 -0
- package/src/core/self/tunables.ts +5 -0
- package/src/core/self/work.ts +35 -2
- package/src/core/self/writer.ts +30 -0
- package/src/core/sleep/INTERFACE-GAPS.md +22 -3
- package/src/core/sleep/NOTES.md +20 -1
- package/src/core/sleep/consolidate.ts +59 -7
- package/src/core/sleep/index.ts +3 -0
- package/src/core/sleep/prune.ts +6 -2
- package/src/core/sleep/types.ts +7 -0
- package/src/core/store/CONTRACT.md +16 -0
- package/src/core/store/NOTES.md +66 -0
- package/src/core/store/feelings.ts +14 -1
- package/src/core/store/index.ts +483 -16
- package/src/core/store/operational.ts +95 -2
- package/src/core/store/owner-op-seam.ts +23 -0
- package/src/core/time.ts +152 -0
- package/tools/install-loop/run.sh +48 -12
- package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
/* Find a memory: ONE box (round 4, 2026-09-28) with a switch beside it
|
|
2
|
-
(2026-09-30)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
(2026-09-30). Three ways since 2026-10-09, when recall took a mode (0.3.12):
|
|
3
|
+
|
|
4
|
+
- "by word" finds memories by their words as you type (`/api/search`);
|
|
5
|
+
Enter only runs it at once.
|
|
6
|
+
- "facts" asks on Enter, in facts mode: every memory that answers the
|
|
7
|
+
question, counted and paged, best first — each with who said it, when it
|
|
8
|
+
happened or was learned, and whether it still holds.
|
|
9
|
+
- "by meaning" asks on Enter, in meaning mode: what a person, a project or
|
|
10
|
+
a feeling has been over time — the journal chapters that hold it, in time
|
|
11
|
+
order, with their moments and the feelings recorded in them.
|
|
12
|
+
|
|
13
|
+
Both asks are the console's own `counterparts ask --json` (with `--mode`),
|
|
14
|
+
through the actions seam, and the page draws the answer the command
|
|
15
|
+
returned: no label here stands for a field the answer does not carry. The
|
|
16
|
+
drawing is pure (`factsRows`, `meaningRows`, …) and the tests feed it real
|
|
17
|
+
answers from a temp store (`test/dashboard-ask-answers.test.ts`) — the page
|
|
18
|
+
read the old answer's shape for a release after it changed, and nothing
|
|
19
|
+
failed, because its tests were fed by hand.
|
|
20
|
+
|
|
21
|
+
The switch never flips by itself. Either way the answers take the list's
|
|
22
|
+
place — never a second list — and the "×" gives the list back. Ask is the
|
|
23
|
+
owner talking to me, so the server turns the question into my voice before
|
|
24
|
+
it searches (`web/ask-voice.ts`); that is not shown. */
|
|
10
25
|
import { absenceLine } from "../../../shared/absence.js";
|
|
11
26
|
import { act, resultHtml } from "../../../shared/actions.js";
|
|
12
27
|
import { api, fail } from "../../../shared/api.js";
|
|
28
|
+
import { dateOr } from "../../../shared/dates.js";
|
|
13
29
|
import { $, esc } from "../../../shared/dom.js";
|
|
14
|
-
import {
|
|
30
|
+
import { withIdMarks } from "../../../shared/memory-marks.js";
|
|
15
31
|
import { memRow, searchWords } from "../row.js";
|
|
16
32
|
import { find, onFilter, setFilter } from "../state.js";
|
|
17
33
|
|
|
@@ -30,11 +46,14 @@ export const markup = `
|
|
|
30
46
|
|
|
31
47
|
let qtimer = null;
|
|
32
48
|
let seq = 0;
|
|
49
|
+
/** The question and mode the answer on the page is for, so its pager asks the same again. */
|
|
50
|
+
let asked = null;
|
|
33
51
|
|
|
34
|
-
/** The
|
|
52
|
+
/** The three ways to find, as the switch says them, and what the box says for each. */
|
|
35
53
|
export const MODES = {
|
|
36
54
|
word: { label: "by word", placeholder: "a word or two — the answers come as you type" },
|
|
37
|
-
|
|
55
|
+
facts: { label: "facts", placeholder: "ask a question, then press Enter — every memory that answers it" },
|
|
56
|
+
meaning: { label: "by meaning", placeholder: "who or what, over time — ask, then press Enter" },
|
|
38
57
|
};
|
|
39
58
|
|
|
40
59
|
/** The switch and the box's placeholder, as `find.mode` says. */
|
|
@@ -57,7 +76,7 @@ export function mount() {
|
|
|
57
76
|
if (e.key === "Enter") {
|
|
58
77
|
e.preventDefault();
|
|
59
78
|
clearTimeout(qtimer);
|
|
60
|
-
if (find.mode === "word") runSearch(); else ask();
|
|
79
|
+
if (find.mode === "word") runSearch(); else ask(box.value.trim(), find.mode, 1);
|
|
61
80
|
} else if (e.key === "Escape" && box.value) { e.preventDefault(); clear(); }
|
|
62
81
|
});
|
|
63
82
|
$("q-x").addEventListener("click", () => { clear(); box.focus(); });
|
|
@@ -70,7 +89,7 @@ export function mount() {
|
|
|
70
89
|
const words = box.value;
|
|
71
90
|
if (!words.trim()) return;
|
|
72
91
|
if (find.mode === "word") { runSearch(); return; }
|
|
73
|
-
//
|
|
92
|
+
// An ask waits for Enter: the list comes back, the question stays.
|
|
74
93
|
seq++;
|
|
75
94
|
if (find.on) setFilter({});
|
|
76
95
|
box.value = words;
|
|
@@ -78,6 +97,14 @@ export function mount() {
|
|
|
78
97
|
$("find-head").hidden = false;
|
|
79
98
|
$("find-head").innerHTML = '<span class="find-hint">press Enter to ask</span>';
|
|
80
99
|
});
|
|
100
|
+
// An answer's pages: the same question, in the same mode, again. (The
|
|
101
|
+
// list's own pager buttons carry `data-off`; these carry `data-ask-page`.)
|
|
102
|
+
$("mpager").addEventListener("click", (e) => {
|
|
103
|
+
const b = e.target.closest("button[data-ask-page]");
|
|
104
|
+
if (!b || b.disabled || !asked || !find.on) return;
|
|
105
|
+
ask(asked.q, asked.mode, Number(b.dataset.askPage));
|
|
106
|
+
$("q").scrollIntoView({ block: "start", behavior: "smooth" });
|
|
107
|
+
});
|
|
81
108
|
// A filter chosen anywhere else (a chip, the chart, a link from Home) ends
|
|
82
109
|
// the find: the box empties so it never shows words the list isn't answering.
|
|
83
110
|
onFilter(() => {
|
|
@@ -127,7 +154,7 @@ async function runSearch() {
|
|
|
127
154
|
const close = d.close || [];
|
|
128
155
|
takeList(esc(findHead(d.hits.length, d.total, close.length)));
|
|
129
156
|
$("mlist").innerHTML = d.absent
|
|
130
|
-
? absenceLine(d.absent, "nothing I hold uses those words — try
|
|
157
|
+
? absenceLine(d.absent, "nothing I hold uses those words — try asking for the facts")
|
|
131
158
|
: d.hits.map((h) => memRow({ ...h, text: h.shown, archived: null }, { mark: searchWords(q) })).join("") +
|
|
132
159
|
(close.length > 0
|
|
133
160
|
? '<div class="mclose-h">Close matches <span>· a letter or two off</span></div>' +
|
|
@@ -150,61 +177,253 @@ export function questionWords(q) {
|
|
|
150
177
|
return searchWords(q).filter((w) => w.length >= 4 && !QUESTION_WORDS.has(w));
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/** An answer's words as a row shows them: headings dropped, a date written at
|
|
157
|
-
* the front lifted off (display only — the memory is untouched). */
|
|
158
|
-
export function answerWords(body) {
|
|
159
|
-
const flat = String(body || "").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")).join(" ");
|
|
160
|
-
const m = /^(\d{4}-\d{2}-\d{2})(?:[ \t]*[:,—–-][ \t]*|[ \t]+)(?=\S)/.exec(flat);
|
|
161
|
-
let rest = m ? flat.slice(m[0].length) : flat;
|
|
162
|
-
if (m) rest = rest.charAt(0).toUpperCase() + rest.slice(1);
|
|
163
|
-
return { date: m ? m[1] : null, text: rest.length > 320 ? rest.slice(0, 319) + "…" : rest };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function ask() {
|
|
167
|
-
const q = $("q").value.trim();
|
|
180
|
+
/** Ask the console, in `mode`, and put its answer where the list is. */
|
|
181
|
+
async function ask(q, mode, page) {
|
|
168
182
|
if (!q) return;
|
|
169
183
|
const mine = ++seq;
|
|
184
|
+
asked = { q, mode };
|
|
170
185
|
takeList("thinking…");
|
|
171
186
|
$("mlist").innerHTML = "";
|
|
172
|
-
const r = await act("ask", { question: q, json: true });
|
|
187
|
+
const r = await act("ask", { question: q, json: true, mode, ...(page > 1 ? { page } : {}) });
|
|
173
188
|
if (mine !== seq) return;
|
|
174
189
|
let result = null;
|
|
175
190
|
if (r && r.ok && Array.isArray(r.out)) {
|
|
176
191
|
try { result = JSON.parse(r.out.join("\n")); } catch (e) { result = null; }
|
|
177
192
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
// An answer in another mode than the one asked is not drawn as if it were.
|
|
194
|
+
if (!result || result.mode !== mode) { takeList("I couldn't ask that"); $("mlist").innerHTML = resultHtml(r); return; }
|
|
195
|
+
const meaning = mode === "meaning";
|
|
196
|
+
takeList(meaning ? meaningHead(result) : factsHead(result));
|
|
197
|
+
$("mlist").innerHTML = meaning ? meaningRows(result) : factsRows(result, q);
|
|
198
|
+
$("mpager").innerHTML = askPager(result);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ── the answers, drawn (pure: no DOM, so `bun test` draws real ones) ─────────
|
|
202
|
+
|
|
203
|
+
/** Results on one page of a facts answer: `mcp/facts.ts#FACTS_PAGE_SIZE` (a test holds the two equal). */
|
|
204
|
+
export const FACTS_PAGE = 10;
|
|
205
|
+
|
|
206
|
+
/** Who said it (`FactItem.saidBy`), in my voice — the console's words (`facts.ts`). */
|
|
207
|
+
export const SAID = { owner: "you said", self: "I said", inferred: "inferred" };
|
|
208
|
+
|
|
209
|
+
const plural = (n, one, many) => n + " " + (n === 1 ? one : many || one + "s");
|
|
210
|
+
|
|
211
|
+
/** Why words alone answered, when they did (`facts.ts#channelWords`); null when meaning searched too. */
|
|
212
|
+
export function channelWords(semantic) {
|
|
213
|
+
if (semantic === "embedder-off") return "by words only — recall by meaning is off";
|
|
214
|
+
if (semantic === "embed-failed") return "by words only — the question could not be embedded";
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The notes under a head line, quieter, or nothing. */
|
|
219
|
+
const noteLine = (notes) => (notes.length > 0 ? '<span class="find-note">' + esc(notes.join(" · ")) + "</span>" : "");
|
|
220
|
+
|
|
221
|
+
/** The open ends of a window ("before 7/22", "after 7/22"): `recall/time-ask.ts`'s
|
|
222
|
+
* `OPEN_START` and `OPEN_END` (2026-10-09). */
|
|
223
|
+
const OPEN_START = "0001-01-01";
|
|
224
|
+
const OPEN_END = "9999-12-31";
|
|
225
|
+
|
|
226
|
+
/** A window of days: "Sep 21st – Sep 27th", one day, "through Jul 21st" or "Jul 23rd onward". */
|
|
227
|
+
function span(w) {
|
|
228
|
+
if (!w) return "";
|
|
229
|
+
if (w.from === OPEN_START) return "through " + dateOr(w.to);
|
|
230
|
+
if (w.to === OPEN_END) return dateOr(w.from) + " onward";
|
|
231
|
+
return w.from === w.to ? dateOr(w.from) : dateOr(w.from) + " – " + dateOr(w.to);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The time a facts question named (`FactsResult.time`), in a line; "" when it named none. */
|
|
235
|
+
export function timeWords(t) {
|
|
236
|
+
if (!t) return "";
|
|
237
|
+
const outside = t.outside > 0 ? ", " + t.outside + " more outside it" : "";
|
|
238
|
+
if (t.anchor && t.anchor.date === null) {
|
|
239
|
+
return t.anchor.kind === "event"
|
|
240
|
+
? "nothing I hold names “" + t.anchor.phrase + "”, so time left nothing out"
|
|
241
|
+
: "no earlier session found, so time left nothing out";
|
|
186
242
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
takeList("nothing came to mind");
|
|
191
|
-
$("mlist").innerHTML = '<div class="empty">' +
|
|
192
|
-
(result.considered === 0
|
|
193
|
-
? "Nothing I hold shared a word with the question."
|
|
194
|
-
: esc(String(result.considered)) + " memories were weighed and none was close enough.") +
|
|
195
|
-
" Try the words the memory itself would use.</div>";
|
|
196
|
-
return;
|
|
243
|
+
if (t.anchor) {
|
|
244
|
+
return (t.anchor.kind === "event" ? t.anchor.phrase : t.cue) + " → " + dateOr(t.anchor.date) +
|
|
245
|
+
(t.anchor.kind === "event" && t.window ? " (" + span(t.window) + ")" : "") + outside;
|
|
197
246
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
247
|
+
return t.cue + " → " + span(t.said) + (t.stretch > 0 ? ", give or take " + plural(t.stretch, "day") : "") + outside;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A facts answer's head: how many answer it, then the quieter notes. Markup. */
|
|
251
|
+
export function factsHead(r) {
|
|
252
|
+
const lead = r.matched === 0
|
|
253
|
+
? (r.fadedTotal > 0 ? "only faded memories answer it" : "nothing answers it")
|
|
254
|
+
: plural(r.matched, "memory answers it", "memories answer it") + (r.matched > 1 ? ", best first" : "");
|
|
255
|
+
const notes = [];
|
|
256
|
+
if (r.subjects.length > 0) notes.push("about " + r.subjects.map((s) => s.name).join(", "));
|
|
257
|
+
const t = timeWords(r.time);
|
|
258
|
+
if (t) notes.push(t);
|
|
259
|
+
const ch = channelWords(r.semantic);
|
|
260
|
+
if (ch) notes.push(ch);
|
|
261
|
+
if (r.weak > 0) notes.push(plural(r.weak, "weak match", "weak matches") + " not shown");
|
|
262
|
+
if (r.meaningCapped) notes.push("the search by meaning stopped at its cap, so this may not be everything");
|
|
263
|
+
if (r.duplicates > 0) notes.push(plural(r.duplicates, "near-copy", "near-copies") + " of an answer left out");
|
|
264
|
+
return esc(lead) + noteLine(notes);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** A chapter's heading at the front of its words ("chapter 2 — Mon 1 Jun 2026 ·
|
|
268
|
+
* lived day 3"), stacked or not, taken off — the row's title says the day and
|
|
269
|
+
* its line says which chapter (`self/episodes.ts#readChapterLead`, flattened).
|
|
270
|
+
* Display only. */
|
|
271
|
+
export function withoutChapterHeading(text) {
|
|
272
|
+
const lead = /^\s*chapter\s+\d+(?:\s*[—–-]\s*(?:[A-Za-z]{3} \d{1,2} [A-Za-z]{3} \d{4}\s*·\s*)?(?:[A-Za-z0-9][A-Za-z0-9._:[\]-]*\s*·\s*)?lived day\s+\d+)?\s*/i;
|
|
273
|
+
let rest = String(text || "");
|
|
274
|
+
for (let m = lead.exec(rest); m && m[0].length > 0; m = lead.exec(rest)) rest = rest.slice(m[0].length);
|
|
275
|
+
return rest;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Under one fact's words: who said it, its status, when it was learned
|
|
279
|
+
* (when the right-hand date is when it happened), which chapter, and what it
|
|
280
|
+
* was before. Only what the answer carries; markup, or "". */
|
|
281
|
+
export function factLines(m) {
|
|
282
|
+
const said = [];
|
|
283
|
+
if (m.journal) {
|
|
284
|
+
if (m.chapter) said.push("chapter " + m.chapter.n + " of " + m.chapter.of);
|
|
285
|
+
if (m.lastWritten) said.push("written until " + dateOr(m.lastWritten));
|
|
286
|
+
} else {
|
|
287
|
+
if (m.saidBy) said.push(SAID[m.saidBy] || m.saidBy);
|
|
288
|
+
if (m.status) said.push(m.status);
|
|
289
|
+
if (m.occurredOn && m.learned && m.learned !== m.occurredOn) said.push("learned " + dateOr(m.learned));
|
|
290
|
+
}
|
|
291
|
+
const parts = said.map(esc);
|
|
292
|
+
if (!m.current) {
|
|
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
|
+
}
|
|
295
|
+
for (const s of m.standing || []) parts.push(withIdMarks(s));
|
|
296
|
+
if (m.corrected > 0) parts.push(esc(plural(m.corrected, "corrected version") + " hidden"));
|
|
297
|
+
const earlier = (m.earlier || []).map((e) =>
|
|
298
|
+
'<div class="mearlier">earlier: “' + esc(e.text) + "”" +
|
|
299
|
+
esc((e.learned ? " (learned " + dateOr(e.learned) + ")" : "") + (e.changed ? ", changed " + dateOr(e.changed) : "")) +
|
|
300
|
+
(e.id ? " " + withIdMarks(e.id) : "") + "</div>").join("") +
|
|
301
|
+
(m.earlierMore > 0 ? '<div class="mearlier">+' + m.earlierMore + " more earlier</div>" : "");
|
|
302
|
+
if (parts.length === 0 && !earlier) return "";
|
|
303
|
+
return '<div class="mfacts">' + (parts.length > 0 ? "<div>" + parts.join(" · ") + "</div>" : "") + earlier + "</div>";
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** One fact as a row: its date is when it happened, else when it was learned
|
|
307
|
+
* (a chapter: when it was written, in its title). */
|
|
308
|
+
export function factRow(m, words) {
|
|
309
|
+
return memRow({
|
|
310
|
+
id: m.id,
|
|
311
|
+
title: m.title,
|
|
312
|
+
text: m.journal ? withoutChapterHeading(m.body) : m.body,
|
|
313
|
+
kind: m.kind,
|
|
314
|
+
journal: m.journal,
|
|
315
|
+
date: m.journal ? m.learned : m.occurredOn || m.learned,
|
|
316
|
+
dateFrom: m.journal ? null : m.occurredOn ? "happened" : "learned",
|
|
317
|
+
confidential: false, core: false, feelings: [], archived: null,
|
|
318
|
+
}, { mark: words, under: factLines(m) });
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** A facts answer's rows: the page's results, then its faded ones. Markup. */
|
|
322
|
+
export function factsRows(r, q) {
|
|
323
|
+
const words = questionWords(q);
|
|
324
|
+
const rows = r.memories.map((m) => factRow(m, words)).join("");
|
|
325
|
+
const faded = r.faded.length === 0 ? "" :
|
|
326
|
+
'<div class="mclose-h">Faded <span>· ' + esc(plural(r.fadedTotal, "memory", "memories") + " not used for a long while") + "</span></div>" +
|
|
327
|
+
r.faded.map((f) => memRow({ id: f.id, title: f.line, text: "", date: f.date, dateFrom: "learned", feelings: [] }, { mark: words })).join("");
|
|
328
|
+
if (!rows && !faded) {
|
|
329
|
+
return '<div class="empty">Nothing I hold answers that. Try the words the memory itself would use, a person or a project it names, or a wider time.</div>';
|
|
330
|
+
}
|
|
331
|
+
return rows + faded;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** A meaning answer's head: what it is about, how much holds it, then the quieter notes. Markup. */
|
|
335
|
+
export function meaningHead(r) {
|
|
336
|
+
if (r.lens === null) return esc("nothing came");
|
|
337
|
+
const c = r.counts;
|
|
338
|
+
const parts = [r.lens.name];
|
|
339
|
+
if (c.chapters > 0) parts.push(plural(c.chapters, "chapter"));
|
|
340
|
+
const chapterless = c.sessions - c.unplaced;
|
|
341
|
+
if (chapterless > 0) parts.push(plural(chapterless, "session") + " with no chapter");
|
|
342
|
+
if (c.unplaced > 0) parts.push(plural(c.unplaced, "session") + " with moments outside its chapters");
|
|
343
|
+
parts.push(plural(c.moments, "moment") + (c.faded > 0 ? " (+" + c.faded + " faded)" : ""));
|
|
344
|
+
const notes = [];
|
|
345
|
+
if (r.feeling) notes.push("feeling asked: " + (r.feeling.words.length > 0 ? r.feeling.words.join(", ") : "any") + " · " + (r.feeling.whose || "both of us"));
|
|
346
|
+
if (r.others.length > 0) {
|
|
347
|
+
notes.push("also named: " + r.others.map((o) => o.name + " (" + plural(o.memories, "memory", "memories") + ")").join(", ") + " — ask about one by name");
|
|
348
|
+
}
|
|
349
|
+
// Its own notes say what makes it thin — words alone, when no card or
|
|
350
|
+
// feeling found the moments, among them — so no channel line is added here.
|
|
351
|
+
for (const n of r.notes) notes.push(n);
|
|
352
|
+
return esc(parts.join(" · ")) + noteLine(notes);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** What a mark on an arc entry says (`MeaningEntry.marks`). */
|
|
356
|
+
const MARK_WORDS = { start: "where it starts", end: "the latest", turn: "the feelings turn here" };
|
|
357
|
+
|
|
358
|
+
/** Whose feelings, side by side and never merged: "mine: proud · Mike's: worried". */
|
|
359
|
+
function feelingSides(f, whose) {
|
|
360
|
+
const side = (list, who) => (list && list.length > 0 ? who + ": " + list.map((x) => x.word).join(", ") : null);
|
|
361
|
+
return [side(f.self, whose.self), side(f.owner, whose.owner)].filter(Boolean).join(" · ");
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** One entry of the arc: a chapter (opens its journal), or a session's moments
|
|
365
|
+
* with no chapter (opens nothing). Its moments are links under it. */
|
|
366
|
+
export function arcRow(e, whose) {
|
|
367
|
+
const chapter = e.kind === "chapter";
|
|
368
|
+
const lines = [];
|
|
369
|
+
if (chapter && e.of > 1) lines.push("chapter " + e.chapter + " of " + e.of);
|
|
370
|
+
for (const mk of e.marks) lines.push(MARK_WORDS[mk] || mk);
|
|
371
|
+
const felt = feelingSides(e.feelings, whose);
|
|
372
|
+
if (felt) lines.push(felt);
|
|
373
|
+
const more = e.momentCount - e.moments.length;
|
|
374
|
+
const moments = e.moments.map((m) =>
|
|
375
|
+
'<button type="button" class="mmoment" data-open="' + esc(m.id) + '">' + withIdMarks(m.title, true) + "</button>").join("") +
|
|
376
|
+
(more > 0 ? '<span class="mmore">+' + more + " more of its moments</span>" : "");
|
|
377
|
+
const under = (lines.length > 0 ? '<div class="mfacts"><div>' + esc(lines.join(" · ")) + "</div></div>" : "") +
|
|
378
|
+
(moments ? '<div class="mmoments">' + moments + "</div>" : "");
|
|
379
|
+
return memRow(chapter
|
|
380
|
+
? { id: e.episodeId, title: e.title, text: e.line, journal: true, date: e.date, feelings: [] }
|
|
381
|
+
: { id: null, title: e.unplaced ? "Moments outside that session's chapters" : "A session with no chapter written", text: "",
|
|
382
|
+
date: e.date, dateFrom: "recorded", feelings: [] },
|
|
383
|
+
{ under });
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** A stretch of the arc this page does not show, as one quiet line. */
|
|
387
|
+
function foldRow(l, page) {
|
|
388
|
+
const what = page === 1 ? plural(l.count, "quieter entry", "quieter entries") : plural(l.count, "entry", "entries");
|
|
389
|
+
const when = l.from === null ? "" : l.to === null || l.to === l.from ? ", " + dateOr(l.from) : ", " + dateOr(l.from) + " – " + dateOr(l.to);
|
|
390
|
+
return '<div class="mfold">' + esc("· " + what + " not shown here" + when) + "</div>";
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** A titled part after the arc, or nothing when it is empty. */
|
|
394
|
+
function part(title, note, rows) {
|
|
395
|
+
return rows ? '<div class="mclose-h">' + esc(title) + (note ? " <span>· " + esc(note) + "</span>" : "") + "</div>" + rows : "";
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** A meaning answer's rows: the arc in time order, then the faded moments,
|
|
399
|
+
* what I made of it before, what is still open, and what recurs. Markup. */
|
|
400
|
+
export function meaningRows(r) {
|
|
401
|
+
if (r.lens === null) {
|
|
402
|
+
return '<div class="empty">Nothing came: the question names no one and nothing I keep a card for, asks about no feeling, and none of its words reach a memory. Try a person’s or a project’s name — or ask for the facts.</div>';
|
|
403
|
+
}
|
|
404
|
+
if (r.reason === "nothing-came") return '<div class="empty">Nothing I hold is about that yet. Try a person’s or a project’s name — or ask for the facts.</div>';
|
|
405
|
+
const plain = (x, under) => memRow({ id: x.id, title: x.title, text: x.excerpt || "", date: x.date, dateFrom: "recorded", feelings: [] },
|
|
406
|
+
under ? { under: '<div class="mfacts"><div>' + esc(under) + "</div></div>" } : {});
|
|
407
|
+
const p = r.patterns;
|
|
408
|
+
const recurring = [
|
|
409
|
+
p.subjects.length > 0 ? "with " + p.subjects.map((x) => x.label + " (" + x.entries + " of " + x.of + ")").join(", ") : "",
|
|
410
|
+
p.feelings.length > 0 ? "feelings: " + p.feelings.map((x) => x.label + " (" + x.entries + " of " + x.of + ")").join(", ") : "",
|
|
411
|
+
].filter(Boolean);
|
|
412
|
+
return r.arc.map((l) => (l.fold ? foldRow(l, r.page) : arcRow(l.entry, r.whose))).join("") +
|
|
413
|
+
part("Faded", plural(r.counts.faded, "moment") + " not used for a long while", r.faded.map((m) => plain(m)).join("")) +
|
|
414
|
+
part("What I made of it before", "dreams and reflections", r.readings.map((g) => plain(g, g.by === "dreamed" ? "from a dream" : "from a reflection")).join("")) +
|
|
415
|
+
part("Still open", "", r.open.map((o) => plain(o, o.why === "dated" ? "a date still ahead" : "not settled yet")).join("")) +
|
|
416
|
+
part("Recurring", "across the entries of the arc", recurring.map((x) => '<div class="mfold">' + esc(x) + "</div>").join(""));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** An answer's pages, as the list's pager looks: back, where, more. "" for one page. */
|
|
420
|
+
export function askPager(r) {
|
|
421
|
+
if (!(r.pages > 1)) return "";
|
|
422
|
+
const first = (r.page - 1) * FACTS_PAGE;
|
|
423
|
+
const range = r.mode === "facts" && r.memories.length > 0
|
|
424
|
+
? '<span class="mpage">' + (first + 1) + "–" + (first + r.memories.length) + " of " + r.matched + "</span>" : "";
|
|
425
|
+
const button = (page, words, off) =>
|
|
426
|
+
'<button type="button" class="mbtn" data-ask-page="' + page + '"' + (off ? " disabled" : "") + ">" + words + "</button>";
|
|
427
|
+
return button(r.page - 1, "← back", r.page <= 1) + range +
|
|
428
|
+
'<span class="mpage mpage-n">page ' + r.page + " of " + r.pages + "</span>" + button(r.page + 1, "more →", r.page >= r.pages);
|
|
210
429
|
}
|
|
@@ -10,7 +10,8 @@ export const filters = {
|
|
|
10
10
|
|
|
11
11
|
/** The find box: while it holds words, its answers stand in the list's place
|
|
12
12
|
* (round 4, 2026-09-28: results REPLACE the list). Any filter change ends it.
|
|
13
|
-
* `mode`: the switch beside it, "word" or "meaning" (2026-09-30)
|
|
13
|
+
* `mode`: the switch beside it, "word" or "meaning" (2026-09-30), or "facts"
|
|
14
|
+
* (2026-10-09). */
|
|
14
15
|
export const find = { on: false, mode: "word" };
|
|
15
16
|
|
|
16
17
|
const listeners = [];
|
|
@@ -84,7 +84,6 @@ import { DREAM_LIMIT, dreamsView } from "./views/dreams.js";
|
|
|
84
84
|
import { resolveStatic } from "./static.js";
|
|
85
85
|
import {
|
|
86
86
|
activityView,
|
|
87
|
-
chapterLinks,
|
|
88
87
|
eventDetail,
|
|
89
88
|
flowView,
|
|
90
89
|
healthView,
|
|
@@ -279,10 +278,6 @@ export function router(
|
|
|
279
278
|
if (path === "/api/search") {
|
|
280
279
|
return json(searchView(src, url.searchParams.get("q") ?? "", intParam(url, "limit", 25)));
|
|
281
280
|
}
|
|
282
|
-
if (path === "/api/chapters") {
|
|
283
|
-
const ids = (url.searchParams.get("ids") ?? "").split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
284
|
-
return json(chapterLinks(src, ids));
|
|
285
|
-
}
|
|
286
281
|
if (path === "/api/mind") return json(mindView(src));
|
|
287
282
|
if (path === "/api/dreams") return json(dreamsView(src, intParam(url, "limit", DREAM_LIMIT)));
|
|
288
283
|
if (path === "/api/flow") return json(flowView(src, intParam(url, "limit", 24)));
|
|
@@ -13,3 +13,10 @@
|
|
|
13
13
|
.mbadge.core{color:#e8dcff;border-color:rgba(179,136,255,.45)}
|
|
14
14
|
.mbadge.lock{color:var(--amber);border-color:rgba(255,215,64,.35);padding:1px 5px}
|
|
15
15
|
.mbadge.journal{color:var(--purple);border-color:rgba(179,136,255,.3)}
|
|
16
|
+
/* An id inside a memory's words, drawn as what it is ("memory ↗"), the id on
|
|
17
|
+
hover (`idMark`). Quiet: the same word, not a link. */
|
|
18
|
+
.idref{display:inline;padding:0;margin:0;background:none;border:none;border-radius:3px;font:inherit;font-size:.92em;
|
|
19
|
+
color:var(--cyan);cursor:pointer;white-space:nowrap}
|
|
20
|
+
.idref:hover,.idref:focus-visible{text-decoration:underline;outline:none}
|
|
21
|
+
.idref.quiet{color:var(--faint);cursor:inherit}
|
|
22
|
+
.idref.quiet:hover{text-decoration:none}
|
|
@@ -82,3 +82,36 @@ export function badges(r) {
|
|
|
82
82
|
|
|
83
83
|
const LOCK = '<svg class="kic" viewBox="0 0 16 16" aria-label="protected"><rect x="3.5" y="7" width="9" height="7" rx="1.3"/>' +
|
|
84
84
|
'<path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2"/></svg>';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A memory's own id written inside words — "(mem_cb6eea7a6b9f)", a dream's
|
|
88
|
+
* "replaces mem_…", a chapter's address "epi_…#2" (2026-10-09). The store's
|
|
89
|
+
* three families (`store/prose.ts#ID_PREFIX`), twelve hex digits from
|
|
90
|
+
* `randomBytes(6)` (sixteen allowed, as `recall/reference.ts#MEMORY_ID`).
|
|
91
|
+
*/
|
|
92
|
+
export const ID_IN_WORDS = /\b(?:mem|epi|sch)_[0-9a-f]{12,16}(?:#\d+)?\b/;
|
|
93
|
+
|
|
94
|
+
/** What an id in the words is called, by its family, instead of its digits. */
|
|
95
|
+
const ID_WORDS = { mem: "memory", epi: "journal", sch: "card" };
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An id inside words, drawn as what it is rather than its digits: a small
|
|
99
|
+
* link that opens it (`data-open`, which the memories list routes to
|
|
100
|
+
* `openMemory`, `row.js#wireRows`), the id itself on hover. A chapter's
|
|
101
|
+
* address opens its journal and says which chapter. `quiet` draws the same
|
|
102
|
+
* word with no link — for words already inside something clickable, where a
|
|
103
|
+
* link cannot nest. Display only: the memory keeps its words.
|
|
104
|
+
*/
|
|
105
|
+
export function idMark(ref, quiet) {
|
|
106
|
+
const [id, chapter] = String(ref).split("#");
|
|
107
|
+
const word = (ID_WORDS[id.slice(0, 3)] || "memory") + (chapter ? " chapter " + chapter : "");
|
|
108
|
+
return quiet
|
|
109
|
+
? '<span class="idref quiet" title="' + esc(ref) + '">' + esc(word) + "</span>"
|
|
110
|
+
: '<button type="button" class="idref" data-open="' + esc(id) + '" title="open ' + esc(ref) + '">' + esc(word) + " ↗</button>";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** `text`, escaped, with every id in it drawn by `idMark`. */
|
|
114
|
+
export function withIdMarks(text, quiet) {
|
|
115
|
+
const parts = String(text || "").split(new RegExp("(" + ID_IN_WORDS.source + ")"));
|
|
116
|
+
return parts.map((p, i) => (i % 2 === 1 ? idMark(p, quiet) : esc(p))).join("");
|
|
117
|
+
}
|
|
@@ -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, stampWords } from "./dates.js";
|
|
16
|
+
import { dateOr, localIso, stampWords } 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,9 +48,11 @@ 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`), else the calendar day
|
|
51
|
+
* the store (v7 `created_at`) on this computer's calendar, else the calendar day
|
|
52
|
+
* it was recorded. It read the UTC day until 2026-10-09, which put a memory
|
|
53
|
+
* written on a Denver evening on the next day. */
|
|
52
54
|
export function writtenOn(d) {
|
|
53
|
-
if (typeof d.createdAt === "number" && d.createdAt > 0) return
|
|
55
|
+
if (typeof d.createdAt === "number" && d.createdAt > 0) return localIso(d.createdAt);
|
|
54
56
|
return /^\d{4}-\d{2}-\d{2}$/.test(String(d.learnedOn || "")) ? d.learnedOn : null;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the four rules in that file's header apply to every line below.
|
|
6
6
|
*/
|
|
7
7
|
import { LAST_HERE_NOROOM_EVENT } from "../../../../core/handoff/last-here.js";
|
|
8
|
+
import { WORK_OVERFLOW_EVENT } from "../../../../core/self/work.js";
|
|
8
9
|
import { symmetryCheck } from "../../../../core/physics/index.js";
|
|
9
10
|
import { MARKER_UNSET, MERGE_ARCHIVE_REASON, PRUNE_ARCHIVE_REASON, readMarker } from "../../../../core/sleep/index.js";
|
|
10
11
|
import { cadenceFor, markerDue } from "../../../../core/sleep/markers.js";
|
|
@@ -136,11 +137,17 @@ export interface WakeBudget {
|
|
|
136
137
|
* one per chapter per lived day) since the published wake was
|
|
137
138
|
* rendered: how many "Last here" lines a session start could
|
|
138
139
|
* not carry. Until then a ring event only, gone with the hook.
|
|
140
|
+
* work — `self.work.overflow` rows with cause `room` (durable since
|
|
141
|
+
* 2026-10-02, one per directory per lived day) since the
|
|
142
|
+
* published wake was rendered: how many directories' "Work
|
|
143
|
+
* here" lines did not all fit. More work than a wake shows
|
|
144
|
+
* (cause `cap`) is the rotation, not a cost.
|
|
139
145
|
*/
|
|
140
146
|
export interface WakeCosts {
|
|
141
147
|
readonly page: { readonly shown: number; readonly whole: number } | null;
|
|
142
148
|
readonly handoffs: number;
|
|
143
149
|
readonly lastHere: number;
|
|
150
|
+
readonly work: number;
|
|
144
151
|
readonly writerHeld: boolean;
|
|
145
152
|
}
|
|
146
153
|
|
|
@@ -179,6 +186,17 @@ export function wakeCosts(src: DashboardSource, text: string, renderDay: number
|
|
|
179
186
|
/* no rows read is no line known to be dropped */
|
|
180
187
|
}
|
|
181
188
|
|
|
189
|
+
const work = new Set<string>();
|
|
190
|
+
try {
|
|
191
|
+
const since = renderDay ?? src.store.livedDay();
|
|
192
|
+
for (const row of src.store.eventLog({ name: WORK_OVERFLOW_EVENT, sinceDay: since, order: "desc", limit: LOG_CEILING })) {
|
|
193
|
+
const p = payloadOf(row.payload);
|
|
194
|
+
if (p["cause"] === "room") work.add(typeof p["scope"] === "string" ? p["scope"] : `seq:${row.seq}`);
|
|
195
|
+
}
|
|
196
|
+
} catch {
|
|
197
|
+
/* no rows read is no line known to be dropped */
|
|
198
|
+
}
|
|
199
|
+
|
|
182
200
|
let writerHeld = false;
|
|
183
201
|
try {
|
|
184
202
|
const last = src.self.pageWriterRuns({ limit: 1 })[0];
|
|
@@ -189,10 +207,10 @@ export function wakeCosts(src: DashboardSource, text: string, renderDay: number
|
|
|
189
207
|
} catch {
|
|
190
208
|
writerHeld = false;
|
|
191
209
|
}
|
|
192
|
-
return { page, handoffs: dropped.size, lastHere: lastHere.size, writerHeld };
|
|
210
|
+
return { page, handoffs: dropped.size, lastHere: lastHere.size, work: work.size, writerHeld };
|
|
193
211
|
}
|
|
194
212
|
|
|
195
|
-
const NO_COSTS: WakeCosts = { page: null, handoffs: 0, lastHere: 0, writerHeld: false };
|
|
213
|
+
const NO_COSTS: WakeCosts = { page: null, handoffs: 0, lastHere: 0, work: 0, writerHeld: false };
|
|
196
214
|
|
|
197
215
|
/** The wake against its ceiling. A read: `wake()` on the observer source writes nothing. */
|
|
198
216
|
export function wakeBudget(src: DashboardSource): WakeBudget {
|
|
@@ -260,7 +278,7 @@ const ADAPTER_EVENTS: readonly DurableEventName[] = [
|
|
|
260
278
|
|
|
261
279
|
const ADAPTER_NOTE: Partial<Record<DurableEventName, string>> = {
|
|
262
280
|
"adapter.wake.injected": "bytes handed to the host, never the text",
|
|
263
|
-
"adapter.wake.delivered": "whether the briefing
|
|
281
|
+
"adapter.wake.delivered": "whether the briefing actually arrived, checked at the first prompt or the first Stop",
|
|
264
282
|
"adapter.recall": "how long recall took, when the adapter recorded it",
|
|
265
283
|
"adapter.ask": "asked, paced out, or capped for the day",
|
|
266
284
|
"adapter.authorship.ask": "historical — nothing writes this now",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `/api/search
|
|
2
|
+
* `/api/search`. (`/api/chapters`, the chapter an Ask answer came from, left
|
|
3
|
+
* with the "from chapter" link on 2026-10-09: facts mode folds a chapter and
|
|
4
|
+
* the memory drawn from it into one answer itself.)
|
|
3
5
|
*
|
|
4
6
|
* Split out of `web/views.ts`, which re-exports every public name from here;
|
|
5
7
|
* the four rules in that file's header apply to every line below.
|
|
@@ -9,7 +11,7 @@ import { isJournal } from "../../../../core/sleep/index.js";
|
|
|
9
11
|
import type { Band, Kind } from "../../../../core/types.js";
|
|
10
12
|
import { NEVER, NONE } from "../../layout.js";
|
|
11
13
|
import type { DashboardSource } from "../../source.js";
|
|
12
|
-
import { reveal
|
|
14
|
+
import { reveal } from "../reveal.js";
|
|
13
15
|
import { feelingsShown, isChapterMemory, shownOf } from "./memory-words.js";
|
|
14
16
|
import type { DateFrom, FeelingShown } from "./memory-words.js";
|
|
15
17
|
|
|
@@ -50,49 +52,6 @@ export interface Hit {
|
|
|
50
52
|
feelings: FeelingShown[];
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
/** How many ids one `/api/chapters` call looks at — an Ask answer is a handful. */
|
|
54
|
-
export const CHAPTER_LINKS_MAX = 50;
|
|
55
|
-
|
|
56
|
-
/** A journal-chapter memory's chapter: the journal entry it was minted from. */
|
|
57
|
-
export interface ChapterLink {
|
|
58
|
-
readonly episodeId: string;
|
|
59
|
-
/** The journal entry's title, or null when it has none (or is withheld). */
|
|
60
|
-
readonly label: string | null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* `/api/chapters?ids=…` — for each id that is a JOURNAL-CHAPTER MEMORY
|
|
65
|
-
* (`isChapterMemory`: minted from a chapter, `meta.episodeId`), the journal
|
|
66
|
-
* entry it came from. Ask (the console's `ask --json`) can return a chapter
|
|
67
|
-
* and the memory drawn from it side by side with the same words; the page
|
|
68
|
-
* folds the pair into one answer with a "from chapter …" link (2026-09-27).
|
|
69
|
-
*
|
|
70
|
-
* Read-only and quiet: `row()` only, never `read()` (a read is an event).
|
|
71
|
-
* Ids that are not chapter memories, or whose journal entry is gone, are left
|
|
72
|
-
* out.
|
|
73
|
-
*/
|
|
74
|
-
export function chapterLinks(src: DashboardSource, ids: readonly string[]): { links: Record<string, ChapterLink> } {
|
|
75
|
-
const store = src.store;
|
|
76
|
-
const links: Record<string, ChapterLink> = {};
|
|
77
|
-
for (const id of ids.slice(0, CHAPTER_LINKS_MAX)) {
|
|
78
|
-
const row = store.row(id);
|
|
79
|
-
if (row === undefined || !isChapterMemory(row)) continue;
|
|
80
|
-
let episodeId: unknown;
|
|
81
|
-
try {
|
|
82
|
-
episodeId = (JSON.parse(row.meta) as Record<string, unknown>)["episodeId"];
|
|
83
|
-
} catch {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (typeof episodeId !== "string" || episodeId === id) continue;
|
|
87
|
-
const episode = store.row(episodeId);
|
|
88
|
-
if (episode === undefined) continue;
|
|
89
|
-
const r = revealHere(store, episodeId, 80);
|
|
90
|
-
const title = episode.title?.trim() ?? "";
|
|
91
|
-
links[id] = { episodeId, label: r.confidential || !r.present || title === "" ? null : title };
|
|
92
|
-
}
|
|
93
|
-
return { links };
|
|
94
|
-
}
|
|
95
|
-
|
|
96
55
|
export function searchView(src: DashboardSource, q: string, limit = 25): SearchView {
|
|
97
56
|
const store = src.store;
|
|
98
57
|
const day = store.livedDay();
|