counterparts 0.3.2 → 0.3.3
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 +72 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/NOTES.md +12 -0
- package/src/adapters/claude-code/bin/hook.ts +85 -22
- package/src/adapters/claude-code/config.ts +7 -0
- package/src/adapters/claude-code/doctor.ts +20 -4
- package/src/adapters/claude-code/hooks.ts +157 -6
- package/src/adapters/claude-code/index.ts +3 -0
- package/src/adapters/cli/commands.ts +11 -0
- package/src/adapters/cli/mechanisms.ts +46 -21
- package/src/adapters/dashboard/registries.ts +4 -0
- package/src/adapters/dashboard/web/README.md +19 -11
- package/src/adapters/dashboard/web/flow.ts +2 -0
- package/src/adapters/dashboard/web/mechanisms/emotional/index.js +9 -5
- package/src/adapters/dashboard/web/mechanisms/prospective/index.js +6 -3
- package/src/adapters/dashboard/web/narrate.ts +8 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +17 -1
- package/src/adapters/dashboard/web/pages/self/index.js +55 -16
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +75 -19
- package/src/adapters/dashboard/web/pages/self/sections/page.js +108 -65
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +94 -99
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +31 -15
- package/src/adapters/dashboard/web/pages/self/self.css +119 -59
- package/src/adapters/dashboard/web/pages/self/state.js +23 -0
- package/src/adapters/dashboard/web/pages/self/tips.js +50 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +9 -0
- package/src/adapters/dashboard/web/views/mechanisms.ts +85 -14
- package/src/adapters/dashboard/web/views/memory.ts +15 -1
- package/src/adapters/dashboard/web/views/mind.ts +130 -6
- package/src/adapters/feelings-line.ts +74 -0
- package/src/adapters/fired.ts +78 -18
- package/src/adapters/mcp/CONTRACT.md +8 -0
- package/src/adapters/mcp/NOTES.md +45 -0
- package/src/adapters/mcp/server.ts +165 -6
- package/src/adapters/mcp/tools.ts +51 -4
- package/src/core/bridge.ts +21 -16
- package/src/core/counterpart.ts +309 -6
- package/src/core/encode/CONTRACT.md +7 -1
- package/src/core/feelings-wheel.ts +171 -13
- package/src/core/mint.ts +9 -0
- package/src/core/physics/CONTRACT.md +43 -0
- package/src/core/physics/NOTES.md +94 -0
- package/src/core/physics/index.ts +98 -6
- package/src/core/prospective/CONTRACT.md +35 -6
- package/src/core/prospective/INTERFACE-GAPS.md +10 -5
- package/src/core/prospective/NOTES.md +175 -4
- package/src/core/prospective/derive.ts +32 -3
- package/src/core/prospective/index.ts +362 -39
- package/src/core/prospective/tunables.ts +18 -1
- package/src/core/prospective/windows.ts +104 -46
- package/src/core/recall/CONTRACT.md +28 -0
- package/src/core/recall/NOTES.md +39 -0
- package/src/core/recall/activate.ts +32 -5
- package/src/core/recall/gate.ts +7 -1
- package/src/core/recall/index.ts +19 -0
- package/src/core/recall/mood.ts +106 -0
- package/src/core/recall/tunables.ts +26 -0
- package/src/core/remember/index.ts +1 -0
- package/src/core/remember/proposals.ts +86 -3
- package/src/core/self/identity.ts +20 -1
- package/src/core/store/CONTRACT.md +9 -2
- package/src/core/store/NOTES.md +20 -0
- package/src/core/store/feelings.ts +23 -6
- package/src/core/store/index.ts +107 -10
- package/src/core/store/operational.ts +15 -1
- package/src/core/types.ts +9 -0
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
/* The self page — the heart of the tab —
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* The self page — the heart of the tab — on the left, whole and untrimmed; and
|
|
2
|
+
in the side column, when it was last rewritten and by whom, what the page
|
|
3
|
+
writer did on its last night, and its history as a line of dots. Clicking a
|
|
4
|
+
dot opens that version and what changed from the one before it; nothing is
|
|
5
|
+
open until then. Read-only: there is no write door here (the doors are the
|
|
6
|
+
MCP tool and the console's `self-page`). */
|
|
5
7
|
import { absenceLine } from "../../../shared/absence.js";
|
|
6
8
|
import { $, esc } from "../../../shared/dom.js";
|
|
7
9
|
import { diffStats, diffText } from "../diff.js";
|
|
8
10
|
import { renderMarkdown } from "../markdown.js";
|
|
11
|
+
import { ui } from "../state.js";
|
|
12
|
+
import { q, wireTips } from "../tips.js";
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
/** The left column: an opened version (when one is), then the page. */
|
|
15
|
+
export const mainMarkup = `
|
|
16
|
+
<div id="self-version"></div>
|
|
17
|
+
<section class="sp-card" id="self-page"></section>`;
|
|
18
|
+
|
|
19
|
+
/** The side column's top: the page's facts, then its history. */
|
|
20
|
+
export const sideMarkup = `
|
|
21
|
+
<div class="side-block" id="self-meta"></div>
|
|
22
|
+
<div class="side-block" id="self-history"></div>`;
|
|
13
23
|
|
|
14
24
|
let steps = [];
|
|
15
|
-
let chosen = -1;
|
|
16
|
-
let showWhole = false;
|
|
17
25
|
|
|
18
26
|
const WHO = { owner: "you, by hand", session: "a session", writer: "the page writer" };
|
|
19
27
|
export const who = (by) => (by ? WHO[by] || by : "someone unrecorded");
|
|
@@ -27,91 +35,126 @@ export function shortDate(iso) {
|
|
|
27
35
|
return d.toLocaleDateString("en-US", opts);
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
/** The writer's outcome → a tone for its line. */
|
|
39
|
+
const WRITER_TONE = { revised: "ok", "nothing-to-say": "ok", refused: "warn", failed: "warn" };
|
|
40
|
+
|
|
41
|
+
export function paintPage(d) {
|
|
31
42
|
const p = d.page;
|
|
32
43
|
$("self-page").innerHTML = d.pageAbsent
|
|
33
|
-
?
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'<div class="sp-chips">' +
|
|
37
|
-
'<span class="chip">version ' + p.version + "</span>" +
|
|
38
|
-
'<span class="chip">revised ' + esc(shortDate(p.revisedOn) || p.revisedOn || "on an unrecorded date") + "</span>" +
|
|
39
|
-
'<span class="chip">by ' + esc(who(p.by)) + "</span>" +
|
|
40
|
-
(p.stale ? '<span class="chip warn">not revised in a while</span>' : "") +
|
|
41
|
-
"</div></div>" +
|
|
42
|
-
(p.reason ? '<div class="sp-reason">Last change: ' + esc(p.reason) + "</div>" : "") +
|
|
43
|
-
'<div class="sp-body">' + renderMarkdown(p.body) + "</div>";
|
|
44
|
+
? absenceLine(d.pageAbsent, "no page has been written yet — it is written at the end of a session, from what keeps coming up, and you can amend it by hand")
|
|
45
|
+
: '<div class="sp-body">' + renderMarkdown(p.body) + "</div>";
|
|
46
|
+
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
export function paintMeta(d) {
|
|
49
|
+
const p = d.page;
|
|
50
|
+
const w = d.writer;
|
|
51
|
+
const rows = [];
|
|
52
|
+
if (p) {
|
|
53
|
+
rows.push('<div class="sb-line"><span class="sb-k">Rewritten</span><span>' +
|
|
54
|
+
esc(shortDate(p.revisedOn) || p.revisedOn || "on an unrecorded date") + " · by " + esc(who(p.by)) +
|
|
55
|
+
" · version " + p.version + "</span></div>");
|
|
56
|
+
if (p.stale) rows.push('<div class="sb-line"><span class="chip warn" title="not rewritten in over ' + p.staleAfter + ' days">not rewritten in a while</span></div>');
|
|
57
|
+
if (p.reason) rows.push('<div class="sb-why" title="' + esc(p.reason) + '">“' + esc(p.reason) + "”</div>");
|
|
58
|
+
}
|
|
59
|
+
if (w) {
|
|
60
|
+
rows.push('<div class="sb-writer' + (WRITER_TONE[w.outcome] ? " " + WRITER_TONE[w.outcome] : "") + '">' +
|
|
61
|
+
(w.absent ? '<span class="sb-absent">' + esc(w.absent) + "</span> " : "") + esc(w.line) +
|
|
62
|
+
q("writer", "The page writer reads the day just gone, once a night, and rewrites the page when something about who I am moved. This is its newest run.") +
|
|
63
|
+
"</div>");
|
|
64
|
+
}
|
|
65
|
+
$("self-meta").innerHTML = rows.join("");
|
|
66
|
+
wireTips($("self-meta"));
|
|
50
67
|
}
|
|
51
68
|
|
|
52
|
-
function paintHistory() {
|
|
69
|
+
export function paintHistory(d) {
|
|
70
|
+
if (d) steps = d.pageHistory || [];
|
|
53
71
|
const el = $("self-history");
|
|
54
|
-
|
|
72
|
+
// A version that is no longer in the history (a cleared page) closes.
|
|
73
|
+
if (ui.version !== null && !steps.some((s) => s.seq === ui.version)) ui.version = null;
|
|
74
|
+
if (steps.length === 0) { el.innerHTML = ""; el.hidden = true; paintVersion(); return; }
|
|
75
|
+
el.hidden = false;
|
|
55
76
|
if (steps.length === 1) {
|
|
56
|
-
el.innerHTML = '<
|
|
77
|
+
el.innerHTML = '<h3 class="sb-h">How the page changed</h3>' +
|
|
78
|
+
'<p class="foot sp-once">Written once; there is no earlier version to compare.</p>';
|
|
79
|
+
paintVersion();
|
|
57
80
|
return;
|
|
58
81
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
const keep = el.querySelector(".tl");
|
|
83
|
+
const scrollLeft = keep ? keep.scrollLeft : null;
|
|
84
|
+
const dots = steps.map((s) => {
|
|
85
|
+
const on = s.seq === ui.version;
|
|
86
|
+
return '<button type="button" class="tl-step' + (on ? " on" : "") + (s.current ? " now" : "") +
|
|
87
|
+
'" data-seq="' + s.seq + '" aria-pressed="' + on + '" title="' + esc(s.reason || "") + '">' +
|
|
62
88
|
'<span class="tl-dot"></span>' +
|
|
63
89
|
'<span class="tl-date">' + esc(shortDate(s.date) || (s.day !== null ? "day " + s.day : "undated")) + "</span>" +
|
|
64
90
|
'<span class="tl-who">' + esc(s.current ? "now" : "v" + (s.seq - 1)) + " · " + esc(s.by === "owner" ? "you" : s.by || "?") + "</span>" +
|
|
65
|
-
"</button>"
|
|
91
|
+
"</button>";
|
|
92
|
+
}).join("");
|
|
66
93
|
el.innerHTML =
|
|
67
|
-
'<
|
|
68
|
-
|
|
69
|
-
'<div class="
|
|
94
|
+
'<h3 class="sb-h">How the page changed ' +
|
|
95
|
+
q("history", steps.length + " versions, oldest on the left. Click one to see what changed from the version before it; click it again to close.") + "</h3>" +
|
|
96
|
+
'<div class="tl"><div class="tl-track">' + dots + "</div></div>";
|
|
97
|
+
const tl = el.querySelector(".tl");
|
|
98
|
+
// Where the line was scrolled stays; the first time, it shows the newest end.
|
|
99
|
+
tl.scrollLeft = scrollLeft === null ? tl.scrollWidth : scrollLeft;
|
|
70
100
|
el.querySelectorAll(".tl-step").forEach((b) => b.addEventListener("click", () => {
|
|
71
|
-
|
|
101
|
+
const seq = Number(b.dataset.seq);
|
|
102
|
+
ui.version = ui.version === seq ? null : seq;
|
|
103
|
+
ui.whole = false;
|
|
72
104
|
paintHistory();
|
|
105
|
+
// Only on a click, never on a refresh: bring the opened view into sight.
|
|
106
|
+
const v = $("self-version");
|
|
107
|
+
if (ui.version !== null && v.scrollIntoView) v.scrollIntoView({ block: "nearest" });
|
|
73
108
|
}));
|
|
74
|
-
|
|
75
|
-
const on = el.querySelector(".tl-step.on");
|
|
76
|
-
if (on && on.scrollIntoView) on.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
109
|
+
wireTips(el);
|
|
77
110
|
paintVersion();
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
function paintVersion() {
|
|
81
|
-
const
|
|
82
|
-
const
|
|
114
|
+
const box = $("self-version");
|
|
115
|
+
const i = ui.version === null ? -1 : steps.findIndex((s) => s.seq === ui.version);
|
|
116
|
+
if (i < 0) { box.innerHTML = ""; box.hidden = true; return; }
|
|
117
|
+
box.hidden = false;
|
|
118
|
+
const s = steps[i];
|
|
119
|
+
const prev = i > 0 ? steps[i - 1] : null;
|
|
83
120
|
const head =
|
|
84
121
|
'<div class="tl-vhead"><b>' + (s.current ? "The page as it stands" : "Version " + (s.seq - 1)) + "</b>" +
|
|
85
122
|
'<span class="tl-meta">' + esc(shortDate(s.date) || "undated") + (s.day !== null ? " · lived day " + s.day : "") +
|
|
86
|
-
" · written by " + esc(who(s.by)) + (s.bytes !== null ? " · " + s.bytes + " bytes" : "") + "</span
|
|
123
|
+
" · written by " + esc(who(s.by)) + (s.bytes !== null ? " · " + s.bytes + " bytes" : "") + "</span>" +
|
|
124
|
+
'<button type="button" class="tl-close" id="self-version-close" aria-label="Close this version">close</button></div>' +
|
|
87
125
|
(s.reason ? '<div class="tl-why">“' + esc(s.reason) + "”</div>" : "");
|
|
88
|
-
|
|
89
|
-
$("self-version").innerHTML = head + '<div class="foot">This version\'s words could not be read.</div>';
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const canDiff = prev !== null && prev.body !== null;
|
|
93
|
-
const toggle = canDiff
|
|
94
|
-
? '<div class="tl-toggle" role="group">' +
|
|
95
|
-
'<button type="button" class="seg' + (showWhole ? "" : " on") + '" data-whole="0">What changed</button>' +
|
|
96
|
-
'<button type="button" class="seg' + (showWhole ? " on" : "") + '" data-whole="1">The whole version</button></div>'
|
|
97
|
-
: "";
|
|
126
|
+
let toggle = "";
|
|
98
127
|
let body;
|
|
99
|
-
if (
|
|
100
|
-
body =
|
|
101
|
-
'<div class="sp-body">' + renderMarkdown(s.body) + "</div>";
|
|
128
|
+
if (s.body === null) {
|
|
129
|
+
body = '<div class="foot">This version\'s words could not be read.</div>';
|
|
102
130
|
} else {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
131
|
+
const canDiff = prev !== null && prev.body !== null;
|
|
132
|
+
toggle = canDiff
|
|
133
|
+
? '<div class="tl-toggle" role="group">' +
|
|
134
|
+
'<button type="button" class="seg' + (ui.whole ? "" : " on") + '" data-whole="0">What changed</button>' +
|
|
135
|
+
'<button type="button" class="seg' + (ui.whole ? " on" : "") + '" data-whole="1">The whole version</button></div>'
|
|
136
|
+
: "";
|
|
137
|
+
if (!canDiff || ui.whole) {
|
|
138
|
+
body = (prev === null ? '<div class="foot">The first page — nothing came before it.</div>' : "") +
|
|
139
|
+
'<div class="sp-body">' + renderMarkdown(s.body) + "</div>";
|
|
140
|
+
} else {
|
|
141
|
+
const rows = diffText(prev.body, s.body);
|
|
142
|
+
const st = diffStats(rows);
|
|
143
|
+
body = '<div class="foot">Compared with version ' + (prev.seq - 1) + ": " +
|
|
144
|
+
'<span class="d-add">' + st.added + " line" + (st.added === 1 ? "" : "s") + " added or changed</span>, " +
|
|
145
|
+
'<span class="d-del">' + st.removed + " taken out or changed</span>.</div>" +
|
|
146
|
+
renderDiff(rows);
|
|
147
|
+
}
|
|
109
148
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
149
|
+
box.innerHTML = '<div class="card pad tl-detail">' + head + toggle + body + "</div>";
|
|
150
|
+
box.querySelectorAll(".seg").forEach((b) => b.addEventListener("click", () => {
|
|
151
|
+
ui.whole = b.dataset.whole === "1";
|
|
113
152
|
paintVersion();
|
|
114
153
|
}));
|
|
154
|
+
$("self-version-close").addEventListener("click", () => {
|
|
155
|
+
ui.version = null;
|
|
156
|
+
paintHistory();
|
|
157
|
+
});
|
|
115
158
|
}
|
|
116
159
|
|
|
117
160
|
/** Unchanged runs longer than a few lines fold to one line saying so. */
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
closest to the core
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/* Settling into the core, as one compact chart: a line of counts (in the core,
|
|
2
|
+
protected, being argued with — each opens the list behind it), then each
|
|
3
|
+
memory closest to the core as one row: a short name, a bar filling toward
|
|
4
|
+
the threshold (earned, with the tick where the core begins), and the day
|
|
5
|
+
dots. The candidates are measured against physics' own promotion rule (the
|
|
6
|
+
view computes it; this only draws it). The explaining words sit behind `?`. */
|
|
6
7
|
import { $, esc } from "../../../shared/dom.js";
|
|
7
8
|
import { headline, n2, said } from "../../../shared/format.js";
|
|
8
9
|
import { openModal } from "../../../shared/modal.js";
|
|
10
|
+
import { ui } from "../state.js";
|
|
11
|
+
import { q, wireTips } from "../tips.js";
|
|
9
12
|
import { storyCard } from "./stories.js";
|
|
10
13
|
|
|
11
14
|
export const markup = `
|
|
12
|
-
<h2 id="self-settling-h">
|
|
15
|
+
<h2 id="self-settling-h">Settling into the core <span id="self-settling-q"></span></h2>
|
|
13
16
|
<div class="card pad" id="self-settling"></div>`;
|
|
14
17
|
|
|
15
|
-
const SHOW = 5;
|
|
16
18
|
let stories = [];
|
|
19
|
+
let last = null;
|
|
20
|
+
|
|
21
|
+
const plural = (n, one, many) => n + " " + (n === 1 ? one : many);
|
|
17
22
|
|
|
18
23
|
export function paint(d) {
|
|
24
|
+
if (d) last = d;
|
|
25
|
+
d = last;
|
|
19
26
|
const s = d.settling;
|
|
20
27
|
stories = d.stories || [];
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
$("self-settling-q").innerHTML = q("settling", "The core is what repetition and weight earned; it no longer fades. " +
|
|
29
|
+
"Protected is permanent, including permanently wrong. Being argued with is a belief under pressure against the bar it has to clear to change.");
|
|
30
|
+
|
|
31
|
+
// A list that emptied closes.
|
|
32
|
+
if (ui.count && listOf(s, ui.count).length === 0) ui.count = null;
|
|
23
33
|
|
|
24
|
-
|
|
34
|
+
const parts = [];
|
|
35
|
+
// ── the one line of counts; each opens its list ──
|
|
25
36
|
const counts = [
|
|
26
|
-
plural(s.core.length, "
|
|
27
|
-
plural(s.guarded.length, "protected", "protected"),
|
|
28
|
-
plural(s.contested.length, "
|
|
37
|
+
["core", s.core.length, plural(s.core.length, "in the core", "in the core")],
|
|
38
|
+
["guarded", s.guarded.length, plural(s.guarded.length, "protected", "protected")],
|
|
39
|
+
["contested", s.contested.length, plural(s.contested.length, "being argued with", "being argued with")],
|
|
29
40
|
];
|
|
30
|
-
parts.push('<div class="st-
|
|
41
|
+
parts.push('<div class="st-counts">' + counts.map(([key, n, label]) =>
|
|
42
|
+
'<button type="button" class="st-count k-' + key + (ui.count === key ? " on" : "") + '" data-count="' + key + '"' +
|
|
43
|
+
(n === 0 ? " disabled" : "") + ' aria-expanded="' + (ui.count === key) + '">' + esc(label) + "</button>").join('<span class="st-sep" aria-hidden="true">·</span>') +
|
|
44
|
+
"</div>");
|
|
45
|
+
if (ui.count) parts.push('<div class="st-list">' + list(s, ui.count) + "</div>");
|
|
31
46
|
|
|
32
47
|
// ── rows it could not read: always shown when it happens (never folded) ──
|
|
33
48
|
if (s.unreadable.length > 0) {
|
|
@@ -35,86 +50,75 @@ export function paint(d) {
|
|
|
35
50
|
" could not be read just now:</b> " + s.unreadable.map((u) => esc(u.label)).join(" · ") + "</div>");
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
// ── the core ──
|
|
39
|
-
if (s.core.length > 0) parts.push(group("In the core", "what repetition and weight earned; it no longer fades", s.core, "core"));
|
|
40
|
-
// ── protected ──
|
|
41
|
-
// When nothing protected stands in the core, the two lists are the same rows:
|
|
42
|
-
// say it once, in the gloss, rather than printing them twice.
|
|
43
|
-
const sameRows = s.outside.length > 0 && s.outside.length === s.guarded.length;
|
|
44
|
-
if (s.guarded.length > 0) {
|
|
45
|
-
parts.push(group("Protected", sameRows
|
|
46
|
-
? "permanent, including permanently wrong — and none of it has earned the core"
|
|
47
|
-
: "permanent — including permanently wrong", s.guarded, "guarded"));
|
|
48
|
-
}
|
|
49
|
-
if (s.outside.length > 0 && !sameRows) {
|
|
50
|
-
parts.push(group("Permanent but not in the core", "worth a look: nothing earned these their place", s.outside, "outside"));
|
|
51
|
-
}
|
|
52
|
-
// ── contested ──
|
|
53
|
-
if (s.contested.length > 0) {
|
|
54
|
-
parts.push('<h4 class="st-h">Being argued with <small>— pressure against the bar it has to clear to change</small></h4>' +
|
|
55
|
-
s.contested.map((c, i) =>
|
|
56
|
-
'<button type="button" class="st-row st-story" data-i="' + i + '">' +
|
|
57
|
-
'<span class="st-text"><span class="st-about">about ' + esc(c.about) + "</span>" + esc(headline(c.now)) + "</span>" +
|
|
58
|
-
(c.revised
|
|
59
|
-
? '<span class="st-tag changed">changed its mind</span>'
|
|
60
|
-
: '<span class="st-bar" title="pressure ' + n2(c.pressure) + " of " + n2(c.bar) + '"><span style="width:' +
|
|
61
|
-
Math.round(Math.min(1, c.fraction) * 100) + '%"></span></span>') +
|
|
62
|
-
"</button>").join(""));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// ── the honest absences, in one line ──
|
|
66
|
-
const empty = [];
|
|
67
|
-
if (s.coreAbsent) empty.push("nothing in the core yet");
|
|
68
|
-
if (s.guardedAbsent) empty.push("nothing protected");
|
|
69
|
-
if (s.contestedAbsent) empty.push("no belief under challenge");
|
|
70
|
-
if (empty.length > 0) {
|
|
71
|
-
const marker = s.coreAbsent || s.guardedAbsent || s.contestedAbsent;
|
|
72
|
-
parts.push('<div class="st-none"><b>' + esc(marker) + "</b> " + esc(empty.join(" · ")) +
|
|
73
|
-
(s.coreAbsent && s.candidates.length > 0 ? " — here's what's closest." : ".") + "</div>");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
53
|
// ── on the way ──
|
|
77
54
|
parts.push(candidates(s));
|
|
78
55
|
|
|
79
|
-
$("self-settling")
|
|
80
|
-
|
|
56
|
+
const box = $("self-settling");
|
|
57
|
+
box.innerHTML = parts.join("");
|
|
58
|
+
box.querySelectorAll(".st-count").forEach((b) => b.addEventListener("click", () => {
|
|
59
|
+
ui.count = ui.count === b.dataset.count ? null : b.dataset.count;
|
|
60
|
+
paint();
|
|
61
|
+
}));
|
|
62
|
+
box.querySelectorAll(".st-story").forEach((b) => b.addEventListener("click", () => {
|
|
81
63
|
const story = stories[Number(b.dataset.i)];
|
|
82
64
|
if (story) openModal("<h3>How I changed my mind — or didn't</h3>" + storyCard(story));
|
|
83
65
|
}));
|
|
84
|
-
$("self-settling
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
66
|
+
wireTips($("self-settling-q"));
|
|
67
|
+
wireTips(box);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function listOf(s, key) {
|
|
71
|
+
return key === "core" ? s.core : key === "guarded" ? s.guarded : key === "contested" ? s.contested : [];
|
|
88
72
|
}
|
|
89
73
|
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
function list(s, key) {
|
|
75
|
+
if (key === "contested") {
|
|
76
|
+
return s.contested.map((c, i) =>
|
|
77
|
+
'<button type="button" class="st-row st-story" data-i="' + i + '">' +
|
|
78
|
+
'<span class="st-text"><span class="st-about">about ' + esc(c.about) + "</span>" + esc(headline(c.now)) + "</span>" +
|
|
79
|
+
(c.revised
|
|
80
|
+
? '<span class="st-tag changed">changed its mind</span>'
|
|
81
|
+
: '<span class="st-bar" title="pressure ' + n2(c.pressure) + " of " + n2(c.bar) + '"><span style="width:' +
|
|
82
|
+
Math.round(Math.min(1, c.fraction) * 100) + '%"></span></span>') +
|
|
83
|
+
"</button>").join("");
|
|
84
|
+
}
|
|
85
|
+
const rows = listOf(s, key);
|
|
86
|
+
// When nothing protected stands in the core, the protected list IS the
|
|
87
|
+
// "permanent but not in the core" list: say so once rather than twice.
|
|
88
|
+
const sameRows = s.outside.length > 0 && s.outside.length === s.guarded.length;
|
|
89
|
+
const note = key === "guarded" && sameRows
|
|
90
|
+
? '<p class="foot st-note">None of these has earned the core.</p>'
|
|
91
|
+
: "";
|
|
92
|
+
const outside = key === "guarded" && s.outside.length > 0 && !sameRows
|
|
93
|
+
? '<h4 class="st-h">Permanent but not in the core</h4>' + s.outside.map(row).join("")
|
|
94
|
+
: "";
|
|
95
|
+
return rows.map(row).join("") + note + outside;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function row(r) {
|
|
99
|
+
return '<button type="button" class="st-row click" onclick="openMemory(\'' + r.id + '\')">' +
|
|
100
|
+
'<span class="st-text">' + said(r.text, r.confidential) + "</span></button>";
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
function candidates(s) {
|
|
101
104
|
const r = s.rule;
|
|
102
105
|
const c = s.candidates;
|
|
103
|
-
const
|
|
104
|
-
" and it has been used on " + r.days + " different days. That is checked every " + r.everyDays + " lived days.";
|
|
106
|
+
const foot = ["A memory joins the core once what it has earned reaches " + n2(r.threshold) +
|
|
107
|
+
" and it has been used on " + r.days + " different days. That is checked every " + r.everyDays + " lived days."];
|
|
108
|
+
if (s.onTheWay > 0) foot.push(plural(s.onTheWay, "memory has", "memories have") + " been used on a later day.");
|
|
109
|
+
if (s.unused > 0) foot.push(s.unused + " more could get there but haven't been used on a later day yet.");
|
|
110
|
+
if (s.outOfReach > 0) {
|
|
111
|
+
foot.push(s.outOfReach + (s.outOfReach === 1 ? " memory was" : " memories were") +
|
|
112
|
+
" scored too low to get there by use alone (use tops out at " + n2(r.repCap + r.bonus) + ").");
|
|
113
|
+
}
|
|
114
|
+
const tip = q("rule", foot.join(" "));
|
|
105
115
|
if (c.length === 0) {
|
|
106
|
-
return '<h4 class="st-h">On the way to the core</h4>
|
|
107
|
-
|
|
108
|
-
'<p class="foot">' + esc(rule) + (s.outOfReach > 0 ? " " + esc(outOfReachLine(s)) : "") + "</p>";
|
|
116
|
+
return '<h4 class="st-h">On the way to the core ' + tip + "</h4>" +
|
|
117
|
+
'<div class="empty"><b>(none yet)</b> nothing is on its way to the core yet.</div>';
|
|
109
118
|
}
|
|
110
|
-
const
|
|
111
|
-
const title = s.onTheWay > 0
|
|
112
|
-
? s.onTheWay + (s.onTheWay === 1 ? " memory is" : " memories are") + " on the way to the core" +
|
|
113
|
-
(lead.days > 0 ? ": the closest has been used on " + Math.min(lead.days, lead.requiredDays) + " of the " + lead.requiredDays + " days it needs" : "")
|
|
114
|
-
: "Closest to the core — strong enough, not yet used on a later day";
|
|
119
|
+
const scale = 1.2; // the bar is drawn from 0 to 1.2 so the threshold sits right of centre
|
|
115
120
|
const rows = c.map((m) => {
|
|
116
121
|
const ready = m.eligible;
|
|
117
|
-
const scale = 1.2; // the bar is drawn from 0 to 1.2 so 0.85 sits right of centre
|
|
118
122
|
const have = Math.min(m.base, scale) / scale * 100;
|
|
119
123
|
const ghost = m.consolidated ? 0 : Math.min(m.bonus, scale - Math.min(m.base, scale)) / scale * 100;
|
|
120
124
|
const strong = m.base >= m.threshold;
|
|
@@ -124,27 +128,18 @@ function candidates(s) {
|
|
|
124
128
|
? "ready — it crosses at the next check"
|
|
125
129
|
: (strong ? "strong enough" : "needs " + n2(m.threshold - m.base) + " more" + (m.consolidated ? "" : " (settling adds " + n2(m.bonus) + " once)")) +
|
|
126
130
|
" · used on " + Math.min(m.days, m.requiredDays) + " of " + m.requiredDays + " days";
|
|
127
|
-
return '<
|
|
128
|
-
|
|
129
|
-
'<
|
|
130
|
-
|
|
131
|
-
'<span class="cm-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"</div>" +
|
|
138
|
-
'<div class="cand-status">' + esc(status) + "</div></div>";
|
|
131
|
+
return '<button type="button" class="cr' + (ready ? " ready" : "") + '" onclick="openMemory(\'' + m.id + '\')" title="' +
|
|
132
|
+
esc((m.confidential ? "" : m.text + " — ") + status) + '">' +
|
|
133
|
+
'<span class="cr-name">' + (ready ? '<span class="cr-ready">ready</span>' : "") + said(headline(m.text), m.confidential) + "</span>" +
|
|
134
|
+
'<span class="cm-track" aria-label="earned ' + n2(m.base) + " of " + n2(m.threshold) + '">' +
|
|
135
|
+
'<span class="cm-fill' + (strong ? " ok" : "") + '" style="width:' + have.toFixed(1) + '%"></span>' +
|
|
136
|
+
(ghost > 0 ? '<span class="cm-ghost" style="left:' + have.toFixed(1) + "%;width:" + ghost.toFixed(1) + '%"></span>' : "") +
|
|
137
|
+
'<span class="cm-mark" style="left:' + (m.threshold / scale * 100).toFixed(1) + '%"></span>' +
|
|
138
|
+
"</span>" +
|
|
139
|
+
'<span class="cm-dots" aria-label="used on ' + m.days + " of " + m.requiredDays + ' days">' + dots + "</span>" +
|
|
140
|
+
"</button>";
|
|
139
141
|
}).join("");
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return '<h4 class="st-h">' + esc(title) + "</h4>" + rows + '<p class="foot">' + esc(foot.join(" ")) + "</p>";
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function outOfReachLine(s) {
|
|
147
|
-
const top = s.rule.repCap + s.rule.bonus;
|
|
148
|
-
return s.outOfReach + (s.outOfReach === 1 ? " memory was" : " memories were") +
|
|
149
|
-
" scored too low to get there by use alone (use tops out at " + n2(top) + ").";
|
|
142
|
+
return '<h4 class="st-h">' + esc(plural(c.length, "memory", "memories")) + " closest to the core " + tip + "</h4>" +
|
|
143
|
+
'<div class="cr-head" aria-hidden="true"><span></span><span>earned</span><span>days</span></div>' +
|
|
144
|
+
'<div class="cr-list">' + rows + "</div>";
|
|
150
145
|
}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
/* What the next session wakes up with —
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* What the next session wakes up with — one line and a stacked bar of its
|
|
2
|
+
parts, in the side column; "read it" opens the whole text in place. The
|
|
3
|
+
rebuild door (`counterparts rebrief`, through the actions seam) is shown but
|
|
4
|
+
not offered for now: rebrief is one step of sleep, and it comes back with
|
|
5
|
+
the sleep work. The console's `counterparts rebrief` is unchanged. */
|
|
4
6
|
import { absenceLine } from "../../../shared/absence.js";
|
|
5
7
|
import { act, resultHtml } from "../../../shared/actions.js";
|
|
6
8
|
import { $, esc } from "../../../shared/dom.js";
|
|
9
|
+
import { ui } from "../state.js";
|
|
10
|
+
import { q, wireTips } from "../tips.js";
|
|
7
11
|
|
|
8
12
|
export const markup = `
|
|
9
|
-
|
|
10
|
-
<
|
|
13
|
+
<div class="side-block">
|
|
14
|
+
<h3 class="sb-h" id="self-wake-h">What the next session wakes up with <span id="self-wake-q"></span></h3>
|
|
15
|
+
<div id="self-wake"></div>
|
|
11
16
|
<div class="wk-act">
|
|
12
|
-
<button type="button" class="act-btn" id="rebrief-go"
|
|
17
|
+
<button type="button" class="act-btn" id="rebrief-go" disabled aria-disabled="true"
|
|
18
|
+
title="comes with the sleep work">Rebuild it now</button><span class="soon" title="comes with the sleep work">coming soon</span>
|
|
13
19
|
<div id="rebrief-out"></div>
|
|
14
|
-
</div
|
|
20
|
+
</div>
|
|
21
|
+
</div>`;
|
|
15
22
|
|
|
16
|
-
let open = false;
|
|
17
23
|
let onDone = null;
|
|
18
24
|
|
|
19
25
|
export const kb = (b) => (b / 1000).toFixed(1) + " KB";
|
|
@@ -21,10 +27,15 @@ export const kb = (b) => (b / 1000).toFixed(1) + " KB";
|
|
|
21
27
|
/** The parts, in reading order, with a colour each. */
|
|
22
28
|
const TONE = { furniture: "p-furn", page: "p-page", identity: "p-page", craft: "p-craft", threads: "p-threads", hints: "p-hints", horizon: "p-horizon" };
|
|
23
29
|
|
|
30
|
+
const EXPLAIN = "When a session starts, a line with today's date goes on top, and in a folder with a handoff note, a pointer to it. " +
|
|
31
|
+
"It is composed without a model, at the end of each day.";
|
|
32
|
+
|
|
24
33
|
export function mount(refresh) {
|
|
25
34
|
onDone = refresh;
|
|
35
|
+
// The action stays wired, so turning the button back on is one attribute.
|
|
26
36
|
$("rebrief-go").addEventListener("click", async () => {
|
|
27
37
|
const go = $("rebrief-go");
|
|
38
|
+
if (go.disabled) return;
|
|
28
39
|
go.disabled = true;
|
|
29
40
|
$("rebrief-out").innerHTML = resultHtml({ out: ["rebuilding…"] });
|
|
30
41
|
const r = await act("rebrief", {});
|
|
@@ -34,7 +45,13 @@ export function mount(refresh) {
|
|
|
34
45
|
});
|
|
35
46
|
}
|
|
36
47
|
|
|
48
|
+
let last = null;
|
|
49
|
+
|
|
37
50
|
export function paint(d) {
|
|
51
|
+
if (d) last = d;
|
|
52
|
+
d = last;
|
|
53
|
+
$("self-wake-q").innerHTML = q("wake", EXPLAIN);
|
|
54
|
+
wireTips($("self-wake-q"));
|
|
38
55
|
const w = d.wake;
|
|
39
56
|
if (!w.ok) {
|
|
40
57
|
$("self-wake").innerHTML = absenceLine(w.absent || "(never run)", "no wake has been composed yet (" + w.reason + ")");
|
|
@@ -50,16 +67,15 @@ export function paint(d) {
|
|
|
50
67
|
'<span class="wk-key"><i class="' + (TONE[p.key] || "p-furn") + '"></i>' + esc(p.label) + " <em>" + kb(p.bytes) + "</em></span>").join("") +
|
|
51
68
|
(budget && budget > w.bytes ? '<span class="wk-key"><i class="p-room"></i>room left <em>' + kb(budget - w.bytes) + "</em></span>" : "");
|
|
52
69
|
$("self-wake").innerHTML =
|
|
53
|
-
'<button type="button" class="wk-sum" id="wake-toggle" aria-expanded="' +
|
|
54
|
-
'<span class="wk-line"
|
|
55
|
-
(budget ? " of " + kb(budget) : " <small>(
|
|
56
|
-
'<span class="wk-open">' + (
|
|
70
|
+
'<button type="button" class="wk-sum" id="wake-toggle" aria-expanded="' + ui.wake + '">' +
|
|
71
|
+
'<span class="wk-line">Next session gets <b>' + (w.bytes / 1000).toFixed(1) + "</b>" +
|
|
72
|
+
(budget ? " of " + kb(budget) : " KB <small>(its ceiling was not recorded)</small>") + "</span>" +
|
|
73
|
+
'<span class="wk-open">' + (ui.wake ? "hide it" : "read it") + "</span>" +
|
|
57
74
|
"</button>" +
|
|
58
75
|
'<div class="wk-bar" role="img" aria-label="' + esc(parts.map((p) => p.label + " " + p.bytes + " bytes").join(", ")) + '">' + seg + "</div>" +
|
|
59
76
|
'<div class="wk-legend">' + legend + "</div>" +
|
|
60
|
-
'<div class="wk-full"' + (
|
|
61
|
-
|
|
62
|
-
$("wake-toggle").addEventListener("click", () => { open = !open; paint(d); });
|
|
77
|
+
'<div class="wk-full" id="wake-full"' + (ui.wake ? "" : " hidden") + ">" + fullText(w) + "</div>";
|
|
78
|
+
$("wake-toggle").addEventListener("click", () => { ui.wake = !ui.wake; paint(); });
|
|
63
79
|
}
|
|
64
80
|
|
|
65
81
|
function fullText(w) {
|