@joe-broadhead/opencode-mem 0.8.5 → 0.9.1
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 +512 -0
- package/README.md +127 -61
- package/docs/agent-protocol.md +67 -177
- package/package.json +1453 -100
- package/skills/mem.pages/SKILL.md +146 -0
- package/skills/mem.sharing/SKILL.md +91 -0
- package/skills/mem.sources/SKILL.md +94 -0
- package/skills/mem.usage/SKILL.md +129 -492
- package/src/backend/records.js +285 -0
- package/src/backend/v3.js +3 -0
- package/src/bootstrap.js +49 -45
- package/src/call-shapes.js +41 -10
- package/src/collector-lock.js +162 -0
- package/src/collector-service.js +441 -0
- package/src/collector.js +381 -0
- package/src/commands.js +3 -3
- package/src/config.js +15 -1
- package/src/credentials.js +26 -1
- package/src/curation.js +1 -1
- package/src/permissions.js +87 -10
- package/src/protocol.js +29 -20
- package/src/recall.js +104 -27
- package/src/records-store.js +267 -121
- package/src/records.js +63 -11
- package/src/runtime.js +23 -14
- package/src/skills.js +44 -18
- package/src/sources.js +58 -0
- package/src/spaces.js +93 -10
- package/src/tools/aliases.js +164 -0
- package/src/tools/commitments.js +12 -9
- package/src/tools/held-write.js +82 -0
- package/src/tools/index.js +100 -23
- package/src/tools/ingest.js +277 -0
- package/src/tools/knowledge.js +6 -1
- package/src/tools/memory.js +722 -229
- package/src/tools/page.js +423 -0
- package/src/tools/recall.js +371 -113
- package/src/tools/records-kit.js +142 -0
- package/src/tools/share.js +1042 -0
- package/src/tools/shared.js +16 -2
- package/src/tools/spaces.js +431 -143
- package/src/tools/status.js +87 -58
- package/src/tools/wiki.js +8 -4
- package/src/views/contracts.js +293 -3
- package/src/views/inbox-decision.js +59 -0
- package/src/views/recall-result.js +12 -0
- package/src/views/records-reads.js +675 -0
- package/src/views/rpc.js +58 -99
- package/src/views/shape.js +61 -0
- package/views/commitments.html +4 -0
- package/views/graph.html +753 -0
- package/views/home.html +11 -5
- package/views/journal.html +621 -0
- package/views/memory.html +7 -1
- package/views/pages.html +636 -0
- package/views/recall.html +123 -0
- package/views/review.html +406 -0
- package/views/today.html +309 -0
package/views/today.html
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-8Sqi7wSJLAxxijfwEWD3e7V0hk91OoFJl0AaP/Dhhdo='; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
|
6
|
+
<title>Today</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color: var(--jelly-text, CanvasText);
|
|
10
|
+
background: var(--jelly-surface, Canvas);
|
|
11
|
+
font: 14px/1.45 var(--jelly-font, system-ui, sans-serif);
|
|
12
|
+
}
|
|
13
|
+
* { box-sizing: border-box; }
|
|
14
|
+
body { margin: 0; padding: 2px; }
|
|
15
|
+
p { margin: 0; }
|
|
16
|
+
h1 { font-size: 16px; margin: 0 0 4px; overflow-wrap: anywhere; }
|
|
17
|
+
.muted { color: var(--jelly-muted, GrayText); font-size: 12px; }
|
|
18
|
+
.state { font-weight: 600; display: flex; align-items: center; gap: 6px; }
|
|
19
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jelly-accent, Highlight); flex: none; }
|
|
20
|
+
.dot.off { background: transparent; border: 1.5px solid var(--jelly-muted, GrayText); }
|
|
21
|
+
.dot.danger { background: var(--jelly-danger, CanvasText); }
|
|
22
|
+
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
|
|
23
|
+
.bar.flat { margin: 0; }
|
|
24
|
+
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
25
|
+
.button, .chip, select, textarea, input {
|
|
26
|
+
font: inherit; font-size: 12px; color: var(--jelly-text, CanvasText); background: var(--jelly-raised, Canvas);
|
|
27
|
+
border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px);
|
|
28
|
+
}
|
|
29
|
+
.button { padding: 2px 8px; cursor: pointer; white-space: nowrap; }
|
|
30
|
+
.button[aria-pressed="true"] { color: var(--jelly-on-accent, HighlightText); background: var(--jelly-accent, Highlight); border-color: var(--jelly-accent, Highlight); }
|
|
31
|
+
.button.quiet { border-color: transparent; background: transparent; padding-left: 0; }
|
|
32
|
+
select { padding: 2px 4px; }
|
|
33
|
+
textarea { width: 100%; padding: 4px 6px; resize: vertical; }
|
|
34
|
+
.button:focus-visible, .chip:focus-visible, .row:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
|
|
35
|
+
outline: 2px solid var(--jelly-accent, Highlight); outline-offset: 2px;
|
|
36
|
+
}
|
|
37
|
+
.chip {
|
|
38
|
+
display: inline-block; max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
39
|
+
vertical-align: bottom; padding: 0 7px; margin: 0 2px; border-radius: 999px; cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
.chip.event, .chip.turn { border-style: dashed; }
|
|
42
|
+
.badge { display: inline-block; font-size: 11px; font-weight: 600; border: 1px solid var(--jelly-border, GrayText); border-radius: 999px; padding: 0 6px; margin-left: 4px; }
|
|
43
|
+
.badge.warn { border-color: var(--jelly-danger, CanvasText); color: var(--jelly-danger, CanvasText); }
|
|
44
|
+
ul.rows { list-style: none; margin: 0; padding: 0; }
|
|
45
|
+
ul.rows > li { border-top: 1px solid var(--jelly-border, GrayText); }
|
|
46
|
+
ul.rows > li:first-child { border-top: 0; }
|
|
47
|
+
.row {
|
|
48
|
+
display: block; width: 100%; text-align: left; font: inherit; color: var(--jelly-text, CanvasText); background: transparent;
|
|
49
|
+
border: 0; padding: 6px 2px; cursor: pointer; overflow-wrap: anywhere;
|
|
50
|
+
}
|
|
51
|
+
.row > span { display: block; }
|
|
52
|
+
.row .title { font-weight: 600; }
|
|
53
|
+
.md { overflow-wrap: anywhere; }
|
|
54
|
+
.md h2 { font-size: 15px; margin: 12px 0 4px; }
|
|
55
|
+
.md h3 { font-size: 14px; margin: 10px 0 4px; }
|
|
56
|
+
.md h4, .md h5 { font-size: 13px; margin: 8px 0 2px; }
|
|
57
|
+
.md p, .md ul, .md ol, .md pre, .md blockquote { margin: 4px 0; }
|
|
58
|
+
.md ul, .md ol { padding-left: 20px; }
|
|
59
|
+
.md li.nested { margin-left: 16px; }
|
|
60
|
+
.md hr { border: 0; border-top: 1px solid var(--jelly-border, GrayText); margin: 10px 0; }
|
|
61
|
+
.md blockquote, blockquote.quote { margin: 4px 0; padding-left: 8px; border-left: 3px solid var(--jelly-border, GrayText); }
|
|
62
|
+
.md pre { overflow: auto; padding: 6px 8px; background: var(--jelly-raised, Canvas); border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px); }
|
|
63
|
+
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
64
|
+
.link { text-decoration: underline; }
|
|
65
|
+
.address { color: var(--jelly-muted, GrayText); overflow-wrap: anywhere; }
|
|
66
|
+
.panel { margin: 8px 0; padding: 8px; border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px); background: var(--jelly-raised, Canvas); }
|
|
67
|
+
.panel:empty { display: none; }
|
|
68
|
+
.panel h2 { font-size: 14px; margin: 0 0 4px; }
|
|
69
|
+
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 6px 0; font-size: 12px; }
|
|
70
|
+
dl.fields dt { color: var(--jelly-muted, GrayText); }
|
|
71
|
+
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
|
|
72
|
+
footer, .section { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--jelly-border, GrayText); }
|
|
73
|
+
details > summary { cursor: pointer; font-size: 12px; }
|
|
74
|
+
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
75
|
+
.proposal { padding: 8px 0; }
|
|
76
|
+
.proposal > * + * { margin-top: 4px; }
|
|
77
|
+
.title { font-weight: 600; }
|
|
78
|
+
#root > p + p { margin-top: 4px; }
|
|
79
|
+
.overdue { color: var(--jelly-danger, CanvasText); }
|
|
80
|
+
</style>
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<main id="root" aria-live="polite"><p class="muted">Loading…</p></main>
|
|
84
|
+
<script>
|
|
85
|
+
// jelly-view.js: a client of Jelly's view bridge. Paste it into the page's own <script>:
|
|
86
|
+
// a sealed page loads no script by URL and is given no global. Call jellyView() as the
|
|
87
|
+
// script starts; it resolves with the client when the app says hello.
|
|
88
|
+
function jellyView() {
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
addEventListener("message", function hello(event) {
|
|
91
|
+
const said = event.data;
|
|
92
|
+
if (event.source !== parent || said?.v !== 1 || said.kind !== "hello" || !event.ports[0])
|
|
93
|
+
return;
|
|
94
|
+
removeEventListener("message", hello);
|
|
95
|
+
const port = event.ports[0];
|
|
96
|
+
const listeners = new Set();
|
|
97
|
+
const latest = new Map();
|
|
98
|
+
const queue = [];
|
|
99
|
+
let sequence = 0;
|
|
100
|
+
let current;
|
|
101
|
+
const theme = (tokens) => {
|
|
102
|
+
const style = document.documentElement.style;
|
|
103
|
+
for (const [name, value] of Object.entries(tokens))
|
|
104
|
+
if (name === "scheme") style.colorScheme = value;
|
|
105
|
+
else style.setProperty(`--jelly-${name}`, value);
|
|
106
|
+
};
|
|
107
|
+
// The app answers one request at a time, so requests go in turn.
|
|
108
|
+
const next = () => {
|
|
109
|
+
if (current !== undefined || queue.length === 0) return;
|
|
110
|
+
current = queue.shift();
|
|
111
|
+
current.timer = setTimeout(
|
|
112
|
+
() => settle({ ok: false, error: "No answer from the app" }),
|
|
113
|
+
15000,
|
|
114
|
+
);
|
|
115
|
+
port.postMessage(current.message);
|
|
116
|
+
};
|
|
117
|
+
const settle = (answer) => {
|
|
118
|
+
const done = current;
|
|
119
|
+
current = undefined;
|
|
120
|
+
clearTimeout(done.timer);
|
|
121
|
+
if (answer.ok) done.resolve(answer.value);
|
|
122
|
+
else done.reject(new Error(answer.error));
|
|
123
|
+
next();
|
|
124
|
+
};
|
|
125
|
+
port.onmessage = ({ data }) => {
|
|
126
|
+
if (data?.v !== 1) return;
|
|
127
|
+
if (typeof data.kind !== "string") {
|
|
128
|
+
if (current !== undefined && data.re === current.message.id) settle(data);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// A call waiting for the person is answered by `until`, not in 15 s.
|
|
132
|
+
if (data.kind === "rpc.waiting" && data.re === current?.message.id) {
|
|
133
|
+
clearTimeout(current.timer);
|
|
134
|
+
current.timer = setTimeout(
|
|
135
|
+
() => settle({ ok: false, error: "No answer from the app" }),
|
|
136
|
+
Math.max(0, Date.parse(data.until) - Date.now()) + 15000,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (data.kind === "theme.changed") theme(data.theme);
|
|
140
|
+
// A wait is news only while it lasts, so a later listener is not told of it.
|
|
141
|
+
if (data.kind !== "rpc.waiting") latest.set(data.kind, data);
|
|
142
|
+
for (const listener of listeners) listener(data);
|
|
143
|
+
};
|
|
144
|
+
port.start();
|
|
145
|
+
theme(said.theme);
|
|
146
|
+
const request = (op, fields = {}) =>
|
|
147
|
+
new Promise((resolve, reject) => {
|
|
148
|
+
queue.push({ resolve, reject, message: { ...fields, v: 1, id: String(++sequence), op } });
|
|
149
|
+
next();
|
|
150
|
+
});
|
|
151
|
+
resolve({
|
|
152
|
+
hello: said,
|
|
153
|
+
// A listener first hears the latest push of each kind that came before it.
|
|
154
|
+
on(listener) {
|
|
155
|
+
for (const push of latest.values()) listener(push);
|
|
156
|
+
listeners.add(listener);
|
|
157
|
+
return () => listeners.delete(listener);
|
|
158
|
+
},
|
|
159
|
+
request,
|
|
160
|
+
data: () => request("data.get"),
|
|
161
|
+
state: () => request("state.get"),
|
|
162
|
+
setState: (revision, data) => request("state.set", { revision, data }),
|
|
163
|
+
call: (method, input = {}) => request("rpc.call", { method, input }),
|
|
164
|
+
openAgent: (prefill) => request("open-agent", prefill === undefined ? {} : { prefill }),
|
|
165
|
+
resize: (height) =>
|
|
166
|
+
request("resize", { height: Math.min(1200, Math.max(1, Math.ceil(height))) }),
|
|
167
|
+
decline: () => request("decline"),
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
</script>
|
|
173
|
+
<script>
|
|
174
|
+
const root = document.getElementById("root");
|
|
175
|
+
let view = null;
|
|
176
|
+
// The space a read goes to: a shared space's id, or undefined for the person's own.
|
|
177
|
+
let space;
|
|
178
|
+
let spaceKind = "personal";
|
|
179
|
+
|
|
180
|
+
function el(tag, className, text) {
|
|
181
|
+
const node = document.createElement(tag);
|
|
182
|
+
if (className) node.className = className;
|
|
183
|
+
if (text !== undefined) node.textContent = text;
|
|
184
|
+
return node;
|
|
185
|
+
}
|
|
186
|
+
function button(label, onClick, className = "button") {
|
|
187
|
+
const node = el("button", className, label);
|
|
188
|
+
node.type = "button";
|
|
189
|
+
node.addEventListener("click", onClick);
|
|
190
|
+
return node;
|
|
191
|
+
}
|
|
192
|
+
function state(words, dot) {
|
|
193
|
+
const line = el("p", "state");
|
|
194
|
+
const mark = el("span", `dot ${dot}`);
|
|
195
|
+
mark.setAttribute("aria-hidden", "true");
|
|
196
|
+
line.append(mark, words);
|
|
197
|
+
return line;
|
|
198
|
+
}
|
|
199
|
+
function fit() {
|
|
200
|
+
// The body's own height: the document is at least as tall as the frame, so it never shrinks.
|
|
201
|
+
if (view) view.resize(document.body.getBoundingClientRect().height).catch(() => undefined);
|
|
202
|
+
}
|
|
203
|
+
function show(...nodes) {
|
|
204
|
+
root.replaceChildren(...nodes);
|
|
205
|
+
root.removeAttribute("aria-busy");
|
|
206
|
+
fit();
|
|
207
|
+
}
|
|
208
|
+
function busy() {
|
|
209
|
+
root.setAttribute("aria-busy", "true");
|
|
210
|
+
}
|
|
211
|
+
// A read's input: the page's own fields and the chosen space.
|
|
212
|
+
function input(fields = {}) {
|
|
213
|
+
return space ? { ...fields, space } : fields;
|
|
214
|
+
}
|
|
215
|
+
// What every view says when the server has no records service (src/views/contracts.js).
|
|
216
|
+
const RECORDS_OFF = "This Memory server has no records service yet, so memories, journals, pages and review can't be shown. Ask whoever runs it to turn it on.";
|
|
217
|
+
function failed(what, error, retry) {
|
|
218
|
+
if (error.message === RECORDS_OFF) return show(el("p", "muted", RECORDS_OFF));
|
|
219
|
+
return show(state(what, "danger"), el("p", "muted", error.message), button("Try again", retry));
|
|
220
|
+
}
|
|
221
|
+
function number(value) {
|
|
222
|
+
return Number(value || 0).toLocaleString("en-GB");
|
|
223
|
+
}
|
|
224
|
+
// "Sun 8 Nov" for a day, from YYYY-MM-DD or an ISO time.
|
|
225
|
+
function dayWords(value) {
|
|
226
|
+
const date = new Date(/^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T00:00:00Z` : value);
|
|
227
|
+
if (Number.isNaN(date.getTime())) return value || "";
|
|
228
|
+
return date.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short", timeZone: "UTC" });
|
|
229
|
+
}
|
|
230
|
+
function waiting(push, what) {
|
|
231
|
+
if (push.kind === "rpc.waiting") show(state("Waiting for you", "off"), el("p", "muted", `Allow this in Jelly to see ${what}.`));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Memory's Today tile: the newest journal's summary line, how many suggestions wait for your
|
|
235
|
+
// review, and what is due today. Three reads over the bridge, each shown as it comes: one that
|
|
236
|
+
// fails says so on its own line and leaves the others.
|
|
237
|
+
const lines = { journal: el("p"), review: el("p"), due: el("p") };
|
|
238
|
+
// Set when a read finds no records service: the tile then says so in one line.
|
|
239
|
+
let off = false;
|
|
240
|
+
|
|
241
|
+
function line(target, label, words, className = "") {
|
|
242
|
+
const strong = el("span", "title", `${label}: `);
|
|
243
|
+
target.className = className;
|
|
244
|
+
target.replaceChildren(strong, words);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function drawJournal(today) {
|
|
248
|
+
try {
|
|
249
|
+
const answer = await view.call("journal.list", { period: "day" });
|
|
250
|
+
const newest = answer.items[0];
|
|
251
|
+
if (!newest) return line(lines.journal, "Journal", "none yet. Memory writes one each evening.", "muted");
|
|
252
|
+
const day = dayWords(newest.date);
|
|
253
|
+
const label = day === today ? "Today" : day;
|
|
254
|
+
line(lines.journal, label, newest.summary || newest.title);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
off ||= error.message === RECORDS_OFF;
|
|
257
|
+
line(lines.journal, "Journal", `couldn't read it (${error.message})`, "muted");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function drawReview() {
|
|
262
|
+
try {
|
|
263
|
+
const answer = await view.call("review.list", {});
|
|
264
|
+
const count = answer.items.length;
|
|
265
|
+
line(lines.review, "Review", count === 0 ? "nothing waits for you." : `${count}${answer.more ? "+" : ""} ${count === 1 ? "suggestion waits" : "suggestions wait"} for you.`);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
off ||= error.message === RECORDS_OFF;
|
|
268
|
+
line(lines.review, "Review", `couldn't read it (${error.message})`, "muted");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function drawDue() {
|
|
273
|
+
try {
|
|
274
|
+
const answer = await view.call("commitments.list", { state: "open" });
|
|
275
|
+
const due = answer.items.filter((item) => item.dueToday);
|
|
276
|
+
const overdue = answer.items.filter((item) => item.overdue).length;
|
|
277
|
+
const words = due.length === 0 ? "nothing due today" : due.slice(0, 3).map((item) => item.what).join("; ") + (due.length > 3 ? `; and ${due.length - 3} more` : "");
|
|
278
|
+
line(lines.due, "Due today", `${words}${overdue ? `. ${overdue} overdue.` : "."}`, overdue ? "overdue" : "");
|
|
279
|
+
return answer.today;
|
|
280
|
+
} catch (error) {
|
|
281
|
+
off ||= error.message === RECORDS_OFF;
|
|
282
|
+
line(lines.due, "Due today", `couldn't read it (${error.message})`, "muted");
|
|
283
|
+
return "";
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function draw() {
|
|
288
|
+
busy();
|
|
289
|
+
for (const target of Object.values(lines)) target.replaceChildren(el("span", "muted", "Loading…"));
|
|
290
|
+
show(lines.journal, lines.review, lines.due);
|
|
291
|
+
root.setAttribute("aria-busy", "true");
|
|
292
|
+
const today = await drawDue();
|
|
293
|
+
fit();
|
|
294
|
+
await drawJournal(today);
|
|
295
|
+
fit();
|
|
296
|
+
await drawReview();
|
|
297
|
+
if (off) return show(el("p", "muted", RECORDS_OFF));
|
|
298
|
+
root.removeAttribute("aria-busy");
|
|
299
|
+
fit();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
jellyView().then((client) => {
|
|
303
|
+
view = client;
|
|
304
|
+
view.on((push) => waiting(push, "today in your memory"));
|
|
305
|
+
draw();
|
|
306
|
+
});
|
|
307
|
+
</script>
|
|
308
|
+
</body>
|
|
309
|
+
</html>
|