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
|
@@ -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), `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
|
|
|
@@ -412,12 +412,57 @@ wider; its bottom is 16px less than `--safe-b`, since the session's card floats
|
|
|
412
412
|
session panel has no bottom padding and runs to the screen's bottom, its card at `--dock-bottom`, 16px or the
|
|
413
413
|
indicator's line), a bottom sheet's offset (`chip_popover.js place`: 8px above the indicator, or a keyboard's offset
|
|
414
414
|
alone), the update sheet, the toast's fallback place (in a session `--toast-bottom` already sits it above the card), the
|
|
415
|
-
|
|
415
|
+
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
416
|
On phones, the standalone app also has a 12px body inset, keeping its content below iOS 26's blurred band under the
|
|
417
417
|
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
418
|
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
419
|
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
420
|
|
|
421
|
+
## Picture viewer
|
|
422
|
+
|
|
423
|
+
`picture_viewer.js` (`createPictureViewer`, made once by app.js as `pictures`; `viewer` there is the capabilities
|
|
424
|
+
object) shows a picture over the whole page in `#lightbox`, an opaque surface in `--bg` (a diagram's ink is the
|
|
425
|
+
theme's text colour, which a dark backdrop would hide on the light theme). A click on an attached image's thumbnail
|
|
426
|
+
opens it (its natural size from the loaded thumbnail, else after a `decode()`, showing nothing till then), and so
|
|
427
|
+
does a click on a drawn diagram or its keyboard button (`block_host.js`'s `openPicture`: its `data:` URL and its size
|
|
428
|
+
from the viewBox; [block-renderers.md](block-renderers.md)). It opens
|
|
429
|
+
fitted (`pan_zoom.js fitScale`: inside 24px of padding, the safe areas and the bar, never above 3 ×) and nothing is
|
|
430
|
+
kept: every open starts fitted.
|
|
431
|
+
|
|
432
|
+
- **Zoom is the layout size**: the picture's box (`.pv-pic`, the `<img>` in it at 100%) gets its width and height in
|
|
433
|
+
px, and a 2D `translate` places it. An SVG `<img>` is drawn again at its layout size; a scaled one can be a blurred
|
|
434
|
+
bitmap. No `will-change`, no 3D transform, no animation: a composited layer at the largest size is hundreds of MB.
|
|
435
|
+
The closest is 8 × natural, less when a side would pass 16,000 px or the area 4096² px (`MAX_SHOWN_PIXELS`, iOS
|
|
436
|
+
Safari's canvas cap, as the iPhone's budget); the farthest half of min(fit, 1). A picture smaller than the screen
|
|
437
|
+
on an axis is centred on it, a larger one keeps 60 px of itself on screen.
|
|
438
|
+
- **Gestures**, on the surface (`touch-action: none`, so the page under it never scrolls or zooms): one pointer
|
|
439
|
+
drags, two pinch (pointer capture; a cancel is an up); a pointerdown on ✕ or the bar starts nothing. Plain wheel
|
|
440
|
+
moves, Ctrl/Cmd + wheel zooms at the cursor (a Chromium trackpad pinch is a ctrl + wheel), by `exp(-deltaY ×
|
|
441
|
+
0.01)`, not fixed steps. Safari's `gesturestart`/`change`/`end` are always prevented (they would zoom the page) and
|
|
442
|
+
applied only while no touch pointer is down: that is a Mac trackpad; iOS fires them beside the pointers for a
|
|
443
|
+
finger pinch, and applying both would double it. A double tap or click (two ups without a move within 300 ms)
|
|
444
|
+
goes to max(2.5 × fit, natural) at that point, or back to fit when closer than fit. The `<img>` is never
|
|
445
|
+
dragged natively (`draggable=false`, `dragstart` prevented, `-webkit-user-drag:none`, `pointer-events:none`) and
|
|
446
|
+
has no iOS long-press sheet (`-webkit-touch-callout:none`).
|
|
447
|
+
- **Keys** are on the viewer's element, not the document, and stop there: `+`/`=` and `-` zoom, `0` fits (not with
|
|
448
|
+
Ctrl/Cmd held: the browser's own zoom), arrows move, Esc closes. The page's document listeners (the all-sessions
|
|
449
|
+
Esc, a popover's Esc, the reader's arrows, type-anywhere) never see them. It is a modal dialog ("Picture viewer",
|
|
450
|
+
`popover_modal.js modalDialog`); the surface takes the focus on open.
|
|
451
|
+
- **Closing** is ✕ and Esc only (a tap on the surface starts a drag). The focus goes back to the opener (a
|
|
452
|
+
diagram's button) without scrolling (`focusBack(…, {preventScroll})`, before hiding); a thumbnail takes no focus,
|
|
453
|
+
so after one it is the page's. A window `resize` (an orientation change) refits a fitted view, else re-clamps; it
|
|
454
|
+
is listened to only while open.
|
|
455
|
+
- **It closes by itself**, whatever it shows, on a system theme change (the diagram behind is redrawn; the viewer
|
|
456
|
+
holds the old picture; app.js), on a switch to another session or the start page (`session_view.js
|
|
457
|
+
forgetSession`, given `pictures`; the same session again keeps it) and when the all-sessions view opens (it hides
|
|
458
|
+
`#center`, the viewer's parent; app.js `applyView`). A bubble rewritten or cloned while it is open leaves it as it
|
|
459
|
+
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
|
|
460
|
+
`aria-modal`, `#center`'s other children aren't made `inert`.
|
|
461
|
+
- index.html keeps `<div id="lightbox" hidden><img alt=""></div>`: an older cached app.js reads that `<img>`. The
|
|
462
|
+
viewer adopts it (or adds one) and draws ✕ and the bar with lit at the first open. ✕ and the bar are glass cards
|
|
463
|
+
(solid `--bg-panel` under `body.no-glass` and reduced transparency), by `--safe-*`, and the standalone phone
|
|
464
|
+
app's ✕ is 12px lower, below iOS 26's band under the clock.
|
|
465
|
+
|
|
421
466
|
## The stage's modules
|
|
422
467
|
|
|
423
468
|
`stage_view.js` wires the stage: its `refresh`, the lifecycle (`turnStarted` … the hand-off) and the event API app.js
|
|
@@ -675,6 +720,82 @@ forgetSession` (a switch, the start page, + New, a deleted or archived session)
|
|
|
675
720
|
`#center` is never left inert, whatever the next session's GET does; close gives focus back to where it was at the
|
|
676
721
|
open (not after a jump or a reset). Styles: `ws_preview.css`.
|
|
677
722
|
|
|
723
|
+
Markdown in both (`ws_markdown.js`): a memory's text (a read, a write, its overlay, the greyed "what it was") and a
|
|
724
|
+
whole read of an `.md`/`.markdown` file (a slice from line 1 with a `lines.whole` read; in the peek, a whole read
|
|
725
|
+
that isn't a preview) render; a slice stays numbered source (it can start inside a fence, and its line numbers are
|
|
726
|
+
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
|
|
727
|
+
source above the HTML (a read of several memories is one text, so only the first body's is). The HTML is
|
|
728
|
+
`markdown_place.js renderMarkdown`'s (app.js passes it to `createWorkingSetPreview`), put in with lit's
|
|
729
|
+
`unsafeHTML` (sanitised on the server); the reader makes the one cache (`createRenderCache`: about 50 texts, HTML
|
|
730
|
+
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
|
|
731
|
+
the route's 64 KiB answered null without a request) and hands it to the peek (`createPeek`'s `md`). HTML that comes
|
|
732
|
+
redraws the reader while an item is open and the peek while one is (`peekChanged`). Until it comes, and without it,
|
|
733
|
+
a card draws its source and has no switch. The reader's cards carry a `rendered | source` switch (`data-wsr="view"`,
|
|
734
|
+
one choice per open item in the reader's closure, back to rendered when another item opens, not stored); the peek
|
|
735
|
+
has none. A slice card carries its first line (`data-first`), which the strip's band jump falls back to on a
|
|
736
|
+
rendered slice (no `.read-line` in it).
|
|
737
|
+
|
|
738
|
+
## The peer exchange
|
|
739
|
+
|
|
740
|
+
A send to a paired peer (claude-peer's `claude_send`, codex-peer's) and the peer's answer, linked in the owner's
|
|
741
|
+
conversation ([bundles.md](../bundles.md#the-claude-peer-bundle), In the web). The data is the server's: `GET
|
|
742
|
+
/api/sessions/:id/peers` (owner only, read from the session's files: `PeerExchanges.joined` over
|
|
743
|
+
`peer_exchanges.jsonl`, the peers from its pushed sources) gives each peer's last exchanges, newest first, with their
|
|
744
|
+
`state` (waiting, answered, none_expected, failed) and an answer's `serial` and `verdict`; a send row carries the
|
|
745
|
+
send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `label`, `re`, `summary`, `serial`,
|
|
746
|
+
`verdict`, `agreed`). The page joins and parses nothing.
|
|
747
|
+
|
|
748
|
+
- `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
|
|
749
|
+
of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
|
|
750
|
+
none): its own closure holds the last read for the open session (`createLatest`: an older read, or one for a
|
|
751
|
+
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
|
|
752
|
+
session has a peer (a context row with `peer`, a drawn send or answer), so a session without one makes no request.
|
|
753
|
+
Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
|
|
754
|
+
`context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
|
|
755
|
+
focus, and a 60 s tick while an exchange waits; a `turn_completed` redraws without a fetch (`touch()`) (one interval, cleared with the session: `forgetSession` →
|
|
756
|
+
`peerLinks.reset()`). The peer chips read the same model: its `onChange` also calls `contextChips.peersChanged()`, and
|
|
757
|
+
the chips' own load (a session opened: `session_sync.js` empties the chips first, so the conversation's `hasPeer`
|
|
758
|
+
may find no peer yet) or a peer new among their rows calls `peers.refresh()`.
|
|
759
|
+
- `peer_exchange.js` (pure): `peerRef(row)`, `stateText` (long and the phone's short words, both drawn; CSS picks),
|
|
760
|
+
`pillTemplate` (a button with ↓ once answered, a span otherwise; its title the row's output text).
|
|
761
|
+
- `peer_note.js`: `peerNoteTemplate`, which `turn_html.js noteBubbleTemplate` draws a note with `peer` as. It keeps
|
|
762
|
+
what an opening note has (`bubble note`, `turn-start`, `data-opening-id`, the time title), so `TURN_PROMPT`,
|
|
763
|
+
`card_stamps.js`, `stage_handoff.js OPENING`, `reload_check.js` and `revise_stack.js` (its `.note-text` is the
|
|
764
|
+
summary) read it as any wake note.
|
|
765
|
+
- **The slot idiom.** Finished rows are never drawn again and a reload makes them anew, so what arrives later is
|
|
766
|
+
drawn into empty slots the templates leave: a send row's `<span class="peer-slot" data-peer-ref>` after its params
|
|
767
|
+
(`turn_html.js toolRowInnerTemplate`; the row's output line isn't drawn on a send that didn't fail, its text the
|
|
768
|
+
slot's title), an answer's ↑ (`.peer-up-slot`) and "Read the full answer" (`.peer-full-slot`), each marked
|
|
769
|
+
`data-peer-slot`, which `history_shape.js` leaves out (an offscreen reload has no model). `peer_links.js` is the
|
|
770
|
+
controller: on the model's `onChange` and after each session draw it renders, with lit, the pill into every slot in
|
|
771
|
+
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
|
|
772
|
+
sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
|
|
773
|
+
(`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
|
|
774
|
+
the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
|
|
775
|
+
answer" into the last answer of each source only. Its one delegated click handler on the turn roots does the jumps,
|
|
776
|
+
buttons, never an `href` (the page routes by its hash): ↓ `revealInHistory` + `scrollIntoView` on the answer; ↑
|
|
777
|
+
`refs.js showRow` on the last row of that id before the answer (its `ref:reveal` opens a folded step or the stage's
|
|
778
|
+
cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js showText(name)`,
|
|
779
|
+
which opens that source's chip popover on its text in a task of its own (the click's way to the document would close
|
|
780
|
+
it); a peer's outbox opens its peer chip.
|
|
781
|
+
- `peer_chip.js` (pure): a paired peer in the session bar. `peerGroups(rows)` splits GET …/context's rows into the
|
|
782
|
+
peers (rows with `peer` and `leg`, per peer `{key: "peer:<name>", name, label, inbox, outbox}`; a muted leg stays in
|
|
783
|
+
its group but counts as absent; a group with no live leg isn't drawn) and the ordinary rows. `peerChipModel` is the
|
|
784
|
+
chip, the first state that applies: answers only (no inbox), can't send (the newest send `failed`, and the inbox not pushed since: pairing again pushes it, so its row's
|
|
785
|
+
`fetched_at` past the failed send's time ends it, `cantSend`), waiting (the
|
|
786
|
+
newest validate/question `waiting`, its age the send's), answered (the outbox unread, with the dot), paired. A peer
|
|
787
|
+
the read doesn't name, an older chi web or a send not in the list is never "can't send": only the server's `failed`
|
|
788
|
+
is. `peerPopoverTemplate` is its popover (scene 2 of the design): the two ways, the last 8 sends with
|
|
789
|
+
`exchangeState`'s words, View latest answer, Status card (`peerStatusCommand`: `/<name>` when the session lists it)
|
|
790
|
+
and Unpair. `context_chips.js` draws it: its chips are keyed (`data-name`: a source's name, a peer's
|
|
791
|
+
`peer:<name>`), peer chips first; an open popover stays while its key is among the drawn chips; View latest answer
|
|
792
|
+
reads the outbox, Unpair confirms once and detaches the outbox, then the inbox (a leg that fails names itself in a toast and stops
|
|
793
|
+
it, so a half unpair never reads "answers only"); after a detach or Unpair that took the focused chip, focus goes to
|
|
794
|
+
the strip's first chip, else the composer (`focusAway`); an
|
|
795
|
+
exchange row is a button only when its send's row is drawn (`peerLinks.hasSend`) and jumps there
|
|
796
|
+
(`peerLinks.showSend`) after closing the popover. Under 600 px the peer popover is a bottom sheet (`sheetPlace`);
|
|
797
|
+
ordinary chips' popovers stay at their chip.
|
|
798
|
+
|
|
678
799
|
## Stale answers
|
|
679
800
|
|
|
680
801
|
The page switches sessions, reopens a popover or asks again while a fetch is out. An answer for the old ask must be
|
|
@@ -685,7 +806,7 @@ dropped. **`latest.js`** is the guard:
|
|
|
685
806
|
- `createLatest(get)`: `begin()` gives a guard that also goes stale when a newer ask begins; `drop()` makes every
|
|
686
807
|
ask out stale (a close, a reset). For a list that is re-read.
|
|
687
808
|
|
|
688
|
-
On it: `context_chips.js`, `project_picker.js`, `participants_panel.js` (`load`), `cards_place.js`
|
|
809
|
+
On it: `context_chips.js`, `peer_data.js`, `project_picker.js`, `participants_panel.js` (`load`), `cards_place.js`
|
|
689
810
|
(`refreshCardBodies`), `stream_handlers.js` (`answer_display`), `working_set_view.js` (`fetchServer`), `ws_peek.js` and `ws_reader.js` (an item's timeline), the
|
|
690
811
|
turn-end re-reads (`session_view.js` `readTurnEnd`, app.js's `refreshTimingFromSession`, `mergeTurnTiming`) and app.js's init-row timers. Still by hand
|
|
691
812
|
(the id decides more than "drop it"): `session_sync.js` `resync`/`retryResync` (the re-read budget, `resyncAgain`), the stream's
|
|
@@ -729,7 +850,7 @@ reach another device or the server.
|
|
|
729
850
|
| `chi_strip_hidden` (`chi_zen`: the old name, read once) | `strip_hidden.js` | the session strip hidden |
|
|
730
851
|
| `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 |
|
|
731
852
|
| `chi_working_set_collapsed:<session>` | `working_set_rail.js` (through `session_prefs.js`) | the session's working set rail collapsed |
|
|
732
|
-
| `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 |
|
|
853
|
+
| `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) |
|
|
733
854
|
| `chi_markdown_tip_dismissed` | `markdown_tip.js` | the markdown tip dismissed |
|
|
734
855
|
| `chi_update_available_shown` | `version_notices.js` | update notices already shown |
|
|
735
856
|
| `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 |
|
|
@@ -927,7 +932,7 @@ A bundle's settings are config.yml's, for every session. A setting a session may
|
|
|
927
932
|
say) is one the manifest lists in `session_settings:`; `chi --set BUNDLE.KEY=VALUE` and `chi send --new --set …`
|
|
928
933
|
(which also take a few core keys, `--set recap.enabled=false`: see
|
|
929
934
|
[Per-session settings](configuration.md#per-session-settings)) then give it to a new session, saved with it (a respawn, a fork and a continued link keep it; a delegate child
|
|
930
|
-
doesn't). chi refuses a bundle that isn't installed (or whose plugin doesn't load) and a key the manifest doesn't
|
|
935
|
+
doesn't). chi refuses a bundle that isn't installed (or that needs a newer chi, or whose plugin doesn't load) and a key the manifest doesn't
|
|
931
936
|
list, so a typo isn't saved. A manifest that types a key (`session_settings: {cap: number}`: `number`, which
|
|
932
937
|
takes off too, `boolean`, `string`, or `any`) gets only a value of that type: `--set my-bundle.cap=five` is refused,
|
|
933
938
|
exit 2, as a key it doesn't list is (a mapping needs a chi newer than 0.91.0). Values are typed simply: an integer (`3`, `-1`) or a decimal (`2.5`, `.5`, `1e1`)
|
|
@@ -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
|
|
@@ -1678,7 +1685,11 @@ A plugin is Ruby code that runs inside chi with your permissions.
|
|
|
1678
1685
|
gem.
|
|
1679
1686
|
|
|
1680
1687
|
- The sha256 is an integrity check, not proof of who wrote the file. A file
|
|
1681
|
-
edited after install is not loaded until you reinstall the bundle
|
|
1688
|
+
edited after install is not loaded until you reinstall the bundle: the plugin,
|
|
1689
|
+
a rule or a script that isn't recorded, is missing or changed is refused in one
|
|
1690
|
+
wording, checked in that order (`bundle NAME's plugin/plugin.rb differs from
|
|
1691
|
+
the installed one (reinstall the bundle)`), and `chi bundle status NAME` shows
|
|
1692
|
+
the plugin `[unrecorded]`, `[missing]` or `[modified]`. A
|
|
1682
1693
|
`--dev` install skips that check for its own bundle: its files are the
|
|
1683
1694
|
source directory's, and an edit loads at the next start.
|
|
1684
1695
|
- Install only copies the file (`--dev` links it). The code first runs at the
|
data/docs/sessions.md
CHANGED
|
@@ -110,7 +110,7 @@ chi sessions clean --dry-run --days 7 # test sessions older than 7 da
|
|
|
110
110
|
- `Session.list` / `SessionManager.list_sessions` / `GET /api/sessions?sort=&order=&limit=&offset=` default to `updated_at desc` (newest activity first). Also supports `created_at`, `asc`. `X-Total-Count` header when paginated.
|
|
111
111
|
- Web UI (`chi web`): the page's scope is in its URL. Started in a project (a git repository or a `chi project init` folder), `chi web` opens `/?dir=<that folder>`: that project's sessions, and new sessions start in that folder; the header chip says `<project> · all`, and `all` opens the same place as `?scope=all` (every session; a new session there starts in chi web's start folder, shown on the start page, and cards name their folder; `← <project>` goes back to the project view it came from, or to the start folder's project). A bare `/` (the LAN link, the Home Screen app) is the start folder's project too: the folder chi web runs in, or `web.start_dir` / `chi web --start-dir DIR`; outside a project (no repository or marked folder) it shows every session. A pushed notification opens its session in that session's own project (`/?dir=<its project>#/s/<id>`; `?scope=all` outside a project). One server serves every project: a second `chi web` (from another repo) finds it through `GET /api/info` and prints (with `--open`, opens) its page for its own folder instead of starting another. The 3 latest sessions sit above the chat, and the grip on the chat's top edge — the same thin handle as the composer's, its twin — puts them away and brings them back: a drag up (or a click, or Enter/Space on it) hides them, a drag down (or a click) shows them again, and the choice is remembered. A hidden strip leaves its status in the top bar (`N sessions · ● 1 live · ● 1 waiting`, from the cards), and a click on that pill opens All sessions, without showing the strip first; there the pill shows whatever the strip's state, pressed, and a click on it goes back to the chat (as Esc does). In a window under 900 px wide, where the strip scrolls sideways, the grip stays under it, outside the scroller; a window under 700 px tall hides the strip by itself, so a question or approval card in the stage keeps room, and the grip shows it until the window is tall again. A parent and its delegates are one card there: its `▸ 2 delegates · 1 live · 1 waiting` chip (the waiting part in the attention colour, the card's border too; just `▸ 2 delegates` while the rows are open: they carry the marks then) opens their rows in a popover under it (a row per delegate at any depth, indented; a click opens that one, Esc or a click outside closes it, and the strip's order holds while it is open). A fork is a card of its own, and so is a delegate whose parent isn't listed (archived, another project), with its `↳ <parent>` chip; the pill counts cards, and every live or waiting session. "All sessions" (or `/`) opens every session at `#/sessions`; its header is the top bar's right end: a search over preview, id and status, the count, an `archived` toggle and Select (on a phone a row of its own under the bar). Esc or the pressed pill returns; where the sessions are stored is a faint line under the list. A card is its title on one line (an untitled session reads `Untitled` over its first message), a line under it (its recap, else its first message) and its meta row, with one mark per state and no status dot: a waiting card has its warn outline and its `question` (or `approval`…) chip, an errored one an `error` badge, a session a worker runs the `live` badge (not on a waiting card: waiting means a worker), and idle, completed and stopped ones are unmarked; a family's and a chain's rows the same. There a parent's card holds its delegates the same way, the chip opening their rows inside the card (each with an archive button on hover), open by itself while one of them waits on you; the count says `14 · 7 delegates` (`3 / 14` while a search narrows it), a search that matches a delegate shows its parent's card with the list open and the matching rows marked, and select mode picks cards (archiving a parent takes its delegates). The open session is in the URL (`#/s/<id>`), so a reload or a copied link opens it again; the chi logo top left goes back to the empty start for a new session. The message box grows with its text; drag its top edge to keep it taller (double-click resets). A file in a tool row (a read, edit or write's title) and its diff lines are refs: hover one and click to open the current file in your editor at that line, on this machine only (`web.editor`; the browser's "always allow" for the page's port and VS Code's "allow opening local files" are asked once; see [Opening files from chi web](configuration.md#opening-files-from-chi-web)). So are an edit or write approval card's paths (at the first line the dry run changes) and its diff lines, before you approve, and the numbered lines of a read's output: `lines 40–60` under it opens the text as read, numbered, when the output is the file as-is (not the head/tail preview of a big file, an error or an image; no numbers after a cut). A `path:line` (or `path:line-line`) in an answer or a step's text is one too once the turn has ended, and after a reload, when it names a file a row or card on the page touched: the path under the session's folder, else the one touched file it ends with (a bare `app.js:12` when only one touched file is named so; two such files make it none); a path without a line counts only when it is a touched file exactly. Code blocks, links, bare URLs and inline code with more than the ref in it are left alone, and a file the session didn't touch is never linked; a link whose text is such a ref alone (github-pr's link to the PR diff) becomes a ref too, and its plain click still goes to the PR. A plugin's refs on an answer (an `after_turn` hook's, see [Refs on the answer](hooks.md#refs-on-the-answer-display-only)) are paired with its links and text whatever the rows touched: they can link a file the session didn't touch, or an issue or a commit, and add their own actions to the ref's menu. A plugin tool's row carries the refs its `refs:` gives (see [Refs on a tool's row](plugins.md#refs-on-a-tools-row)): its title opens the first, and its `▾` menu adds the others as `<ref> · <action>` (the URL on hover); their URL actions work on a phone too. A ref with more than one target shows a small `▾` on hover: it opens a menu of them, in order **PR diff** (a link's), **Open in editor**, **Show in turn** and **Copy path**, and a plain click runs the first (a link's own, else the editor, else show in turn). **Show in turn** scrolls to the tool row that touched the file (looked for in the ref's own step, then its own turn, then the rows before it, then the nearest after it; there, the last one showing the ref's line, else the last one), opens the steps, the stage's steps and the row's diff (or the read showing the line) and flashes the row and the line; an answer's or a step's ref and an approval card's path have it, not a row's own title or lines. It needs no editor, so a viewer without one (a phone on the LAN) gets an answer's refs with **Show in turn** as their click; a row's title and diff lines stay plain text there. On a touch screen a tap opens the menu. A ref with a target is a tab stop: Enter runs its first target, ↓ opens the menu (↑/↓ move, Enter picks, Esc closes back to the ref). Diff and read lines have their click only. The info bar's id copies the full session id on click ("Session id copied"), the id every CLI command takes (`chi --attach ID`, `chi send ID`). A session whose prompt carried model notes has a `notes: deepseek` chip there (the names without `model_notes_`; the tooltip lists each with its scope and size; `session.prompt_notes` in `GET /api/sessions/:id`, the live worker's, else the session file's; see [Memory](memory.md#model-notes)). Its ⚙ chip, after the model, holds the session's thinking level, reasoning history and LLM context: `⚙` alone while the session follows the model for all three, else `⚙` and what the session set, in the accent colour (`⚙ think low · ctx stale,forget`; a phone shows ⚙ with a dot; the tooltip gives each value and its source). Its panel is the start page's ⚙ panel for this session: a Thinking row (`/thinking`), on a chat host a Reasoning row (the reasoning history, `/reasoning-history`), and a Context row with its Apply and budget fields (`/llm-context`); a tap runs that row's command at once in the worker (one reply in the conversation, as a typed one) and changes that field alone, the Context row's `default` resets the strategy, apply rule and budget (`/llm-context reset`), and a tap while a turn runs is queued for after it (the panel's note says so). `GET /api/sessions/:id`'s `session.thinking`, `session.reasoning_history` (null on a native host) and `session.llm_context` carry the values (the live worker's, else resolved from the session file), and a `command_ran` that changed them carries the new ones. After ⚙, the 🧰 chip names the session's toolkit: `🧰` alone on the configured default (`toolkit.default`, `session.toolkit_default`), `🧰 lean` on another (see [Toolkits](configuration.md#toolkits); `/toolkit` changes it). A `/thinking` or `/reasoning-history` change typed in the composer that restarts the prompt cache asks first: the reply bubble has an **Apply (restarts the cache)** button that sends its `--yes` line (the ⚙ panel sends that line itself; see [Changes that restart the prompt cache](configuration.md#changes-that-restart-the-prompt-cache)). It shows the context used (`ctx 42%`) and the last generation's decode speed (`87 tok/s`, `~64 tok/s` when estimated; see `/stats` in [cli.md](cli.md#session-commands)); hovering `ctx` there or on a session card lists the session's tokens in (summed over every request, with the cached share), out (with reasoning) and the cost when the provider reports one, for this session only (one estimated from a `hosts.<name>.models` price shows with `~`: `cost: ~$0.54 ($0.42 reported, ~$0.12 estimated)`); after a `/model` switch the info bar's tooltip adds a `per model:` row per run of turns on one model above those totals (`splash:qwen3-35b · 6 turns · 96.0k in / 9.0k out · ~$0.02`, a switch's prefill under its row: `└ switch prefill 58.0k uncached prompt ≈$0.01`; the timing's `model_segments`, replaced by each `generation_completed`'s; the session cards stay as they were), and right after the switch its ctx % is the new model's window's; and the memory indexes its prompt holds (`memory index: ~3.4k tokens in this session's prompt (system 2.0k, project 1.4k)`; see [Memory](memory.md#the-indexs-size)). The start page's model picker (bottom left of the composer, the chosen name `▾`) chooses the model a new session starts on, and a fresh chain link's (see [Session chains](#session-chains); there a pick shows as a `/model` command bubble in the link); it opens a search list over the conversation (↓ or a click; downward when the start page leaves no room above): an empty search shows the last 5 picks (Recent) and then each host's model ids A–Z under the host, the default host first (an id the host declares under `hosts.<name>.models` first, noted `config`, its tooltip `served by config (hosts.<name>.models)`; a host that failed to list its models keeps those ids, greyed and noted `host down`, still pickable; a remembered or default model stays chosen even then, greyed on the button); typed words must each match the host or the id (a substring, else for 3+ characters the letters in order, so `deepseek4.1 fla` finds `openrouter · deepseek/deepseek-v4.1-flash`), ⏎ picks, Esc/Tab close, a pick puts the focus in the message box: `GET /api/models` lists the hosts' models as chi spells them (`{default, models: [{name, host, id, configured?, unavailable?, sampling?, llm_context?}], warning?}`; `configured: true` marks an id declared under `hosts.<name>.models`, listed first under its host, `unavailable: true` one whose host failed to list its models; `sampling` is the model's configured request parameters as `/model` words them, the row's tooltip in the list; bare for the default host, `host:model` for the others, from the same cached lists as `/models`, a bounded wait, a host that is down noted in `warning`; `toolkits`: `{default, suggest, kits: [{name, description?}]}`, the start page's 🧰 list: the configured `toolkit.default`, `suggest` `on` only when a new session's first message may get a suggested kit (`toolkit.suggest.mode: on`, a System 1 host, two described kits; else `audit` or `off`), and the built-in and config kits a new session can start on, without `child` or `undecided`, a kit `groups:` refuses or one that doesn't resolve (a base that is a bundle kit), the default always listed; left out when it can't be read), and `POST /api/sessions` takes `model` (blank means the default). Beside it, ⚙ opens the new session's rarely used settings (thinking and LLM context, following each `GET /api/models` row's `thinking` and `llm_context`, ; see [configuration.md](configuration.md#llm-context-a-sessions-own-strategy)), and 🧰 its toolkit: **Auto** (with `toolkit.suggest.mode: on`: the first message may get a suggested kit, else the default) or a kit from the payload's `toolkits`, sent as `POST /api/sessions`'s `toolkit` (see [configuration.md](configuration.md#toolkits)); a refused kit (`400 toolkit_refused`) is said in the list, opened again. What is set shows on the row as an accent chip (`think high`, `tools: lean`; a dot on ⚙ or 🧰 on a phone); each is for the next new session only, never remembered. The start page's first message goes as later ones do: `POST /api/sessions` with `idle: true` and `preview` (the message, which names the session until its turn is saved), then `POST /api/sessions/:id/turn`, so a failed first turn puts its prompt back in the composer too; a first line that is one of the new session's commands (`/model …`) goes to `POST /api/sessions/:id/command` instead, as later ones do. The browser remembers the last model picked; a running session's model is in the info bar and changes only with `/model`. In the composer a line is a command when it is `!…` or starts with one of the session's command names (its `commands` list; `/stats`, `/exit` and the other terminal words get the page's own reply); an unknown `/word` (`/usr/bin/env is missing`) goes to the model as a prompt, as in a terminal; a one-word `/word` no command answers (`/modle`) is not sent: the page shows `Unknown command /modle. Did you mean /model? /help lists the commands.` (the "Did you mean" part only when a name is close). A `POST /turn` (or a session's first `prompt`) that is one of the worker's commands runs as that command too (`202 {status, command_id, session_id}`), so `chi send`, `chi -p` and a page whose command list lags all get the command. ↑/↓ in the composer walk the prompt history the TUI's ↑ walks ([Persistent Prompt History](cli.md#persistent-prompt-history)): ↑ with the caret on the first line, ↓ from the last line while browsing, ↓ past the newest brings the draft back; `GET /api/history` returns `{entries: [...]}`, oldest first (the page fetches it on focus and after each send). The server records a sent line in the routes once the worker took it (`POST /turn` accepted, a `!command` through `POST /command` or as a session's first line); `"history": false` in the body keeps it out (an image-only send).
|
|
112
112
|
- Web notifications: when a session needs you while the tab is hidden or behind another window (a question or a guardrail approval, a plugin card with buttons during a turn such as check-in's, a failed turn, a turn done after 10 s or more; a delegated session only for its questions, a canceled turn never), the page title counts it, `(N) Chi`, until you come back to the tab. The bell at the right of the top bar also turns on OS notifications ("needs an answer", "needs approval", "needs you", "turn failed", "done in 42 s", under the session's first message; a click opens the session): its first click asks the browser for the permission, and the choice is kept per browser. Any session of the page's scope counts, not only the open one. What was already so when the page loaded never counts, and several chi tabs show one notification per event. A chi tab in front tells the others (a `BroadcastChannel`), so while you look at one, the ones behind neither notify nor count what it shows; coming back to a tab clears those events in the other tabs' titles too. The hub's `session` frames carry what this needs: `pending_question` (`{id, kind}`, kind `question` or `approval`), `pending_card` (`{id, bundle}`: the running turn's card with actions, from `pending_card.json` that the worker keeps in the session's folder while one is open; a card without actions, such as loop-guard's, never counts) and `last_turn` (`{outcome, ended_at, seconds, origin}`, saved in the session's JSON as the engine ends each turn).
|
|
113
|
-
- The web frontend is a zero-build ES-module stack in `lib/samagotchi/web/public/`: `data.js` (retrieval, typed SSE `openStream` for a session and `openEvents` for the session list), `sessions_list.js` (the list as a pure reducer over `GET /api/events`: a snapshot replaces it, an upsert keeps a known card in place, a removal drops it; `families()` groups delegates under their parent), `families_view.js` (a parent's family chip, its rows and the strip's popover; the chip and rows as lit-html templates), `keep_focus.js` (lit reuses a list's nodes by position: a redraw keeps the focus on the same item by its `data-id` / `data-name`), `chains.js` (session chains: the links from `continues`, the cards folded into the latest link's, its `#N` chip and rows as lit-html templates, the info bar's ← → links, a refused continue, and the fresh-link rule), `notify.js` (which of those events needs the user, for the notifications), `app.js` (presentation/state; a session with no live stream gets one when its `session` event says `bridge_up`, after one re-read: `event_seq` starts over in each worker, so a dropped stream is never resumed with its old cursor), `bubbles.js` (the history's bubbles between the turns' rows: output chunks, end lines, every client's prompt bubbles by `enqueued_id` with their queued/steered badges, the idle recap, guardrail warnings, hooks' notices, plugins' steers, command and note bubbles; lit-html templates, put in the history with the sticky follow by `createBubbles`), `cards_place.js` (where plugin cards and a snapshot's notices go in the history: a card added or updated in place by its id, a running turn's into its step, a snapshot's each above the first turn after it, a finished turn's notice in its step's rows and its question resolved where it was asked; a card's action buttons), `format.js` (pure formatters such as `previewOf`), `plain_line.js` (markdown out of the plain one-line places: the stage headline, a closed step's title, an answered question card's kept-reply line), `prompt_history.js` (the composer's ↑/↓ over the shared prompt history), `commands.js` (session commands: which composer lines are commands, the page's own replies, a `command_ran`'s bubble, the page's command bubbles kept across a re-read), `composer.js` (where a composer line goes, `routeComposerLine`: /cut and /queue, the start page's own replies, a session command or `!cmd`, a typo hint, else a turn; and a session command sent from the composer or a chip), `delivery_line.js` (the composer's row above the text field in a session, always there so the composer keeps its height (on a phone no row: the line lies over the session bar's left while a turn runs and you type or have a choice armed): the key hint while idle, and the delivery line while a turn runs: where a message typed now goes in, from the step's phase, clock and size, whether "cut in now" can land, and the queue link for a worker with the `delivery` feature, as a pure `deliveryLine`, its lit-html template and `createDeliveryControl`, which ticks it and keeps a choice armed from a link; see docs/cli.md, "Typing during a turn"), `restore.js` (a failed turn's prompt handed back into this tab's composer, before or after its `/turn` ack), `lists_view.js` (the session lists: the strip and its pill, all sessions with its search, count and select mode, their cards, the family and chain popovers; the cards, tile and pill as lit-html templates, drawn as new nodes each time, and the lists' orders as pure functions), `stream_handlers.js` (the open session's stream event handlers, by event type, over the page's views and hooks; a snapshot replays through them too), `stage_view.js` (the stage view: the running turn pinned above the composer, with Stop turn in its status row while it runs, then handed off into the history; its pure rules and texts in `stage_model.js`, its live slots (headline, now row, trail, ticks) in `stage_slots.js`, its cap and held height in `stage_frame.js`, the in-use watch that times the hand-off in `stage_watch.js`), `info_bar.js` (the session bar's info line as a lit-html template over a plain model, three groups with hairlines between them, on one line above a phone's width (the folder gives way first): the setup (id, status, model, the ⚙ and 🧰 chips, notes, the memory or working-set chip), the relations (chain links, the parent as `↑ <id>`, delegates, participants; only when there is one) and the telemetry (folder, ctx, speed, the session's time, worker badge)), `settings_chip.js` (the session bar's ⚙ chip and its panel over `settings_panel.js`: a tap runs that row's command, one field), `toolkit_chip.js` (the session bar's 🧰 chip: the kit against `toolkit.default`), `info_bar_model.js` (that model and the bar's buttons' states, built from the page's session state, its list and its in-flight continues and restarts (the restarting set is `version_notices.js`'s) as pure functions; `app.js`'s `updateInfoBar` applies them every second while a turn runs), `session_state.js` (what the page knows about the open session: its empty state, and `sessionStateFrom`, the fields a `GET /sessions/:id` payload sets), `refs.js` (refs: a kind and a target on the element, a plugin's ref data (label, http(s) URL actions) bound in a WeakMap by `bindRef`, the targets per kind, show in turn, one delegated set of click, key and hover listeners), `ref_menu.js` (a ref's `▾` and its menu), `ref_scan.js` (the `path:line` refs in an answer's or a step's text that name a file the session's rows touched), `answer_refs.js` (the refs a plugin attached to an answer, its `display_refs`: bound to the answer's bubble, paired with its links and text, bound with `bindRef`), `markdown_place.js` (where rendered markdown and its refs go: a text as markdown HTML, its `path:line` refs, a final answer's rendering), `images.js` (image chips in the composer: paste, drop and the image button, the upload before a turn, the thumbnails
|
|
113
|
+
- The web frontend is a zero-build ES-module stack in `lib/samagotchi/web/public/`: `data.js` (retrieval, typed SSE `openStream` for a session and `openEvents` for the session list), `sessions_list.js` (the list as a pure reducer over `GET /api/events`: a snapshot replaces it, an upsert keeps a known card in place, a removal drops it; `families()` groups delegates under their parent), `families_view.js` (a parent's family chip, its rows and the strip's popover; the chip and rows as lit-html templates), `keep_focus.js` (lit reuses a list's nodes by position: a redraw keeps the focus on the same item by its `data-id` / `data-name`), `chains.js` (session chains: the links from `continues`, the cards folded into the latest link's, its `#N` chip and rows as lit-html templates, the info bar's ← → links, a refused continue, and the fresh-link rule), `notify.js` (which of those events needs the user, for the notifications), `app.js` (presentation/state; a session with no live stream gets one when its `session` event says `bridge_up`, after one re-read: `event_seq` starts over in each worker, so a dropped stream is never resumed with its old cursor), `bubbles.js` (the history's bubbles between the turns' rows: output chunks, end lines, every client's prompt bubbles by `enqueued_id` with their queued/steered badges, the idle recap, guardrail warnings, hooks' notices, plugins' steers, command and note bubbles; lit-html templates, put in the history with the sticky follow by `createBubbles`), `cards_place.js` (where plugin cards and a snapshot's notices go in the history: a card added or updated in place by its id, a running turn's into its step, a snapshot's each above the first turn after it, a finished turn's notice in its step's rows and its question resolved where it was asked; a card's action buttons), `format.js` (pure formatters such as `previewOf`), `plain_line.js` (markdown out of the plain one-line places: the stage headline, a closed step's title, an answered question card's kept-reply line), `prompt_history.js` (the composer's ↑/↓ over the shared prompt history), `commands.js` (session commands: which composer lines are commands, the page's own replies, a `command_ran`'s bubble, the page's command bubbles kept across a re-read), `composer.js` (where a composer line goes, `routeComposerLine`: /cut and /queue, the start page's own replies, a session command or `!cmd`, a typo hint, else a turn; and a session command sent from the composer or a chip), `delivery_line.js` (the composer's row above the text field in a session, always there so the composer keeps its height (on a phone no row: the line lies over the session bar's left while a turn runs and you type or have a choice armed): the key hint while idle, and the delivery line while a turn runs: where a message typed now goes in, from the step's phase, clock and size, whether "cut in now" can land, and the queue link for a worker with the `delivery` feature, as a pure `deliveryLine`, its lit-html template and `createDeliveryControl`, which ticks it and keeps a choice armed from a link; see docs/cli.md, "Typing during a turn"), `restore.js` (a failed turn's prompt handed back into this tab's composer, before or after its `/turn` ack), `lists_view.js` (the session lists: the strip and its pill, all sessions with its search, count and select mode, their cards, the family and chain popovers; the cards, tile and pill as lit-html templates, drawn as new nodes each time, and the lists' orders as pure functions), `stream_handlers.js` (the open session's stream event handlers, by event type, over the page's views and hooks; a snapshot replays through them too), `stage_view.js` (the stage view: the running turn pinned above the composer, with Stop turn in its status row while it runs, then handed off into the history; its pure rules and texts in `stage_model.js`, its live slots (headline, now row, trail, ticks) in `stage_slots.js`, its cap and held height in `stage_frame.js`, the in-use watch that times the hand-off in `stage_watch.js`), `info_bar.js` (the session bar's info line as a lit-html template over a plain model, three groups with hairlines between them, on one line above a phone's width (the folder gives way first): the setup (id, status, model, the ⚙ and 🧰 chips, notes, the memory or working-set chip), the relations (chain links, the parent as `↑ <id>`, delegates, participants; only when there is one) and the telemetry (folder, ctx, speed, the session's time, worker badge)), `settings_chip.js` (the session bar's ⚙ chip and its panel over `settings_panel.js`: a tap runs that row's command, one field), `toolkit_chip.js` (the session bar's 🧰 chip: the kit against `toolkit.default`), `info_bar_model.js` (that model and the bar's buttons' states, built from the page's session state, its list and its in-flight continues and restarts (the restarting set is `version_notices.js`'s) as pure functions; `app.js`'s `updateInfoBar` applies them every second while a turn runs), `session_state.js` (what the page knows about the open session: its empty state, and `sessionStateFrom`, the fields a `GET /sessions/:id` payload sets), `refs.js` (refs: a kind and a target on the element, a plugin's ref data (label, http(s) URL actions) bound in a WeakMap by `bindRef`, the targets per kind, show in turn, one delegated set of click, key and hover listeners), `ref_menu.js` (a ref's `▾` and its menu), `ref_scan.js` (the `path:line` refs in an answer's or a step's text that name a file the session's rows touched), `answer_refs.js` (the refs a plugin attached to an answer, its `display_refs`: bound to the answer's bubble, paired with its links and text, bound with `bindRef`), `markdown_place.js` (where rendered markdown and its refs go: a text as markdown HTML, its `path:line` refs, a final answer's rendering), `images.js` (image chips in the composer: paste, drop and the image button, the upload before a turn, the thumbnails; a click on one opens it in `picture_viewer.js`), `composer_grip.js` (the composer's grip and fold: the drag, tap and keys, the fold per visit), `composer_mount.js` (the composer mounted on a page's markup: the message box and its height, the image chips from a paste, a drop or the image button, the grip and fold, ↑/↓ over the prompt history and the keys; the page's own parts come in as hooks: what Enter and Send do, keys taken first, Esc, where the history comes from, the info bar's drop while folded, typing anywhere to open it; its styles, the card it sits in (`.composer-card`, its footer and its line above the text field) included, are the shared `composer.css`, linked after `tokens.css` by `index.html`), `strip_grip.js` (the latest-sessions strip's grip, the composer grip's twin: hides and shows the strip), `strip_hidden.js` (the strip hidden or shown: the saved choice, the short window's own hide, the grip and the body's class), `storage.js` (the page's per-browser choices in localStorage, guarded: a choice that can't be read or written is not remembered), `unqueue.js` (the × on a message queued for after the turn: takes it back, its text into an empty composer or a toast), `toasts.js` (the page's toast stack: a timer each, sticky ones until acted on, the same text reusing its item), `toast_place.js` (where the toast sits: above the composer card, the stage and an open model panel), `dock_reserve.js` (what floats over the history: the history's bottom reserve (`--dock-h`) at the composer card's and the showing stage's height, a reader at the end kept there, and the toast's place measured for `toast_place.js`), `notice_links.js` (a hook notice line's http(s) URLs as links), `start_page.js` (the start page's model picker, its ⚙ panel's and 🧰 list's choices for the next new session only and their override chips; a fresh chain link's picker and its `/model`), `start_settings.js` (the start page's ⚙ panel: thinking and LLM context as rows of segments, applied at once, the Apply and budget disclosure; the override chips' words and ⚙'s dot), `settings_panel.js` (the panel's rows as lit-html templates, shared: the segments, the disclosure, a hidden row's sent-anyway line; the caller passes its rows and applies the picks), `start_toolkit.js` (the start page's 🧰 list: Auto with suggest on, the kits, the default marked; a pick closes it; its override chip and dot), `session_actions.js` (Continue, Archive and its Undo, Delete and Stop, and the start page when the open session is gone), `send_turn.js` (the composer's send: a new session first on the start page, the route, the echo, the image upload, the `/turn` ack, a fast failure's restore and each error's place). Unit-tested via `npm test` (`spec/web/public/*.test.js`).
|
|
114
114
|
- Selecting a session in the web UI is read-only: `GET /api/sessions/:id` never spawns a worker (it reads a live worker's snapshot when one runs, else the session file). A prompt (`POST /turn`) or a command (`POST /command`) wakes the worker, and `/stream` briefly waits for a freshly-spawned bridge before answering. A caught-up SSE reconnect holds the stream open; `reset` markers are only sent for reconnects behind the ring window, or with a cursor from another worker (event ids are `<event_seq>-<epoch>`, one epoch per worker).
|
|
115
115
|
- The web session page's message box folds away for room to read. Drag the grip on its top edge (the pill that shows on hover; always on a phone) down, past the box by 32 px: the pill turns accent while releasing would hide it, and on release the box folds and the info bar stays as the page's bottom edge. The grip stays as a handle on the info bar's top edge, drawn always: pull it up (8 px opens it, and the box follows the pointer in the same gesture), click or tap it (opens it and focuses the box), or just type on the page (the key lands in the box) to bring it back; Enter or Space on the focused grip folds or opens too. A draft (text or images, which folding never clears) colours the handle with the accent, a session waiting on you with the attention colour; its tooltip says so. Stop turn isn't the message box's: it sits in the running turn's stage, at the right edge of its status row beside the fold caret (collapsed stage or not), while the turn runs, and goes when the turn ends A turn the page knows runs but has nothing of to draw (a reload whose session payload carries no current turn) shows that status row alone, `running` and Stop turn. The fold is each session's own, remembered per browser (`chi_composer_collapsed:<session>`: folding one session's box leaves the others' as they were), an archived session opens folded for the visit, and opening it there, like the page opening it itself (a restored line, a quote, continue →'s opener), is for that visit only. The fold keeps the height the grip set, also the session's own (`chi_composer_floor:<session>`; the start page's lasts until a reload): the box opens again at the height it had, and only a double-click on the grip forgets it. That height never takes more than half of the window the box is drawn in: a floor saved in a bigger window is held to that half in a smaller one (a rotated phone, a resized window, another device on the same origin), and the saved floor itself stays, so the height comes back when the room does. A click on the expanded grip hides the box as well: it folds 250 ms after the press, so a second click inside that window is read as a double-click and resets the height instead (a drag, Enter or Space act at once, and a drag after a click takes the wait back). The start page's grip only resizes.
|
|
116
116
|
|
data/docs/testing.md
CHANGED
|
@@ -124,7 +124,7 @@ its case.
|
|
|
124
124
|
The web specs run in plain node. One that loads lit-html, itself or through a module it imports (`turn_block.js`,
|
|
125
125
|
`turn_html.js`, `card.js`, `copy.js`, `images.js`, `scope.js`, `command_view.js`, `diff_view.js`, `read_view.js`,
|
|
126
126
|
`question_cards.js`, `stream_handlers.js`, `stage_view.js`, `bubbles.js`, `cards_place.js`, the chips, `info_bar.js`, `info_bar_model.js`, `lists_view.js`, `context_chips.js`, `families_view.js`,
|
|
127
|
-
`chains.js`, `working_set_view.js`, `working_set_rail.js`, `unqueue.js`, `toasts.js`, `notice_links.js`, `start_page.js`, `start_settings.js`, `settings_panel.js`, `start_toolkit.js`, `session_actions.js`, `send_turn.js`, `composer_mount.js`, `dock_reserve.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`,
|
|
127
|
+
`chains.js`, `working_set_view.js`, `working_set_rail.js`, `ws_markdown.js`, `unqueue.js`, `toasts.js`, `notice_links.js`, `start_page.js`, `start_settings.js`, `settings_panel.js`, `start_toolkit.js`, `session_actions.js`, `send_turn.js`, `composer_mount.js`, `dock_reserve.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`,
|
|
128
128
|
`vendor/lit-html.js`) needs a DOM: `import "./dom_shim.js";` as its first import (happy-dom, a devDependency only,
|
|
129
129
|
never shipped; lit reads `document` as it loads). The shim's `markupOf(template)`,
|
|
130
130
|
`htmlOf(nodes)` and `canon(html)` compare markup without lit's marker comments; the DOM writes text with only `&`, `<`, `>`
|
|
@@ -308,6 +308,10 @@ group and also answers them as module calls (`SpecWaiting.pop!`, for a stubbed l
|
|
|
308
308
|
- `time_bound(seconds, below: nil)`: a wall-clock upper bound, scaled and kept under `below:` (rule 5).
|
|
309
309
|
- `eventually(timeout: 5) { expect(…) }` (spec only) retries until the expectations hold, then re-raises the last
|
|
310
310
|
failure prefixed `still failing after 5 s:`, so the matcher's own expected/got is in the message.
|
|
311
|
+
- `gone_soon?(pid, group: false, timeout: 2)` (spec only): "stopped" after a stop returned, a pid (or with
|
|
312
|
+
`group: true` its group) gone within 2 s. Never an immediate `kill(0)`: a stopped process can answer it for a
|
|
313
|
+
moment (on Linux a dying process drops its `flock` before it is reaped, and `Leftovers.stop_group` returns on the
|
|
314
|
+
log's release).
|
|
311
315
|
|
|
312
316
|
One formatter builds the failure text of `wait_for`, `join!` (which adds "to finish") and `pop!`:
|
|
313
317
|
|
|
@@ -36,7 +36,8 @@ module Samagotchi
|
|
|
36
36
|
# Languages core draws itself: a bundle's renderer for one would be a
|
|
37
37
|
# second drawer for the same block.
|
|
38
38
|
RESERVED = [InlineWidgets::LANG].freeze
|
|
39
|
-
#
|
|
39
|
+
# What .renderers and .too_new? have logged in this process: [bundle,
|
|
40
|
+
# problem] pairs, and [bundle, version, refusal] for a bundle too new.
|
|
40
41
|
WARNED = Set.new
|
|
41
42
|
WARNED_LOCK = Mutex.new
|
|
42
43
|
|
|
@@ -77,12 +78,13 @@ module Samagotchi
|
|
|
77
78
|
|
|
78
79
|
# What the installed bundles draw: the first bundle by name wins a
|
|
79
80
|
# language. A bundle whose requires_chi this chi doesn't meet, or whose list
|
|
80
|
-
# doesn't parse
|
|
81
|
+
# doesn't parse, is skipped (each logged once); a record that doesn't read
|
|
82
|
+
# lists none.
|
|
81
83
|
# @return [Array<Installed>]
|
|
82
84
|
def for_installed
|
|
83
85
|
taken = {}
|
|
84
86
|
InstalledBundles.standings do |standing|
|
|
85
|
-
next if
|
|
87
|
+
next if too_new?(standing)
|
|
86
88
|
|
|
87
89
|
bundle = standing.name
|
|
88
90
|
renderers(bundle, standing.record.manifest).each do |renderer|
|
|
@@ -109,6 +111,23 @@ module Samagotchi
|
|
|
109
111
|
File.join(installed.scripts_dir, file)
|
|
110
112
|
end
|
|
111
113
|
|
|
114
|
+
# A bundle this chi is too old for (the verdict's :too_new) draws
|
|
115
|
+
# nothing: skip it, and say so once per process per bundle and version,
|
|
116
|
+
# only when it declares renderers (as ContextProviders.too_new? does).
|
|
117
|
+
# @param standing [InstalledBundles::Standing]
|
|
118
|
+
def too_new?(standing)
|
|
119
|
+
return false unless standing.too_new?
|
|
120
|
+
|
|
121
|
+
manifest = standing.record.manifest
|
|
122
|
+
if manifest.block_renderers? &&
|
|
123
|
+
WARNED_LOCK.synchronize { WARNED.add?([standing.name, manifest.version.to_s, standing.refusal.text]) }
|
|
124
|
+
Log.warn(:web, "block_renderers_too_new", bundle: standing.name, version: manifest.version.to_s,
|
|
125
|
+
requires_chi: manifest.requires_chi.to_s, msg: standing.refusal.text)
|
|
126
|
+
end
|
|
127
|
+
true
|
|
128
|
+
end
|
|
129
|
+
private_class_method :too_new?
|
|
130
|
+
|
|
112
131
|
# Its parsed renderers; a kept list that doesn't parse is the record's
|
|
113
132
|
# mirror, else none. Logged once per bundle and problem: this runs on each
|
|
114
133
|
# list request and each renderer file fetch.
|
|
@@ -109,6 +109,10 @@ module Samagotchi
|
|
|
109
109
|
STATUS_HELP = "Usage: chi bundle status [<bundle>]"
|
|
110
110
|
DIFF_HELP = "Usage: chi bundle diff <bundle> [file]"
|
|
111
111
|
LIST_HELP = "Usage: chi bundle list"
|
|
112
|
+
# What `chi bundle status NAME` says after a plugin's state
|
|
113
|
+
# (MemoryBundle::Status.plugin_status) that keeps it from loading.
|
|
114
|
+
PLUGIN_NOTES = { "modified" => " (edited after install: not loaded; reinstall the bundle)",
|
|
115
|
+
"unrecorded" => " (no sha256 recorded: not loaded; reinstall the bundle)" }.freeze
|
|
112
116
|
|
|
113
117
|
# The subcommands' flags: --help only; a word not starting with -- is
|
|
114
118
|
# a positional (install's source, -h included). --scope takes whatever
|
|
@@ -584,7 +588,7 @@ module Samagotchi
|
|
|
584
588
|
print_assets("Rules", st.rules, " (edited after install: not loaded; reinstall the bundle)")
|
|
585
589
|
print_assets("Scripts", st.scripts, " (edited after install: the next install replaces it, a copy kept in the trash)")
|
|
586
590
|
if (plugin = st.plugin)
|
|
587
|
-
note = plugin[:state]
|
|
591
|
+
note = PLUGIN_NOTES.fetch(plugin[:state], "")
|
|
588
592
|
@stdout.puts " Plugin: #{plugin[:file]} [#{plugin[:state]}]#{note}"
|
|
589
593
|
@stdout.puts " requires_chi: #{plugin[:requires_chi]}" if plugin[:requires_chi]
|
|
590
594
|
@stdout.puts " not loaded: #{plugin[:requires_failure]}" if plugin[:requires_failure]
|
|
@@ -622,7 +626,10 @@ module Samagotchi
|
|
|
622
626
|
return if states.empty?
|
|
623
627
|
|
|
624
628
|
@stdout.puts " #{heading} (#{states.size}):"
|
|
625
|
-
states.each
|
|
629
|
+
states.each do |file, state|
|
|
630
|
+
note = state == "unrecorded" ? PLUGIN_NOTES.fetch(state) : (modified if state == "modified")
|
|
631
|
+
@stdout.puts " #{file} [#{state}]#{note}"
|
|
632
|
+
end
|
|
626
633
|
end
|
|
627
634
|
|
|
628
635
|
# "Manifest: [kept]", or "[from the install record]", and what its case
|
|
@@ -66,7 +66,7 @@ module Samagotchi
|
|
|
66
66
|
def self.entry_markers(scope, path:, bundles_dir:)
|
|
67
67
|
InstalledBundles.standings(dir: bundles_dir).each_with_object({}) do |standing, acc|
|
|
68
68
|
bundle = standing.record
|
|
69
|
-
# A bundle too new for this chi keeps its markers: its memories are read
|
|
69
|
+
# A bundle too new for this chi keeps its markers: its memories are read.
|
|
70
70
|
next if standing.unreadable? || bundle.effective_scope != scope.to_s
|
|
71
71
|
|
|
72
72
|
needs = bundle.manifest.needs
|
|
@@ -14,7 +14,8 @@ module Samagotchi
|
|
|
14
14
|
# value's type a manifest's settings: rules out. A config file only warns:
|
|
15
15
|
# the rest of it still runs, and `chi --set` is what refuses
|
|
16
16
|
# (SessionConfig.check!, in the same words). A manifest with no settings:
|
|
17
|
-
# (a record from before them too) has its keys left alone
|
|
17
|
+
# (a record from before them too) has its keys left alone; one this chi is
|
|
18
|
+
# too old for (requires_chi) gets one line saying why. A digest of the
|
|
18
19
|
# lines last shown is stamped in $XDG_STATE_HOME/samagotchi/bundles_warned.
|
|
19
20
|
module BundleSettingsCheck
|
|
20
21
|
STAMP_FILE = "bundles_warned"
|
|
@@ -30,8 +31,10 @@ module Samagotchi
|
|
|
30
31
|
section.flat_map do |name, values|
|
|
31
32
|
standing = installed[name]
|
|
32
33
|
next ["config.yml bundles: #{name}: #{SessionConfig.no_installed_bundle(name)}#{near(name, installed.keys)}"] unless standing
|
|
33
|
-
# A bundle too new for this chi is still checked (the plan's D1).
|
|
34
34
|
next [] if standing.unreadable?
|
|
35
|
+
# One this chi is too old for isn't used: its keys aren't checked
|
|
36
|
+
# against a manifest this chi may not read right.
|
|
37
|
+
next ["config.yml bundles: #{name}: #{SessionConfig.unusable(name, standing.refusal.text)}"] if standing.too_new?
|
|
35
38
|
|
|
36
39
|
record_warnings(standing.record.manifest, values)
|
|
37
40
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: known-names
|
|
3
|
-
version: 0.2.
|
|
3
|
+
version: 0.2.1
|
|
4
4
|
requires_chi: ">= 0.150.0"
|
|
5
5
|
scope: system
|
|
6
6
|
description: Catches a near-miss of a protected name (home folder, login, git name, repo name, names from config) in a tool call and rejects it with the right spelling; mode ask / correct optional
|
|
@@ -9,6 +9,6 @@ files:
|
|
|
9
9
|
known_names.md: sha256:d5348b95b6c655017b541910b36e384220da280818160201f6ec9a50e1e4287c
|
|
10
10
|
plugin:
|
|
11
11
|
file: plugin.rb
|
|
12
|
-
sha256: sha256:
|
|
12
|
+
sha256: sha256:f519ec42023a6857f87fba9ff8a8db5d261dccfd88e3a9b58310ae3293b3cbdc
|
|
13
13
|
# config.yml bundles: known-names: (another key warns; an older chi ignores this)
|
|
14
14
|
settings: [names, ignore, mode, derive, min_length, max_distance]
|