samagotchi 0.195.0 → 0.196.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 +41 -1
- data/docs/architecture.md +2 -1
- data/docs/bundle-authoring.md +23 -23
- data/docs/bundles.md +11 -3
- data/docs/cli.md +4 -0
- data/docs/context.md +13 -3
- data/docs/guardrails.md +6 -4
- data/docs/hooks.md +3 -1
- data/docs/internals/block-renderers.md +4 -1
- data/docs/internals/engine.md +2 -1
- data/docs/internals/knowledge.md +15 -5
- data/docs/internals/participants.md +15 -3
- data/docs/internals/peers.md +12 -8
- data/docs/internals/session-lifecycle.md +26 -12
- data/docs/internals/web-frontend.md +64 -27
- data/docs/pages.md +1 -1
- data/docs/peers.md +1 -1
- data/docs/plugins.md +73 -3
- data/docs/sessions.md +1 -1
- data/docs/system-one.md +3 -1
- data/lib/samagotchi/bundle_manifest.rb +30 -5
- data/lib/samagotchi/bundles/core/manifest.yml +2 -2
- data/lib/samagotchi/bundles/cost-cap/manifest.yml +4 -4
- data/lib/samagotchi/bundles/cost-cap/plugin.rb +54 -3
- data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/manifest.yml +4 -2
- data/lib/samagotchi/bundles/knowledge/chi_adapters.rb +43 -25
- data/lib/samagotchi/bundles/knowledge/manifest.yml +6 -4
- data/lib/samagotchi/bundles/knowledge/plugin.rb +37 -18
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/context_change.rb +44 -0
- data/lib/samagotchi/context_note.rb +1 -1
- data/lib/samagotchi/context_providers.rb +14 -0
- data/lib/samagotchi/context_sources.rb +3 -25
- data/lib/samagotchi/engine/plugins.rb +21 -0
- data/lib/samagotchi/events.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +12 -4
- data/lib/samagotchi/guardrails/targets.rb +24 -2
- data/lib/samagotchi/installed_bundles/manifest.rb +7 -1
- data/lib/samagotchi/memory_bundle/builder.rb +2 -1
- data/lib/samagotchi/memory_bundle/installed_copy.rb +2 -1
- data/lib/samagotchi/participants.rb +17 -6
- data/lib/samagotchi/peer_exchanges.rb +1 -2
- data/lib/samagotchi/peer_note.rb +38 -5
- data/lib/samagotchi/peer_presence.rb +20 -7
- data/lib/samagotchi/plugin/api.rb +5 -1
- data/lib/samagotchi/plugin/chips.rb +125 -0
- data/lib/samagotchi/plugin/context.rb +19 -1
- data/lib/samagotchi/plugin/peer_pairing.rb +2 -2
- data/lib/samagotchi/plugin/peer_start.rb +1 -1
- data/lib/samagotchi/plugin/peers.rb +5 -2
- data/lib/samagotchi/plugin/tool_spec.rb +19 -9
- data/lib/samagotchi/schedules.rb +8 -2
- data/lib/samagotchi/session_access/local.rb +34 -33
- data/lib/samagotchi/session_chain/sharing.rb +79 -0
- data/lib/samagotchi/session_chain/successor.rb +4 -2
- data/lib/samagotchi/session_chips.rb +133 -0
- data/lib/samagotchi/session_inbox_delivery.rb +11 -11
- data/lib/samagotchi/session_manager/emptiness.rb +4 -1
- data/lib/samagotchi/session_observer.rb +1 -1
- data/lib/samagotchi/session_stats.rb +5 -4
- data/lib/samagotchi/session_stores.rb +3 -0
- data/lib/samagotchi/speaker.rb +228 -0
- data/lib/samagotchi/steer.rb +36 -132
- data/lib/samagotchi/testing/bundle.rb +5 -0
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +10 -0
- data/lib/samagotchi/tools/registry.rb +8 -3
- data/lib/samagotchi/turn_excerpts.rb +8 -4
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +21 -10
- data/lib/samagotchi/web/participant_view.rb +1 -1
- data/lib/samagotchi/web/peer_routes.rb +5 -2
- data/lib/samagotchi/web/plugin_chip_rows.rb +39 -0
- data/lib/samagotchi/web/public/agent_rows.js +1 -0
- data/lib/samagotchi/web/public/app.js +17 -25
- data/lib/samagotchi/web/public/chains.js +0 -26
- data/lib/samagotchi/web/public/command_list.js +2 -3
- data/lib/samagotchi/web/public/composer.js +2 -3
- data/lib/samagotchi/web/public/composer_mount.js +3 -6
- data/lib/samagotchi/web/public/context_chips.js +240 -93
- data/lib/samagotchi/web/public/context_groups.js +84 -0
- data/lib/samagotchi/web/public/draft_follow.js +33 -0
- data/lib/samagotchi/web/public/drafts.js +26 -22
- data/lib/samagotchi/web/public/index.html +32 -0
- data/lib/samagotchi/web/public/peer_chip_kind.js +49 -0
- data/lib/samagotchi/web/public/peer_note.js +2 -2
- data/lib/samagotchi/web/public/peer_row.js +10 -5
- data/lib/samagotchi/web/public/peer_wait.js +4 -2
- data/lib/samagotchi/web/public/plugin_chip.js +55 -0
- data/lib/samagotchi/web/public/plugin_chip_kind.js +48 -0
- data/lib/samagotchi/web/public/send_turn.js +8 -21
- data/lib/samagotchi/web/public/session_actions.js +10 -23
- data/lib/samagotchi/web/public/session_view.js +7 -3
- data/lib/samagotchi/web/public/stream_handlers.js +2 -0
- metadata +12 -1
|
@@ -14,7 +14,7 @@ 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`): 1547, its size once the composer's writes went into `drafts.js` and continue →'s draft guess went; down from 1577, its size once the views by hash went into `views.js` and the pages' wiring landed; itself down from 1637, its size once the diagrams' wiring went into `diagram_wiring.js`, itself down from 1638,
|
|
17
|
+
`app.js` (`samagotchi/app-size`): 1540, its size once the composer-drafts shims for an older cached `session_actions.js` went; down from 1547, its size once the composer's writes went into `drafts.js` and continue →'s draft guess went; down from 1577, its size once the views by hash went into `views.js` and the pages' wiring landed; itself down from 1637, its size once the diagrams' wiring went into `diagram_wiring.js`, itself down from 1638,
|
|
18
18
|
its size once the lightbox went into `picture_viewer.js`, itself down from 1649, its
|
|
19
19
|
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
|
|
20
20
|
Verify, the composer's mode and the strip's hide went into modules of their own. A new feature goes into a module of
|
|
@@ -42,7 +42,7 @@ answers and notes: The notes rows and the run line, below; it imports only names
|
|
|
42
42
|
and `quiet_notes.js` exported, and `quiet_notes.js installQuietNotes` stays for an older cached `app.js`), `details_motion.js`,
|
|
43
43
|
`turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
|
|
44
44
|
`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` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while a view owns the URL (`keepSessionHash`), a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js` (its `showPending` calls the injected `keepSessionHash`, following `views.js`'s rule not to write the session hash while a view owns the URL), `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_part_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`, `peer_text.js`, `peer_row.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), `peer_wait.js` (the chip of a peer
|
|
45
|
-
the session waits for, its popover and Cancel: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `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), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `served_ref.js`
|
|
45
|
+
the session waits for, its popover and Cancel: The peer exchange), `peer_chip_kind.js` (the peer chips as a kind of the context chips: The peer exchange), `plugin_chip.js` and `plugin_chip_kind.js` (a bundle's own chip, its card and buttons, and its kind: The peer exchange, the plugin chips), `context_groups.js` (a bundle's sources folded into one chip: its rows, chip and list, pure: The peer exchange, the source kind), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `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), `drafts.js` (the composer's drafts: The drafts, below), `draft_follow.js` (a continue made elsewhere: the drafts to hand over, pure), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `served_ref.js`
|
|
46
46
|
(`isServedRef`, which the stream's `generation_completed` reads, beside a `modelServed` already set, for a served
|
|
47
47
|
model's `modelServed`), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) 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).
|
|
48
48
|
|
|
@@ -946,7 +946,8 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
946
946
|
the chips' own load (a session opened) calls `peers.refresh({ reuse: true })`. A pairing made from the peer's side
|
|
947
947
|
sends the page nothing: the chip appears at the next read (a focus, a peer note, a send).
|
|
948
948
|
- `peer_wait.js` (pure): `waitingChipModel` ("Claude · waiting 8 min", state `awaiting`, apart from a send's
|
|
949
|
-
`waiting
|
|
949
|
+
`waiting`; the app it names is the row's `app`, the wait mark's, else `APPS`, the fallback for an older worker's
|
|
950
|
+
wait, gone in the release after next, else the label), `waitingPopoverTemplate` (the wait, the minutes left, Cancel: `context_chips.js cancelWait`, the
|
|
950
951
|
Unpair route with no confirm), `waitMinutesLeft`. `peer_chip.js peerGroups` admits a row with `paired_at` or
|
|
951
952
|
`waiting`; a waited-for one is drawn by these.
|
|
952
953
|
- `peer_mailbox_api.js` (state): `getPeerMessage(id, name, serial)` (a message's text: View latest answer, a
|
|
@@ -968,8 +969,10 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
968
969
|
in `#history`, short too, starts closed as one row before its bubble, `<name> <verdict> <summary> N lines` in a plain
|
|
969
970
|
panel box with no chevron (`.answer-fold.peer`; the verdict in the text colour whatever it says). `peer_row.js`
|
|
970
971
|
(pure) gives the words: the verdict as `verdictWord`'s lower-case word, none without one; the summary the peer sent
|
|
971
|
-
without the verdict mark it wrote into it (`
|
|
972
|
-
|
|
972
|
+
without the verdict mark it wrote into it: the server's (`PeerNote.said`, the payload's `said`, on the bubble as
|
|
973
|
+
`data-peer-said`), else, for a note saved before `said` or an older worker's, `summaryWithoutVerdict` (its port's
|
|
974
|
+
twin: the last `VERDICT X` when X is the server's verdict, the punctuation it leaves tidied; both run
|
|
975
|
+
`spec/fixtures/peer_said_cases.json`; it goes two releases on), else (`.note-text` marked `data-fallback` by `peer_note.js`) the first
|
|
973
976
|
line of the peer's text; N the lines of the peer's own text (`.peer-text`'s `data-peer-md`), never the bubble's copy
|
|
974
977
|
text, and no length without a body. A tap opens the bubble under the same line (the box's top edge; the bubble's
|
|
975
978
|
`.under-row` class drops its own head, verdict and summary, which the row says, keeping the ↑ to the send), a
|
|
@@ -1005,7 +1008,7 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
1005
1008
|
`refs.js showRow` on the last row of that id before the answer (its `ref:reveal` opens a folded step or the stage's
|
|
1006
1009
|
cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js
|
|
1007
1010
|
showMessage(name, serial)` for a mailbox message (its peer chip's popover on that message's text) or
|
|
1008
|
-
`showText(source)` for an older answer (that source's own chip), in a task of its own (the click's way to the
|
|
1011
|
+
`showText(source)` for an older answer (that source's own chip, or its group's chip on it), in a task of its own (the click's way to the
|
|
1009
1012
|
document would close it).
|
|
1010
1013
|
- `peer_chip.js` (pure): a paired peer in the session bar. `peerGroups(peers)` gives one group per peer of the
|
|
1011
1014
|
model that is paired (`paired_at`; an unpaired one keeps its messages but has no chip): `{key: "peer:<name>", name,
|
|
@@ -1018,14 +1021,53 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
1018
1021
|
is its popover (scene 2 of the design): where chi sends (the address), how it answers, the last 8 exchanges (sends,
|
|
1019
1022
|
and messages no send claims as `#N · summary`) with `exchangeState`'s words and the answer's receipt words, View
|
|
1020
1023
|
latest answer, Status card (`peerStatusCommand`: `/<name>` when the session lists it) and Unpair.
|
|
1021
|
-
`context_chips.js` draws it: its chips are keyed (`data-name`: a source's name, a
|
|
1022
|
-
|
|
1024
|
+
`context_chips.js` draws it: its chips are keyed (`data-name`: a source's name, a group's `group:<provider>`, a
|
|
1025
|
+
peer's `peer:<name>`), peer chips first. The controller asks its **chip kinds** and never branches on peer or source:
|
|
1026
|
+
a kind gives its chips (the strip is the kinds' chips joined end to end: peer, source, then plugin), `owns(key)`, its
|
|
1027
|
+
`popover(key, {text, now, member})`, `label(key, {member})` (the popover's `aria-label`), `shape` (`{width, sheet,
|
|
1028
|
+
className}`: 440, a bottom sheet under `SHEET_MAX` and `peer-pop` for a peer; 380 for a source), `readText(key,
|
|
1029
|
+
{serial, box, member})` (what "view text" reads and a failure toast's name), `onLoad` (a session's open: the peers
|
|
1030
|
+
read with `reuse`), `ticks` (whether the minute's tick redraws: the source kind while it has rows, the peer kind
|
|
1031
|
+
while it has chips, so a waiting peer counts down with no source) and `keyFor` (the key `showText`/`showMessage`
|
|
1032
|
+
open), and may give `hasMember(key, name)` and `standsFor(key)` (below); a model that changed calls the
|
|
1033
|
+
controller's `changed(kind)` (`peersChanged`). The source kind is in `context_chips.js` (unexported); the peer kind
|
|
1034
|
+
is `peer_chip_kind.js` (`createPeerChipKind`, a wrapper over `peer_chip.js` and `peer_wait.js`, with `peerOf(key)`
|
|
1035
|
+
for Unpair, Cancel and Status card). **The source kind's groups** (`context_groups.js`, inside the source kind, so a
|
|
1036
|
+
group sits at its first source's place among the lone ones; kinds are only joined end to end): two or more unmuted
|
|
1037
|
+
rows of one `provider` whose bundle has a label (the row's `group`, its manifest's `context_group:`) are one chip,
|
|
1038
|
+
`groupChipModel` ("PRs 3 · 2m": the count in `.ctx-count`, the newest fetch's age, the worst state, the dot when any
|
|
1039
|
+
is unread); a lone source, or one with no bundle or label, keeps its chip. The controller holds the open
|
|
1040
|
+
**member** (`openMember`, null: the group's list, `groupListTemplate`): a row (`data-act="member"`) shows that
|
|
1041
|
+
source's `popoverTemplate` with `back` (`data-act="back"`), focus on back or on the member's row again; view text
|
|
1042
|
+
and detach act on the member (`rowAt(key, member)`); `follow` puts a member that left back on the list, and a group
|
|
1043
|
+
that fell under two closes as any chip that went. `standsFor` maps a key no longer drawn to the chip that stands for
|
|
1044
|
+
it (a lone source that joined a group: the group; a group down to one: that source), so the focus follows it on a
|
|
1045
|
+
redraw and on close. A popover click that redraws its own target (`ownClick`, as `chip_popover.js` has it) isn't a
|
|
1046
|
+
click outside. The group has no action of its own. The actions stay in the controller; a source is grouped only by
|
|
1047
|
+
its bundle's label (a `claude-outbox` source is an ordinary chip); an open popover stays while its
|
|
1023
1048
|
key is among the drawn chips; View latest answer reads the newest message (`api.message`), Unpair confirms once,
|
|
1024
1049
|
`DELETE`s the pairing and reads the peers again (the chip goes; a failure names itself in a toast); after a detach
|
|
1025
1050
|
or Unpair that took the focused chip, focus goes to the strip's first chip, else the composer (`focusAway`); an
|
|
1026
1051
|
exchange row is a button only when its send's row is drawn (`peerLinks.hasSend`) and jumps there
|
|
1027
1052
|
(`peerLinks.showSend`) after closing the popover. Under 600 px the peer popover is a bottom sheet (`sheetPlace`);
|
|
1028
1053
|
ordinary chips' popovers stay at their chip.
|
|
1054
|
+
- **The plugin chips** (a bundle's own, `ctx.chips`): the third kind, after the peer and source kinds,
|
|
1055
|
+
`plugin_chip_kind.js` (`createPluginChipKind`) over the pure `plugin_chip.js` (`pluginChipModel`,
|
|
1056
|
+
`pluginPopoverTemplate`, `pluginChipOpens`). Every kind gets the `GET …/context` read through `onRead(data)`
|
|
1057
|
+
(the source kind keeps `data.sources`, the plugin kind `data.chips`; an older chi web's answer has none) and
|
|
1058
|
+
`reset()` on a session's open or close and a failed read: the controller holds no rows of its own. A chip is keyed
|
|
1059
|
+
`chip:<bundle>/<name>`, drawn with core's `ok`/`warn`/`error` class (`.ctx-chip.warn`, kept when open) and the
|
|
1060
|
+
dot; with an `at` its label ends ` · 3m` and the kind `ticks`. A chip with no `body_html` and no actions has
|
|
1061
|
+
`opens: false`: `chipsTemplate` gives it no `aria-haspopup`, and a tap only closes another popover. Its card is
|
|
1062
|
+
the name, the bundle, the server's `body_html` (`unsafeHTML`, as `card.js` does a card's; the first paragraph in the
|
|
1063
|
+
text colour, the rest muted) and the actions through `card_actions.js` (`cardActions`, `cardActionUrl`; own class
|
|
1064
|
+
names `.ctx-plugin-*`, never `.card-action`). A kind may take its own `data-act`s (`act(name, target, {close})`,
|
|
1065
|
+
asked before the controller's): a command button (`plugin-command`) closes the card and calls `api.command(id,
|
|
1066
|
+
line)`, app.js's `sendCommand(id, line, {clientId, card: true})` then `followWokenWorker`, as `cards_place.js
|
|
1067
|
+
onCardAction` sends a card's (so the reply shows as a bubble, the line isn't echoed as typed, and no cache-confirm
|
|
1068
|
+
asks); a failure is a toast. The stream's `chips_updated` calls `contextChips.refresh()`: one `GET …/context` per
|
|
1069
|
+
change per open tab, and an open card follows its chip in place. A lost event (a stream `reset`) leaves the strip
|
|
1070
|
+
as it was until the next event or the window's focus.
|
|
1029
1071
|
|
|
1030
1072
|
## The drafts
|
|
1031
1073
|
|
|
@@ -1049,9 +1091,7 @@ one painted (`setChips(list, {revoke: false})`, `fit()`, the ↑/↓ browsing re
|
|
|
1049
1091
|
(the grip's draft class and the fit see the new text), so `select` and `clearSelection` (+ new) both swap; app.js
|
|
1050
1092
|
calls it once at boot, before `selectFromHash()`, which always paints (over a value the browser may have restored) and
|
|
1051
1093
|
covers a page opened at `/` (the Home Screen app's start URL), where nothing selects. A chip's preview URL is freed on
|
|
1052
|
-
its ×, at its send (`chipsAfterSend`) or when its draft is dropped, never on a swap.
|
|
1053
|
-
calls no `show`: the drafts see the shown key differ from the painted one and take the box as that window's draft
|
|
1054
|
-
(today's one box), painting a kept draft only over an empty box.
|
|
1094
|
+
its ×, at its send (`chipsAfterSend`) or when its draft is dropped, never on a swap.
|
|
1055
1095
|
|
|
1056
1096
|
**Saved in this browser**: the text, on every write and every input event (`syncFromView`, the box's input listener;
|
|
1057
1097
|
no save on leave, nor on `pagehide`: `store.selected` is already the next id by `forgetSession`, and iOS gives no
|
|
@@ -1079,8 +1119,19 @@ which session is open, `handOverDraft(id, next, created)` = `drafts.handOver(A,
|
|
|
1079
1119
|
with text or chips moves whole to the new link (A's saved copy gone), an empty one leaves the link the opener. On
|
|
1080
1120
|
another session at the answer: the toast's Open, that session's draft untouched; still on A (or back on it): `await
|
|
1081
1121
|
select(next)`, then `revealDraft()` (the composer opens, the box takes the focus, the caret at the end). There is no
|
|
1082
|
-
Restore draft
|
|
1083
|
-
|
|
1122
|
+
Restore draft or guess of where a draft came from (the old source and opener-fill rule, gone).
|
|
1123
|
+
A 409 `continued` hands the draft to the link that continues it only into an empty draft of its own, no opener.
|
|
1124
|
+
A continue made elsewhere (a terminal `/continue`, a chain schedule, `chi send --new --continues`, another tab; a send
|
|
1125
|
+
has no `continued` path) hands the draft over the same way, without an opener: app.js `followContinuedDrafts` at the
|
|
1126
|
+
end of the hub's `snapshot` and `session` handlers and at a leave (`session_view.js forgetSession`, after the swap),
|
|
1127
|
+
`draft_follow.js continuedDrafts` naming each continued session with a draft and its chain's newest listed link; never
|
|
1128
|
+
the session on view (its box is not emptied under the user) nor one this tab's Continue → is taking (`continuing`).
|
|
1129
|
+
It hands over through `drafts.follow`, which first reads the session's text from storage again when this tab hasn't
|
|
1130
|
+
changed it since it last read it (a background tab holds the text as it was when it saw it; another tab may have typed
|
|
1131
|
+
on, or moved it already: storage empty, nothing moves). Several tabs may each run it: the first moves the stored text,
|
|
1132
|
+
the others find nothing stored, or the next link's draft, and stop. Images live only in the tab that added them: a
|
|
1133
|
+
hand-over into a link that already holds the session's very text (another tab moved it first, also before this tab's
|
|
1134
|
+
own Continue → lands) moves this tab's images there too and empties the session's draft (`drafts.handOver`).
|
|
1084
1135
|
Chips moved from A go up again to A' at its send (`images.js uploadChips`, by `chip.session`).
|
|
1085
1136
|
|
|
1086
1137
|
**Swept** with the view settings (`COMPOSER_DRAFT` is in `PREF_KEYS`): only an unscoped list, ids missing from it,
|
|
@@ -1098,20 +1149,6 @@ The sweep now deletes draft **text**, not only view settings: another chi web on
|
|
|
1098
1149
|
port with another state dir, a smoke run on 4567) lists other sessions, and its page's first load sweeps this
|
|
1099
1150
|
browser's drafts of the sessions it doesn't know.
|
|
1100
1151
|
|
|
1101
|
-
**A mixed cache**: `send_turn.js` and `composer.js` take an older app.js's bag (`el`, `chips()`, `setChips(list)`,
|
|
1102
|
-
`clear()`: the one box) as well as this one's, and app.js still passes those members for an older cached
|
|
1103
|
-
`send_turn.js` (`drafts_mixed_cache.test.js` loads 0.191.0's from `spec/web/public/fixtures/v0.191.0/`); its `select`
|
|
1104
|
-
dep moves the start page's draft to a created session too (an older `send_turn.js` doesn't). The mount's `onWrite`, a
|
|
1105
|
-
no-argument `afterPick` and send_turn's `noteDraft` are an older module's way to say it wrote the box itself: app.js
|
|
1106
|
-
wires them to `syncFromView`. Beside an older app.js, this mount gets no `setText` (↑/↓ recall nothing until a reload),
|
|
1107
|
-
this command list's `afterPick` writes nothing (a Tab pick does nothing), and `unqueue.js` gets no `putBackTo` (today's
|
|
1108
|
-
toasts). An older cached `composer_mount.js` ignores `{revoke: false}`: a swap frees the chips' previews (broken
|
|
1109
|
-
thumbnails until a reload; the upload still works). An older `session_prefs.js` doesn't sweep the drafts until a
|
|
1110
|
-
reload. app.js still passes `fillOpener` (a shim: the hand-over and the reveal, returning no displaced draft) and a
|
|
1111
|
-
no-op `restoreDraft` for an older cached `session_actions.js`, which calls `fillOpener` after its select (without it
|
|
1112
|
-
its continue would toast "Can't continue" though it succeeded); `chains.js openerFill` and `restoredComposer` stay
|
|
1113
|
-
exported, unused, until after the next release.
|
|
1114
|
-
|
|
1115
1152
|
## Stale answers
|
|
1116
1153
|
|
|
1117
1154
|
The page switches sessions, reopens a popover or asks again while a fetch is out. An answer for the old ask must be
|
data/docs/pages.md
CHANGED
|
@@ -148,7 +148,7 @@ uses them (the reflect bundle's) settles.
|
|
|
148
148
|
dropped), `unpaired`, `unreadable`. An excerpt has `session_id`, `turn_id`, `started_at`, `status`, `failure` (a
|
|
149
149
|
failed turn's line), `calls` (at most 8: `tool`, `target` for a `call_tool`'s `<server>/<tool>`, `status` `error`
|
|
150
150
|
or `blocked`, `args` cut at 200 characters, `result` cut at 300), `paired`, and `prompt` / `answer` (the turn's
|
|
151
|
-
opening message and last answer, cut at 300; nil unless `include_text: true`). Every field has key shapes
|
|
151
|
+
opening message and last answer, cut at 300; nil unless `include_text: true`; a participant's turn has neither, and no `calls`). Every field has key shapes
|
|
152
152
|
redacted and your home as `~`, and all of them together stay within about 4k tokens (14,000 characters), filled
|
|
153
153
|
in the order given. A turn whose calls can't be matched to its messages exactly (a continue turn, a raw-prompt
|
|
154
154
|
batch) is `paired: false`: its calls with tool and status only, never a guess.
|
data/docs/peers.md
CHANGED
|
@@ -148,7 +148,7 @@ lost: it is a note, and the user's next message lets chi read it. The skills say
|
|
|
148
148
|
A say is refused, with nothing written, for: no such session; a session being deleted; a continued one whose live
|
|
149
149
|
link isn't paired (a chain an older chi continued: `this session was continued as <id>: say it there`, naming that
|
|
150
150
|
link); one being continued right now (`this session is being continued as
|
|
151
|
-
<id>: say it again in a moment`: its new link
|
|
151
|
+
<id>: say it again in a moment`: its new link saved or not); one busy with another change (`this session is busy
|
|
152
152
|
with another change; try again in a moment`); not paired (`not paired: run the pair script`); an older worker
|
|
153
153
|
(`restart the session`); 200 messages chi hasn't read yet.
|
|
154
154
|
|
data/docs/plugins.md
CHANGED
|
@@ -303,6 +303,7 @@ run by `call_tool` as the tool itself ([the chi group](#chitool_sourcecall-acts_
|
|
|
303
303
|
- `refs`: `->(args) { [{ kind:, target:, label:, actions: [] }, …] }`, what the call's row traces to in the web
|
|
304
304
|
(display only, the model never sees them). See [Refs on a tool's row](#refs-on-a-tools-row).
|
|
305
305
|
- `declare`: `:always` or `:kit`, which toolkits declare it (below); omitted, a kit's list decides, as for a built-in.
|
|
306
|
+
- `participant`: `:deny` keeps it for the owner: a participant's turn is refused it (below); default `:allow`.
|
|
306
307
|
|
|
307
308
|
The block returns the result text. If it starts with `Error:`, it counts as
|
|
308
309
|
a failure. If it raises, the model gets `Error: <message>`. To return images
|
|
@@ -329,6 +330,20 @@ too, see [Returning images](#returning-images).
|
|
|
329
330
|
- `declare:` needs a chi newer than 0.194.0: an older chi refuses the keyword, a load error, so a bundle passing it
|
|
330
331
|
sets `requires_chi` past that (`chi bundle check` warns on a lower one).
|
|
331
332
|
|
|
333
|
+
#### `participant:`: the owner's only
|
|
334
|
+
|
|
335
|
+
`participant: :deny` keeps a tool for the session's owner: a [participant's](cli.md#participants) pair turn that
|
|
336
|
+
calls it, by its name or through `call_tool` (`chi/<name>`), is refused by the pair boundary
|
|
337
|
+
(`PairBoundary::BUNDLE_OWNER`, [guardrails](guardrails.md#a-participants-pair-boundary)) before any path or command
|
|
338
|
+
check and before any ask: the owner is never asked about a call that is refused anyway, and the handler never runs.
|
|
339
|
+
The default, `:allow`, leaves the call to the boundary's checks as before (one whose `targets:` name no command or
|
|
340
|
+
path asks the owner). It is per tool, not per argument: a rule on a call's arguments (a participant may search, but
|
|
341
|
+
not a named catalog, say) stays in the handler, with `ctx.turn_author`. Anything else (`"deny"` too) is a load error
|
|
342
|
+
(`tool x: participant must be :allow or :deny`). A changed `participant:` in `chi.replace_tools` takes effect from
|
|
343
|
+
the next call without building the prompts again (it never reaches them). A handler that runs another bundle tool
|
|
344
|
+
itself, not through a tool call, goes around the boundary: that is the bundle's to check. It needs a chi newer than
|
|
345
|
+
0.195.0: an older chi refuses the keyword, a load error, so a bundle passing it sets `requires_chi` past that.
|
|
346
|
+
|
|
332
347
|
#### `args`
|
|
333
348
|
|
|
334
349
|
`args` is a frozen Hash with **string keys**: the arguments the model gave,
|
|
@@ -967,6 +982,7 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
967
982
|
| `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 |
|
|
968
983
|
| `ctx.log` | `ctx.log.info(:event, key: value)`: debug-log records tagged `plugins`, with `bundle=<bundle>` |
|
|
969
984
|
| `ctx.messages` | the conversation, as a frozen copy, without the system prompt. While a turn runs, a session worker's (attached, web) adds that turn so far: its prompt, the model's text and the lines merged into it (no tool calls or thinking); a `--non-interactive` one-shot's is the conversation before that turn. An entry may carry `at`, when it happened (docs/sessions.md, Message times) |
|
|
985
|
+
| `ctx.speaker(message)` | who wrote a message of `ctx.messages` or `ctx.sessions.read`: `:owner`, `:participant`, `:chi` (a note, a reminder, a `!cmd` line), `:sender` (an agent, a parent, `chi send`), `:plugin`, `:model` or `:tool`; nil for a non-Hash. Read it rather than the message's keys, which stay chi's own. Needs the next chi (guard it with `ctx.respond_to?(:speaker)`) |
|
|
970
986
|
| `ctx.last_answer` | the newest answer's text as the user saw it: the newest answer bubble of `ctx.messages`, its thoughts (one cut off before it closed too) and tool-call markup taken out, the rule chi's continue note uses. nil when there is none or it was a thought alone; mid-turn, a worker's can be the running turn's interim text. Needs chi newer than 0.153.0 |
|
|
971
987
|
| `ctx.messages_partial?` | whether `ctx.messages` leaves out a running turn (a `--non-interactive` one-shot mid-turn), so a plugin can say what its answer is about |
|
|
972
988
|
| `ctx.prompt_files` | the files whose text is in the session's system prompt now: the AGENTS.md chain (the work tree top down to the cwd) and the appended files (`append_system_prompt:`, `--append-system-prompt`); absolute paths, in prompt order, `[]` before the first build |
|
|
@@ -984,6 +1000,7 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
984
1000
|
| `ctx.judge(name, state:)`, `ctx.judge_later(name, state:) { |result| … }`, `ctx.judgments` | a cheap System 1 question this bundle declared, saved as a run: see [Judgments](#judgments-chijudgment-and-ctxjudge) |
|
|
985
1001
|
| `ctx.sign_in(title:, button:, timeout: 300, port: nil, path: "/callback", cancel: nil) { \|redirect_uri\| address }` | send the owner to an address and get back where the browser was sent: see [Sign-in](#sign-in-ctxsign_in) |
|
|
986
1002
|
| `ctx.secrets` | the bundle's tokens, kept apart from its data files (`get`, `set`, `delete`, `update`): see [Secrets](#secrets-ctxsecrets) |
|
|
1003
|
+
| `ctx.chips` | the bundle's own chips in chi web's session bar (`set`, `remove`, `list`): see [Chips](#chips-ctxchips) |
|
|
987
1004
|
| `ctx.http` | an HTTP client for calling services (`get`, `post_json`, `request`, `stream`): see [Calling services](#calling-services-ctxhttp) |
|
|
988
1005
|
| `ctx.sessions` | fork, send to, read, list and stop other sessions: see [Other sessions](#other-sessions-ctxsessions) |
|
|
989
1006
|
| `ctx.toolkit` | the name of the session's toolkit (`full` for a session from before toolkits); nil with no session |
|
|
@@ -1122,6 +1139,48 @@ in_turn:}` (`source` is the bundle; each action `{label:, command:}` or
|
|
|
1122
1139
|
`{label:, url:}`), plus `command:` when a session command
|
|
1123
1140
|
showed it (`"/short"`), logged as `card` with its source, id and title.
|
|
1124
1141
|
|
|
1142
|
+
## Chips: `ctx.chips`
|
|
1143
|
+
|
|
1144
|
+
A bundle can draw a chip of its own in chi web's session bar, after the peer chips and the attached sources: a short
|
|
1145
|
+
label for something that holds for the whole session (cost-cap's `cap · $4.10 of $5.00`). A tap opens a small card
|
|
1146
|
+
with the bundle's text and up to four buttons, in a card's shape. The chips are stored with the session, so chi web
|
|
1147
|
+
shows them when no worker runs, and they stay until the bundle removes them.
|
|
1148
|
+
|
|
1149
|
+
```ruby
|
|
1150
|
+
ctx.chips.set("cap", label: "cap · $4.10 of $5.00", state: :warn,
|
|
1151
|
+
title: "cost-cap: 82% of this session's cap",
|
|
1152
|
+
body: "This session has used **$4.10** of its **$5.00** cap.",
|
|
1153
|
+
actions: [{ label: "Raise to $10", command: "/cap 10", primary: true },
|
|
1154
|
+
{ label: "Turn the cap off", command: "/cap off" }])
|
|
1155
|
+
ctx.chips.remove("cap") # => true when there was one
|
|
1156
|
+
ctx.chips.list # => this bundle's chips by name: {label:, state:, dot:, title:, at:, body:, actions:, set_at:}
|
|
1157
|
+
```
|
|
1158
|
+
|
|
1159
|
+
- The name follows a source name's rules (lowercase letters, digits and `-`, at most 40). A chip is its bundle's: a
|
|
1160
|
+
bundle sees and changes only its own, at most 3 (a 4th `set` raises `ArgumentError`).
|
|
1161
|
+
- `label:` is required: one line, cut at 40 characters. `state:` is `:ok` (the default), `:warn` or `:error`, core's
|
|
1162
|
+
three looks: a bundle brings no colours or styles of its own. `dot: true` adds a dot. `title:` is the tooltip.
|
|
1163
|
+
`at:` (a Time or an ISO 8601 string) draws an age after the label (`· 3m`) that ticks every minute, so a chip that
|
|
1164
|
+
stops being updated shows how old it is.
|
|
1165
|
+
- `body:` is markdown, as a card's. `actions:` are a card's actions (a `command:` or an http(s) `url:`, `primary:`
|
|
1166
|
+
drawn solid), at most 4. A command runs as a card's button runs it: its reply shows in the conversation, the line
|
|
1167
|
+
isn't echoed as typed, and it never asks for the cache. A url opens in a new tab, its host named under the buttons.
|
|
1168
|
+
A chip with no body and no actions opens nothing: it is a label only.
|
|
1169
|
+
- `set` returns whether it changed anything. The same chip again writes nothing and tells no one, so a hook may call
|
|
1170
|
+
it each time (cost-cap sets its chip after every generation, never per streamed token). A change is one small file
|
|
1171
|
+
write, one event to the open tabs and one read of the strip from each.
|
|
1172
|
+
- With no session yet (`chi.ctx` at load, an init task before the first session) `set` and `remove` do nothing and
|
|
1173
|
+
return false, `list` is `{}`.
|
|
1174
|
+
- The chips live in the session's folder (`chips.json`) and don't make a session count as used: a bundle that sets
|
|
1175
|
+
one at session start leaves an untouched session discardable. A continue or a fork copies none (set them again
|
|
1176
|
+
there); deleting the session removes them. A bundle that is uninstalled (or one this chi refuses) has its chips
|
|
1177
|
+
left out of the strip.
|
|
1178
|
+
- chi web only: the terminal draws no chips. A `--non-interactive` one-shot sets them too, shown when the session is
|
|
1179
|
+
opened in chi web later. A participant never sees them.
|
|
1180
|
+
- It needs a chi newer than 0.195.0: guard with `ctx.respond_to?(:chips)` and mark the bundle `requires_chi_next`
|
|
1181
|
+
([releasing](releasing.md)). In the test kit chips are in memory: `bundle.chips` (this bundle's, by name, as
|
|
1182
|
+
stored) and `bundle.chip_writes` (how many changes were written).
|
|
1183
|
+
|
|
1125
1184
|
## Side answers: `ctx.ask_model`
|
|
1126
1185
|
|
|
1127
1186
|
```ruby
|
|
@@ -1705,7 +1764,7 @@ ctx.peers.last_message("claude") # the newest message still in the mailbox, or n
|
|
|
1705
1764
|
ctx.peers.here("claude") # the live Claude Code sessions of this project that announced themselves (PeerHere)
|
|
1706
1765
|
ctx.peers.pair("claude", address: "/tmp/…sock", from: "…", peer_session: "…") # => PeerPaired (status :paired, or a refusal)
|
|
1707
1766
|
ctx.peers.unpair("claude") # => PeerUnpaired (unpaired:, waited:): ends the pairing and the wait
|
|
1708
|
-
ctx.peers.wait("claude")
|
|
1767
|
+
ctx.peers.wait("claude", app: "Claude Code") # this session waits 10 min for one (app: the waiting chip's name); .waiting(name): the wait (stale? until_at)
|
|
1709
1768
|
ctx.peers.claim("claude") # takes the wait before pairing against it (nil: none to take); .release(claim)
|
|
1710
1769
|
ctx.peers.claimed?("claude") # another pairing holds the wait right now (a pair then writes nothing)
|
|
1711
1770
|
ctx.panes.find(pid: 1234) # the kitty window a pid runs in (title, cwd), or nil
|
|
@@ -1763,6 +1822,7 @@ context_providers:
|
|
|
1763
1822
|
cmd: '{ruby} {bundle_dir}/scripts/pr_context.rb {url}'
|
|
1764
1823
|
why: GitHub PR # optional
|
|
1765
1824
|
every_seconds: 300 # optional, at least 30
|
|
1825
|
+
context_group: PRs # optional: the web's one chip for two or more of its sources
|
|
1766
1826
|
```
|
|
1767
1827
|
|
|
1768
1828
|
- `scripts:` are files in the bundle's `scripts/` folder. Install copies them
|
|
@@ -1781,6 +1841,14 @@ context_providers:
|
|
|
1781
1841
|
version), and a source already attached to one — before a chi downgrade,
|
|
1782
1842
|
say — is refused by name, as a changed script is.
|
|
1783
1843
|
- The command follows [the contract](context.md#the-command-contract).
|
|
1844
|
+
- `context_group:` (optional, one per bundle: a source records its bundle, not
|
|
1845
|
+
which provider made it) is a label of 1–16 characters on one line; anything
|
|
1846
|
+
else is refused at install and by `chi bundle check`. With it, two or more
|
|
1847
|
+
of the bundle's sources in a session are one chip in the web's session bar,
|
|
1848
|
+
`PRs 3 · 2m`, that lists them ([Attached context](context.md)); without it
|
|
1849
|
+
they never group. It is read from the installed bundle's kept
|
|
1850
|
+
`manifest.yml` when the list is read, so sources attached before the label
|
|
1851
|
+
existed group as soon as the bundle that names it is installed.
|
|
1784
1852
|
|
|
1785
1853
|
## Block renderers
|
|
1786
1854
|
|
|
@@ -1904,7 +1972,7 @@ that calls it, or for a real external bundle that does. No method on the chance
|
|
|
1904
1972
|
7. **The manifest schema**: the manifest's keys and shapes, as [A bundle with a plugin](#a-bundle-with-a-plugin)
|
|
1905
1973
|
and [bundles.md](bundles.md) document them — `name`, `version`, `scope`, `description`, `files`, `hooks`,
|
|
1906
1974
|
`trust_level`, `plugin`, `requires_chi`, `requires_chi_next` (shipped bundles only: the release tooling
|
|
1907
|
-
reads it, chi doesn't), `needs`, `scripts`, `context_providers`, `block_renderers`, `pages`, `includes`,
|
|
1975
|
+
reads it, chi doesn't), `needs`, `scripts`, `context_providers`, `context_group`, `block_renderers`, `pages`, `includes`,
|
|
1908
1976
|
`session_settings`, `settings`. Those are `BundleManifest::KEYS`; `BundleManifest::SINCE` is the chi release each
|
|
1909
1977
|
key or shape first worked in, and the docs don't copy it — the code is its truth.
|
|
1910
1978
|
- A key keeps its meaning. A new key gets a `SINCE` entry and a CHANGELOG line, and an older chi says
|
|
@@ -1960,7 +2028,8 @@ bundle.command("/tone x", confirm: true) # sent from a web tab o
|
|
|
1960
2028
|
bundle.set(history: true, context_tokens: 900) # a model reply to restart (ctx.cache_confirm), its size
|
|
1961
2029
|
bundle.set(model_names: %w[tiny box:gemma gemma]) # ctx.model_names (default: model_name and its id)
|
|
1962
2030
|
bundle.prompt_text # the prompt sections' text, as a build runs them
|
|
1963
|
-
bundle.tool("my_tool", path: "a.txt") # → the text the model reads
|
|
2031
|
+
bundle.tool("my_tool", path: "a.txt") # → the text the model reads (no guardrails: the handler as given)
|
|
2032
|
+
bundle.tools["my_tool"].participant # its participant: (:allow, :deny): what the pair boundary reads
|
|
1964
2033
|
verdict = bundle.tool_call({ name: "execute", content: "rm -rf /" })
|
|
1965
2034
|
verdict.deny? # a real Guardrails::Verdict (votes: verdict.votes)
|
|
1966
2035
|
bundle.notices.map(&:text) # also cards, steers, stops, generation_stops, questions
|
|
@@ -1977,6 +2046,7 @@ bundle.http.stub(:post, "http://127.0.0.1:9000/classify", json: { label: "safe"
|
|
|
1977
2046
|
bundle.set(running: false) # the session's values: cwd:, messages:, cancelled: …
|
|
1978
2047
|
bundle.set(declared_tools: %w[read]) # ctx.declared_tools (default: every tool, as on full)
|
|
1979
2048
|
bundle.set(cost: 2.5) # ctx.cost: reported USD, or { reported:, estimated:, side:, known: }
|
|
2049
|
+
bundle.chips["cap"]["label"] # ctx.chips, in memory; bundle.chip_writes counts the changes written
|
|
1980
2050
|
bundle.set(usage: { tool_calls: 40, active_ms: 600_000 }) # ctx.usage: { turns:, tool_calls:, tool_calls_by_tool:, steps:, active_ms:, tool_ms_by_tool: }
|
|
1981
2051
|
bundle.set(turn_author: "p:p_0123abcd") # a participant's turn: ctx.turn_author, and author: on every event
|
|
1982
2052
|
bundle.set(turn_interactive: false) # ctx.turn_interactive? (default true: the owner's turn from a screen)
|
data/docs/sessions.md
CHANGED
|
@@ -412,7 +412,7 @@ A session can **continue** an earlier one: "the next run of the same routine" (a
|
|
|
412
412
|
- **If the continue fails part-way:** what a continue carries (its delegates, attached context, objectives and notes, in that order) and how each is given back is one list, `SessionContinue::CARRY` (the per-session stores it leaves behind, and why, are `SessionContinue::NOT_CARRIED`). A new link that fails to start gives its moved delegates back before it is deleted (each gets a note saying so; its worker is stopped first, if one started, and a worker that won't stop is reported, the link left), with any report one of them rang it with meanwhile, and the notes it moved with any sent to it meanwhile (never the continue's own: the carry note, the attached-context note, the objectives' list): its session file goes first, so a note sent to the previous link from then on stays there, then the notes go back, then its folder goes, and a note an older chi writes into it after that is given back too (a note for a session with no file and no folder is refused, never a stray folder); the previous link, back in the lists, is woken for reports waiting. A continue that dies in the middle leaves a `move.json` in the new link's folder: the new link's next worker finishes that move (only the delegates it names, and without a second note to one already told) as it starts. Its `continue.json` intent remains in the previous link's folder too, so a later list can restore it if the successor was never saved. Until the new link's own worker holds it, a ring from a moved delegate doesn't start another (a `starting` marker in its folder, which that worker removes; a stale one, over 60 s old or from a process that is gone, is ignored). An open delegate below an archived delegate refuses the continue (`under archived …`): unarchive that one, or archive this one.
|
|
413
413
|
- **Refused too:** a link that is continued already (`session 3f9a1c2e was continued as 7b2d41aa-…; continue that one (or last:3f9a1c2e)`; a schedule's anchor whose successor a prune deleted counts as continued by the schedule's head, so no second line starts beside the chain), a previous link whose folder is gone, and one whose model's host can't run it when no default model is configured to fall back to. A refusal starts nothing and archives nothing; a new link that fails to start puts back what was archived. Every refusal that can be known up front (the archive's ones included) comes before the recap wait. One continue of a session runs at a time (a lock in its folder; other chains don't wait), so a double click finds the first one's link and is refused, while a `last:<id>` continue that waited follows the chain to its new end.
|
|
414
414
|
- **Web:** `POST /api/sessions` takes `continues: "<id, prefix or last:id>"`, with `idle: true` (a new link waiting for its first message, previewed by the previous link's, or `preview`) or a `prompt`, and `model` (or `model_name`) for the new link's model, but not `dir`, `llm_context`, `thinking`, `settings`, `toolkit`, `tools`, `no_tools` or `parent_answers` (400 `invalid_continues`: the previous link's are taken). 201 is the new session's summary, `continues` set, with `moved`: the ids of the delegates that moved to it (`[]` for none), and `model_warning`: the default-model fallback's warning, then any about the model id, joined by `; ` (`null` for none), and `opener`: the previous link's first typed message, in full, when that link continues one itself (`null` otherwise: a chain's first link's first message is its task), and `moved_context`: `{moved: [names], stayed: [{name, why}]}`, the attached context it took (`why` `pushed` or `not movable`); 404 `not_found`; 400 `ambiguous_id` for a prefix of several sessions, `invalid_model` for a given model whose host config.yml doesn't have (or a fallback with no default model); 409 `continued` with `next_id` (the link that continues it already, which the page opens instead), `open_children` with `ids` (open delegates that can't move), `folder_gone`, `transition_busy` (another continue or change of it held its transition lock past 10 s), `busy`, `scratch` or `owned_by_tui`. Every session summary carries `continues`.
|
|
415
|
-
- **The page:** the info bar's `continue →` continues the open session (`continues: <id>, idle: true`; it reads `continuing…` through the recap wait) and opens the new link with the session's draft in its composer (text typed while it waited too, images included), or with none an opener, not sent; the draft moves to the new link even when another session is open as it lands (that session keeps its own; the toast's Open shows the link): the opener is the previous link's own first typed message when that link continues one (the 201's `opener`; a `!shell` line isn't taken), else `Continue where we left off.`. So whatever you sent on the last link comes back on the next one, and editing it once changes it for every later link; the previous link is archived, a toast says so (`Continued 3fa2c1d0 in 4b7e9a01; 3fa2c1d0 is archived; 1 open delegate moved`), and a moved delegate's card folds under the new link. When the previous link's model's host is gone the link starts on the default model and the toast carries the server's `model_warning` too, and then stays until closed. A fresh link (one with no turn yet, however it was made: `continue →`, `chi send --new --continues`, a reload) shows the model picker in its composer with the link's model, until its first turn starts (a failed or canceled first turn ends it too); a pick runs `/model <name>` in the link (a command bubble; the info bar follows) and changes neither the start page's remembered model nor its Recent list, and a Send right after it waits for the `/model` to be taken. A link a one-turn `chi --non-interactive` run has, or one continued already, shows none. A link continued already has no `continue →`: its `→` link goes to the next link (a stale page's continue answered 409 `continued` opens `next_id`). A continue refused for open delegates that can't move shows a toast that names each one (its preview and what the server says to do: `older chi worker 0.46.1; restart it`, `in use by a one-turn chi --non-interactive run or an older chi's terminal; let it finish`), each a link to its page; any other refusal shows the server's words. The info bar of a link carries `← 2026-10-08` (the previous link's day) and, on an earlier link, `2026-10-10 →`, each a link with its id, its full start (`2026-10-10 14:32`) and its preview in the tooltip; a neighbour that started on the open link's own day shows its time instead (`← 09:12`, `14:32 →`). A link made by `continue →` inherits the previous link's preview (and its title, if it has one) when it is created, so its card keeps its chain's title whatever opener it is sent, and its top bar and browser tab show its card's title. A link with a recap of its own reads its auto title, else its recap's first sentence, instead (a link without one reads its chain's name, and a first link's recap names its chain). A link whose title is the opener and nothing else (a `chi send --new --continues` link whose first message is `Continue where we left off.`) shows its chain's first link's title instead, on its card, in the popover and in its info bar's title line, display only (its messages and data keep the opener; its own title when the first link is gone). The lists fold a chain into the card of its latest listed link, whatever the earlier links' archived state (typing in an archived link brings it back, folded there still), their delegates with them: the card's `↩ #N` chip (`#N of M` when later links aren't listed; its tooltip `Session chain: link N of M`) opens a popover of the other links, newest first (`#N`, its date, with its time (`2026-10-17 14:32`) when another link of the chain started the same day, its own title when it differs from the card's (a link inherits its chain's, so mostly it doesn't), else its recap's first sentence, else its preview, `archived`), a click opens one; the chip shows a live dot or `waiting` for a link that has a worker or waits on the user, and a waiting link puts its chain's card first. All sessions folds nothing while a search is typed or the `archived` toggle is on: every link is a card of its own then, its chip `#N of M`, with its own delegates folded in, so a search finds an earlier link and its delegates.
|
|
415
|
+
- **The page:** the info bar's `continue →` continues the open session (`continues: <id>, idle: true`; it reads `continuing…` through the recap wait) and opens the new link with the session's draft in its composer (text typed while it waited too, images included), or with none an opener, not sent; the draft moves to the new link even when another session is open as it lands (that session keeps its own; the toast's Open shows the link); a continue made anywhere else (a terminal's `/continue`, a chain schedule, `chi send --new --continues`, another tab) moves the draft to the chain's newest link the same way, without an opener, once that session isn't on view (while it is, the box keeps the text until you leave it), and a next link with a draft of its own keeps it: the opener is the previous link's own first typed message when that link continues one (the 201's `opener`; a `!shell` line isn't taken), else `Continue where we left off.`. So whatever you sent on the last link comes back on the next one, and editing it once changes it for every later link; the previous link is archived, a toast says so (`Continued 3fa2c1d0 in 4b7e9a01; 3fa2c1d0 is archived; 1 open delegate moved`), and a moved delegate's card folds under the new link. When the previous link's model's host is gone the link starts on the default model and the toast carries the server's `model_warning` too, and then stays until closed. A fresh link (one with no turn yet, however it was made: `continue →`, `chi send --new --continues`, a reload) shows the model picker in its composer with the link's model, until its first turn starts (a failed or canceled first turn ends it too); a pick runs `/model <name>` in the link (a command bubble; the info bar follows) and changes neither the start page's remembered model nor its Recent list, and a Send right after it waits for the `/model` to be taken. A link a one-turn `chi --non-interactive` run has, or one continued already, shows none. A link continued already has no `continue →`: its `→` link goes to the next link (a stale page's continue answered 409 `continued` opens `next_id`). A continue refused for open delegates that can't move shows a toast that names each one (its preview and what the server says to do: `older chi worker 0.46.1; restart it`, `in use by a one-turn chi --non-interactive run or an older chi's terminal; let it finish`), each a link to its page; any other refusal shows the server's words. The info bar of a link carries `← 2026-10-08` (the previous link's day) and, on an earlier link, `2026-10-10 →`, each a link with its id, its full start (`2026-10-10 14:32`) and its preview in the tooltip; a neighbour that started on the open link's own day shows its time instead (`← 09:12`, `14:32 →`). A link made by `continue →` inherits the previous link's preview (and its title, if it has one) when it is created, so its card keeps its chain's title whatever opener it is sent, and its top bar and browser tab show its card's title. A link with a recap of its own reads its auto title, else its recap's first sentence, instead (a link without one reads its chain's name, and a first link's recap names its chain). A link whose title is the opener and nothing else (a `chi send --new --continues` link whose first message is `Continue where we left off.`) shows its chain's first link's title instead, on its card, in the popover and in its info bar's title line, display only (its messages and data keep the opener; its own title when the first link is gone). The lists fold a chain into the card of its latest listed link, whatever the earlier links' archived state (typing in an archived link brings it back, folded there still), their delegates with them: the card's `↩ #N` chip (`#N of M` when later links aren't listed; its tooltip `Session chain: link N of M`) opens a popover of the other links, newest first (`#N`, its date, with its time (`2026-10-17 14:32`) when another link of the chain started the same day, its own title when it differs from the card's (a link inherits its chain's, so mostly it doesn't), else its recap's first sentence, else its preview, `archived`), a click opens one; the chip shows a live dot or `waiting` for a link that has a worker or waits on the user, and a waiting link puts its chain's card first. All sessions folds nothing while a search is typed or the `archived` toggle is on: every link is a card of its own then, its chip `#N of M`, with its own delegates folded in, so a search finds an earlier link and its delegates.
|
|
416
416
|
- **CLI:** `chi send --new --continues (ID|PREFIX|last:ID) [--model M] [-m TEXT]` (see *Starting a session*).
|
|
417
417
|
- **Which link:** an id, a unique prefix, or `last:<id or prefix>`, the latest link of the chain that session is in. It walks the links that still exist: a deleted link in the middle (`chi sessions delete`, the retention sweep of an unarchived one) ends the walk before it, so `last:` of an earlier link then names that earlier link, and continuing it starts a second line beside the links after the gap; name a link after the gap instead. The one exception is a schedule's anchor (below). A trigger names the chain this way: a person's message to an archived link that nobody continued brings it back (a human's input), it doesn't continue the chain; an unattended sender's is refused (*Who may wake a session*). That is the rule: `chi send` and a note go to the chain's newest link (*Sending a message*, *Context notes*); the web composer, a participant's turn and `delegate(session:)` go to the link they name. One walker answers every one of these (`SessionChain::Links`: one session listing, archive flags read once; the earliest created successor wins a fork a hand edit made, a loop ends where it would repeat), with two rules on it, not unified on purpose: `last:` and a schedule take the chain's **end** (`Links#latest`: a continue refuses a link continued already, and a schedule never un-archives a chain you retired), `chi send` and a note the **first link not archived** (`Links#first_live`: a person's input goes where the chain is live, and brings back an archived end). A chain pruned by a schedule keeps its `anchor`, and the prune deletes the links behind its window, the anchor's successor among them, so nobody continues the anchor any more. The addressing walks bridge that gap: at an archived link nobody continues, `last:`, `chi send`, a note and the peer/context refusals' `next_id` go on at the head of a schedule anchored there (`Links#anchor_forward`; the first entry in `schedules.json` whose head still exists and isn't the anchor, disabled ones too), so `last:<anchor>` names the chain's end and a send to the anchor reaches the live link (`3f9a1c2e → 7b2d41aa (continued)`), as for any continued link; a continue of the anchor itself (without `last:`) is refused as continued already, naming the head. The graph stays raw: `next_of`, the chain's links (`Links#chain`: the anchor alone), the deletes and a delegate's ring never cross the gap. With the head gone (no forward) the walk stops at the anchor, as before; an anchor a person's send brought back before this (no longer archived) isn't bridged either. Backward, the kept window's oldest link still names a link that is gone, so the walk back stops there; the page's chip counts from the surviving root (pruning renumbers the links) and its popover says `earlier links pruned` where the walk stops, rather than linking to a deleted session.
|
|
418
418
|
- **Deleting a link** (`SessionChain::Delete`; the CLI, the web and `/exit --delete`): a link of a chain is deleted alone by default, and what follows depends on where it is. **The newest link** (nobody continues it, it isn't archived itself, the link before it is archived) undoes its continue: the delegates the continue moved go back to the previous link, finished ones too (`continued_from.json`'s `moved_ids`, still under the link; without the record, its children whose `parent.json` says they came from the previous link), each with a note saying the link was deleted; every note waiting in the link but the continue's own goes back too (`NoteMove.give_back`); then the previous link and what the continue archived with it come back to the lists (without the record, the previous link alone). The previous link is **not started**: reports a moved-back delegate left wait for its next start. What dies with the link: its turns, context sources, objectives edits, session approvals and participant grants (the previous link kept its own copies). Every refusal comes before anything goes: the link's delegates that would go are checked too (a schedule on one through `SessionProtection.hold`, a one-turn run), and they and the link are removed (and the undo runs) only under their `owner.lock`s (kind deleting, taken without waiting, so a worker that took one refuses it); a moved delegate that can't go back (`ChildMove.unmovable`: an older chi's worker, a one-turn run) refuses it (`delegate_unmovable`, naming it), as does a worker that took the link after the stop. Deleting the links one after another undoes each continue by its own record. **A middle link** splits the chain (the earlier links stay archived, the later ones go on as their own chain); nothing is undone or re-linked. A link whose chain is all archived stays archived around the gap. **The link's own delegates** (any position) follow one rule, `SessionManager::DELEGATES` (`SessionManager::DelegateRule`; one shared preview row snapshot): a running one (a worker owns it or is starting for it, a one-turn run; a saved `running` with no worker is a crashed run, and goes) is left running with its whole subtree, its file untouched (its parent's id names a deleted session; its reports are refused as for any gone parent); every other node under the link goes, deepest first, before the link. A session in no chain (a link alone past a gap too) is a link with nothing to undo: its delegates follow the same rule (*Deleting a session*). **The web asks first**: chi web's delete sheet reads `GET /api/sessions/:id/delete_plan` (`:owner`; no query or body; no-store) for any session, `SessionChain::Delete::Preview` over the same `LinkPlan`/`ChainPlan` and checks the delete runs (`check_link!`, `check_chain!`): the link's place in the chain, what comes back and goes for each choice, and each choice's refusal now (a schedule on the chain, the link or a delegate that would go, a continue under way, a one-turn run, a moved delegate that can't go back and whether the page can stop it). A session in no chain answers `{chained: false, session_id, link}`, the same `link` a chained one gets (`previous_id` null, `earlier`/`later` 0, `next_id` null); an older page reads only `chained`. Each choice (`link`, `chain`) also carries `delegates` (`{delete: [ids], leave: [{id, running}]}`; `running` false for a stopped session left under a running delegate, beside the counts `deletes` and `left_running`), `tasks` (`{running, unverified, unreadable}`: `RunningTasks.of` the ids the choice deletes) and `worker` (a link's: `"turn"` when a worker owns it and a turn runs, `"idle"` when a worker owns it or is starting, null; a chain's `{idle, turn}` counts over its links). No titles: the page names each id from its own list. One shared session-row snapshot serves the link and chain choices; Links lists on its own, and a folder whose session file is gone answers too (the delete still takes it). Each call read-only checks each link's continue lock (a session in no chain too), and writes nothing else but the listing's own repair of an interrupted continue; an unknown id is the usual 404. chi web lists `delete_plan_all` in `/api/info`'s features (`Web::App::DELETE_PLAN_FEATURE`). **The tap stops only what the sheet named**: whenever the choice lists any task, the page sends `stop_tasks=true&tasks=<id,id>`, the choice's running ids (`tasks=` when it has only unverified or unreadable records, which a stop never signals, so such a session can still be deleted); archive's sheet sends `{"stop_tasks": true, "tasks": [ids]}` in its body. `tasks` works only with `stop_tasks`; without it, it is ignored, and `stop_tasks` without `tasks` (the CLI's `--stop-tasks`, an older page) takes every running task the operation can stop. A running task not named refuses (`tasks_running`), and the sheet reads the plan again and shows it with "changed; check again". A chain stops link by link: a link refused that way leaves it and the earlier links whole. The moved count is each moved delegate with its subtree (they come back with it), and a `delegate_unmovable` 409 says `stoppable` itself. Each choice carries a `digest` (`SessionChain::Delete.digest`: the sorted ids it deletes, leaves, revives and moves back); the sheet's DELETE sends it as `expect=`, and the delete compares it with the plan it runs (a link's under its holds, as `delete_link` starts; the chain's before its checks) and refuses `plan_changed` (409) before anything changes; a session in no chain is compared the same way (a sheet shown for a link whose chain is gone since deletes when its ids still match). Without `expect` (the CLI, an older page) it deletes as it plans then.
|
data/docs/system-one.md
CHANGED
|
@@ -106,7 +106,9 @@ Later lines name their run by `run_id` and may sit in a later day's file, or in
|
|
|
106
106
|
the run: a join happens at read, and a line whose run is gone is dropped.
|
|
107
107
|
|
|
108
108
|
- `label` {`value`, `by`, `strength`, `question`, `at`}.
|
|
109
|
-
- Approvals (`SystemOne::ApprovalLabel`, the one reading of an answer for the log and the run
|
|
109
|
+
- Approvals (`SystemOne::ApprovalLabel`, the one reading of an answer for the log and the run; its
|
|
110
|
+
`ApprovalLabel.choice(index, scopes)`, in `system_one/approval_choice.rb` with no requires, is the chosen scope
|
|
111
|
+
as the value, shared with `chi guardrails replay` and `SessionStats`):
|
|
110
112
|
`allow_once`, `allow_wide`, `deny` by `user`, strong; `should_have_asked` from `/guardrails wrong` or the
|
|
111
113
|
web's **should have asked**, strong; `deny` by `parent`, weak, only where the parent could have allowed; a
|
|
112
114
|
parent's allow is no label; `none` for a cancelled ask, which is not an answer.
|
|
@@ -48,6 +48,9 @@ module Samagotchi
|
|
|
48
48
|
# cmd: '{ruby} {bundle_dir}/scripts/pr_context.rb {url}'
|
|
49
49
|
# why: GitHub PR # optional
|
|
50
50
|
# every_seconds: 300 # optional
|
|
51
|
+
# context_group: PRs # optional — the label of one chip the web's
|
|
52
|
+
# # session bar folds two or more of this
|
|
53
|
+
# # bundle's sources into (1–16 characters)
|
|
51
54
|
# block_renderers: # optional — a fence's language → the scripts/
|
|
52
55
|
# - lang: mermaid # files chi web's page loads to draw it
|
|
53
56
|
# load: [lib.js, draw.js] # (BlockRenderers); each one a scripts: key
|
|
@@ -113,7 +116,7 @@ module Samagotchi
|
|
|
113
116
|
# here is one this chi ignores: #unknown_keys, which `chi bundle check`
|
|
114
117
|
# and the Installer say.
|
|
115
118
|
KEYS = %w[name version scope description files hooks trust_level plugin requires_chi requires_chi_next needs
|
|
116
|
-
scripts context_providers block_renderers pages includes session_settings settings].freeze
|
|
119
|
+
scripts context_providers context_group block_renderers pages includes session_settings settings].freeze
|
|
117
120
|
|
|
118
121
|
# The first chi release that reads each manifest key or shape (from git:
|
|
119
122
|
# the first tag whose manifest.rb reads it), for `chi bundle check`'s
|
|
@@ -137,13 +140,14 @@ module Samagotchi
|
|
|
137
140
|
"block_renderers" => "0.151.0",
|
|
138
141
|
"plugin.required" => "0.157.0",
|
|
139
142
|
"plugin.parts" => "0.183.0",
|
|
140
|
-
"pages" => "0.189.0"
|
|
143
|
+
"pages" => "0.189.0",
|
|
144
|
+
"context_group" => "0.196.0"
|
|
141
145
|
}.freeze
|
|
142
146
|
|
|
143
147
|
# files: name → "sha256:<hex>" (both forms); file_descriptions: name →
|
|
144
148
|
# the description a mapping gave, for the files that have one.
|
|
145
149
|
attr_reader :name, :version, :scope, :description, :files, :file_descriptions, :trust_level, :plugin, :requires_chi, :needs, :includes,
|
|
146
|
-
:scripts, :context_providers, :block_renderers, :pages, :session_settings, :session_setting_types, :settings, :setting_types, :unknown_keys
|
|
150
|
+
:scripts, :context_providers, :context_group, :block_renderers, :pages, :session_settings, :session_setting_types, :settings, :setting_types, :unknown_keys
|
|
147
151
|
|
|
148
152
|
def initialize(path:)
|
|
149
153
|
@path = path
|
|
@@ -173,6 +177,7 @@ module Samagotchi
|
|
|
173
177
|
@needs = self.class.parse_needs(raw["needs"])
|
|
174
178
|
@scripts = parse_scripts(raw["scripts"])
|
|
175
179
|
@context_providers = parse_context_providers(raw["context_providers"])
|
|
180
|
+
@context_group = self.class.parse_context_group(raw["context_group"])
|
|
176
181
|
@block_renderers = parse_block_renderers(raw["block_renderers"])
|
|
177
182
|
@pages = parse_pages(raw["pages"])
|
|
178
183
|
@includes = parse_includes(raw["includes"])
|
|
@@ -206,7 +211,7 @@ module Samagotchi
|
|
|
206
211
|
# that key, which reads as empty with its message in the problems:
|
|
207
212
|
# name, version (never checked: identity is the record's), scope;
|
|
208
213
|
# files and their descriptions, scripts, plugin (hooks: is ignored,
|
|
209
|
-
# HooksRetired); needs, context_providers; block_renderers and pages
|
|
214
|
+
# HooksRetired); needs, context_providers, context_group; block_renderers and pages
|
|
210
215
|
# (against +fallback_scripts+ when scripts: failed); includes (after
|
|
211
216
|
# what its check reads); session_settings with its types, settings
|
|
212
217
|
# with theirs (one raw value each, so one problem); requires_chi,
|
|
@@ -309,6 +314,7 @@ module Samagotchi
|
|
|
309
314
|
found["includes"] = SINCE["includes"] unless @includes.empty?
|
|
310
315
|
found["scripts"] = SINCE["scripts"] unless @scripts.empty?
|
|
311
316
|
found["context_providers"] = SINCE["context_providers"] unless @context_providers.empty?
|
|
317
|
+
found["context_group"] = SINCE["context_group"] if @context_group && SINCE.key?("context_group")
|
|
312
318
|
found["block_renderers"] = SINCE["block_renderers"] unless @block_renderers.empty?
|
|
313
319
|
found["pages"] = SINCE["pages"] if !@pages.empty? && SINCE.key?("pages")
|
|
314
320
|
found["plugin.required"] = SINCE["plugin.required"] if @plugin&.dig(:required) && SINCE.key?("plugin.required")
|
|
@@ -324,7 +330,7 @@ module Samagotchi
|
|
|
324
330
|
# Writes a fresh manifest.yml from computed checksums at `dir`.
|
|
325
331
|
# +file_descriptions+ (name → text) writes those files as mappings.
|
|
326
332
|
def self.write(dir:, name:, version:, files:, scope: nil, description: "", trust_level: nil,
|
|
327
|
-
plugin: nil, requires_chi: nil, needs: nil, scripts: {}, context_providers: [], block_renderers: [], file_descriptions: {},
|
|
333
|
+
plugin: nil, requires_chi: nil, needs: nil, scripts: {}, context_providers: [], context_group: nil, block_renderers: [], file_descriptions: {},
|
|
328
334
|
session_settings: [], session_setting_types: {}, settings: nil, setting_types: {}, pages: [])
|
|
329
335
|
FileUtils.mkdir_p(dir)
|
|
330
336
|
manifest = {
|
|
@@ -350,6 +356,7 @@ module Samagotchi
|
|
|
350
356
|
manifest["needs"] = needs.map { |n| n.transform_keys(&:to_s).compact } unless needs.empty?
|
|
351
357
|
manifest["scripts"] = scripts.transform_keys(&:to_s) unless scripts.empty?
|
|
352
358
|
manifest["context_providers"] = context_providers.map(&:to_h) unless context_providers.empty?
|
|
359
|
+
manifest["context_group"] = context_group.to_s if context_group
|
|
353
360
|
manifest["block_renderers"] = block_renderers.map(&:to_h) unless block_renderers.empty?
|
|
354
361
|
manifest["pages"] = pages.map(&:to_s) unless pages.empty?
|
|
355
362
|
manifest["session_settings"] = session_settings_entry(session_settings, session_setting_types) unless Array(session_settings).empty?
|
|
@@ -404,6 +411,23 @@ module Samagotchi
|
|
|
404
411
|
keys.to_h { |key| [key, types[key] || "any"] }
|
|
405
412
|
end
|
|
406
413
|
|
|
414
|
+
# The longest context_group: label (a chip's few words).
|
|
415
|
+
CONTEXT_GROUP_MAX = 16
|
|
416
|
+
|
|
417
|
+
# context_group: → the label, stripped; nil when absent. Anything but a
|
|
418
|
+
# one-line string of 1–CONTEXT_GROUP_MAX characters is a ValidationError.
|
|
419
|
+
def self.parse_context_group(raw)
|
|
420
|
+
return nil if raw.nil?
|
|
421
|
+
raise ValidationError, "context_group: must be a short label, not #{raw.inspect}" unless raw.is_a?(String)
|
|
422
|
+
|
|
423
|
+
label = raw.strip
|
|
424
|
+
if label.empty? || label.length > CONTEXT_GROUP_MAX || label.match?(/[[:cntrl:]]/)
|
|
425
|
+
raise ValidationError, "context_group: #{raw.inspect} isn't a one-line label of 1–#{CONTEXT_GROUP_MAX} characters"
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
label
|
|
429
|
+
end
|
|
430
|
+
|
|
407
431
|
# needs: → [{command:, why:, hint:}] (why/hint a String or nil), [] when
|
|
408
432
|
# absent. Takes the manifest's string-keyed YAML or the symbol-keyed
|
|
409
433
|
# form provenance stores. Duplicates merge (the first one's why/hint
|
|
@@ -458,6 +482,7 @@ module Samagotchi
|
|
|
458
482
|
# An old kept manifest's hooks: is no problem: it isn't read (HooksRetired).
|
|
459
483
|
@needs = tolerate(problems, "needs", []) { self.class.parse_needs(raw["needs"]) }
|
|
460
484
|
@context_providers = tolerate(problems, "context_providers", []) { parse_context_providers(raw["context_providers"]) }
|
|
485
|
+
@context_group = tolerate(problems, "context_group", nil) { self.class.parse_context_group(raw["context_group"]) }
|
|
461
486
|
script_names = problems.key?("scripts") ? fallback_scripts.map(&:to_s) : @scripts.keys
|
|
462
487
|
@block_renderers = tolerate(problems, "block_renderers", []) { parse_block_renderers(raw["block_renderers"], script_names) }
|
|
463
488
|
@pages = tolerate(problems, "pages", []) { parse_pages(raw["pages"], script_names) }
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: core
|
|
3
|
-
version: 0.4.
|
|
3
|
+
version: 0.4.5
|
|
4
4
|
scope: system
|
|
5
5
|
description: "Recommended safety set"
|
|
6
6
|
trust_level: reviewed
|
|
7
7
|
# Its members' highest floor (work-cap's: ctx.usage, raised at the release)
|
|
8
|
-
requires_chi: ">= 0.
|
|
8
|
+
requires_chi: ">= 0.196.0"
|
|
9
9
|
includes:
|
|
10
10
|
- loop-guard
|
|
11
11
|
- check-in
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cost-cap
|
|
3
|
-
version: 0.
|
|
3
|
+
version: 0.3.0
|
|
4
4
|
scope: system
|
|
5
|
-
description: "A per-session $ cap: at the cap the turn pauses on Continue (another cap's worth) / Stop, a warning at 80% goes to the user only; /cap shows or sets it"
|
|
5
|
+
description: "A per-session $ cap: at the cap the turn pauses on Continue (another cap's worth) / Stop, a warning at 80% goes to the user only; /cap shows or sets it; a chip in the web's session bar shows the spend against it"
|
|
6
6
|
trust_level: reviewed
|
|
7
7
|
plugin:
|
|
8
8
|
file: plugin.rb
|
|
9
|
-
sha256: sha256:
|
|
9
|
+
sha256: sha256:f8773feba2741f6a149a971c71bad3300e84528af507afc632586a5519c69f17
|
|
10
10
|
# ctx.cost is new in chi 0.83.0; ask_user's effects: in the next chi
|
|
11
11
|
# ctx.session_dir is new in 0.143.0
|
|
12
|
-
requires_chi: ">= 0.
|
|
12
|
+
requires_chi: ">= 0.196.0"
|
|
13
13
|
# session_settings: as a mapping of keys to types is new
|
|
14
14
|
# chi --set cost-cap.cap=3: a session's own cap (ctx.settings["cap"]), a number or off
|
|
15
15
|
session_settings: {cap: number}
|