selflore 0.0.2 → 0.2.0
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/README.md +80 -17
- package/dist/cli.js +87 -17
- package/dist/hooks/capture-worker.js +27 -0
- package/dist/hooks/io.js +6 -1
- package/dist/hooks/session-start.js +2 -8
- package/dist/hooks/stop.js +3 -21
- package/dist/hooks/user-prompt-submit.js +10 -0
- package/dist/init.js +84 -18
- package/dist/lib/background.js +173 -0
- package/dist/lib/capture-prompt.js +39 -0
- package/dist/lib/commands.js +321 -67
- package/dist/lib/config.js +84 -5
- package/dist/lib/entries.js +82 -3
- package/dist/lib/heat.js +141 -0
- package/dist/lib/hook-logic.js +107 -0
- package/dist/lib/index-cache.js +46 -0
- package/dist/lib/install.js +2 -3
- package/dist/lib/links.js +58 -0
- package/dist/lib/logo.js +6 -0
- package/dist/lib/notes-graph.js +585 -0
- package/dist/lib/notes-html.js +148 -330
- package/dist/lib/notes-page-css.js +279 -0
- package/dist/lib/notes-page-js.js +959 -0
- package/dist/lib/notes.js +19 -6
- package/dist/lib/nudge.js +8 -1
- package/dist/lib/paths.js +6 -0
- package/dist/lib/question.js +19 -0
- package/dist/lib/queue.js +6 -4
- package/dist/lib/recall.js +149 -0
- package/dist/lib/results.js +11 -1
- package/dist/lib/retag.js +150 -0
- package/dist/lib/server-launch.js +73 -0
- package/dist/lib/server.js +120 -0
- package/dist/lib/session.js +27 -1
- package/dist/lib/settings.js +5 -1
- package/dist/lib/signals.js +51 -0
- package/dist/lib/stats.js +72 -40
- package/dist/lib/struggle.js +120 -0
- package/dist/lib/surface.js +75 -0
- package/dist/lib/transcript.js +205 -37
- package/dist/lib/ui.js +127 -0
- package/dist/notes-server.js +39 -0
- package/dist/sl.js +33 -14
- package/dist/vendor/graph3d.js +5402 -0
- package/package.json +6 -3
- package/skill/SKILL.md +29 -14
- package/skill/references/capture.md +16 -12
- package/skill/references/log.md +2 -2
- package/skill/references/recall.md +44 -0
- package/skill/references/stats.md +5 -1
- package/skill/references/test.md +49 -31
package/dist/lib/notes-html.js
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { readConfig } from "./config.js";
|
|
2
2
|
import { listEntries, splitBody } from "./entries.js";
|
|
3
|
-
import {
|
|
3
|
+
import { computeHeat, hotAreas } from "./heat.js";
|
|
4
|
+
import { computeLinks } from "./links.js";
|
|
5
|
+
import { DAY_MS, readSignals, REASK_AFTER_DAYS } from "./signals.js";
|
|
6
|
+
import { GRAPH_CSS, GRAPH_JS } from "./notes-graph.js";
|
|
7
|
+
import { FAVICON, LOGO_MASK, LOGO_MASK_RATIO } from "./logo.js";
|
|
8
|
+
import { PAGE_CSS } from "./notes-page-css.js";
|
|
9
|
+
import { PAGE_JS } from "./notes-page-js.js";
|
|
10
|
+
import { entryStatus, weekOfDate, weekStart } from "./notes.js";
|
|
4
11
|
import { readQueue } from "./queue.js";
|
|
5
12
|
import { readResults, testedEntryIds } from "./results.js";
|
|
6
|
-
|
|
13
|
+
/** Last grade and number of answers per entry (results are in the order they were recorded). */
|
|
14
|
+
export function gradeHistory(results) {
|
|
15
|
+
const out = new Map();
|
|
16
|
+
for (const r of results)
|
|
17
|
+
out.set(r.entry_id, { last: r.grade, attempts: (out.get(r.entry_id)?.attempts ?? 0) + 1 });
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
export function toCard(e, tested, queue, history, heat) {
|
|
21
|
+
const h = history?.get(e.id);
|
|
22
|
+
const ht = heat?.get(e.id);
|
|
7
23
|
const { prose, snippet } = splitBody(e.body);
|
|
8
24
|
return {
|
|
9
25
|
id: e.id,
|
|
10
26
|
date: e.date,
|
|
11
27
|
project: e.project,
|
|
12
28
|
kind: e.kind,
|
|
29
|
+
level: e.level,
|
|
13
30
|
skill: e.skill,
|
|
31
|
+
topics: e.topics,
|
|
32
|
+
origin: e.origin,
|
|
14
33
|
paths: e.paths,
|
|
15
34
|
commit: e.commit,
|
|
16
35
|
testable: e.testable,
|
|
@@ -18,330 +37,70 @@ export function toCard(e, tested, queue) {
|
|
|
18
37
|
snippet: snippet ? snippet.replace(/\s+$/, "") : null,
|
|
19
38
|
snippetLang: e.body.match(/```([\w+-]+)/)?.[1] ?? "",
|
|
20
39
|
...entryStatus(e, tested, queue),
|
|
40
|
+
last_grade: h?.last ?? null,
|
|
41
|
+
attempts: h?.attempts ?? 0,
|
|
42
|
+
heat: ht?.heat ?? null,
|
|
43
|
+
heat_why: ht?.why ?? [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function recentActivity(signals, now, days = 30) {
|
|
47
|
+
const since = now.getTime() - days * DAY_MS;
|
|
48
|
+
const recent = signals.filter((s) => new Date(s.ts).getTime() >= since);
|
|
49
|
+
const firstAsk = new Map();
|
|
50
|
+
const count = new Map();
|
|
51
|
+
let reasks = 0;
|
|
52
|
+
for (const s of [...signals].sort((a, b) => a.ts.localeCompare(b.ts))) {
|
|
53
|
+
if (s.type !== "ask")
|
|
54
|
+
continue;
|
|
55
|
+
const ts = new Date(s.ts).getTime();
|
|
56
|
+
count.set(s.entry_id, (count.get(s.entry_id) ?? 0) + 1);
|
|
57
|
+
if (!firstAsk.has(s.entry_id))
|
|
58
|
+
firstAsk.set(s.entry_id, ts);
|
|
59
|
+
else if (ts >= since && ts - firstAsk.get(s.entry_id) >= REASK_AFTER_DAYS * DAY_MS)
|
|
60
|
+
reasks++;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
days,
|
|
64
|
+
asks: recent.filter((s) => s.type === "ask").length,
|
|
65
|
+
reasks,
|
|
66
|
+
loops: recent.filter((s) => s.type === "loop").length,
|
|
67
|
+
asked: [...count.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 5).map(([id, n]) => ({ id, n })),
|
|
21
68
|
};
|
|
22
69
|
}
|
|
23
70
|
export function buildNotesData(now = new Date()) {
|
|
24
71
|
const config = readConfig();
|
|
25
|
-
const
|
|
72
|
+
const results = readResults();
|
|
73
|
+
const tested = testedEntryIds(results);
|
|
74
|
+
const history = gradeHistory(results);
|
|
26
75
|
const queue = readQueue();
|
|
76
|
+
const entries = listEntries();
|
|
77
|
+
const signals = readSignals();
|
|
78
|
+
const heat = computeHeat({ entries, results, signals, now });
|
|
27
79
|
return {
|
|
28
80
|
generated_at: now.toISOString(),
|
|
29
81
|
week_start: weekStart(now),
|
|
30
82
|
rating: config.rating,
|
|
31
83
|
keep_sharp: config.keep_sharp,
|
|
32
|
-
entries:
|
|
84
|
+
entries: entries.map((e) => toCard(e, tested, queue, history, heat)),
|
|
85
|
+
hot: hotAreas(entries, heat, { limit: 8 }),
|
|
86
|
+
activity: recentActivity(signals, now),
|
|
87
|
+
links: computeLinks(entries),
|
|
88
|
+
results: results.map((r) => ({ entry_id: r.entry_id, week: weekOfDate(r.ts), grade: r.grade, is_retest: r.is_retest })),
|
|
33
89
|
};
|
|
34
90
|
}
|
|
35
91
|
/** JSON safe to embed in a <script> element: no "<" can close the tag early. */
|
|
36
92
|
export function embedJson(data) {
|
|
37
93
|
return JSON.stringify(data).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
38
94
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
:root:not([data-theme="light"]) {
|
|
49
|
-
--bg: #0f0f10; --surface: #18181b; --surface-2: #1f1f23; --text: #f2f1ee; --muted: #a3a09a; --faint: #6b6862;
|
|
50
|
-
--border: #2a2a2f; --accent: #a5b4fc; --accent-soft: #1e1f3a; --code-bg: #121214;
|
|
51
|
-
--bug: #fb923c; --decision: #c4b5fd; --concept: #5eead4; --pattern: #fcd34d;
|
|
52
|
-
--ok: #4ade80; --warn: #fbbf24;
|
|
53
|
-
color-scheme: dark;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
* { box-sizing: border-box; }
|
|
57
|
-
html, body { margin: 0; }
|
|
58
|
-
body {
|
|
59
|
-
background: var(--bg); color: var(--text);
|
|
60
|
-
font: 15px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
|
|
61
|
-
-webkit-font-smoothing: antialiased;
|
|
62
|
-
}
|
|
63
|
-
.wrap { max-width: 880px; margin: 0 auto; padding: 40px 16px 80px; }
|
|
64
|
-
header.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
|
|
65
|
-
.brand { display: flex; align-items: center; gap: 12px; }
|
|
66
|
-
.mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: var(--surface); font-weight: 700; font-size: 18px; }
|
|
67
|
-
.brand h1 { font-size: 22px; letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
|
|
68
|
-
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
|
|
69
|
-
.weeknav { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
|
|
70
|
-
.weeknav button { border: 0; background: transparent; color: var(--text); font: inherit; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
|
|
71
|
-
.weeknav button:hover:not(:disabled) { background: var(--surface-2); }
|
|
72
|
-
.weeknav button:disabled { color: var(--faint); cursor: default; }
|
|
73
|
-
.weeknav .label { min-width: 150px; text-align: center; font-weight: 600; font-size: 14px; }
|
|
74
|
-
.weeknav .alltime[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
|
|
75
|
-
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
|
|
76
|
-
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
|
|
77
|
-
.tile .n { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
|
|
78
|
-
.tile .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
|
|
79
|
-
.sharp { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 26px; }
|
|
80
|
-
.pill { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; background: var(--surface); color: var(--text); font-size: 12.5px; }
|
|
81
|
-
.filters { padding: 0 0 14px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
|
|
82
|
-
.search { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none; }
|
|
83
|
-
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
|
|
84
|
-
.chiprows { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
|
|
85
|
-
.chiprow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
|
|
86
|
-
.chiprow .k { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; width: 62px; flex-shrink: 0; }
|
|
87
|
-
.chip { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
|
|
88
|
-
.chip:hover { border-color: var(--faint); }
|
|
89
|
-
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
|
|
90
|
-
.day { margin-top: 30px; }
|
|
91
|
-
.day h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; }
|
|
92
|
-
.day h2 .c { color: var(--faint); font-weight: 500; }
|
|
93
|
-
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; margin-bottom: 12px; border-left: 4px solid var(--kind, var(--border)); }
|
|
94
|
-
.card.suppressed { opacity: 0.6; }
|
|
95
|
-
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
96
|
-
.badge { font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; border-radius: 6px; padding: 2px 8px; }
|
|
97
|
-
.kind { color: var(--kind); background: color-mix(in srgb, var(--kind) 12%, transparent); text-transform: capitalize; }
|
|
98
|
-
.skill { color: var(--muted); background: var(--surface-2); font-weight: 500; }
|
|
99
|
-
.status { margin-left: auto; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
|
|
100
|
-
.status.tested { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
|
|
101
|
-
.status.retest { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
|
|
102
|
-
.status.suppressed { text-decoration: line-through; }
|
|
103
|
-
.q { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; margin: 12px 0 8px; }
|
|
104
|
-
.meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
|
|
105
|
-
.meta code { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text); }
|
|
106
|
-
details { margin-top: 14px; }
|
|
107
|
-
summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); padding: 6px 12px; border-radius: 8px; background: var(--accent-soft); user-select: none; }
|
|
108
|
-
summary::-webkit-details-marker { display: none; }
|
|
109
|
-
summary::before { content: "▸"; transition: transform 0.15s; }
|
|
110
|
-
details[open] summary::before { transform: rotate(90deg); }
|
|
111
|
-
details[open] summary .show { display: none; }
|
|
112
|
-
details:not([open]) summary .hide { display: none; }
|
|
113
|
-
.answer { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
|
|
114
|
-
.answer p { margin: 0 0 10px; }
|
|
115
|
-
.code { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 6px; background: var(--code-bg); }
|
|
116
|
-
.codebar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
|
|
117
|
-
.copy { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 2px 8px; border-radius: 6px; cursor: pointer; }
|
|
118
|
-
pre { margin: 0; padding: 12px 0; overflow-x: auto; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; counter-reset: ln; }
|
|
119
|
-
pre .ln { display: block; padding: 0 14px 0 0; white-space: pre; }
|
|
120
|
-
pre .ln::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 3em; padding-right: 1em; text-align: right; color: var(--faint); user-select: none; }
|
|
121
|
-
.empty { text-align: center; color: var(--muted); padding: 60px 16px; border: 1px dashed var(--border); border-radius: 16px; margin-top: 24px; background: var(--surface); }
|
|
122
|
-
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
|
|
123
|
-
.empty button { margin-top: 12px; }
|
|
124
|
-
footer { margin-top: 48px; color: var(--faint); font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
|
|
125
|
-
kbd { font: 11px ui-monospace, Menlo, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface); }
|
|
126
|
-
@media (max-width: 640px) {
|
|
127
|
-
.wrap { padding-top: 24px; }
|
|
128
|
-
.tiles { grid-template-columns: repeat(2, 1fr); }
|
|
129
|
-
.weeknav { width: 100%; justify-content: space-between; }
|
|
130
|
-
.weeknav .label { min-width: 0; }
|
|
131
|
-
.q { font-size: 16.5px; }
|
|
132
|
-
.card { padding: 16px; }
|
|
133
|
-
.chiprow .k { width: 100%; }
|
|
134
|
-
}
|
|
135
|
-
`;
|
|
136
|
-
// Client script. Plain ES2017, no template literals, so it embeds cleanly. All entry text goes through textContent.
|
|
137
|
-
const JS = String.raw `
|
|
138
|
-
(function () {
|
|
139
|
-
var DATA = JSON.parse(document.getElementById("selflore-data").textContent);
|
|
140
|
-
var NOW = new Date();
|
|
141
|
-
var KIND_VAR = { bug: "--bug", decision: "--decision", concept: "--concept", pattern: "--pattern" };
|
|
142
|
-
var STATUS_LABEL = { untested: "Untested", tested: "Tested", suppressed: "Suppressed" };
|
|
143
|
-
|
|
144
|
-
function pad(n) { return (n < 10 ? "0" : "") + n; }
|
|
145
|
-
function parse(s) { var p = s.split("-"); return new Date(Date.UTC(+p[0], +p[1] - 1, +p[2])); }
|
|
146
|
-
function iso(d) { return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()); }
|
|
147
|
-
function monday(s) { var d = parse(s); d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 6) % 7)); return iso(d); }
|
|
148
|
-
function addDays(s, n) { var d = parse(s); d.setUTCDate(d.getUTCDate() + n); return iso(d); }
|
|
149
|
-
function fmt(s, opts) { return parse(s).toLocaleDateString(undefined, Object.assign({ timeZone: "UTC" }, opts)); }
|
|
150
|
-
|
|
151
|
-
var init = DATA.initial || {};
|
|
152
|
-
var state = { week: DATA.week_start, all: !!init.all, project: init.project || null, skill: null, kind: null, status: null, q: "" };
|
|
153
|
-
(location.hash.slice(1) || "").split("&").forEach(function (kv) {
|
|
154
|
-
var p = kv.split("="); var k = decodeURIComponent(p[0] || ""); var v = p[1] ? decodeURIComponent(p[1]) : "";
|
|
155
|
-
if (k === "all") state.all = true;
|
|
156
|
-
else if (k === "week" && /^\d{4}-\d{2}-\d{2}$/.test(v)) state.week = monday(v);
|
|
157
|
-
else if (["project", "skill", "kind", "status"].indexOf(k) >= 0 && v) state[k] = v;
|
|
158
|
-
});
|
|
159
|
-
var earliest = DATA.entries.reduce(function (m, e) { var w = monday(e.date); return w < m ? w : m; }, DATA.week_start);
|
|
160
|
-
|
|
161
|
-
function h(tag, attrs) {
|
|
162
|
-
var el = document.createElement(tag);
|
|
163
|
-
if (attrs) for (var k in attrs) {
|
|
164
|
-
if (k === "text") el.textContent = attrs[k];
|
|
165
|
-
else if (k === "class") el.className = attrs[k];
|
|
166
|
-
else if (k.slice(0, 2) === "on") el.addEventListener(k.slice(2), attrs[k]);
|
|
167
|
-
else if (attrs[k] != null) el.setAttribute(k, attrs[k]);
|
|
168
|
-
}
|
|
169
|
-
for (var i = 2; i < arguments.length; i++) { var c = arguments[i]; if (c != null) el.appendChild(typeof c === "string" ? document.createTextNode(c) : c); }
|
|
170
|
-
return el;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function inScope(e) { return state.all || monday(e.date) === state.week; }
|
|
174
|
-
function matches(e, skip) {
|
|
175
|
-
if (skip !== "project" && state.project && e.project !== state.project) return false;
|
|
176
|
-
if (skip !== "skill" && state.skill && e.skill !== state.skill) return false;
|
|
177
|
-
if (skip !== "kind" && state.kind && e.kind !== state.kind) return false;
|
|
178
|
-
if (skip !== "status" && state.status && e.status !== state.status) return false;
|
|
179
|
-
if (state.q) {
|
|
180
|
-
var hay = (e.testable + " " + e.paths.join(" ") + " " + e.project + " " + e.skill).toLowerCase();
|
|
181
|
-
if (hay.indexOf(state.q.toLowerCase()) < 0) return false;
|
|
182
|
-
}
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function statusText(e) {
|
|
187
|
-
if (e.status !== "retest") return STATUS_LABEL[e.status];
|
|
188
|
-
if (e.retest_due && new Date(e.retest_due) <= NOW) return "Retest due";
|
|
189
|
-
return "Retest " + (e.retest_due ? new Date(e.retest_due).toLocaleDateString(undefined, { month: "short", day: "numeric" }) : "");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function renderNav() {
|
|
193
|
-
var label = document.getElementById("weeklabel");
|
|
194
|
-
label.textContent = state.all ? "Since " + fmt(earliest, { month: "short", day: "numeric" }) : (state.week === DATA.week_start ? "This week · " : "Week of ") + fmt(state.week, { month: "short", day: "numeric" });
|
|
195
|
-
document.getElementById("prev").disabled = state.all || state.week <= earliest;
|
|
196
|
-
document.getElementById("next").disabled = state.all || state.week >= DATA.week_start;
|
|
197
|
-
document.getElementById("alltime").setAttribute("aria-pressed", String(state.all));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function renderTiles(scope) {
|
|
201
|
-
var due = scope.filter(function (e) { return e.status === "retest" && e.retest_due && new Date(e.retest_due) <= NOW; }).length;
|
|
202
|
-
var tiles = [
|
|
203
|
-
[scope.length, state.all ? "Entries captured" : "Captured this week"],
|
|
204
|
-
[scope.filter(function (e) { return e.status === "untested"; }).length, "Untested"],
|
|
205
|
-
[scope.filter(function (e) { return e.status === "retest"; }).length, due ? "In retest queue · " + due + " due" : "In retest queue"],
|
|
206
|
-
[scope.filter(function (e) { return e.status === "tested"; }).length, "Tested & solid"],
|
|
207
|
-
];
|
|
208
|
-
var el = document.getElementById("tiles"); el.textContent = "";
|
|
209
|
-
tiles.forEach(function (t) { el.appendChild(h("div", { class: "tile" }, h("div", { class: "n", text: String(t[0]) }), h("div", { class: "l", text: t[1] }))); });
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function chipRow(key, label, scope, labeler) {
|
|
213
|
-
var values = {};
|
|
214
|
-
scope.filter(function (e) { return matches(e, key); }).forEach(function (e) { var v = e[key]; if (v) values[v] = (values[v] || 0) + 1; });
|
|
215
|
-
if (state[key] && !values[state[key]]) values[state[key]] = 0;
|
|
216
|
-
var keys = Object.keys(values).sort();
|
|
217
|
-
if (keys.length < 2 && !state[key]) return null;
|
|
218
|
-
var row = h("div", { class: "chiprow" }, h("span", { class: "k", text: label }));
|
|
219
|
-
row.appendChild(h("button", { class: "chip", "aria-pressed": String(!state[key]), onclick: function () { state[key] = null; render(); }, text: "All" }));
|
|
220
|
-
keys.forEach(function (v) {
|
|
221
|
-
row.appendChild(h("button", {
|
|
222
|
-
class: "chip", "aria-pressed": String(state[key] === v),
|
|
223
|
-
onclick: function () { state[key] = state[key] === v ? null : v; render(); },
|
|
224
|
-
text: (labeler ? labeler(v) : v) + " · " + values[v],
|
|
225
|
-
}));
|
|
226
|
-
});
|
|
227
|
-
return row;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function renderChips(scope) {
|
|
231
|
-
var el = document.getElementById("chips"); el.textContent = "";
|
|
232
|
-
[chipRow("project", "Project", scope), chipRow("skill", "Skill", scope),
|
|
233
|
-
chipRow("kind", "Kind", scope, function (v) { return v.charAt(0).toUpperCase() + v.slice(1); }),
|
|
234
|
-
chipRow("status", "Status", scope, function (v) { return v === "retest" ? "Retest" : STATUS_LABEL[v]; })]
|
|
235
|
-
.forEach(function (r) { if (r) el.appendChild(r); });
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function codeBlock(e) {
|
|
239
|
-
var pre = h("pre");
|
|
240
|
-
e.snippet.split("\n").forEach(function (line) { pre.appendChild(h("span", { class: "ln", text: line || " " })); });
|
|
241
|
-
var copy = h("button", { class: "copy", text: "Copy", onclick: function () {
|
|
242
|
-
(navigator.clipboard ? navigator.clipboard.writeText(e.snippet) : Promise.reject()).then(
|
|
243
|
-
function () { copy.textContent = "Copied"; setTimeout(function () { copy.textContent = "Copy"; }, 1200); },
|
|
244
|
-
function () { copy.textContent = "Select & copy"; });
|
|
245
|
-
} });
|
|
246
|
-
var lines = e.snippet.split("\n").length;
|
|
247
|
-
var info = [e.snippetLang, lines + (lines === 1 ? " line" : " lines"), e.commit ? "@ " + e.commit : ""].filter(Boolean).join(" · ");
|
|
248
|
-
return h("div", { class: "code" }, h("div", { class: "codebar" }, h("span", { text: info }), copy), pre);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function card(e) {
|
|
252
|
-
var c = h("article", { class: "card" + (e.status === "suppressed" ? " suppressed" : ""), id: e.id });
|
|
253
|
-
c.style.setProperty("--kind", "var(" + (KIND_VAR[e.kind] || "--border") + ")");
|
|
254
|
-
c.appendChild(h("div", { class: "row" },
|
|
255
|
-
h("span", { class: "badge kind", text: e.kind }),
|
|
256
|
-
h("span", { class: "badge skill", text: e.skill }),
|
|
257
|
-
h("span", { class: "badge status " + e.status, text: statusText(e) })));
|
|
258
|
-
c.appendChild(h("div", { class: "q", text: e.testable }));
|
|
259
|
-
var meta = h("div", { class: "meta" });
|
|
260
|
-
if (e.project) meta.appendChild(h("span", { text: e.project }));
|
|
261
|
-
e.paths.forEach(function (p) { meta.appendChild(h("code", { text: p })); });
|
|
262
|
-
c.appendChild(meta);
|
|
263
|
-
var answer = h("div", { class: "answer" });
|
|
264
|
-
e.prose.split(/\n\s*\n/).forEach(function (para) { if (para.trim()) answer.appendChild(h("p", { text: para.replace(/\s*\n\s*/g, " ").trim() })); });
|
|
265
|
-
if (e.snippet) answer.appendChild(codeBlock(e));
|
|
266
|
-
c.appendChild(h("details", null,
|
|
267
|
-
h("summary", null, h("span", { class: "show", text: "Show answer" }), h("span", { class: "hide", text: "Hide answer" })),
|
|
268
|
-
answer));
|
|
269
|
-
return c;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function renderList(scope) {
|
|
273
|
-
var list = document.getElementById("list"); list.textContent = "";
|
|
274
|
-
var shown = scope.filter(function (e) { return matches(e); });
|
|
275
|
-
if (DATA.entries.length === 0) {
|
|
276
|
-
list.appendChild(h("div", { class: "empty" }, h("strong", { text: "Nothing captured yet" }), "Work normally in Claude Code. Lore-worthy moments land here as they happen."));
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
if (shown.length === 0) {
|
|
280
|
-
var filtered = state.project || state.skill || state.kind || state.status || state.q;
|
|
281
|
-
list.appendChild(h("div", { class: "empty" },
|
|
282
|
-
h("strong", { text: filtered ? "No entries match these filters" : "Nothing captured this week" }),
|
|
283
|
-
filtered ? null : "Try another week or switch to All time.",
|
|
284
|
-
filtered ? h("button", { class: "chip", text: "Clear filters", onclick: function () {
|
|
285
|
-
state.project = state.skill = state.kind = state.status = null; state.q = ""; document.getElementById("search").value = ""; render();
|
|
286
|
-
} }) : null));
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
var days = {};
|
|
290
|
-
shown.forEach(function (e) { (days[e.date] = days[e.date] || []).push(e); });
|
|
291
|
-
Object.keys(days).sort().reverse().forEach(function (d) {
|
|
292
|
-
var sec = h("section", { class: "day" }, h("h2", null, fmt(d, { weekday: "long", month: "short", day: "numeric" }), h("span", { class: "c", text: String(days[d].length) })));
|
|
293
|
-
days[d].sort(function (a, b) { return a.id < b.id ? -1 : 1; }).forEach(function (e) { sec.appendChild(card(e)); });
|
|
294
|
-
list.appendChild(sec);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function syncHash() {
|
|
299
|
-
var parts = [];
|
|
300
|
-
if (state.all) parts.push("all"); else if (state.week !== DATA.week_start) parts.push("week=" + state.week);
|
|
301
|
-
["project", "skill", "kind", "status"].forEach(function (k) { if (state[k]) parts.push(k + "=" + encodeURIComponent(state[k])); });
|
|
302
|
-
history.replaceState(null, "", parts.length ? "#" + parts.join("&") : location.pathname);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function render() {
|
|
306
|
-
var scope = DATA.entries.filter(inScope);
|
|
307
|
-
renderNav(); renderTiles(scope); renderChips(scope); renderList(scope); syncHash();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
document.getElementById("prev").onclick = function () { state.week = addDays(state.week, -7); render(); };
|
|
311
|
-
document.getElementById("next").onclick = function () { state.week = addDays(state.week, 7); render(); };
|
|
312
|
-
document.getElementById("alltime").onclick = function () { state.all = !state.all; render(); };
|
|
313
|
-
var search = document.getElementById("search");
|
|
314
|
-
search.addEventListener("input", function () { state.q = search.value.trim(); render(); });
|
|
315
|
-
|
|
316
|
-
var sharp = document.getElementById("sharp");
|
|
317
|
-
if (DATA.keep_sharp.length) {
|
|
318
|
-
sharp.appendChild(document.createTextNode("Keeping sharp:"));
|
|
319
|
-
DATA.keep_sharp.forEach(function (k) { sharp.appendChild(h("span", { class: "pill", text: k })); });
|
|
320
|
-
sharp.appendChild(document.createTextNode("· self-rating " + DATA.rating + "/10"));
|
|
321
|
-
}
|
|
322
|
-
document.getElementById("generated").textContent = "Generated " + new Date(DATA.generated_at).toLocaleString();
|
|
323
|
-
|
|
324
|
-
document.addEventListener("keydown", function (ev) {
|
|
325
|
-
if (ev.target && (ev.target.tagName === "INPUT" || ev.target.tagName === "TEXTAREA") ) {
|
|
326
|
-
if (ev.key === "Escape") ev.target.blur();
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
if (ev.metaKey || ev.ctrlKey || ev.altKey) return;
|
|
330
|
-
if (ev.key === "/") { ev.preventDefault(); search.focus(); }
|
|
331
|
-
else if (ev.key === "a") {
|
|
332
|
-
var all = Array.prototype.slice.call(document.querySelectorAll("#list details"));
|
|
333
|
-
var open = all.some(function (d) { return !d.open; });
|
|
334
|
-
all.forEach(function (d) { d.open = open; });
|
|
335
|
-
}
|
|
336
|
-
else if (ev.key === "ArrowLeft" && !document.getElementById("prev").disabled) document.getElementById("prev").click();
|
|
337
|
-
else if (ev.key === "ArrowRight" && !document.getElementById("next").disabled) document.getElementById("next").click();
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
render();
|
|
341
|
-
})();
|
|
342
|
-
`;
|
|
343
|
-
const FAVICON = "data:image/svg+xml," +
|
|
344
|
-
encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#4f46e5"/><text x="16" y="22" font-family="system-ui,sans-serif" font-size="18" font-weight="700" text-anchor="middle" fill="#fff">s</text></svg>');
|
|
95
|
+
// Icons are drawn, one stroke weight, and inherit the text colour.
|
|
96
|
+
const svg = (d) => `<svg class="ic" viewBox="0 0 16 16" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
97
|
+
const ICON = {
|
|
98
|
+
left: svg("M10 3L5 8l5 5"),
|
|
99
|
+
right: svg("M6 3l5 5-5 5"),
|
|
100
|
+
plus: svg("M8 3v10M3 8h10"),
|
|
101
|
+
minus: svg("M3 8h10"),
|
|
102
|
+
fit: svg("M3 6V3h3M10 3h3v3M13 10v3h-3M6 13H3v-3"),
|
|
103
|
+
};
|
|
345
104
|
export function renderNotesHtml(data) {
|
|
346
105
|
return `<!doctype html>
|
|
347
106
|
<html lang="en">
|
|
@@ -349,37 +108,96 @@ export function renderNotesHtml(data) {
|
|
|
349
108
|
<meta charset="utf-8">
|
|
350
109
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
351
110
|
<title>selflore notes</title>
|
|
352
|
-
<link rel="icon" href="${FAVICON}">
|
|
353
|
-
<style
|
|
111
|
+
<link rel="icon" type="image/png" href="${FAVICON}">
|
|
112
|
+
<style>:root { --logo: url("${LOGO_MASK}"); --logo-ratio: ${LOGO_MASK_RATIO}; }
|
|
113
|
+
${PAGE_CSS}${GRAPH_CSS}</style>
|
|
354
114
|
</head>
|
|
355
115
|
<body>
|
|
356
116
|
<div class="wrap">
|
|
357
117
|
<header class="top">
|
|
358
|
-
<div class="brand">
|
|
359
|
-
|
|
360
|
-
<
|
|
118
|
+
<div class="brand"><span class="mark" aria-hidden="true"></span><h1>selflore</h1></div>
|
|
119
|
+
<div class="seg" id="viewseg" role="group" aria-label="View">
|
|
120
|
+
<button data-view="graph" aria-pressed="true">Map</button>
|
|
121
|
+
<button data-view="list" aria-pressed="false">Notes</button>
|
|
122
|
+
<button data-view="stats" aria-pressed="false">Stats</button>
|
|
361
123
|
</div>
|
|
362
|
-
<
|
|
363
|
-
|
|
364
|
-
<span class="label" id="weeklabel"></span>
|
|
365
|
-
<button id="next" aria-label="Next week">›</button>
|
|
366
|
-
<button id="alltime" class="alltime" aria-pressed="false">All time</button>
|
|
367
|
-
</nav>
|
|
124
|
+
<span class="spacer"></span>
|
|
125
|
+
<button id="testbtn" class="btn primary" hidden title="Up to 10 questions: what you missed last time, then the notes where you get stuck">Test me</button>
|
|
368
126
|
</header>
|
|
369
|
-
<
|
|
370
|
-
<div class="
|
|
371
|
-
|
|
372
|
-
<
|
|
373
|
-
<div class="
|
|
127
|
+
<div id="notesview">
|
|
128
|
+
<div class="statline">
|
|
129
|
+
<span id="facts"></span>
|
|
130
|
+
<span class="active" id="active"></span>
|
|
131
|
+
<div class="range">
|
|
132
|
+
<button id="prev" class="btn quiet icon" aria-label="Previous week" hidden>${ICON.left}</button>
|
|
133
|
+
<span class="wk" id="weeklabel" hidden></span>
|
|
134
|
+
<button id="next" class="btn quiet icon" aria-label="Next week" hidden>${ICON.right}</button>
|
|
135
|
+
<div class="seg" id="rangeseg" role="group" aria-label="Time range">
|
|
136
|
+
<button data-range="all" aria-pressed="true">All time</button>
|
|
137
|
+
<button data-range="week" aria-pressed="false">By week</button>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
<section id="graphview" class="map" aria-label="Map of your notes">
|
|
142
|
+
<div class="gwrap" id="gwrap">
|
|
143
|
+
<canvas id="gcanvas" role="img" aria-label="Your notes as a heat map, grouped into clusters. Dots run from dim slate where things are settled, through amber, to red where you get stuck; a hollow grey dot has no signal yet. The Notes tab has the same notes as text."></canvas>
|
|
144
|
+
<div class="g3d" id="g3d" hidden></div>
|
|
145
|
+
<div class="gctl tl">
|
|
146
|
+
<div class="seg" id="groupseg" role="group" aria-label="Group by">
|
|
147
|
+
<button data-group="project" aria-pressed="true" title="Group by project">Project</button>
|
|
148
|
+
<button data-group="skill" aria-pressed="false" title="Group by topic">Topic</button>
|
|
149
|
+
<button data-group="kind" aria-pressed="false" title="Group by kind of note">Kind</button>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="gctl tr">
|
|
153
|
+
<div class="seg" id="dimseg" role="group" aria-label="Graph view" hidden>
|
|
154
|
+
<button data-dim="3d" aria-pressed="true" title="Drag to rotate, pinch or ⌘ + scroll to zoom, click a dot to open it">3D</button>
|
|
155
|
+
<button data-dim="2d" aria-pressed="false" title="The flat view: easier for reading names and picking out one note">Flat</button>
|
|
156
|
+
</div>
|
|
157
|
+
<button class="chip" id="glabels" aria-pressed="true" title="Hide the names to get a picture with no project text in it">Labels</button>
|
|
158
|
+
</div>
|
|
159
|
+
<div class="ghint" id="ghint"></div>
|
|
160
|
+
<div class="gempty" id="gempty" hidden>No notes match. Remove a filter or switch to All time.</div>
|
|
161
|
+
<div class="gctl bl">
|
|
162
|
+
<div class="legend" aria-label="Dot colour is heat">
|
|
163
|
+
<span>Settled</span><span class="heatbar" id="heatbar" aria-hidden="true"></span><span>Stuck</span>
|
|
164
|
+
<span><i class="hdot none" aria-hidden="true"></i>No signal yet</span>
|
|
165
|
+
<span><i class="hring" aria-hidden="true"></i><span id="lgroup">A project</span></span>
|
|
166
|
+
</div>
|
|
167
|
+
<div class="gcap" id="gcap"></div>
|
|
168
|
+
</div>
|
|
169
|
+
<div class="gctl br">
|
|
170
|
+
<button id="gzoomin" class="btn icon" aria-label="Zoom in" title="Zoom in (or pinch, or ⌘ + scroll)">${ICON.plus}</button>
|
|
171
|
+
<button id="gzoomout" class="btn icon" aria-label="Zoom out" title="Zoom out">${ICON.minus}</button>
|
|
172
|
+
<button id="gzoomfit" class="btn icon" aria-label="Fit to view" title="Fit to view">${ICON.fit}</button>
|
|
173
|
+
</div>
|
|
174
|
+
<aside class="gpanel" id="gpanel" hidden></aside>
|
|
175
|
+
</div>
|
|
176
|
+
<aside class="rail" id="rail" aria-label="Where you get stuck"></aside>
|
|
177
|
+
</section>
|
|
178
|
+
<section id="listview" class="col" hidden aria-label="Notes">
|
|
179
|
+
<div class="toolbar">
|
|
180
|
+
<input id="search" class="search" type="search" placeholder="Search questions, files, projects" aria-label="Search notes" autocomplete="off">
|
|
181
|
+
<button id="filterbtn" class="btn" aria-expanded="false" aria-controls="filters">Filters</button>
|
|
182
|
+
<div class="seg" id="sortseg" role="group" aria-label="Order">
|
|
183
|
+
<button data-sort="new" aria-pressed="true">Newest</button>
|
|
184
|
+
<button data-sort="stuck" aria-pressed="false">Stuck first</button>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<div class="fpanel" id="filters" hidden></div>
|
|
188
|
+
<div id="selrow"></div>
|
|
189
|
+
<main id="list"></main>
|
|
190
|
+
</section>
|
|
191
|
+
<section id="statsview" class="stats" hidden aria-label="Stats"></section>
|
|
374
192
|
</div>
|
|
375
|
-
<
|
|
193
|
+
<div id="testview" class="col" hidden></div>
|
|
376
194
|
<footer>
|
|
377
|
-
<span id="generated"></span>
|
|
378
|
-
<span><kbd>
|
|
195
|
+
<span>What your agent built for you, and what you should own. <span id="generated"></span></span>
|
|
196
|
+
<span><kbd>g</kbd> map or notes · <kbd>/</kbd> search · <kbd>a</kbd> open all · <span id="testhint">run <code>/selflore test</code> in Claude Code to be quizzed</span></span>
|
|
379
197
|
</footer>
|
|
380
198
|
</div>
|
|
381
199
|
<script type="application/json" id="selflore-data">${embedJson(data)}</script>
|
|
382
|
-
<script>${
|
|
200
|
+
<script>${GRAPH_JS}${PAGE_JS}</script>
|
|
383
201
|
</body>
|
|
384
202
|
</html>
|
|
385
203
|
`;
|