@howaboua/pi-agent-board 0.0.1 → 0.0.2
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 +16 -1
- package/README.md +32 -0
- package/dist/viewer/archive.js +69 -12
- package/dist/viewer/web/app.js +36 -6
- package/dist/viewer/web/index.html +3 -1
- package/dist/viewer/web/style.css +36 -0
- package/index.ts +61 -2
- package/package.json +7 -4
- package/src/activity.ts +1 -0
- package/src/archive.ts +5 -0
- package/src/awareness.ts +7 -4
- package/src/briefing.ts +7 -2
- package/src/config.ts +78 -0
- package/src/contract.ts +60 -3
- package/src/delivery.ts +9 -0
- package/src/paging.ts +7 -8
- package/src/queries.ts +38 -43
- package/src/runtime.ts +60 -7
- package/src/search.ts +93 -0
- package/src/store.ts +71 -7
- package/src/summaries.ts +118 -0
- package/src/summarizer.ts +199 -0
- package/src/viewer/archive.ts +86 -12
- package/src/viewer/contracts.ts +17 -1
- package/src/viewer/web/app.js +36 -6
- package/src/viewer/web/index.html +3 -1
- package/src/viewer/web/style.css +36 -0
package/src/viewer/web/app.js
CHANGED
|
@@ -9,6 +9,8 @@ const state = {
|
|
|
9
9
|
channel: "",
|
|
10
10
|
author: "",
|
|
11
11
|
query: "",
|
|
12
|
+
searchFull: false,
|
|
13
|
+
full: false,
|
|
12
14
|
thread: "",
|
|
13
15
|
detail: null,
|
|
14
16
|
page: null,
|
|
@@ -106,12 +108,19 @@ function threadParams() {
|
|
|
106
108
|
channel: state.channel,
|
|
107
109
|
author: state.author,
|
|
108
110
|
q: state.query,
|
|
111
|
+
full: state.searchFull ? "true" : "",
|
|
109
112
|
};
|
|
110
113
|
}
|
|
111
114
|
function same(a, b) {
|
|
112
115
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
function statusLabel(status) {
|
|
119
|
+
return node("span", `thread-status status-${status}`, {
|
|
120
|
+
open: "Open", completed: "Completed", abandoned: "Abandoned",
|
|
121
|
+
}[status]);
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
function renderBoard() {
|
|
116
125
|
const detail = state.detail;
|
|
117
126
|
const channels = [
|
|
@@ -194,6 +203,7 @@ function renderThreads() {
|
|
|
194
203
|
);
|
|
195
204
|
const foot = node("div", "thread-foot");
|
|
196
205
|
foot.append(
|
|
206
|
+
statusLabel(thread.status),
|
|
197
207
|
node("span", "", thread.channel),
|
|
198
208
|
node(
|
|
199
209
|
"span",
|
|
@@ -201,6 +211,7 @@ function renderThreads() {
|
|
|
201
211
|
`${thread.replies} ${thread.replies === 1 ? "reply" : "replies"}`,
|
|
202
212
|
),
|
|
203
213
|
);
|
|
214
|
+
if (thread.summarized) foot.append(node("span", "", "Summary"));
|
|
204
215
|
link.append(meta, node("p", "thread-preview", thread.preview), foot);
|
|
205
216
|
link.onclick = (event) => {
|
|
206
217
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
@@ -219,14 +230,14 @@ function renderThreads() {
|
|
|
219
230
|
$("more-threads").hidden = !state.page.nextCursor;
|
|
220
231
|
}
|
|
221
232
|
|
|
222
|
-
function renderPost(post, root) {
|
|
233
|
+
function renderPost(post, root, summary = false) {
|
|
223
234
|
const article = node("article", "post");
|
|
224
235
|
if (root) article.append(node("div", "post-channel", post.channel));
|
|
225
236
|
const header = node("header", "post-header");
|
|
226
237
|
const time = node("time", "", date(post.createdAt));
|
|
227
238
|
time.dateTime = post.createdAt;
|
|
228
239
|
time.title = post.createdAt;
|
|
229
|
-
header.append(author(post.author), time);
|
|
240
|
+
header.append(summary ? node("strong", "", "Summary") : author(post.author), time);
|
|
230
241
|
const body = node("div", "prose");
|
|
231
242
|
body.innerHTML = DOMPurify.sanitize(
|
|
232
243
|
marked.parse(post.text, { async: false }),
|
|
@@ -277,8 +288,16 @@ function renderPost(post, root) {
|
|
|
277
288
|
}
|
|
278
289
|
function renderConversation() {
|
|
279
290
|
const conversation = state.conversation;
|
|
291
|
+
const summary = conversation.summary;
|
|
292
|
+
$("thread-status").replaceChildren(statusLabel(conversation.status));
|
|
293
|
+
$("discussion-mode").hidden = !summary;
|
|
294
|
+
$("full-discussion").checked = state.full;
|
|
295
|
+
const snapshot = $("summary-snapshot");
|
|
296
|
+
snapshot.hidden = !summary;
|
|
297
|
+
snapshot.textContent = summary ? `Summary saved ${date(summary.createdAt)} · ${summary.provider}/${summary.model} · ${summary.reasoning} · Through ${summary.throughMessageId}` : "";
|
|
298
|
+
if (summary?.hasNewerPosts) snapshot.prepend(node("strong", "", "New replies after this summary. "));
|
|
280
299
|
$("posts").replaceChildren(
|
|
281
|
-
renderPost(conversation.root, true),
|
|
300
|
+
...(conversation.root ? [renderPost(conversation.root, true)] : summary ? [renderPost(summary, false, true)] : []),
|
|
282
301
|
...conversation.replies.map((post) => renderPost(post, false)),
|
|
283
302
|
);
|
|
284
303
|
$("more-replies").hidden = !conversation.nextCursor;
|
|
@@ -291,6 +310,9 @@ function clearConversation() {
|
|
|
291
310
|
$("more-replies").hidden = true;
|
|
292
311
|
document.body.classList.remove("detail-open");
|
|
293
312
|
$("posts").replaceChildren();
|
|
313
|
+
$("thread-status").replaceChildren();
|
|
314
|
+
$("discussion-mode").hidden = true;
|
|
315
|
+
$("summary-snapshot").hidden = true;
|
|
294
316
|
saveSelection();
|
|
295
317
|
}
|
|
296
318
|
async function loadList() {
|
|
@@ -304,8 +326,9 @@ async function loadList() {
|
|
|
304
326
|
setChanged(false);
|
|
305
327
|
if (page.threads[0]) await openThread(page.threads[0].id);
|
|
306
328
|
}
|
|
307
|
-
async function openThread(id) {
|
|
308
|
-
const conversation = await api("/api/thread", { boardId: state.board, id });
|
|
329
|
+
async function openThread(id, full = false) {
|
|
330
|
+
const conversation = await api("/api/thread", { boardId: state.board, id, full: full ? "true" : "" });
|
|
331
|
+
state.full = full;
|
|
309
332
|
state.thread = id;
|
|
310
333
|
state.conversation = conversation;
|
|
311
334
|
state.firstConversation = conversation;
|
|
@@ -348,7 +371,7 @@ async function refresh(explicit = false) {
|
|
|
348
371
|
api("/api/board", { boardId: state.board }),
|
|
349
372
|
api("/api/threads", params),
|
|
350
373
|
state.thread
|
|
351
|
-
? api("/api/thread", { boardId: state.board, id: state.thread })
|
|
374
|
+
? api("/api/thread", { boardId: state.board, id: state.thread, full: state.full ? "true" : "" })
|
|
352
375
|
: Promise.resolve(null),
|
|
353
376
|
]);
|
|
354
377
|
if (!explicit && (state.threadPages > 1 || state.replyPages > 1)) {
|
|
@@ -396,9 +419,15 @@ $("search-form").onsubmit = (event) => {
|
|
|
396
419
|
event.preventDefault();
|
|
397
420
|
run(async () => {
|
|
398
421
|
state.query = $("search").value.trim();
|
|
422
|
+
state.searchFull = $("search-full").checked;
|
|
399
423
|
await loadList();
|
|
400
424
|
});
|
|
401
425
|
};
|
|
426
|
+
$("search-full").onchange = () => run(async () => {
|
|
427
|
+
state.searchFull = $("search-full").checked;
|
|
428
|
+
await loadList();
|
|
429
|
+
});
|
|
430
|
+
$("full-discussion").onchange = () => run(() => openThread(state.thread, $("full-discussion").checked));
|
|
402
431
|
$("refresh").onclick = () => run(() => refresh(true));
|
|
403
432
|
$("back").onclick = () => {
|
|
404
433
|
document.body.classList.remove("detail-open");
|
|
@@ -433,6 +462,7 @@ $("more-replies").onclick = () =>
|
|
|
433
462
|
const page = await api("/api/thread", {
|
|
434
463
|
boardId: state.board,
|
|
435
464
|
id: state.thread,
|
|
465
|
+
full: state.full ? "true" : "",
|
|
436
466
|
cursor: state.conversation.nextCursor,
|
|
437
467
|
});
|
|
438
468
|
if (state.replyPages === 1) state.firstConversation = state.conversation;
|
|
@@ -24,13 +24,15 @@
|
|
|
24
24
|
</aside>
|
|
25
25
|
<section class="index" aria-labelledby="list-title">
|
|
26
26
|
<div class="index-head"><h2 id="list-title">All activity</h2>
|
|
27
|
-
<form id="search-form" role="search"><label for="search">Search
|
|
27
|
+
<form id="search-form" role="search"><label for="search">Search threads</label><div class="search-row"><input id="search" type="search"><button type="submit">Search</button></div><label class="mode-control"><input id="search-full" type="checkbox"> Search full discussions</label><p class="search-hint">Searches summaries where available, otherwise posts.</p></form>
|
|
28
28
|
</div>
|
|
29
29
|
<div id="threads" class="thread-list"></div>
|
|
30
30
|
<button id="more-threads" class="page-button" hidden>More threads</button>
|
|
31
31
|
</section>
|
|
32
32
|
<main id="conversation" class="conversation" aria-label="Conversation">
|
|
33
33
|
<button id="back" type="button">Back to threads</button>
|
|
34
|
+
<div class="conversation-tools"><div id="thread-status"></div><label id="discussion-mode" class="mode-control" hidden><input id="full-discussion" type="checkbox"> Full discussion</label></div>
|
|
35
|
+
<p id="summary-snapshot" hidden></p>
|
|
34
36
|
<div id="posts"></div>
|
|
35
37
|
<button id="more-replies" class="page-button" hidden>More replies</button>
|
|
36
38
|
</main>
|
package/src/viewer/web/style.css
CHANGED
|
@@ -260,7 +260,43 @@ summary {
|
|
|
260
260
|
display: flex;
|
|
261
261
|
justify-content: space-between;
|
|
262
262
|
gap: 8px;
|
|
263
|
+
flex-wrap: wrap;
|
|
263
264
|
}
|
|
265
|
+
.thread-status {
|
|
266
|
+
display: inline-block;
|
|
267
|
+
padding: 2px 7px;
|
|
268
|
+
border-radius: 3px;
|
|
269
|
+
font-size: 11px;
|
|
270
|
+
font-weight: 650;
|
|
271
|
+
line-height: 1.5;
|
|
272
|
+
}
|
|
273
|
+
.status-open { color: #365678; background: #dde7ee; }
|
|
274
|
+
.status-completed { color: #315d3d; background: #dfe9da; }
|
|
275
|
+
.status-abandoned { color: #80502d; background: #eee0cf; }
|
|
276
|
+
.mode-control {
|
|
277
|
+
display: flex;
|
|
278
|
+
align-items: center;
|
|
279
|
+
gap: 6px;
|
|
280
|
+
margin: 12px 0 0;
|
|
281
|
+
}
|
|
282
|
+
.mode-control[hidden] { display: none; }
|
|
283
|
+
.search-hint, #summary-snapshot {
|
|
284
|
+
font-size: 11px;
|
|
285
|
+
line-height: 1.6;
|
|
286
|
+
color: var(--muted);
|
|
287
|
+
margin: 8px 0 0;
|
|
288
|
+
overflow-wrap: anywhere;
|
|
289
|
+
}
|
|
290
|
+
.conversation-tools {
|
|
291
|
+
display: flex;
|
|
292
|
+
align-items: center;
|
|
293
|
+
justify-content: space-between;
|
|
294
|
+
gap: 12px;
|
|
295
|
+
max-width: 800px;
|
|
296
|
+
margin: 0 auto 20px;
|
|
297
|
+
}
|
|
298
|
+
.conversation-tools .mode-control { margin: 0; }
|
|
299
|
+
#summary-snapshot { max-width: 800px; margin: 0 auto 24px; }
|
|
264
300
|
.conversation {
|
|
265
301
|
padding: 30px clamp(22px, 4vw, 64px) 60px;
|
|
266
302
|
}
|