samagotchi 0.180.0 → 0.182.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 +71 -1
- data/bin/chi +11 -0
- data/docs/architecture.md +2 -2
- data/docs/bundles.md +7 -2
- data/docs/cli.md +46 -13
- data/docs/configuration.md +25 -4
- data/docs/internals/anthropic.md +4 -3
- data/docs/internals/background-tasks.md +2 -0
- data/docs/internals/block-renderers.md +123 -6
- data/docs/internals/bridge.md +10 -0
- data/docs/internals/engine.md +11 -0
- data/docs/internals/inline-widgets.md +3 -1
- data/docs/internals/objectives.md +9 -4
- data/docs/internals/prompt-caching.md +9 -1
- data/docs/internals/remote-sessions.md +14 -2
- data/docs/internals/web-frontend.md +100 -10
- data/docs/internals/working-set.md +24 -5
- data/docs/memory.md +3 -0
- data/docs/plugins.md +11 -4
- data/docs/sessions.md +8 -5
- data/docs/testing.md +1 -1
- data/lib/samagotchi/answer_display.rb +3 -2
- data/lib/samagotchi/block_fix/stamp.rb +49 -0
- data/lib/samagotchi/block_fix.rb +220 -0
- data/lib/samagotchi/bridge/block_fix_route.rb +30 -0
- data/lib/samagotchi/bridge/turn_drawings.rb +19 -0
- data/lib/samagotchi/bridge.rb +11 -2
- data/lib/samagotchi/bridge_client.rb +9 -0
- data/lib/samagotchi/bundle_command.rb +4 -1
- 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 +9 -1
- data/lib/samagotchi/continue_intent.rb +8 -0
- data/lib/samagotchi/core_notice.rb +44 -0
- data/lib/samagotchi/engine/block_fix.rb +332 -0
- data/lib/samagotchi/engine/side_requests.rb +7 -5
- data/lib/samagotchi/engine.rb +4 -0
- data/lib/samagotchi/events.rb +1 -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/idle_client.rb +10 -6
- data/lib/samagotchi/inline_widgets.rb +12 -0
- data/lib/samagotchi/kernel_loop.rb +10 -7
- 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 +8 -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/markdown_parser.rb +28 -0
- data/lib/samagotchi/memory_bundle/status.rb +2 -1
- 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_access/contract.rb +3 -0
- data/lib/samagotchi/session_access/delete_plan.rb +77 -0
- data/lib/samagotchi/session_access/local.rb +13 -0
- data/lib/samagotchi/session_access/remote.rb +19 -1
- data/lib/samagotchi/session_access.rb +1 -0
- data/lib/samagotchi/session_chain/delete.rb +45 -87
- data/lib/samagotchi/session_chain/delete_preview.rb +55 -19
- data/lib/samagotchi/session_delete_command.rb +129 -3
- data/lib/samagotchi/session_manager/delegate_rule.rb +86 -0
- data/lib/samagotchi/session_manager/listing.rb +4 -4
- data/lib/samagotchi/session_manager/removal.rb +40 -14
- data/lib/samagotchi/session_manager/running_tasks.rb +50 -23
- data/lib/samagotchi/session_manager.rb +1 -0
- 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 +34 -0
- data/lib/samagotchi/turn_stages/objectives.rb +10 -5
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +13 -1
- data/lib/samagotchi/web/block_fix_routes.rb +39 -0
- data/lib/samagotchi/web/markdown_renderer.rb +24 -9
- data/lib/samagotchi/web/message_display.rb +6 -1
- data/lib/samagotchi/web/participant_view.rb +1 -1
- data/lib/samagotchi/web/public/app.js +15 -19
- data/lib/samagotchi/web/public/block_fix.js +270 -0
- data/lib/samagotchi/web/public/block_fix_note.js +104 -0
- data/lib/samagotchi/web/public/block_frame.js +6 -3
- data/lib/samagotchi/web/public/block_host.js +21 -21
- data/lib/samagotchi/web/public/block_renderers.css +17 -5
- data/lib/samagotchi/web/public/block_watch.js +16 -2
- data/lib/samagotchi/web/public/context_chips.js +3 -4
- data/lib/samagotchi/web/public/images.js +1 -1
- data/lib/samagotchi/web/public/index.html +24 -5
- data/lib/samagotchi/web/public/inline_widgets.js +1 -1
- 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 +3 -3
- data/lib/samagotchi/web/public/peer_data.js +27 -15
- 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 +4 -0
- data/lib/samagotchi/web/public/stream_handlers.js +5 -1
- data/lib/samagotchi/web/public/turn_block.js +5 -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
- data/lib/samagotchi/web/server.rb +6 -4
- data/lib/samagotchi/web/session_control.rb +53 -21
- data/lib/samagotchi/worker/block_fixes.rb +22 -0
- data/lib/samagotchi/worker.rb +10 -3
- metadata +17 -1
data/docs/internals/engine.md
CHANGED
|
@@ -465,6 +465,17 @@ ask it (`Engine#cut_for_steer`, `#input_epoch`, `#generation_snapshot`), the str
|
|
|
465
465
|
- `WaitingSteer`: a cut that came too early. It waits until the thinking passes the cut wait (rechecked on each
|
|
466
466
|
thinking chunk), until a drain hands it to the model at a boundary, or until the turn ends.
|
|
467
467
|
|
|
468
|
+
### A block fix: written between turns
|
|
469
|
+
|
|
470
|
+
`Engine::BlockFixPart` (`engine/block_fix.rb`) is the one writer of the conversation outside a turn that a side
|
|
471
|
+
thread feeds. `#fix_block` (the Bridge's route) resolves the answer once, takes its anchor (index, digest, the turn
|
|
472
|
+
counter `#turn_messages` bumps for every turn) and asks on `SideJudgments#aside`; the result waits in
|
|
473
|
+
`@block_fix_ready` and wakes the worker. `#apply_block_fixes` runs only on the worker's loop between turns
|
|
474
|
+
(`Worker::BlockFixesPart`, after the queued commands and before the notes and the next prompt) and never while a turn
|
|
475
|
+
runs: under the event lock it replaces the session's messages (`replace_session_messages`) with a copy of the answer
|
|
476
|
+
whose text (no turn since, still the newest answer) or display (a turn since) holds the fix, or drops the fix when
|
|
477
|
+
the anchor no longer matches. See [block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again).
|
|
478
|
+
|
|
468
479
|
## Events
|
|
469
480
|
|
|
470
481
|
### The turn's sink (`on_event`) and the observers
|
|
@@ -113,7 +113,9 @@ session switch, a turn's end, Revise's clones, the stage's hand-off to `#history
|
|
|
113
113
|
listeners. A widget's position and picks live in the widget, so a clone or a rewrite starts over (accepted for v1).
|
|
114
114
|
- **A refused block** (`data-widget-error`) stays source under `failBlock`'s muted `.block-note` ("Couldn't draw this
|
|
115
115
|
chi-ui block: …", an attribute CSS shows, a click copies it). Bad JSON or an unknown `type` fails the same way, from
|
|
116
|
-
the watcher. A `chi-ui` `<pre>` with neither attribute (an older server) is left alone.
|
|
116
|
+
the watcher. A `chi-ui` `<pre>` with neither attribute (an older server) is left alone. In the newest answer a
|
|
117
|
+
refused block is asked for again, once (the schemas go with the request: `InlineWidgets::FIX_RULES`, and the fix
|
|
118
|
+
must parse before it is used; [block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again)).
|
|
117
119
|
- **walk** (`widget_walk.js`): the swimlane (one column per actor, one row per step; the current, seen and a hovered
|
|
118
120
|
case's target marked; a click jumps), the step card (actor, `does`, "You see", the dashed "Behind it"), a fork's
|
|
119
121
|
"Which case?" buttons, Back / Next / Start over, the path taken, and ← → while the widget has the focus
|
|
@@ -171,8 +171,10 @@ any call. An add's text can't split on ` | `. The body names the line, for a ter
|
|
|
171
171
|
`Objectives.view` (`List#to_view`) is what the page draws: the items, each with its last move, and `pending`, whether
|
|
172
172
|
the newest list is a file still waiting. The session read (`objectives`, no key with no list) and the live
|
|
173
173
|
`:objectives_updated` carry it. `Engine#announce_objectives` (under the event lock, `TurnStages::Objectives#announce` giving the event) emits when the view differs from the last: after an edit,
|
|
174
|
-
once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A
|
|
175
|
-
|
|
174
|
+
once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A list
|
|
175
|
+
that goes away (a rollback, or a canceled or failed turn's kept messages, past the note that set it) emits one event
|
|
176
|
+
with `items: nil`, and the strip's `take` clears (an N-1 page's too); a session with no list before and after emits
|
|
177
|
+
nothing. Between two tabs that is all it takes. A participant gets neither: the event is in
|
|
176
178
|
`ParticipantView::DROPPED`.
|
|
177
179
|
|
|
178
180
|
Idle, an edit lands at once: the worker's anytime path wakes the loop (`@waker.wake`, one extra pass for any anytime
|
|
@@ -185,7 +187,10 @@ command), which absorbs the file. It no longer waits for the fallback tick.
|
|
|
185
187
|
by `forgetSession`. Its edit list is a `chip_popover.js` shell, so a phone gets the bottom sheet and the focus rules.
|
|
186
188
|
Every edit is a line on the command route with `card: true`: no echo, and `commandView` hides a good `/objectives`
|
|
187
189
|
answer that came with that mark, so a tap leaves no bubble, a refusal does. The strip redraws from the event, never
|
|
188
|
-
optimistically.
|
|
190
|
+
optimistically. A list with only dropped objectives draws no strip, as no list (`stripItems` is empty), and
|
|
191
|
+
`hasList()` is false, so the history's /short button hides too. The last one dropped from inside the open edit list
|
|
192
|
+
keeps the list and its strip until the list closes (its Undo stays under the finger); the close redraws the strip
|
|
193
|
+
away. `/objectives undo <id>` brings one back meanwhile.
|
|
189
194
|
- **The entry** (`objectives_entry.js`, from `turn_html.js noteBubbleTemplate`): `Objectives.entry` puts the note's items
|
|
190
195
|
and, against the list before it, `changes` (`Objectives.changes`, display only) on the history item and on
|
|
191
196
|
`context_added`. A first list is pills; a later one a line, `You marked O1 done`. The raw text stays the tooltip.
|
|
@@ -237,7 +242,7 @@ command), which absorbs the file. It no longer waits for the fallback tick.
|
|
|
237
242
|
- **Continue**: `Objectives.carry`, in `SessionContinue`'s `before_spawn`, writes a second note file in the new link,
|
|
238
243
|
after the carry note and any moved context's note, so the list reads as the latest word. It is not in
|
|
239
244
|
`SessionChain.note_text` (capped; the last answer gets what the recap leaves). It reads the previous link fresh,
|
|
240
|
-
with its unabsorbed newest file. A failure is only logged (`continue_objectives_failed`), because it runs inside the
|
|
245
|
+
with its unabsorbed newest file; a list with nothing active or done isn't carried (`List#meant?`). A failure is only logged (`continue_objectives_failed`), because it runs inside the
|
|
241
246
|
continue's rollback. The previous link's other waiting notes move after it (`NoteMove.move`, the step after: moved first, the
|
|
242
247
|
carry would miss a pending edit, and the stale list would be the batch's newest); its objectives notes never move,
|
|
243
248
|
and the new link's worker never adopts one from it (`NoteMove.adoption`), so a list from the archived link can't
|
|
@@ -192,7 +192,15 @@ user message starts (`KernelLoop#warmup_prompt`) and sends it in a thread (`Clie
|
|
|
192
192
|
server has since cleared skips its prompt cache and prefills everything (measured 0.5 s → 12 s). For the same
|
|
193
193
|
reason `id_slot` is a reserved sampling key.
|
|
194
194
|
- What breaks it (the warm-up simply misses): a system-prompt rebuild (`/thinking`, `/model`, a tool change),
|
|
195
|
-
the image cut moving a batch, `!rollback
|
|
195
|
+
the image cut moving a batch, `!rollback`, a block fix that patched the last answer.
|
|
196
|
+
|
|
197
|
+
**A block fix patches the last answer before a turn sends it.** A block the page couldn't draw in the newest answer
|
|
198
|
+
is asked for again on the side, and when it comes back before the next turn starts the answer's text holds the fix
|
|
199
|
+
([block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again)): that is the one change to an earlier
|
|
200
|
+
message a turn's request sees. The cached prefix ends before the answer on a remote prefix cache and on Anthropic's
|
|
201
|
+
Messages API (nothing lost); on llama.cpp the slot re-evaluates from the patched block (a few hundred tokens), and a
|
|
202
|
+
warm-up already sent loses its gain for that turn (measured 0.73 s against 0.11 s on a hybrid model). A fix that comes
|
|
203
|
+
back after the next turn started lands in the answer's `display` only, never sent to a model.
|
|
196
204
|
|
|
197
205
|
## The image window
|
|
198
206
|
|
|
@@ -134,9 +134,12 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
|
|
|
134
134
|
`SessionManager::OwnedByTUI` / `DeleteRefused` / `ArchiveRefused` / `RestartRefused`, `SessionContinue::Refused`,
|
|
135
135
|
and `ModelProfile::MissingModel` for `invalid_model` (no model there, or `--model`'s host unknown there: "could not
|
|
136
136
|
start a session: …", exit 1, as here). A delete's or archive's `409 tasks_running` carries `op` (`delete` or
|
|
137
|
-
`archive`), `tasks` (`{running, unverified, unreadable}`), `worker_stopped`, `stopped_worker` (whose; an older chi web
|
|
137
|
+
`archive`), `tasks` (`{running, unverified, unreadable}`), `worker_stopped`, `stopped_worker` (whose; an older chi web
|
|
138
|
+
sends only the Boolean), `stopped_workers` (the archive tree's stopped worker ids), and `sessions` (the archive's
|
|
139
|
+
hidden session count), plus a chain's `links`: `raise_refusal`
|
|
138
140
|
rebuilds `DeleteRefused` or `ArchiveRefused` by `op`, with the `RunningTasks::Listing`, and makes the words here
|
|
139
|
-
(`RunningTasks.words
|
|
141
|
+
(`RunningTasks.words`, plus `RunningTasks.worker_words`: "its worker was stopped", "9d0e1f2a's worker was stopped",
|
|
142
|
+
or "N workers were stopped: its own, 9d0e1f2a"), not from chi web's `message`. Its own code, not archive's `busy`: an older client prints
|
|
140
143
|
`RemoteFailed "… answered 409 tasks_running: …"` rather than "a turn is running". `--stop-tasks` asks for the
|
|
141
144
|
`stop_tasks` feature first (`RemoteTooOld` without it).
|
|
142
145
|
Checks the client would make locally come back as `SessionAccess::Refused` (`parent_answers_refused`,
|
|
@@ -191,6 +194,15 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
|
|
|
191
194
|
`unarchived`/`moved_back` (read as `[]`). The delete refusals reach the CLI with their own reason and message
|
|
192
195
|
(`continuing`, `delegate_unmovable`, `scheduled`, `chain_scheduled`, `worker_running`, `still_stopping`:
|
|
193
196
|
`Remote#raise_refusal` raises `DeleteRefused` with `ids` and `schedule_id`).
|
|
197
|
+
- **A route that answers more.** `GET /api/sessions/:id/delete_plan` answering for every session (`{chained: false,
|
|
198
|
+
session_id, link}` for one in no chain, and a file-less folder), together with a plain delete that takes the
|
|
199
|
+
session's stopped delegates, is `delete_plan_all` (`App::DELETE_PLAN_FEATURE`). Its first caller is the CLI's
|
|
200
|
+
remote `sessions delete --dry-run` (`Remote#delete_plan`; `SessionAccess::DeletePlan.read` reads its JSON and
|
|
201
|
+
`Local#delete_plan`'s symbol-keyed preview into the same value objects), which requires it first: an older chi web answers a session in no chain with
|
|
202
|
+
`{chained: false}` alone and still leaves a plain session's delegates, so its plan would be wrong. A plain remote
|
|
203
|
+
delete needs no feature: against an older chi web it leaves the delegates, and the CLI prints what the result
|
|
204
|
+
says. The deletes' `tasks=` and archive's `tasks` (the sheet's named tasks) need none either: an older chi web
|
|
205
|
+
ignores them and stops what runs, which is what a CLI without them asks for.
|
|
194
206
|
|
|
195
207
|
## Which checks run where
|
|
196
208
|
|
|
@@ -14,8 +14,8 @@ by `npm run e2e` (`spec/e2e/`). `app.js` has no unit spec of its own; `viewer_bo
|
|
|
14
14
|
**Every module has a size cap, `app.js` its own**: `npm run lint` fails past `max-lines` in `eslint.config.js`
|
|
15
15
|
(counted as `wc -l` counts, comments and blank lines too). Every `public/*.js` module: 1200 (`samagotchi/module-size`,
|
|
16
16
|
about 10% over the largest, `turn_block.js`), so a module near it splits rather than becoming the next `app.js`.
|
|
17
|
-
`app.js` (`samagotchi/app-size`):
|
|
18
|
-
`session_view.js
|
|
17
|
+
`app.js` (`samagotchi/app-size`): 1638, its size once the lightbox went into `picture_viewer.js`; down from 1649, its
|
|
18
|
+
size plus 50 once the session-open flow went into `session_sync.js` and `session_view.js`, itself ratcheted down from 2000, itself down from 2250 when the versions, the owner's claim links and
|
|
19
19
|
Verify, the composer's mode and the strip's hide went into modules of their own. A new feature goes into a module of
|
|
20
20
|
its own, wired from `app.js` in a few lines; a refactor that shrinks `app.js` ratchets its cap down with it. Never
|
|
21
21
|
raise either: extract instead. Ruby's twin is `Samagotchi/FileSize` (docs/testing.md, File size).
|
|
@@ -31,7 +31,7 @@ page. A factory dep a new version stops passing is the same hazard the other way
|
|
|
31
31
|
out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
|
|
32
32
|
until a reload, so the risk is a mixed cache, not an open tab. `answer_fold.js`, `details_motion.js`,
|
|
33
33
|
`turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
|
|
34
|
-
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
34
|
+
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
35
35
|
|
|
36
36
|
## One page, every viewer
|
|
37
37
|
|
|
@@ -389,9 +389,11 @@ links too). In ⋯'s menu, Delete doesn't click `#infoDeleteBtn` for a chained s
|
|
|
389
389
|
card (`createDeleteSheet`, on `chip_popover.js`: a bottom sheet on a phone). Both shells keep one live host: a
|
|
390
390
|
`host(anchor, id)` (the card's, with the session it opened for) or a Delete in ⋯ makes a new one, and a flow whose host
|
|
391
391
|
is no longer the live one (a ✕ on another card while the first plan was read) draws and acts on nothing. What the sheet says comes from
|
|
392
|
-
`GET /api/sessions/:id/delete_plan`, fetched as it opens
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
`GET /api/sessions/:id/delete_plan`, fetched as it opens for every session: the server's own plan and refusals
|
|
393
|
+
(`SessionChain::Delete::Preview`, the code the delete runs), so the sheet and the delete can't disagree. Plain
|
|
394
|
+
sessions have a server-side link plan; the page still uses the plain confirm until the delete-sheet phase sends plans
|
|
395
|
+
for it. The preview shares one `session_rows` snapshot across the link and chain choices, while Links performs its own
|
|
396
|
+
listing. `deleteChoices` (pure) turns it into the two choices, a schedule's banner
|
|
395
397
|
and each refusal's "Not while …"; a plan that says no chain (a link alone past a gap) falls back to the confirm. The
|
|
396
398
|
confirm sends the shown choice's `digest` (`expect=`, `data.js deleteSession`/`deleteChain` keep it out of `fetch`);
|
|
397
399
|
a `409 plan_changed` re-reads the plan and redraws the sheet with "What this deletes changed; check again" (a link no
|
|
@@ -412,12 +414,85 @@ wider; its bottom is 16px less than `--safe-b`, since the session's card floats
|
|
|
412
414
|
session panel has no bottom padding and runs to the screen's bottom, its card at `--dock-bottom`, 16px or the
|
|
413
415
|
indicator's line), a bottom sheet's offset (`chip_popover.js place`: 8px above the indicator, or a keyboard's offset
|
|
414
416
|
alone), the update sheet, the toast's fallback place (in a session `--toast-bottom` already sits it above the card), the
|
|
415
|
-
|
|
417
|
+
picture viewer's padding (its fit's insets) and its ✕'s and bar's offsets, and the signed-out banner (`auth_lost.js`, `env()` itself).
|
|
416
418
|
On phones, the standalone app also has a 12px body inset, keeping its content below iOS 26's blurred band under the
|
|
417
419
|
clock. A new fixed or bottom-anchored piece reads `--safe-*`, never `env()`: the e2e set the names by hand (`web.spec.js`, a portrait phone and a landscape one),
|
|
418
420
|
as Chromium has no insets. The theme-color metas are tokens.css's `--bg-top` per theme up to 600px wide (a phone's page starts from that colour at its top edge, so the status bar meets the top bar with no seam), else its `--bg` (`theme.test.js` pins them). An iOS 26 Home Screen app ignores them for the status bar strip: it paints the strip in the body's `background-color`, so a phone's body gradient keeps a `--bg-top` colour layer under it (black strip without one).
|
|
419
421
|
In a session, the dock (composer card) shares the history's centered column, at most 960px wide; its right edge follows a classic scrollbar (`--history-sb`, 0 with overlay scrollbars; index.html and `dock_reserve.js`).
|
|
420
422
|
|
|
423
|
+
## Picture viewer
|
|
424
|
+
|
|
425
|
+
`picture_viewer.js` (`createPictureViewer`, made once by app.js as `pictures`; `viewer` there is the capabilities
|
|
426
|
+
object) shows a picture over the whole page in `#lightbox`, an opaque surface in `--bg` (a diagram's ink is the
|
|
427
|
+
theme's text colour, which a dark backdrop would hide on the light theme). A click on an attached image's thumbnail
|
|
428
|
+
opens it (its natural size from the loaded thumbnail, else after a `decode()`, showing nothing till then), and so
|
|
429
|
+
does a click on a drawn diagram or its keyboard button (`block_host.js`'s `openPicture`: its `data:` URL and its size
|
|
430
|
+
from the viewBox; [block-renderers.md](block-renderers.md)). It opens
|
|
431
|
+
fitted (`pan_zoom.js fitScale`: inside 24px of padding, the safe areas and the bar, never above 3 ×) and nothing is
|
|
432
|
+
kept: every open starts fitted.
|
|
433
|
+
|
|
434
|
+
- **Zoom is the layout size**: the picture's box (`.pv-pic`, the `<img>` in it at 100%) gets its width and height in
|
|
435
|
+
px, and a 2D `translate` places it. An SVG `<img>` is drawn again at its layout size; a scaled one can be a blurred
|
|
436
|
+
bitmap. No `will-change`, no 3D transform, no animation: a composited layer at the largest size is hundreds of MB.
|
|
437
|
+
The closest is 8 × natural, less when a side would pass 16,000 px or the area 4096² px (`MAX_SHOWN_PIXELS`, iOS
|
|
438
|
+
Safari's canvas cap, as the iPhone's budget); the farthest half of min(fit, 1). A picture smaller than the screen
|
|
439
|
+
on an axis is centred on it, a larger one keeps 60 px of itself on screen.
|
|
440
|
+
- **Gestures**, on the surface (`touch-action: none`, so the page under it never scrolls or zooms): one pointer
|
|
441
|
+
drags, two pinch (pointer capture; a cancel is an up); a pointerdown on ✕ or the bar starts nothing. Plain wheel
|
|
442
|
+
moves, Ctrl/Cmd + wheel zooms at the cursor (a Chromium trackpad pinch is a ctrl + wheel), by `exp(-deltaY ×
|
|
443
|
+
0.01)`, not fixed steps. Safari's `gesturestart`/`change`/`end` are always prevented (they would zoom the page) and
|
|
444
|
+
applied only while no touch pointer is down: that is a Mac trackpad; iOS fires them beside the pointers for a
|
|
445
|
+
finger pinch, and applying both would double it. A double tap or click (two ups without a move within 300 ms)
|
|
446
|
+
goes to max(2.5 × fit, natural) at that point, or back to fit when closer than fit. The `<img>` is never
|
|
447
|
+
dragged natively (`draggable=false`, `dragstart` prevented, `-webkit-user-drag:none`, `pointer-events:none`) and
|
|
448
|
+
has no iOS long-press sheet (`-webkit-touch-callout:none`).
|
|
449
|
+
- **Keys** are on the viewer's element, not the document, and stop there: `+`/`=` and `-` zoom, `0` fits (not with
|
|
450
|
+
Ctrl/Cmd held: the browser's own zoom), arrows move, Esc closes. The page's document listeners (the all-sessions
|
|
451
|
+
Esc, a popover's Esc, the reader's arrows, type-anywhere) never see them. It is a modal dialog ("Picture viewer",
|
|
452
|
+
`popover_modal.js modalDialog`); the surface takes the focus on open.
|
|
453
|
+
- **Closing** is ✕ and Esc only (a tap on the surface starts a drag). The focus goes back to the opener (a
|
|
454
|
+
diagram's button) without scrolling (`focusBack(…, {preventScroll})`, before hiding); a thumbnail takes no focus,
|
|
455
|
+
so after one it is the page's. A window `resize` (an orientation change) refits a fitted view, else re-clamps; it
|
|
456
|
+
is listened to only while open.
|
|
457
|
+
- **It closes by itself**, whatever it shows, on a system theme change (the diagram behind is redrawn; the viewer
|
|
458
|
+
holds the old picture; app.js), on a switch to another session or the start page (`session_view.js
|
|
459
|
+
forgetSession`, given `pictures`; the same session again keeps it) and when the all-sessions view opens (it hides
|
|
460
|
+
`#center`, the viewer's parent; app.js `applyView`). A bubble rewritten or cloned while it is open leaves it as it
|
|
461
|
+
is: it holds its own copy of the URL. The toast may show over it (both z-index 50, the toast later); it is modal by
|
|
462
|
+
`aria-modal`, `#center`'s other children aren't made `inert`.
|
|
463
|
+
- index.html keeps `<div id="lightbox" hidden><img alt=""></div>`: an older cached app.js reads that `<img>`. The
|
|
464
|
+
viewer adopts it (or adds one) and draws ✕ and the bar with lit at the first open. ✕ and the bar are glass cards
|
|
465
|
+
(solid `--bg-panel` under `body.no-glass` and reduced transparency), by `--safe-*`, and the standalone phone
|
|
466
|
+
app's ✕ is 12px lower, below iOS 26's band under the clock.
|
|
467
|
+
|
|
468
|
+
## A failed block asked for again
|
|
469
|
+
|
|
470
|
+
Two modules, owner page only ([block-renderers.md](block-renderers.md#a-failed-block-is-asked-for-again) has the
|
|
471
|
+
mechanism): `block_fix.js` (`wireBlockFix`, one call in app.js: the owner's page, `viewer.can("block_renderers")`,
|
|
472
|
+
with `<body data-block-fix="auto">`, else null; `createBlockFix`) and `block_fix_note.js` (the line's states, DOM
|
|
473
|
+
only). A drawer that fails a block because of the model's input marks it (`block_watch.js failBlock(..., {fixable})`,
|
|
474
|
+
`pre.dataset.blockFixable`, the reason kept in `pre.dataset.blockReason`, a bubbling `block-failed` event): a refused
|
|
475
|
+
`chi-ui` block (`inline_widgets.js`) and a renderer's own `error` (`block_frame.js` `FrameError.renderer`). `block_fix.js`
|
|
476
|
+
listens for that event and scans added nodes (a Revise clone arrives failed) in the turn roots, and decides from the DOM
|
|
477
|
+
alone: the newest answer's first 2 such blocks are posted (`POST /api/sessions/:id/blocks/fix`, `postFix`); the worker
|
|
478
|
+
also enforces the 2-per-answer limit and remains the authority (`fix_limit`, even if the page or a second tab posts).
|
|
479
|
+
A block
|
|
480
|
+
that is a fix (`data-block-fixed`) or whose fix failed (`data-block-fix-failed`), an older answer, a third block and a
|
|
481
|
+
live worker without the `block_fix` feature (`worker_features.js workerPredates`, with `bridgeUp`) get their line
|
|
482
|
+
instead. Nothing is kept across a re-render: a block failing again is posted again, and the worker answers it runs (or
|
|
483
|
+
how it went); only the redraw is counted: an answer is read again at most once per turn and block for the page's life
|
|
484
|
+
(the route's 200 `fixed` or the event's), and a block failing after it says a fix didn't help. The stream's `block_fix` handler
|
|
485
|
+
(`stream_handlers.js`, dep `blockFix`) hands the worker's word over: `fixed` re-reads that turn's answer (`getSession(id,
|
|
486
|
+
{tail, turnId})`) and writes the bubble as `applyFinalAnswer` writes it, which can't find it by its old text; `failed`
|
|
487
|
+
and `dropped` say a fix didn't help. A block is marked asked (`data-block-fix-asked`) before its POST, since the word can
|
|
488
|
+
come before the 202 (a quick side answer); a 202 after it starts no give-up. No word within 60 s of a 202: the line
|
|
489
|
+
gives up (today's words and Ask in chat);
|
|
490
|
+
a session switch drops the timers. The line's words are `data-text` (CSS), Ask in chat a button whose label is CSS
|
|
491
|
+
(`data-label`) with an `aria-label`, one delegated click listener per root; it fills the composer after the draft
|
|
492
|
+
(`widget_picks.js withDraft`), never sends. "Drawn after a fix" (`.block-note.fixed`) follows a `data-block-fixed`
|
|
493
|
+
block once its figure is placed; a click on it copies nothing (a failed block's line copies its error). A reload's drawn turn takes the saved answer when `block_fixed` is on its item (what
|
|
494
|
+
streamed is the block before the fix: `turn_block.js savedAnswer`).
|
|
495
|
+
|
|
421
496
|
## The stage's modules
|
|
422
497
|
|
|
423
498
|
`stage_view.js` wires the stage: its `refresh`, the lifecycle (`turnStarted` … the hand-off) and the event API app.js
|
|
@@ -675,6 +750,21 @@ forgetSession` (a switch, the start page, + New, a deleted or archived session)
|
|
|
675
750
|
`#center` is never left inert, whatever the next session's GET does; close gives focus back to where it was at the
|
|
676
751
|
open (not after a jump or a reset). Styles: `ws_preview.css`.
|
|
677
752
|
|
|
753
|
+
Markdown in both (`ws_markdown.js`): a memory's text (a read, a write, its overlay, the greyed "what it was") and a
|
|
754
|
+
whole read of an `.md`/`.markdown` file (a slice from line 1 with a `lines.whole` read; in the peek, a whole read
|
|
755
|
+
that isn't a preview) render; a slice stays numbered source (it can start inside a fence, and its line numbers are
|
|
756
|
+
the strip's jumps), an edit or a write its diff, a fetch its text. A leading front matter is taken off and shown as
|
|
757
|
+
source above the HTML (a read of several memories is one text, so only the first body's is). The HTML is
|
|
758
|
+
`markdown_place.js renderMarkdown`'s (app.js passes it to `createWorkingSetPreview`), put in with lit's
|
|
759
|
+
`unsafeHTML` (sanitised on the server); the reader makes the one cache (`createRenderCache`: about 50 texts, HTML
|
|
760
|
+
only, a null not kept so the next draw asks again, one request per text at a time, a text whose JSON body is over
|
|
761
|
+
the route's 64 KiB answered null without a request) and hands it to the peek (`createPeek`'s `md`). HTML that comes
|
|
762
|
+
redraws the reader while an item is open and the peek while one is (`peekChanged`). Until it comes, and without it,
|
|
763
|
+
a card draws its source and has no switch. The reader's cards carry a `rendered | source` switch (`data-wsr="view"`,
|
|
764
|
+
one choice per open item in the reader's closure, back to rendered when another item opens, not stored); the peek
|
|
765
|
+
has none. A slice card carries its first line (`data-first`), which the strip's band jump falls back to on a
|
|
766
|
+
rendered slice (no `.read-line` in it).
|
|
767
|
+
|
|
678
768
|
## The peer exchange
|
|
679
769
|
|
|
680
770
|
A send to a paired peer (claude-peer's `claude_send`, codex-peer's) and the peer's answer, linked in the owner's
|
|
@@ -688,7 +778,7 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
|
|
|
688
778
|
- `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
|
|
689
779
|
of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
|
|
690
780
|
none): its own closure holds the last read for the open session (`createLatest`: an older read, or one for a
|
|
691
|
-
session left, is dropped); `exchange(id)` (
|
|
781
|
+
session left, is dropped); `exchange(id)` (the newest of an id: each send has its own, but an older chi's resend shared one), `answer(name, serial, re)`. It reads only when the
|
|
692
782
|
session has a peer (a context row with `peer`, a drawn send or answer), so a session without one makes no request.
|
|
693
783
|
Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
|
|
694
784
|
`context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
|
|
@@ -708,7 +798,7 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
|
|
|
708
798
|
slot's title), an answer's ↑ (`.peer-up-slot`) and "Read the full answer" (`.peer-full-slot`), each marked
|
|
709
799
|
`data-peer-slot`, which `history_shape.js` leaves out (an offscreen reload has no model). `peer_links.js` is the
|
|
710
800
|
controller: on the model's `onChange` and after each session draw it renders, with lit, the pill into every slot in
|
|
711
|
-
the history and the stage (two rows of one id show the same newest exchange; an id the read doesn't have reads "not
|
|
801
|
+
the history and the stage (two rows of one id, an older chi's resend, show the same newest exchange; an id the read doesn't have reads "not
|
|
712
802
|
sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
|
|
713
803
|
(`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
|
|
714
804
|
the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
|
|
@@ -790,7 +880,7 @@ reach another device or the server.
|
|
|
790
880
|
| `chi_strip_hidden` (`chi_zen`: the old name, read once) | `strip_hidden.js` | the session strip hidden |
|
|
791
881
|
| `chi_stage_collapsed:<session>` | `stage_asking.js` (through `session_prefs.js`) | the session's stage collapsed or opened by hand (not written from the asking form, whose fold is that question's only); none: the page's default, `<body data-stage-collapsed="1">` (`web.stage_collapsed`), else open |
|
|
792
882
|
| `chi_working_set_collapsed:<session>` | `working_set_rail.js` (through `session_prefs.js`) | the session's working set rail collapsed |
|
|
793
|
-
| `chi_ws_sections_folded:<session>` | `working_set_view.js` (through `session_prefs.js`; the key is `ws_sections.js WS_SECTION_FOLD`) | the working-set list's sections folded by hand, a JSON list of keys (`start`, `read`, `talk`); none: all open |
|
|
883
|
+
| `chi_ws_sections_folded:<session>` | `working_set_view.js` (through `session_prefs.js`; the key is `ws_sections.js WS_SECTION_FOLD`) | the working-set list's sections folded by hand, a JSON list of keys (`start`, `read`, `talk`); none stored: `start` folded (a stored `[]` is all open) |
|
|
794
884
|
| `chi_markdown_tip_dismissed` | `markdown_tip.js` | the markdown tip dismissed |
|
|
795
885
|
| `chi_update_available_shown` | `version_notices.js` | update notices already shown |
|
|
796
886
|
| `chi_notify`, `chi_push_device` | `notifications.js` (an injected storage) | the bell's state, this device's push id |
|
|
@@ -317,7 +317,8 @@ preview for a long one). 400 without a known `kind` and a `key`.
|
|
|
317
317
|
|
|
318
318
|
## The page's overlay
|
|
319
319
|
|
|
320
|
-
The page keeps its row-derived items and their `at`
|
|
320
|
+
The page keeps its row-derived items and their `at` (first entry) and `last` (newest touch) ordinals (the step
|
|
321
|
+
tags' jump path; `itemsOfTurn` moves `last` at every touch, `sessionItems` keeps the latest turn's), and overlays the server's
|
|
321
322
|
`state` and `tokens` by key (`working_set.js overlay`):
|
|
322
323
|
- files by absolute path (the row's `ref.path`; a title fallback won't match, so it stays live);
|
|
323
324
|
- memories by name;
|
|
@@ -356,16 +357,30 @@ passes `working_set_updated` to it, and does nothing when the flag is off. A new
|
|
|
356
357
|
session lens; a footprint (`footClick`) and the rail (`openTurn`) open the lens on their turn. In a turn lens
|
|
357
358
|
(`working_set.js turnLens`, `lensItem`) the rows the turn touched are `lit` and the rest `dim` (`opacity:
|
|
358
359
|
var(--ws-lens-dim)`, a `:root` token in both palettes). A lit row is the session item's state, tokens and actions with
|
|
359
|
-
the turn item's `at`, ops and count (its step tag is the turn's, `s3`; a dimmed row keeps the session's,
|
|
360
|
+
the turn item's `at`, ops and count (its step tag is the turn's, `s3`; a dimmed row keeps the session's, its last
|
|
361
|
+
touch, `t1·s3`; `rowTemplate` picks by the lens class, since a lit row carries the session's `last` too): the
|
|
360
362
|
turn item is passed through, the session item is never overwritten. The header's `session | ‹ turn N ›` steps over the
|
|
361
363
|
finished turns and the running one (`lastTurn()`), `‹` and `›` disabled at the ends; the line under it reads "turn N
|
|
362
364
|
touched A · B new" (new: the session set's first `at` is this turn's, a prompt memory never). A folded inner group
|
|
363
365
|
(`labelsTemplate`) shows its lit members while folded. A new seed that leaves the lens past the last turn, or a reset
|
|
364
366
|
that drops the running turn, puts it back to the session.
|
|
365
367
|
|
|
368
|
+
**The list's order** (`ws_order.js`). The popover's list only: the rail, the footprints and the reader's side list
|
|
369
|
+
(`items()`) keep the set's entry order. `recencyOrder` sorts the items newest `last` (else `at`: an older page's item)
|
|
370
|
+
first, by turn, step, row, stable on ties; an item with neither (a preloaded memory never read, a used memory no row
|
|
371
|
+
explains) goes after the rest in its order, so without parts too those memories end the memories. The order is
|
|
372
|
+
taken when the list opens (`show` with `opening`: the item keys, `openKeys`) and held while it is open
|
|
373
|
+
(`heldOrder`): an item not among them comes in on top, newest first, the others stay where they were drawn, one that
|
|
374
|
+
left the set is gone. The lens buttons, a refresh, a seed's redraw keep it; a footprint or the rail clicked while it
|
|
375
|
+
is open opens it again (`popover.open`), which takes it again; a close drops it. `bodySections` filters by kind and
|
|
376
|
+
`fold` puts a group at its first member's place, so a folded directory group stands at its newest member's place,
|
|
377
|
+
and a new file in a folder already grouped brings the group to the top (accepted: the group moves as one). A turn lens keeps
|
|
378
|
+
the order (lit rows light where they stand). The session lens's step tag (and a dimmed row's) is the last touch:
|
|
379
|
+
its text, its jump and its title ("last touched at turn N (prompt), step S"); a lit row's is the turn's entry.
|
|
380
|
+
|
|
366
381
|
**The head view: sections** (`ws_sections.js headSections`, drawn by `working_set_view.js headTemplate`). With the
|
|
367
382
|
session's `prompt_parts` (the worker's sizes of its system prompt; `promptParts` on the page) the list is what is in
|
|
368
|
-
chi's head, in three sections:
|
|
383
|
+
chi's head, in three sections, drawn as Read, Conversation, From the start (every reader finds a section by its key):
|
|
369
384
|
- **From the start** (`start`): every part in prompt order, the tools part first. A memory part (identity, a model
|
|
370
385
|
note, a preload) IS a memory row: merged with the session set's rows of the same memory, else a row of its own
|
|
371
386
|
(identity: the set never lists it). **The match is scope + name** (`same`): the names match (`memoryName`, which
|
|
@@ -390,7 +405,9 @@ chi's head, in three sections:
|
|
|
390
405
|
the tool schemas out, so without server usage the rest can go negative and the row hides); the "~" says so.
|
|
391
406
|
|
|
392
407
|
**Held twice.** A start memory row whose ops include `read` is held twice: in the prompt and in a read's output. The
|
|
393
|
-
session lens tags it `held twice` (warn tokens)
|
|
408
|
+
session lens tags it `held twice` (warn tokens), and the start header counts them, folded or open (`· N held
|
|
409
|
+
twice`, the section's `twice`, in `--warn-text`: a span of its own after the meta, so on a phone the meta's ellipsis
|
|
410
|
+
cuts the meta first); a turn lens whose items read it lights it amber with a note under it:
|
|
394
411
|
"read again in this turn: already in the prompt, held twice (+X)". A lens lights a merged row by any of its merged
|
|
395
412
|
keys (`lensTouched`), and a part-only start row (no merged item, e.g. `x@system`) by its bare name too: a turn's rows
|
|
396
413
|
come from tool titles, which carry no scope, so in a turn lens a project `x` read lights a system `x`'s own row (lit,
|
|
@@ -401,7 +418,9 @@ drop strikes the row where it stands (today's state words); the server knows an
|
|
|
401
418
|
changed it, so a turn lens has no forget count.
|
|
402
419
|
|
|
403
420
|
**Section folds.** Each section header folds (`data-ws="section"`), per session (`chi_ws_sections_folded:<session>`,
|
|
404
|
-
`session_prefs.js`); none stored:
|
|
421
|
+
`session_prefs.js`); none stored: From the start folded, the rest open (`foldedSections(null)`; the view reads the pref
|
|
422
|
+
with no fallback, so nothing stored is told from a stored `[]`, which is all open). A stored list is used as it is, so
|
|
423
|
+
a session folded or opened by hand keeps that. Conversation has no header to fold: a stored `talk` (an older page's) is
|
|
405
424
|
ignored (`foldedSections`) and the next toggle writes the list without it. Folded, a section shows only the rows the lens lights (the read section's
|
|
406
425
|
lit members flat, without their inner groups). The header carries no size (the name, the lens, the ring
|
|
407
426
|
and ×: one line on a phone at 390 px); the line under it does. The session lens's: "in chi's head now · ~X of Y"
|
data/docs/memory.md
CHANGED
|
@@ -662,6 +662,9 @@ profiles, meta bundles that install a set of them:
|
|
|
662
662
|
|
|
663
663
|
`chi bootstrap` installs `core` and, on a terminal, offers `dev`. An existing
|
|
664
664
|
install gets neither by itself: `chi bundle install core` (or `dev`).
|
|
665
|
+
When no core member has an install record, chi prints a one-line reminder to
|
|
666
|
+
stderr at a session or web launch, including a one-shot. It is shown only once
|
|
667
|
+
per state directory, even if core is later removed.
|
|
665
668
|
|
|
666
669
|
A profile's `manifest.yml` has `includes:` (bundle names) and nothing else to
|
|
667
670
|
install; its dir holds only that file. What installing it does follows one
|
data/docs/plugins.md
CHANGED
|
@@ -400,6 +400,10 @@ end
|
|
|
400
400
|
the phone too; a file's "Open in editor" only where the editor opens (this machine).
|
|
401
401
|
- It runs **once per call, on the tool path**, before the call runs: keep it cheap, with no I/O (no
|
|
402
402
|
network, no file reads); build the refs from `args` alone.
|
|
403
|
+
- A lambda that takes two args, `->(args, tool_id) { … }`, gets the run's own id too (chi's tool id, `"t41"`;
|
|
404
|
+
nil when the run has none, a [bundle test](bundle-authoring.md)'s `bundle.tool` for one), and the block reads
|
|
405
|
+
the same id as `ctx.tool_id`: what makes an id for the row that differs between two calls with equal args (the
|
|
406
|
+
peer bundles' send id). A one-arg lambda gets the args alone. Needs chi 0.181.0.
|
|
403
407
|
- If it raises or returns something other than a list, the row gets no refs and the tool still runs; a bad
|
|
404
408
|
ref (an unknown kind, a `javascript:` URL, a file outside the folder) is dropped. Both are logged (tag
|
|
405
409
|
`plugins`, `tool_refs_failed` / `tool_refs_rejected`).
|
|
@@ -891,6 +895,7 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
891
895
|
| `ctx.cost` | the session's spend so far, read now, as a frozen value: `total` (USD, reported + estimated, side requests included; 0.0 before any), `reported` (by providers, `usage.cost`), `estimated` (from `hosts.<name>.models` prices; a generation is one or the other, never both), `side` (recap, `/btw`, `ask_model`: their share of `total`) and `known?` (false while generations or side requests ran but none was reported or priced, so a limit on it can't be enforced; a session with some priced generations reads known, the unpriced ones counting 0). It includes the running turn's finished generations and what earlier workers of the session spent. Use its methods, not its class. Needs chi 0.83.0 |
|
|
892
896
|
| `ctx.usage` | the session's work so far, read now, as a frozen value: `turns` (finished ones and the running one), `tool_calls` and `tool_calls_by_tool` (every call, running ones included; canonical names: an alias counts under its tool, a `call_tool` call under the inner tool), `steps` (the loop rounds that dispatched tools, `/stats`' iterations) and `active_ms` (`active_minutes` too): work time, the generations' time plus the finished tool calls' time, never the waits between them (a question, an approval, the user's answer to `ask_user_question`), with `tool_ms_by_tool` its tool part by tool, so a waiting tool's time (`task_wait`) can be left out. Its counts are the ones `/stats` and `chi sessions stats` show, earlier workers' included. Use its methods, not its class. Needs chi 0.100.0 (guard it with `ctx.respond_to?(:usage)`) |
|
|
893
897
|
| `ctx.turn_author` | who wrote the running turn when it isn't the session's owner: a participant's `"p:<id>"` (`chi share`); nil for the owner's turns and between turns. Every hook event of such a turn carries the same as `author:`. The handler runs with the owner's power whatever the author ([hooks](hooks.md#participants-turns)). Needs chi 0.105.0 (guard it with `ctx.respond_to?(:turn_author)`) |
|
|
898
|
+
| `ctx.tool_id` | inside a tool's block, the run's own id (chi's tool id, `"t41"`), the one a two-arg `refs:` lambda got for its row ([Refs on a tool's row](#refs-on-a-tools-row)); nil anywhere else (a hook, a command, a thread the block started) and for a run with none. Needs chi 0.181.0 (guard it with `ctx.respond_to?(:tool_id)`) |
|
|
894
899
|
| `ctx.settings` | the bundle's settings, frozen: config.yml's `bundles: <bundle>:` with the session's own `--set` values laid over it ([Per-session settings](#per-session-settings)); the config alone until the session is bound (in `register` and `chi.ctx`) |
|
|
895
900
|
| `ctx.data_dir` | `$XDG_STATE_HOME/samagotchi/plugins/<bundle>/`, created on first use: what the bundle keeps across sessions |
|
|
896
901
|
| `ctx.session_dir` | this session's own folder there, created on use, read now; nil with no session yet. `ctx.session_dir(create: false)` is the same path with no folder made, for a read, so a session that saved nothing leaves none (a `File.read` of what isn't there raises `Errno::ENOENT`); needs chi newer than 0.143.0. chi removes it when the session is deleted, discarded or pruned, so don't build the path yourself. A `sessions/<id>.json` an older version of your bundle kept moves in as `state.json` (chi still removes one left there). Needs chi newer than 0.142.0 |
|
|
@@ -1456,10 +1461,12 @@ that calls it, or for a real external bundle that does. No method on the chance
|
|
|
1456
1461
|
`check_hint!`, `paired_lines`, `transport_line`, `peer_dir` and
|
|
1457
1462
|
`setup_paragraph` (optionally `skill_substitutions`), and sets `NAME`,
|
|
1458
1463
|
`APP`, `COMMAND`, `USAGE`, `OUTBOX` and `SCRIPTS_DIRS`. These constants are
|
|
1459
|
-
read as `self.class::X`. The base names each send: `Peer.send_id(kind, title, text)` (`s-` and 6 hex
|
|
1460
|
-
of SHA-256 over the args as given
|
|
1461
|
-
|
|
1462
|
-
|
|
1464
|
+
read as `self.class::X`. The base names each send: `Peer.send_id(kind, title, text, salt)` (`s-` and 6 hex
|
|
1465
|
+
of SHA-256 over the args as given and the send's salt: the tool run's `ctx.tool_id`, a random one for a
|
|
1466
|
+
`/<peer>` command's, so each send has its own id; a nil salt gives an older chi's id, over the args alone) is the
|
|
1467
|
+
message's second line (`ref: <id>`), the tool row's `peer` ref (display only, no actions; computed from the args
|
|
1468
|
+
and the run's id before the call runs, a two-arg `refs:`, so a send that then fails has it too) and the last
|
|
1469
|
+
send's `id`; the peer's answer echoes it as `re` ([context.md](context.md#the-command-contract)).
|
|
1463
1470
|
Successful sends and transport failures are recorded in the session's peer exchange log; answer pushes add
|
|
1464
1471
|
summaries, not answer texts. The log does not enter the model's context.
|
|
1465
1472
|
See the [claude-peer](bundles.md#the-claude-peer-bundle) and
|