samagotchi 0.179.0 → 0.181.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -1
- data/bin/chi +10 -0
- data/docs/architecture.md +1 -1
- data/docs/bundles.md +39 -3
- data/docs/cli.md +16 -9
- data/docs/configuration.md +25 -5
- data/docs/context.md +7 -0
- data/docs/internals/anthropic.md +4 -3
- data/docs/internals/background-tasks.md +4 -1
- data/docs/internals/block-renderers.md +11 -7
- data/docs/internals/bundles.md +12 -10
- data/docs/internals/objectives.md +9 -4
- data/docs/internals/web-frontend.md +127 -6
- data/docs/internals/working-set.md +24 -5
- data/docs/memory.md +3 -0
- data/docs/plugins.md +17 -6
- data/docs/sessions.md +1 -1
- data/docs/testing.md +5 -1
- data/lib/samagotchi/block_renderers.rb +22 -3
- data/lib/samagotchi/bundle_command.rb +9 -2
- data/lib/samagotchi/bundle_needs.rb +1 -1
- data/lib/samagotchi/bundle_settings_check.rb +5 -2
- data/lib/samagotchi/bundles/known-names/manifest.yml +2 -2
- data/lib/samagotchi/bundles/known-names/plugin.rb +4 -3
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +3 -2
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/client.rb +8 -1
- data/lib/samagotchi/config.rb +6 -1
- data/lib/samagotchi/context_providers.rb +6 -8
- data/lib/samagotchi/core_notice.rb +44 -0
- data/lib/samagotchi/host_address.rb +7 -0
- data/lib/samagotchi/host_config.rb +8 -5
- data/lib/samagotchi/host_registry.rb +26 -8
- data/lib/samagotchi/installed_bundles/dir.rb +17 -55
- data/lib/samagotchi/installed_bundles/standing.rb +23 -3
- data/lib/samagotchi/installed_bundles.rb +26 -11
- data/lib/samagotchi/kernel_loop.rb +3 -2
- data/lib/samagotchi/llm/adapter_common.rb +3 -2
- data/lib/samagotchi/llm/adapters.rb +2 -1
- data/lib/samagotchi/llm/anthropic_assembly.rb +5 -0
- data/lib/samagotchi/llm/anthropic_messages.rb +6 -2
- data/lib/samagotchi/llm/chat_loop.rb +6 -5
- data/lib/samagotchi/llm/errors.rb +41 -3
- data/lib/samagotchi/llm/http.rb +85 -22
- data/lib/samagotchi/llm/openai_chat.rb +20 -3
- data/lib/samagotchi/memory_bundle/status.rb +10 -6
- data/lib/samagotchi/objectives.rb +7 -2
- data/lib/samagotchi/owner_lock.rb +2 -0
- data/lib/samagotchi/plugin/api.rb +4 -1
- data/lib/samagotchi/plugin/context.rb +9 -0
- data/lib/samagotchi/plugin/peer.rb +32 -15
- data/lib/samagotchi/plugin/tool_spec.rb +13 -2
- data/lib/samagotchi/row_refs.rb +14 -3
- data/lib/samagotchi/session_chain/delete.rb +6 -6
- data/lib/samagotchi/session_config.rb +15 -9
- data/lib/samagotchi/session_manager/removal.rb +2 -2
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/formatting.rb +13 -3
- data/lib/samagotchi/terminal_ui/join_replay.rb +1 -1
- data/lib/samagotchi/tool_ids.rb +19 -0
- data/lib/samagotchi/tool_runner.rb +8 -4
- data/lib/samagotchi/tools/registry.rb +3 -2
- data/lib/samagotchi/tools/task_runtime.rb +46 -3
- data/lib/samagotchi/turn_stages/objectives.rb +10 -5
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/app.js +22 -14
- data/lib/samagotchi/web/public/block_host.js +20 -20
- data/lib/samagotchi/web/public/block_renderers.css +5 -5
- data/lib/samagotchi/web/public/context_chips.js +183 -49
- data/lib/samagotchi/web/public/history_shape.js +5 -3
- data/lib/samagotchi/web/public/images.js +1 -1
- data/lib/samagotchi/web/public/index.html +90 -5
- data/lib/samagotchi/web/public/objectives_strip.js +16 -6
- data/lib/samagotchi/web/public/pan_zoom.js +121 -0
- data/lib/samagotchi/web/public/peer_chip.js +171 -0
- data/lib/samagotchi/web/public/peer_data.js +131 -0
- data/lib/samagotchi/web/public/peer_exchange.js +83 -0
- data/lib/samagotchi/web/public/peer_links.js +161 -0
- data/lib/samagotchi/web/public/peer_note.js +49 -0
- data/lib/samagotchi/web/public/picture_viewer.js +304 -0
- data/lib/samagotchi/web/public/popover_modal.js +3 -2
- data/lib/samagotchi/web/public/session_view.js +10 -1
- data/lib/samagotchi/web/public/stream_handlers.js +17 -4
- data/lib/samagotchi/web/public/turn_html.js +11 -2
- data/lib/samagotchi/web/public/working_set.js +9 -3
- data/lib/samagotchi/web/public/working_set_view.js +28 -11
- data/lib/samagotchi/web/public/ws_cards.js +36 -10
- data/lib/samagotchi/web/public/ws_markdown.js +129 -0
- data/lib/samagotchi/web/public/ws_order.js +48 -0
- data/lib/samagotchi/web/public/ws_peek.js +22 -5
- data/lib/samagotchi/web/public/ws_preview.css +41 -1
- data/lib/samagotchi/web/public/ws_reader.js +35 -6
- data/lib/samagotchi/web/public/ws_sections.js +24 -15
- metadata +11 -1
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
.wsr-card-h{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:6px 12px;border-bottom:1px solid var(--border);background:var(--bg-raised);font-size:12px}
|
|
70
70
|
.wsr-card-t{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text)}
|
|
71
71
|
.wsr-card-m{color:var(--ws-faint)}
|
|
72
|
-
.wsr-card-
|
|
72
|
+
.wsr-card-actions{display:inline-flex;align-items:center;gap:6px;margin-left:auto;white-space:nowrap}
|
|
73
|
+
.wsr-card-h .wsr-call{margin-left:0;font-size:12px}
|
|
73
74
|
.wsr-pill{padding:0 6px;border-radius:4px;font-size:11px}
|
|
74
75
|
.wsr-pill.latest{background:var(--accent-bg);color:var(--accent)}
|
|
75
76
|
.wsr-pill.gone{background:var(--badge-bg);color:var(--text-muted)}
|
|
@@ -81,6 +82,37 @@
|
|
|
81
82
|
.wsr-had>summary{cursor:pointer}
|
|
82
83
|
.wsr-overlay{margin:0 10px 10px;padding:6px 0 0;border:1px dashed var(--border-strong);border-radius:6px}
|
|
83
84
|
.wsr-overlay-h{padding:0 10px;font-size:11.5px;color:var(--ws-muted)}
|
|
85
|
+
/* Markdown (ws_markdown.js): a memory's text, a whole read of an .md file; the answers' values, scoped here. */
|
|
86
|
+
.wsr-md{padding:10px 14px;font-size:13.5px;line-height:1.55;color:var(--text-2);white-space:normal;overflow-wrap:anywhere}
|
|
87
|
+
.wsr-md :is(h1,h2,h3,h4,h5,h6){margin:16px 0 6px;font-weight:600;line-height:1.3;color:var(--text-bright)}
|
|
88
|
+
.wsr-md>:is(h1,h2,h3,h4,h5,h6):first-child{margin-top:2px}
|
|
89
|
+
.wsr-md h1{font-size:18px}
|
|
90
|
+
.wsr-md h2{font-size:16px}
|
|
91
|
+
.wsr-md h3{font-size:15px}
|
|
92
|
+
.wsr-md :is(h4,h5,h6){font-size:14px;color:var(--text-2)}
|
|
93
|
+
.wsr-md :is(p,ul,ol,blockquote,table,pre){margin:0 0 10px}
|
|
94
|
+
.wsr-md>:last-child{margin-bottom:0}
|
|
95
|
+
.wsr-md :is(ul,ol){padding-left:1.5em}
|
|
96
|
+
.wsr-md li+li{margin-top:3px}
|
|
97
|
+
.wsr-md li>:is(ul,ol){margin:3px 0 0}
|
|
98
|
+
.wsr-md strong{color:var(--text-bright)}
|
|
99
|
+
.wsr-md a{color:var(--accent)}
|
|
100
|
+
.wsr-md hr{border:0;border-top:1px solid var(--border);margin:12px 0}
|
|
101
|
+
.wsr-md code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.88em}
|
|
102
|
+
.wsr-md :not(pre)>code{padding:1px 4px;border:1px solid var(--border);border-radius:4px;background:var(--bg-inset);color:var(--text)}
|
|
103
|
+
.wsr-md pre{overflow-x:auto;padding:8px 10px;border:1px solid var(--border);border-radius:6px;background:var(--bg-inset);font-size:12.5px;line-height:1.45;white-space:pre;overflow-wrap:normal}
|
|
104
|
+
.wsr-md blockquote{padding-left:12px;border-left:3px solid var(--border-strong);color:var(--text-muted)}
|
|
105
|
+
.wsr-md table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse}
|
|
106
|
+
.wsr-md :is(th,td){padding:4px 8px;border:1px solid var(--border-strong);font-size:13px;overflow-wrap:normal}
|
|
107
|
+
.wsr-md th{background:var(--bg-inset);font-weight:600}
|
|
108
|
+
.wsr-front{margin:0;padding:6px 14px;border-bottom:1px solid var(--border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:16px;white-space:pre-wrap;word-break:break-word;color:var(--text-faint)}
|
|
109
|
+
/* The card's "rendered | source" switch, as the list's lens. */
|
|
110
|
+
.wsr-view{display:inline-flex;gap:2px}
|
|
111
|
+
.wsr-view button{padding:1px 8px;border:1px solid transparent;border-radius:999px;background:transparent;color:var(--text-muted);font-size:11px;line-height:16px;cursor:pointer}
|
|
112
|
+
.wsr-view button.on{color:var(--text-2);border-color:var(--border-strong);background:var(--bg-inset)}
|
|
113
|
+
.wsr-view button:hover:not(:disabled){filter:none}@media(hover:hover){.wsr-view button:hover{color:var(--text)}}
|
|
114
|
+
.ws-peek-b .wsr-md{max-height:220px;overflow:auto;font-size:12.5px}
|
|
115
|
+
.ws-peek-b .wsr-front{font-size:11px}
|
|
84
116
|
.wsr-banner{flex:none;margin:10px 20px 0;padding:8px 10px;border:1px solid var(--warn-border);border-radius:8px;background:var(--warn-bg);color:var(--warn-text);font-size:12.5px;line-height:18px}
|
|
85
117
|
.wsr-tabs{flex:none;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));margin:10px 20px 0;padding:2px;border-radius:8px;background:var(--bg-inset);max-width:420px}
|
|
86
118
|
.wsr-tabs button{height:32px;border:0;border-radius:6px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer}
|
|
@@ -116,8 +148,16 @@
|
|
|
116
148
|
.wsr-bar{height:8px}
|
|
117
149
|
.wsr-body{padding:10px 0;gap:10px}
|
|
118
150
|
.wsr-card{border-left:0;border-right:0;border-radius:0}
|
|
151
|
+
.wsr-card-h{flex-wrap:wrap;gap:6px;padding:6px 8px}
|
|
152
|
+
.wsr-card-t{flex:1 1 160px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
153
|
+
.wsr-card-actions{flex:none;margin-left:auto}
|
|
154
|
+
.wsr-card-h .wsr-call{white-space:nowrap}
|
|
119
155
|
.wsr-lines{font-size:11.5px;line-height:18px}
|
|
120
156
|
.wsr-card .read-lines code{min-width:max-content}
|
|
157
|
+
.wsr-view{flex:none}
|
|
158
|
+
.wsr-view button{position:relative;min-height:20px;padding:1px 8px}
|
|
159
|
+
.wsr-view button::after{content:"";position:absolute;inset:-12px 0}
|
|
160
|
+
.wsr-md{padding:10px 14px}
|
|
121
161
|
.wsr-banner,.wsr-tabs{margin:10px 12px 0}
|
|
122
162
|
.wsr-tabs{max-width:none}
|
|
123
163
|
.wsr-from{padding:8px 14px}
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
// the running turn's view as of its last step. Leaving the
|
|
23
23
|
// session (another one, the start page) resets it: session_view.js
|
|
24
24
|
// forgetSession calls reset(), so #center is never left inert under it.
|
|
25
|
+
//
|
|
26
|
+
// Markdown (+renderMarkdown+, markdown_place.js): a memory's text and a
|
|
27
|
+
// whole read of an .md file render, in the reader and the peek, from one
|
|
28
|
+
// cache (ws_markdown.js); the reader's cards carry a "rendered | source"
|
|
29
|
+
// switch, one choice per open item, back to rendered when another opens.
|
|
25
30
|
|
|
26
31
|
import { html, nothing, render } from "./vendor/lit-html.js";
|
|
27
32
|
import { api } from "./data.js";
|
|
@@ -32,6 +37,7 @@ import { setTimelineWayIn } from "./ws_way_in.js";
|
|
|
32
37
|
import { cardTemplate } from "./ws_cards.js";
|
|
33
38
|
import { bandBox, countsText, eventTag, fileStrip, itemPath, linesText, timelineCards } from "./ws_timeline.js";
|
|
34
39
|
import { olderAnswer } from "./ws_item_sig.js";
|
|
40
|
+
import { createRenderCache } from "./ws_markdown.js";
|
|
35
41
|
import { GLYPHS, leafText, opsText, steerId, steerLine, tokensText } from "./working_set.js";
|
|
36
42
|
|
|
37
43
|
// The item route's answer for session +id+ (+now+: a memory's text now;
|
|
@@ -41,6 +47,10 @@ export function getWorkingSetItem(id, kind, key, { now = false, latest = false }
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
const PHONE_MAX = 600;
|
|
50
|
+
// An item with no events while a turn runs (the answer's +running+): its
|
|
51
|
+
// read is in the step whose tool batch hasn't ended (the route answers the
|
|
52
|
+
// turn as of its last step).
|
|
53
|
+
const STEP_RUNNING = "chi read this in the step still running. It shows here when that step's tools finish.";
|
|
44
54
|
|
|
45
55
|
// The head's pill: what is true of the item as a whole.
|
|
46
56
|
function itemPill(item, events) {
|
|
@@ -62,9 +72,10 @@ function itemName(item) {
|
|
|
62
72
|
// +centerEl+: what the reader covers (#center); +session()+, +state()+: the
|
|
63
73
|
// open session's id and fields (its folder: the undrop line); +getItem+: the
|
|
64
74
|
// item route (tests pass a stand-in); +sendLine(line)+: a steer line
|
|
65
|
-
// (undrop; null: none)
|
|
75
|
+
// (undrop; null: none); +renderMarkdown(text)+: a text's markdown HTML or
|
|
76
|
+
// null (none: every text as its source).
|
|
66
77
|
export function createWorkingSetPreview({ centerEl, session, state = () => ({}), getItem = getWorkingSetItem, sendLine = null,
|
|
67
|
-
doc = document, win = window }) {
|
|
78
|
+
renderMarkdown = null, doc = document, win = window }) {
|
|
68
79
|
let workingSet = null;
|
|
69
80
|
// The open item ({kind, key}), its answer, the memory's now, the tab.
|
|
70
81
|
let open = null;
|
|
@@ -73,9 +84,16 @@ export function createWorkingSetPreview({ centerEl, session, state = () => ({}),
|
|
|
73
84
|
let tab = "has";
|
|
74
85
|
let openFor = null;
|
|
75
86
|
let askedSig;
|
|
87
|
+
// The open item's "rendered | source".
|
|
88
|
+
let view = "rendered";
|
|
76
89
|
const latest = createLatest(() => `${session()}|${open ? `${open.kind}:${open.key}` : ""}`);
|
|
77
90
|
const sigOf = (it) => workingSet?.serverSig?.(it);
|
|
78
|
-
|
|
91
|
+
// One cache for both places: HTML that came redraws the open one(s).
|
|
92
|
+
const cache = renderMarkdown ? createRenderCache(renderMarkdown, () => {
|
|
93
|
+
if (open && !el.hidden) draw();
|
|
94
|
+
if (peek.any()) workingSet?.peekChanged();
|
|
95
|
+
}) : null;
|
|
96
|
+
const peek = createPeek({ session, getItem, sigOf, onChange: () => workingSet?.peekChanged(), md: cache });
|
|
79
97
|
|
|
80
98
|
const el = doc.createElement("section");
|
|
81
99
|
el.className = "ws-reader";
|
|
@@ -169,9 +187,12 @@ export function createWorkingSetPreview({ centerEl, session, state = () => ({}),
|
|
|
169
187
|
let body;
|
|
170
188
|
if (failed) body = html`<div class="wsr-note">Couldn't load what chi has of it.</div>`;
|
|
171
189
|
else if (!data) body = html`<div class="wsr-note">Loading…</div>`;
|
|
172
|
-
else if (!cards.length) body = html`<div class="wsr-note"
|
|
190
|
+
else if (!cards.length) body = html`<div class="wsr-note">${data.running ? STEP_RUNNING : "Nothing of it in the conversation yet: a running turn's reads show at its next step."}</div>`;
|
|
173
191
|
else if (memory?.nowBody) body = memory.nowBody;
|
|
174
|
-
else
|
|
192
|
+
else {
|
|
193
|
+
const md = cache ? { view, html: cache.html } : null;
|
|
194
|
+
body = cards.map((card) => cardTemplate(card, { item, undrop, md }));
|
|
195
|
+
}
|
|
175
196
|
const list = shown();
|
|
176
197
|
const at = list.findIndex((it) => it.kind === item.kind && it.key === item.key);
|
|
177
198
|
const tpl = html`<div class="wsr-main">
|
|
@@ -200,6 +221,7 @@ export function createWorkingSetPreview({ centerEl, session, state = () => ({}),
|
|
|
200
221
|
data = null;
|
|
201
222
|
failed = false;
|
|
202
223
|
tab = "has";
|
|
224
|
+
view = "rendered";
|
|
203
225
|
}
|
|
204
226
|
if (el.hidden) {
|
|
205
227
|
const active = doc.activeElement;
|
|
@@ -262,9 +284,16 @@ export function createWorkingSetPreview({ centerEl, session, state = () => ({}),
|
|
|
262
284
|
else if (what === "tab") {
|
|
263
285
|
tab = act.dataset.tab === "now" ? "now" : "has";
|
|
264
286
|
draw();
|
|
287
|
+
} else if (what === "view") {
|
|
288
|
+
view = act.dataset.view === "source" ? "source" : "rendered";
|
|
289
|
+
draw();
|
|
265
290
|
} else if (what === "band") {
|
|
291
|
+
// The slice holding the band's first line; a rendered one has no
|
|
292
|
+
// numbered lines: the slice its first line falls in (data-first).
|
|
266
293
|
const first = Number(act.dataset.first);
|
|
267
|
-
const
|
|
294
|
+
const slices = [...el.querySelectorAll(".wsr-card.slice")];
|
|
295
|
+
const card = slices.find((c) => c.querySelector(`.read-line[data-line="${first}"]`))
|
|
296
|
+
|| slices.filter((c) => Number(c.dataset.first) <= first).sort((a, b) => Number(b.dataset.first) - Number(a.dataset.first))[0];
|
|
268
297
|
card?.scrollIntoView?.({ block: "start" });
|
|
269
298
|
} else if (what === "undrop" && sendLine) {
|
|
270
299
|
const item = current();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The working set's head view (docs/internals/working-set.md, The head
|
|
2
|
-
// view): the popover's list as what is in chi's head, in three sections
|
|
2
|
+
// view): the popover's list as what is in chi's head, in three sections,
|
|
3
|
+
// drawn in this order: read, talk, start (folded until the user opens it).
|
|
3
4
|
// start From the start: the system prompt's parts (the session's
|
|
4
5
|
// prompt_parts), in prompt order, the tools part first. A memory
|
|
5
6
|
// part (identity, a model note, a preload) IS a memory row: merged
|
|
@@ -10,7 +11,9 @@
|
|
|
10
11
|
// `x@system`, no actions). Other parts are `part` rows: a label, a
|
|
11
12
|
// sub, their tokens, no actions.
|
|
12
13
|
// read Read in this session: today's files / memories / urls sections
|
|
13
|
-
// (working_set.js bodySections), minus the memories shown in start
|
|
14
|
+
// (working_set.js bodySections), minus the memories shown in start,
|
|
15
|
+
// in the order of the set given (the view's: last touched first,
|
|
16
|
+
// ws_order.js).
|
|
14
17
|
// talk Conversation: one row (drawn at section level, no header, no
|
|
15
18
|
// fold), the rest of the context: the context's
|
|
16
19
|
// tokens minus the parts' and the held items'. Mixed units (parts and
|
|
@@ -25,9 +28,11 @@
|
|
|
25
28
|
import { bodySections, itemKey, tokensText } from "./working_set.js";
|
|
26
29
|
|
|
27
30
|
// The sections folded by hand, per session (session_prefs.js): a JSON list
|
|
28
|
-
// of section keys. None:
|
|
31
|
+
// of section keys. None stored: start folded (DEFAULT_FOLDED).
|
|
29
32
|
export const WS_SECTION_FOLD = "chi_ws_sections_folded";
|
|
30
33
|
|
|
34
|
+
const DEFAULT_FOLDED = Object.freeze(["start"]);
|
|
35
|
+
|
|
31
36
|
export const MEMORY_PARTS = Object.freeze(["identity", "notes", "preloads"]);
|
|
32
37
|
|
|
33
38
|
// What a memory part's row says it is.
|
|
@@ -118,7 +123,8 @@ export function heldTwiceNote(row, turnItem) {
|
|
|
118
123
|
// overlaid), or null without parts (today's list). +parts+: the session's
|
|
119
124
|
// prompt_parts; +ctxTokens+: the context's tokens now (null: unknown);
|
|
120
125
|
// +turns+: how many turns the session has (the conversation row's).
|
|
121
|
-
// @return [{key, title, meta, tokens, rows?, inner?}]
|
|
126
|
+
// @return [{key, title, meta, tokens, rows?, inner?, twice?}] read, talk?, start
|
|
127
|
+
// (start's +twice+: how many of its rows are held twice)
|
|
122
128
|
export function headSections(set, budget, { parts = null, ctxTokens = null, turns = 0, inTurn = false } = {}) {
|
|
123
129
|
if (!Array.isArray(parts) || !parts.length) return null;
|
|
124
130
|
const { rows, used, partNames } = startRows(set, parts);
|
|
@@ -136,18 +142,19 @@ export function headSections(set, budget, { parts = null, ctxTokens = null, turn
|
|
|
136
142
|
// into the conversation's arithmetic, not into either section.
|
|
137
143
|
const readTokens = sum(readItems.filter(held), (i) => i.tokens);
|
|
138
144
|
const heldTokens = readTokens + sum(rows.filter(readHeld), (r) => r.tokens);
|
|
139
|
-
const sections = [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tokens: readTokens, inner: bodySections(rest, budget),
|
|
144
|
-
},
|
|
145
|
-
];
|
|
145
|
+
const sections = [{
|
|
146
|
+
key: "read", title: "Read in this session", meta: [`${readItems.filter(held).length} held`, out ? `${out} out` : ""].filter(Boolean).join(" · "),
|
|
147
|
+
tokens: readTokens, inner: bodySections(rest, budget),
|
|
148
|
+
}];
|
|
146
149
|
const talk = Number.isFinite(ctxTokens) ? ctxTokens - partsTokens - heldTokens : NaN;
|
|
147
150
|
if (talk > 0) {
|
|
148
151
|
const row = { kind: "talk", key: "conversation", label: "conversation", sub: `${turns} turn${turns === 1 ? "" : "s"}`, partTokens: talk, ops: [], at: null, count: 0, state: "live" };
|
|
149
152
|
sections.push({ key: "talk", title: "Conversation", meta: "", tokens: talk, rows: [row] });
|
|
150
153
|
}
|
|
154
|
+
sections.push({
|
|
155
|
+
key: "start", title: "From the start", meta: inTurn ? "in every turn" : `${rows.length} part${rows.length === 1 ? "" : "s"} · in every turn`, tokens: partsTokens, rows,
|
|
156
|
+
twice: rows.filter(heldTwice).length,
|
|
157
|
+
});
|
|
151
158
|
return sections;
|
|
152
159
|
}
|
|
153
160
|
|
|
@@ -232,14 +239,16 @@ export function lensTouched(sections, touched) {
|
|
|
232
239
|
return out;
|
|
233
240
|
}
|
|
234
241
|
|
|
235
|
-
// The section keys folded, from the stored value (a JSON list)
|
|
242
|
+
// The section keys folded, from the stored value (a JSON list). Nothing
|
|
243
|
+
// stored (null) or unreadable: the default, start folded; a stored list,
|
|
244
|
+
// an empty one too, as it is (the user folded or opened them by hand).
|
|
236
245
|
// Conversation never folds (one row): an older page's stored "talk" is ignored.
|
|
237
246
|
export function foldedSections(stored) {
|
|
238
247
|
try {
|
|
239
|
-
const list = JSON.parse(stored
|
|
240
|
-
return new Set(Array.isArray(list) ? list.filter((k) => typeof k === "string" && k !== "talk")
|
|
248
|
+
const list = stored == null ? null : JSON.parse(stored);
|
|
249
|
+
return new Set((Array.isArray(list) ? list : DEFAULT_FOLDED).filter((k) => typeof k === "string" && k !== "talk"));
|
|
241
250
|
} catch (_) {
|
|
242
|
-
return new Set();
|
|
251
|
+
return new Set(DEFAULT_FOLDED);
|
|
243
252
|
}
|
|
244
253
|
}
|
|
245
254
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: samagotchi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.181.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -347,6 +347,7 @@ files:
|
|
|
347
347
|
- lib/samagotchi/continue_intent.rb
|
|
348
348
|
- lib/samagotchi/continue_offer.rb
|
|
349
349
|
- lib/samagotchi/continued_from.rb
|
|
350
|
+
- lib/samagotchi/core_notice.rb
|
|
350
351
|
- lib/samagotchi/cut.rb
|
|
351
352
|
- lib/samagotchi/cut_policy.rb
|
|
352
353
|
- lib/samagotchi/debug_log.rb
|
|
@@ -1031,6 +1032,7 @@ files:
|
|
|
1031
1032
|
- lib/samagotchi/web/public/objectives_wiring.js
|
|
1032
1033
|
- lib/samagotchi/web/public/owner_claim.js
|
|
1033
1034
|
- lib/samagotchi/web/public/owner_verify.js
|
|
1035
|
+
- lib/samagotchi/web/public/pan_zoom.js
|
|
1034
1036
|
- lib/samagotchi/web/public/participant_bar.js
|
|
1035
1037
|
- lib/samagotchi/web/public/participant_history.js
|
|
1036
1038
|
- lib/samagotchi/web/public/participant_main.js
|
|
@@ -1038,6 +1040,12 @@ files:
|
|
|
1038
1040
|
- lib/samagotchi/web/public/participant_names.js
|
|
1039
1041
|
- lib/samagotchi/web/public/participant_revise.js
|
|
1040
1042
|
- lib/samagotchi/web/public/participants_panel.js
|
|
1043
|
+
- lib/samagotchi/web/public/peer_chip.js
|
|
1044
|
+
- lib/samagotchi/web/public/peer_data.js
|
|
1045
|
+
- lib/samagotchi/web/public/peer_exchange.js
|
|
1046
|
+
- lib/samagotchi/web/public/peer_links.js
|
|
1047
|
+
- lib/samagotchi/web/public/peer_note.js
|
|
1048
|
+
- lib/samagotchi/web/public/picture_viewer.js
|
|
1041
1049
|
- lib/samagotchi/web/public/plain_line.js
|
|
1042
1050
|
- lib/samagotchi/web/public/popover_modal.js
|
|
1043
1051
|
- lib/samagotchi/web/public/project_picker.js
|
|
@@ -1156,6 +1164,8 @@ files:
|
|
|
1156
1164
|
- lib/samagotchi/web/public/working_set_view.js
|
|
1157
1165
|
- lib/samagotchi/web/public/ws_cards.js
|
|
1158
1166
|
- lib/samagotchi/web/public/ws_item_sig.js
|
|
1167
|
+
- lib/samagotchi/web/public/ws_markdown.js
|
|
1168
|
+
- lib/samagotchi/web/public/ws_order.js
|
|
1159
1169
|
- lib/samagotchi/web/public/ws_peek.js
|
|
1160
1170
|
- lib/samagotchi/web/public/ws_preview.css
|
|
1161
1171
|
- lib/samagotchi/web/public/ws_reader.js
|