samagotchi 0.164.0 → 0.166.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 +88 -1
- data/docs/architecture.md +7 -5
- data/docs/cli.md +23 -12
- data/docs/configuration.md +8 -2
- data/docs/guardrails.md +19 -18
- data/docs/internals/block-renderers.md +1 -1
- data/docs/internals/bridge.md +10 -3
- data/docs/internals/bundles.md +4 -2
- data/docs/internals/inline-widgets.md +8 -1
- data/docs/internals/remote-sessions.md +1 -1
- data/docs/internals/web-frontend.md +73 -13
- data/docs/memory.md +12 -7
- data/docs/plugins.md +6 -4
- data/docs/releasing.md +17 -4
- data/docs/scheduling.md +25 -3
- data/docs/sessions.md +12 -10
- data/docs/testing.md +37 -4
- data/lib/samagotchi/block_renderers.rb +3 -6
- data/lib/samagotchi/bridge/card_store.rb +2 -1
- data/lib/samagotchi/bridge/turn_accumulator.rb +7 -8
- data/lib/samagotchi/bridge.rb +45 -3
- data/lib/samagotchi/bundle_command/installed_check.rb +2 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/chi_home.rb +44 -2
- data/lib/samagotchi/client_id.rb +34 -3
- data/lib/samagotchi/compat.rb +34 -0
- data/lib/samagotchi/context_command.rb +3 -0
- data/lib/samagotchi/context_providers.rb +5 -6
- data/lib/samagotchi/context_sources.rb +2 -2
- data/lib/samagotchi/continue_intent.rb +50 -5
- data/lib/samagotchi/events.rb +4 -4
- data/lib/samagotchi/extension_load.rb +2 -1
- data/lib/samagotchi/guardrails/approvals.rb +36 -9
- data/lib/samagotchi/guardrails/child_boundary.rb +7 -27
- data/lib/samagotchi/guardrails/rules.rb +11 -9
- data/lib/samagotchi/guardrails/targets.rb +3 -4
- data/lib/samagotchi/inline_widgets.rb +16 -1
- data/lib/samagotchi/memory_bundle/provenance.rb +46 -4
- data/lib/samagotchi/memory_bundle/status.rb +2 -1
- data/lib/samagotchi/memory_command.rb +3 -0
- data/lib/samagotchi/memory_orphans.rb +4 -7
- data/lib/samagotchi/memory_paths.rb +64 -7
- data/lib/samagotchi/memory_usage.rb +1 -1
- data/lib/samagotchi/plugin/sessions.rb +8 -3
- data/lib/samagotchi/project_command.rb +4 -1
- data/lib/samagotchi/project_id_clash.rb +37 -26
- data/lib/samagotchi/project_init.rb +24 -7
- data/lib/samagotchi/reply_wait/poll.rb +4 -14
- data/lib/samagotchi/reply_wait.rb +0 -23
- data/lib/samagotchi/run_options.rb +1 -1
- data/lib/samagotchi/schedules.rb +124 -106
- data/lib/samagotchi/send_command.rb +71 -18
- data/lib/samagotchi/session.rb +3 -2
- data/lib/samagotchi/session_access/local.rb +19 -2
- data/lib/samagotchi/session_access/remote.rb +13 -17
- data/lib/samagotchi/session_chain/links.rb +109 -0
- data/lib/samagotchi/session_chain.rb +7 -19
- data/lib/samagotchi/session_continue.rb +138 -54
- data/lib/samagotchi/session_inbox.rb +1 -1
- data/lib/samagotchi/session_inbox_delivery.rb +57 -38
- data/lib/samagotchi/session_manager/delivery.rb +104 -18
- data/lib/samagotchi/session_manager/removal.rb +13 -7
- data/lib/samagotchi/session_manager.rb +1 -0
- data/lib/samagotchi/session_retention.rb +20 -10
- data/lib/samagotchi/session_setup.rb +31 -1
- data/lib/samagotchi/state_format.rb +12 -8
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +6 -7
- data/lib/samagotchi/terminal_ui.rb +20 -9
- data/lib/samagotchi/tools/delegate.rb +2 -3
- data/lib/samagotchi/verify_fresh.rb +4 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/activity.js +2 -2
- data/lib/samagotchi/web/public/app.js +28 -21
- data/lib/samagotchi/web/public/auth_lost.js +3 -1
- data/lib/samagotchi/web/public/bar_fold.js +293 -0
- data/lib/samagotchi/web/public/card.js +1 -1
- data/lib/samagotchi/web/public/chip_popover.js +5 -1
- data/lib/samagotchi/web/public/composer_mode.js +5 -7
- data/lib/samagotchi/web/public/delivery_line.js +19 -4
- data/lib/samagotchi/web/public/index.html +242 -94
- data/lib/samagotchi/web/public/info_bar.js +28 -16
- data/lib/samagotchi/web/public/info_bar_model.js +76 -2
- data/lib/samagotchi/web/public/live_timing.js +3 -0
- data/lib/samagotchi/web/public/more_sheet.js +98 -40
- data/lib/samagotchi/web/public/resync_reach.js +59 -0
- data/lib/samagotchi/web/public/session_fields.js +1 -0
- data/lib/samagotchi/web/public/session_state.js +5 -0
- data/lib/samagotchi/web/public/stage_frame.js +4 -2
- data/lib/samagotchi/web/public/stage_stall.js +134 -0
- data/lib/samagotchi/web/public/stage_view.js +78 -7
- data/lib/samagotchi/web/public/stream_handlers.js +1 -1
- data/lib/samagotchi/web/public/turn_events.js +0 -122
- data/lib/samagotchi/web/public/turn_model.js +1 -1
- data/lib/samagotchi/web/public/widget_picks.js +18 -3
- data/lib/samagotchi/web/session_control.rb +15 -2
- data/lib/samagotchi/web/session_create.rb +4 -2
- data/lib/samagotchi/web/token.rb +2 -2
- data/lib/samagotchi/web/update_check.rb +27 -8
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4c657470043000593ee445e5f7a7ec832351653c9135d09296bf348b636b823
|
|
4
|
+
data.tar.gz: ea134e12c930c3d8b369aba8a265a3d79d28f16346b7d61fb9e498e5a99698a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 145442a0b44a66a92f20ff0115f49c9656faa6a30c9919fba7b11acfa141254e8404fcc917454753e338f2d54fd132662bf249311ad28abe3b1cfb4a51a41fc2
|
|
7
|
+
data.tar.gz: 59a0fa2222a06428aa63e43550feb26a8cbc149b033d8bf393dcd33e5c4136143b854d4d4fb1d6cac5bb3b478f5b9dd138ebca6a86ebdae1a3731970e4695a00
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,91 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.166.0] - 2026-11-11
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Web: a running turn that has sent nothing for 30 s says so in the stage ("quiet 0:40", "thinking quietly 0:50"
|
|
16
|
+
before the first token, "reconnecting…" when the stream dropped); it clears on the next event and stays off while a
|
|
17
|
+
tool runs or a card waits.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Guardrails: approvals.json reads a versioned `{"version", "approvals"}` store as well as today's list, and keeps
|
|
22
|
+
writing the list for one more release so a 0.165 session sharing the store doesn't set it aside. From 0.167 the
|
|
23
|
+
store is written versioned.
|
|
24
|
+
- chi web on a phone: the composer has no row above the text field. While a turn runs and you type (the text field
|
|
25
|
+
focused or holding text or images) or have `cut in` or `queue` armed, where a message goes in and those chips show
|
|
26
|
+
in the session bar, in place of the status, ctx and speed; otherwise the bar keeps them. The composer is shorter and
|
|
27
|
+
still never changes height.
|
|
28
|
+
- chi web on iPhone: the page uses the full screen and keeps the composer, sheets, toasts and the lightbox clear of the
|
|
29
|
+
notch and the home indicator (Home Screen app and Safari); in a Safari tab the composer no longer sits under the
|
|
30
|
+
toolbar (100dvh).
|
|
31
|
+
- chi web: the top bar is one line at every width: its words share one text line, the plus is drawn, both pills are
|
|
32
|
+
as tall as the bell, and the project pill and `all` are one control. A phone's bar keeps its tap targets and its row.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- A plugin's `ctx.sessions.read` of a live session gets its messages and running turn again (it read an older reply
|
|
37
|
+
shape and saw no messages and never running).
|
|
38
|
+
- chi web on a phone: the ⚙ chip marks changed settings with its blue dot alone, without the accent border that was cut off at the top and bottom.
|
|
39
|
+
- chi web going away while a session is open no longer replaces its conversation with "Error: Failed to fetch": the
|
|
40
|
+
conversation stays and the session bar's status says "reconnecting…", then "can't reach chi web" once the retries
|
|
41
|
+
run out; it clears when chi web is back and the session is read again.
|
|
42
|
+
- `chi web --help`: `--new-token` says it replaces chi web's access token for every way in (LAN, `--tunnel tailscale`, a proxy), not only the LAN's.
|
|
43
|
+
|
|
44
|
+
Update with `chi update`, then restart chi web and running sessions (`chi sessions restart`).
|
|
45
|
+
|
|
46
|
+
## [0.165.0] - 2026-11-11
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Guardrails: `tool: shell` rules and child boundaries also match plugin tools whose `targets:` declare a command,
|
|
51
|
+
so a plugin's read-only command in another checkout no longer asks.
|
|
52
|
+
- web: the session bar is one row at every window width. What doesn't fit folds into `⋯` by priority, lowest first
|
|
53
|
+
(the folder and 🧰 first, then the notes, set and participants, the model, the clock…); `⋯` is on the row everywhere,
|
|
54
|
+
with a count of what it holds on a desktop and its dot when a folded item asks for a look. Archive and delete live in
|
|
55
|
+
`⋯` alone. A chain whose earlier links a schedule pruned now says so on the bar (`↩ earlier links pruned`).
|
|
56
|
+
- A session you stopped or archived stays that way for senders other than you: a schedule's firing, a plugin's
|
|
57
|
+
`sessions.send`, a `delegate` follow-up and a participant's turn start an idle session as before, but no longer
|
|
58
|
+
un-stop or un-archive one (`the session is stopped; only its owner's message starts it again`). `chi send`, a web tab
|
|
59
|
+
and a terminal still do.
|
|
60
|
+
- chi web on a phone: a session's panel runs edge to edge, tap targets are about 40px, the brand in a session is a
|
|
61
|
+
round `+` (new session), and an answer's copy button floats so the first line wraps short of it. Inline code's side
|
|
62
|
+
padding is 3px at every width.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- chi web on touch: Revise no longer looks disabled.
|
|
67
|
+
- chi web: an answered card that ends exactly at its line's edge brings the line back.
|
|
68
|
+
- chi web: a `/command` from a client that names no sender is recorded as `web:unnamed` instead of as you.
|
|
69
|
+
- The retention sweep's skeleton-folder prune reads the folder again under the session's lock, so a session file
|
|
70
|
+
or content written between its check and its removal is kept instead of deleted.
|
|
71
|
+
- A worker's `GET /session/:id/state` reply is read under the event lock, so its `event_id` always matches its state.
|
|
72
|
+
- A Verify fresh child now keeps its session's own `parent_answers` (`--parent-answers`, `/parent-answers`), as a
|
|
73
|
+
`delegate` child does, instead of falling back to config.yml's.
|
|
74
|
+
- A schedule no longer restarts a session you stopped: it skips it (`the session is stopped; …`), in both modes, and a
|
|
75
|
+
stop that lands just before a firing counts as a skip, not a failure.
|
|
76
|
+
- Project marker ids no longer reuse another project's memory folder; `chi project init --new-id` gives it a safe id.
|
|
77
|
+
- A schedule that comes due while you are continuing its session (`chi send --new --continues`, web `continue →`) is
|
|
78
|
+
skipped for that tick (`being continued as 7b2d41aa; retry at the next tick`) instead of failing as `archived`, so
|
|
79
|
+
the race no longer counts toward `max_failures`. A chain you archived yourself still fails its schedules.
|
|
80
|
+
- A context source from a bundle whose script is gone, or that its install record has no sha256 for, now says so
|
|
81
|
+
(`scripts/pr.rb is missing (reinstall the bundle)`) instead of claiming the script "differs from the installed one".
|
|
82
|
+
- A chain schedule whose session was archived between the tick's check and its firing now fails as `archived`, as the
|
|
83
|
+
check says, instead of `the chain is gone`.
|
|
84
|
+
- web: a ```` ```chi-ui ```` picks row whose id starts with `!` or `/` no longer makes **Fill reply** start a shell
|
|
85
|
+
line or a session command: the leading `!` and `/` are dropped from the id (`!touch x` reads `touch x: …`), and an id
|
|
86
|
+
of nothing else refuses the block.
|
|
87
|
+
- `chi send` to a continued session no longer brings the old link back beside the new one when the continue finishes
|
|
88
|
+
just as the send goes in: it resends to the new link (or says `refused: being continued; send again in a moment`
|
|
89
|
+
after 10 s), and a same-mode schedule firing at that moment queues its turn in the new link instead of failing as
|
|
90
|
+
`archived`. With `--remote`, the other machine's chi web needs this release for the send half.
|
|
91
|
+
- `chi send OLD NEW` no longer sends twice when a continue makes NEW out of OLD just as the send goes in, and a send
|
|
92
|
+
with `--image` that resends that way no longer leaves its images copied into the old link (on this machine).
|
|
93
|
+
|
|
94
|
+
Update with `chi update`, then restart chi web and running sessions (`chi sessions restart`).
|
|
95
|
+
|
|
11
96
|
## [0.164.0] - 2026-11-10
|
|
12
97
|
|
|
13
98
|
### Changed
|
|
@@ -6068,7 +6153,9 @@ and long-lived sessions.
|
|
|
6068
6153
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6069
6154
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6070
6155
|
|
|
6071
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6156
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.166.0...HEAD
|
|
6157
|
+
[0.166.0]: https://github.com/dm1try/samagotchi/compare/v0.165.0...v0.166.0
|
|
6158
|
+
[0.165.0]: https://github.com/dm1try/samagotchi/compare/v0.164.0...v0.165.0
|
|
6072
6159
|
[0.164.0]: https://github.com/dm1try/samagotchi/compare/v0.163.0...v0.164.0
|
|
6073
6160
|
[0.163.0]: https://github.com/dm1try/samagotchi/compare/v0.162.0...v0.163.0
|
|
6074
6161
|
[0.162.0]: https://github.com/dm1try/samagotchi/compare/v0.161.0...v0.162.0
|
data/docs/architecture.md
CHANGED
|
@@ -199,7 +199,7 @@ log's last 4 MB). Rows: [configuration.md](configuration.md#checking-it-chi-home
|
|
|
199
199
|
- **Starting:** every spawn marks the session starting (`<uuid>/starting`, `{pid, at}`, `StartingMarker`) until its worker holds the lock: `spawn_worker_for_session` writes it with its own pid before `Process.spawn` and the starter's after (the starter lives until the worker holds the lock, at most `WORKER_START_GRACE`; a spawn that raises or whose starter is gone leaves none), `spawn_session` before the new file is saved, and `Worker#start` removes it. It holds for 60 s at most, and only while the pid it names runs. A resume claims it (`StartingMarker.claim`, a link(2): of resumes racing from any processes one wins), then reads the owner again. A stop marker cancels the hold-off (`start_pending?` = starting and not stop-marked) for a start marked before the stop only: of two sends after a stop, the claim lets one spawn. The stop marker carries its own `at` (`{"at"}`, on the starting marker's clock; `Session.stopped_at`), an older chi's empty one its mtime. The sweep, archive (`:starting`) and delete (refused as an owned session) honour it. N-1: an older spawner writes none for a resume (the owner checks stay); an older worker never leaves one it was given (every worker clears it at start); a leftover one is stale by age or pid (a claim's temp files a kill left, `starting.*`, count as skeleton); a 0.160 spawner or chi web still holds off on a fresh marker under a stop (it reads `starting?` before the stop), until the start ends or 60 s. `SessionManager` keeps only its starters' pids, for chi web's restart to adopt (`live_spawn_pids`), and decides nothing from them.
|
|
200
200
|
- **Deleting:** `delete_session`, the retention sweep and a failed continue's cleanup use `remove_files` for the session JSON, sidecar dir, plugin state, attached context, participant grants, System 1 runs and context-candidate records. The JSON and dir go through `remove_session_files`, holding the owner lock (kind `deleting`, which `stop_session` never signals; not waited for: a worker that took it since the check keeps the session) and reading the starting marker again under it (a resume that claimed the start just before keeps the session; one after it sees the lock held). N-1: an older chi's stop reading the owner then would TERM the deleter (chi web, the CLI) in that moment; an older reader shows the kind as unknown. `Session#save` of a session read from its file (or saved once) skips a file that is gone (log `save_skipped_deleted`) rather than recreate it; only a new session's first save creates one.
|
|
201
201
|
- **Worker presence:** whether a worker is up, coming or held off is read once per decision as a `WorkerPresence` (`worker_presence.rb`, a `Data.define`), the deciders' one reader of those facts (display and list rows still read `session_owner` / `WorkerLink` themselves): the owner lock's holder, the stop marker (`stop_marked?`: the only "stopped" a decider reads, never the session file's status), the `starting` marker (`StartingMarker`, `starting?`, `start_pending?`: every spawn writes it, see Starting), the archive marker, the session file's existence, and the `WorkerLink` outcome when asked (never the file itself: a scratch session's flag is read by `WakePolicy`, last). The deciders read it: `resume_session` (tui, owned, `resume_held_off?`), the session inbox's `WakePolicy` (a ring, a push's wake, a note, a fresh verdict, `wake_for_report`, `deliver_turn`'s two liveness checks, `WorkerBoot`'s leave: below), `Local#wake`/`#worker`, `AttachLauncher`, `Schedules#busy_reason`, archive, delete and the retention sweep. Each keeps its own subset of the facts and their order.
|
|
202
|
-
- **Session inbox:** a delivery into a session (`SessionInbox.deliver(kind, id) { |at| write }`, `session_inbox_delivery.rb`) runs one path: resolve the link (`SessionInbox::Head.resolve`: push and a fresh verdict are pinned to the id named; a send and a note go to the chain's newest link, and for a send (a kind that starts an archived link) a continue of the reached link in flight (`ContinueIntent.in_flight`: `continue.json` written, `continue.lock` held, the successor not saved yet) gives `:continuing` with the successor's id, which chi send asks again for a moment and then refuses; a note needs no such check (`NoteMove` moves or adopts it); a ring's file stays with the parent `parent.json` names and its wake goes one hop, to the link whose `ChildReports` reads that file; only an archived id is walked, with one `Session.list`), refuse before any write (a gone session; a one-turn run's or a scratch session for send and a note), write with the kind's own writer (formats unchanged), read `WorkerPresence` once, and apply the kind's `WakePolicy` row. `decide` reads in one order for every kind: gone, one-turn run (`:owned`), owned (`:live`), the stop marker (`:stopped`: the only "stopped", the file's status never decides; send un-stops), archived (send alone starts one), starting (`:starting`, never a second spawn), the kind never starts (`:none`: a note, a fresh verdict) or wasn't asked to (`:off`), scratch (the session file is read only here), else `:start` through `SessionManager.start_for_inbox` (`resume_session`, its claim on the starting marker; it answers `:woken` only when it spawned the worker, `:starting` when another start won the claim, `:live` when a worker took the lock since). N-1 gap: a session file that says `stopped` with no stop marker (stopped before the marker existed, or a resume whose spawn failed after it cleared the marker) is woken, and an older worker, which has no `Worker#settle_stale_status`, exits on its first pass; the wake still reads `:woken`, and each later ring or push spawns another such worker (bounded by the rings and pushes). Restarting chi on the new version (`chi web`, the workers) closes it. `SessionInbox.wake` is the wake half alone (`wake_for_report`, a failed continue's rings). On it: `ChildRing.ring` (its start on a thread), `Local#context_push`'s wake (its outcome is `ContextPush#wake`, the push line's ending), `NoteDelivery.deliver` (every note writer a person or another session drives: `chi note`, `send_note`, `chi broadcast`, chi web's notes route; `NoteDelivery::Result#id` is the link that has it, `#asked` the one named; `/objectives` passes `pin: true`: its list is its own session's) and `VerifyFresh.forward` (`:fresh_verdict`: the child's parent, pinned, no worker). Send keeps its Bridge/file flow in `SessionManager.deliver_turn`, which resolves nothing (it acts on the id it is given: an archived link gets the message and comes back); chi send resolves the head first (`SessionAccess#head`, remotely `GET /api/sessions/resolve?head=1`), while the web composer, a participant's turn, `delegate` follow-ups, `Plugin::Sessions` and `Schedules` stay on the id they name; its two liveness checks (before the post, after a file's write) read the `:send`
|
|
202
|
+
- **Session inbox:** a delivery into a session (`SessionInbox.deliver(kind, id) { |at| write }`, `session_inbox_delivery.rb`) runs one path: resolve the link (`SessionInbox::Head.resolve`: push and a fresh verdict are pinned to the id named; a send and a note go to the chain's newest link, and for a send (a kind that starts an archived link) a continue of the reached link in flight (`ContinueIntent.in_flight`: `continue.json` written, `continue.lock` held, the successor not saved yet) gives `:continuing` with the successor's id, which chi send asks again for a moment and then refuses; a note needs no such check (`NoteMove` moves or adopts it); a ring's file stays with the parent `parent.json` names and its wake goes one hop, to the link whose `ChildReports` reads that file; only an archived id is walked, with one `Session.list`: `SessionChain::Links#first_live`), refuse before any write (a gone session; a one-turn run's or a scratch session for send and a note), write with the kind's own writer (formats unchanged), read `WorkerPresence` once, and apply the kind's `WakePolicy` row. `decide` reads in one order for every kind: gone, one-turn run (`:owned`), owned (`:live`), the stop marker (`:stopped`: the only "stopped", the file's status never decides; send un-stops), archived (send alone starts one), starting (`:starting`, never a second spawn), the kind never starts (`:none`: a note, a fresh verdict) or wasn't asked to (`:off`), scratch (the session file is read only here), else `:start` through `SessionManager.start_for_inbox` (`resume_session`, its claim on the starting marker; it answers `:woken` only when it spawned the worker, `:starting` when another start won the claim, `:live` when a worker took the lock since). N-1 gap: a session file that says `stopped` with no stop marker (stopped before the marker existed, or a resume whose spawn failed after it cleared the marker) is woken, and an older worker, which has no `Worker#settle_stale_status`, exits on its first pass; the wake still reads `:woken`, and each later ring or push spawns another such worker (bounded by the rings and pushes). Restarting chi on the new version (`chi web`, the workers) closes it. `SessionInbox.wake` is the wake half alone (`wake_for_report`, a failed continue's rings). On it: `ChildRing.ring` (its start on a thread), `Local#context_push`'s wake (its outcome is `ContextPush#wake`, the push line's ending), `NoteDelivery.deliver` (every note writer a person or another session drives: `chi note`, `send_note`, `chi broadcast`, chi web's notes route; `NoteDelivery::Result#id` is the link that has it, `#asked` the one named; `/objectives` passes `pin: true`: its list is its own session's) and `VerifyFresh.forward` (`:fresh_verdict`: the child's parent, pinned, no worker). Send keeps its Bridge/file flow in `SessionManager.deliver_turn`, which resolves nothing (it acts on the id it is given: an archived link gets the message and comes back); chi send resolves the head first (`SessionAccess#head`, remotely `GET /api/sessions/resolve?head=1`), while the web composer, a participant's turn, `delegate` follow-ups, `Plugin::Sessions` and `Schedules` stay on the id they name; its two liveness checks (before the post, after a file's write) read the sender's row (`WakePolicy.for_sender(client_id)`, `ClientId.wake_kind`: a person's — chi send, a web tab, a TUI — is `:send`; a schedule, a plugin, a delegate follow-up and a participant have rows of their own, any other id `:automatic`, which start an idle session but neither un-stop nor start an archived link: refused before the write, `DeliverResult::STOPPED` / `ARCHIVED`) and leave the other refusals to `resume_session`'s wording. One row is not a delivery: `:leave`, `WorkerBoot.run_session_loop`'s successor as a worker leaves (input left after a signal, an idle exit's or `/exit`'s input or rings, a restart), read on a fresh presence once the lock is free: a stop that landed as it left starts none for any way out (`resume_session` would clear the stop; logged `respawn_dropped`, `restart_dropped` for a restart, whose reminders go with it), the input and rings stay for the next start. The notes a spawn writes into the session it starts stay direct `SessionInbox.write_note` calls, pinned by construction: spawn_session's chain note, `ContextMove`'s notes, `Objectives.carry`, `ChildMove`'s note to a moved child. A continue moves the previous link's waiting notes to the new link last in its `before_spawn` (`NoteMove.move`), a failed one gives them back before the link goes (`NoteMove.give_back`), and the new link's worker adopts what the archived links before it get after their continue (`NoteMove.adoption`, from `WorkerInbound#absorb_notes` and `Worker#start`: back along the chain through up to 8 archived links, from each only notes from the creation of the link that continued it, never an objectives list). `write_note` refuses a session with no file and no folder (`Session::NotFound`), so a late writer can't bring back a deleted link's folder.
|
|
203
203
|
- **Retention:** 14 days / 500 cap (env `SAMAGOTCHI_SESSION_RETENTION_DAYS`/`MAX_COUNT`, optional `KEEP_STATUS`), live-owner and starting guard (looked at again right before a session's files go), only when `*.json` present; lazy sweep at most once per `session.sweep_interval_hours` (default 24) from the session hub's full-probe tick (and on `GET /api/sessions`, which the page no longer calls), manual via `bin/chi sessions prune --dry-run`.
|
|
204
204
|
- **Ordering:** `Session.list(sort:,order:,limit:,offset:)` and `GET /api/sessions?sort=&order=&limit=&offset=` default `updated_at desc`; Web UI sort/filter/pagination.
|
|
205
205
|
- **Test hygiene:** `test_run` flag when `SAMAGOTCHI_ENV=test`/`RACK_ENV=test`/`CI`, targetable via `prune --test-only` / `clean`.
|
|
@@ -351,7 +351,9 @@ first RubyGems check is about 30 seconds after chi web starts, then it checks at
|
|
|
351
351
|
intervals. A stable release is available only after `update.min_age_hours` and when newer than both
|
|
352
352
|
the running and newest installed chi. Its atomic, mode-0600
|
|
353
353
|
`$XDG_STATE_HOME/samagotchi/update_check.json` keeps the check cooldown and versions already
|
|
354
|
-
announced across restarts, and AutoUpdate's record (`auto`, `auto_failed`; `save_auto`)
|
|
354
|
+
announced across restarts, and AutoUpdate's record (`auto`, `auto_failed`; `save_auto`); its `version` is its
|
|
355
|
+
`StateFormat` (`UpdateCheck::STATE_FORMAT`: a file without one is an older chi's, a newer chi's keeps its version and
|
|
356
|
+
unknown keys through a write). `update.notify: off`
|
|
355
357
|
with `update.auto: off` starts no checker thread and makes no network request. `update_blocked` names why the local gem cannot be updated in place (checkout, Bundler, or
|
|
356
358
|
an unwritable gem directory). The page tells the owner to run `chi update`; a newer `installed`
|
|
357
359
|
version than the server itself still means restart chi web (its workers already run the newest chi,
|
|
@@ -624,7 +626,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
624
626
|
| Paths | `paths.rb` (`Paths`) | The XDG base dirs chi's files live under, read from the env on every call: `Paths.state_home` (`$XDG_STATE_HOME`, else `~/.local/state`) and `Paths.config_home` (`$XDG_CONFIG_HOME`, else `~/.config`), both defaults under `Dir.home`; a blank variable counts as unset, a relative one is made absolute from the current directory. `Paths.tilde` shows a path with `~` for the home folder. `SessionManager` hands a spawned worker the spawner's `XDG_STATE_HOME` / `XDG_CONFIG_HOME`, when set, made absolute, so a relative one isn't read from the session's folder. |
|
|
625
627
|
| MemoryBundle | `memory_bundle.rb`, `memory_bundle/{installer,builder,installed_bundle,plugin_ref,bundle_hook}.rb` (`Installer`, `Builder`, `InstalledBundle`, `PluginRef`, `BundleHook`) | Installing, building and reading bundles of memories, rules, plugins and scripts (`BundleHook`: an older record's retired class-file hook). |
|
|
626
628
|
| Bundle authoring | `bundle_command.rb` (`BundleCommand`), `bundle_command/{scaffold,check,test_run}.rb`, `bundle_command/try/{run,sandbox,trace}.rb`, `testing.rb` + `testing/` (the test kit) | `chi bundle new`, `check`, `test` and `try`, and the kit a bundle's tests load it with ([bundle-authoring.md](bundle-authoring.md), [internals/bundles.md](internals/bundles.md)). |
|
|
627
|
-
| Session file | `session.rb` (`Session`, `Session::FIELDS`), `session_field.rb` (`SessionField`), `session_paths.rb` (`SessionPaths`), `session_setup.rb` (`SessionSetup`) | A session's `<uuid>.json`: one `SessionField` row per key (default, cast, what the file gets; the codec on its type), from which `Session.new`, `.from_h` and `#to_h` are built; `SessionPaths` is where the file and the session's dir are and the id rule, a leaf `Session` extends (so `ArchiveStore`, `ContextSources` and `ParticipantMode` name no `Session` constant; the first two still require session.rb at load, `ParticipantMode` lazily); `SessionSetup` the settings a fork and a continue carry, applied by member name. See [sessions.md](sessions.md#session-file). |
|
|
629
|
+
| Session file | `session.rb` (`Session`, `Session::FIELDS`), `session_field.rb` (`SessionField`), `session_paths.rb` (`SessionPaths`), `session_setup.rb` (`SessionSetup`) | A session's `<uuid>.json`: one `SessionField` row per key (default, cast, what the file gets; the codec on its type), from which `Session.new`, `.from_h` and `#to_h` are built; `SessionPaths` is where the file and the session's dir are and the id rule, a leaf `Session` extends (so `ArchiveStore`, `ContextSources` and `ParticipantMode` name no `Session` constant; the first two still require session.rb at load, `ParticipantMode` lazily); `SessionSetup` the settings a fork and a continue carry (`.of`), applied by member name; every new-session request (chi's run flags, the one-shot, `chi send --new`, chi web's create) builds its setup with `SessionSetup.from_request`, and `spec/session_setup_entrypoints_spec.rb` holds each entrypoint's cell for each member. See [sessions.md](sessions.md#session-file). |
|
|
628
630
|
| Session config (`--set`) | `session_config.rb` (`SessionConfig`, `SessionConfig::Settings`) | A session's own settings as one value (`Session#settings`, `SessionSetup#settings`): `core`, the `--set KEY=VALUE` values of the core keys marked `session: true` (`Config::Entry`), typed by `Config.coerce!` and read first through `Config.get(key, session:)` (`RecapSetup`; `Engine#session=` rebuilds the recap job, `IdleScheduler#replace_job`), file key `config_settings`; `bundles`, the `--set BUNDLE.KEY=VALUE` values, checked against the manifest's `session_settings:`, laid over `bundles: <name>:` in `ctx.settings` ([plugins.md](plugins.md)), file key `bundle_settings`. `SessionConfig.clash` refuses a bundle setting named like a core one (install, `chi bundle check`). See [configuration.md](configuration.md#per-session-settings). |
|
|
629
631
|
| Plugin API | `plugin/api.rb` (`Plugin::Api`), `plugin/tool_spec.rb` (`Plugin::ToolSpec`: a checked tool declaration, how it is registered), `plugin/loader.rb`, `plugin/context.rb` (`ctx`), `plugin/http.rb` + `plugin/http_transport.rb` (`ctx.http`), `plugin/card.rb` (`Plugin::Card`) | What a bundle's plugin registers: tools, commands, annotation actions, hooks, services, toolkits, peer sources; what its handlers get as `ctx` ([plugins.md](plugins.md)). |
|
|
630
632
|
| Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`) | What claude-peer and codex-peer share (the send tool, the command, the cards, payloads); each bundle's subclass sets its strings and transport ([bundles.md](bundles.md#the-claude-peer-bundle)). |
|
|
@@ -639,7 +641,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
639
641
|
| Idle work | `idle_scheduler.rb` (`IdleScheduler`), `idle_recap.rb` (`IdleRecap`), `idle_reminders.rb` | One poller for an idle session's recap and reminders. |
|
|
640
642
|
| Attached context | `context_sources.rb` (`ContextSources`), `context_poller.rb`, `context_absorber.rb`, `context_candidates.rb` (`ContextCandidates`: proposed sources, attached on the owner's mention at a turn's start, before the worker's absorb, or in a one-shot's turn; `owner_prompt.rb` decides whose words count), `peer_sources.rb` (`PeerSources`: the sources peer bundles declare) | External sources a session keeps fresh, and the peer loop's wakes ([context.md](context.md)). |
|
|
641
643
|
| LLM context strategies | `llm_context_strategy.rb`, `llm_context_view.rb`, `llm_context_stale.rb`, `llm_context_forget.rb` | What a request sends of the history (none, stale, forget) ([internals/llm-context-forget.md](internals/llm-context-forget.md)). |
|
|
642
|
-
| Session chains | `session_continue.rb` (`SessionContinue`), `session_chain.rb` (`SessionChain`) | A session that continues an earlier one. `SessionChain.opener_for` gives the text web `continue →` prefills in the new link: the previous link's own first typed message when that link continues one itself, else nil (the 201's `opener`; not saved) ([sessions.md](sessions.md)). |
|
|
644
|
+
| Session chains | `session_continue.rb` (`SessionContinue`), `session_chain.rb` (`SessionChain`), `session_chain/links.rb` (`SessionChain::Links`) | A session that continues an earlier one. `SessionChain::Links` is the one chain walker (one listing; `latest`, `first_live`, `root`, `next_of`): `SessionChain.latest`/`.next_of`, `SessionInbox::Head` and the schedule tick all ask it. `SessionChain.opener_for` gives the text web `continue →` prefills in the new link: the previous link's own first typed message when that link continues one itself, else nil (the 201's `opener`; not saved) ([sessions.md](sessions.md)). |
|
|
643
645
|
| Review sessions | `review_start.rb` (`ReviewStart`), `session_review.rb` (`SessionReview`, the session's `review` field), `review_command.rb` (`ReviewCommand`, `chi review`), `review_apply.rb` (`ReviewApply`) | A session made to be shared: idle, its subjects project files checked by `Guardrails::ReviewPaths`, a fork of a working session from its recap (`--from`); Apply quotes a participant's review turn into the owner's composer ([sessions.md](sessions.md#review-sessions), [internals/participants.md](internals/participants.md)). |
|
|
644
646
|
| chi web's routes | `web/app.rb` (`Web::App`: the gate, `ROUTES`, the shared helpers), `web/message_display.rb` (`Web::MessageDisplay`: saved messages and cards as display items, the owner show's stamped with their turns' drawings and carrying no parts (a step's ✂ marks only), the participant review's with their parts, `POST /api/render`), `web/session_show.rb` (`Web::SessionShow`: `GET /api/sessions/:id` with its `cards`, `tail` and `timing` re-reads, `GET …/output`, the timing payload), `web/session_create.rb` (`Web::SessionCreate`: `POST /api/sessions`, a continue, a review fork), `web/session_control.rb` (`Web::SessionControl`: answer, command, turn and images, cancel, stop, restart, archive, delete), `web/push_routes.rb` (`Web::PushRoutes`: `/api/push`, its subscriptions, prefs, test and presence), `web/block_renderer_routes.rb` (`Web::BlockRendererRoutes`: `GET /api/block_renderers` and one renderer's file, [internals/block-renderers.md](internals/block-renderers.md)), `web/reload_check_route.rb` (`Web::ReloadCheckRoute`: `POST /api/sessions/:id/reload_check`, the opt-in `web.reload_check`'s counts from the page's `reload_check.js`, 204 and one `reload_checked` log line, with `reload_mismatch`, its `kinds`, `excused` (ACCEPTED ids) and `explained` when the turn read otherwise after a reload; the worker's version is chi web's own view, its sidecar) | The handlers `App`'s `ROUTES` name, in the file that holds their kind; each mixin is included in `App` and reads its helpers and ivars, so `app.send(:handle_show, …)` and the specs that stub `App` methods work as before. |
|
|
645
647
|
| Web Push | `web/push.rb` (`Web::Push`: `Runtime`, `preflight!`, the `web.push.*` settings), `web/push/crypto.rb` (`Push::Crypto`: RFC 8291 aes128gcm, RFC 8292 VAPID), `web/push/store.rb` (`Push::Store`, `Store::Sub`: `web-push/vapid.pem`, `subscriptions.json`), `web/push/client.rb` (`Push::Client`, `Client::Result`), `web/push/attention.rb` (`Push::Attention`: notify.js's rules in Ruby, shared cases in `spec/fixtures/attention_cases.json`), `web/push/presence.rb` (`Push::Presence`: the pages' "in front" reports), `web/push/notifier.rb` (`Push::Notifier`, a hub subscriber with a sender thread), `web/push_routes.rb` (`Web::PushRoutes`), `private_files.rb` (`PrivateFiles`, shared with the grants), `public/sw.js`, `public/push.js`, `public/manifest.webmanifest` | chi web pushes what the tab notifies for (approvals, questions, step-limit questions, cards, failed turns; done turns to a device that asks) to the owner's Home Screen app over an https public URL: the Notifier turns the hub's new attentions into show pushes after a hold, unless a chi web page is in front, at most 30 an hour, with one retry and a restart catch-up (`sent.json`) (each carries the keys still open, and the badge; no close push: every push shows a notification); the bell (`notifications.js`) subscribes the device, and the service worker and the page close the answered ones. See [internals/web-push.md](internals/web-push.md). |
|
|
@@ -658,7 +660,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
658
660
|
| Dialects | `llm/dialect.rb` (`LLM::Dialect`) | What an `api: anthropic` provider's `/v1/messages` does differently (`dialect: fireworks`) ([internals/anthropic.md](internals/anthropic.md)). |
|
|
659
661
|
| Logging | `log.rb` (`Log`), `log_subscriber.rb` (`LogSubscriber`), `log_path.rb` (`LogPath`), `log_line.rb` | The debug log: tagged records, a session's event trail, where the file goes ([configuration.md](configuration.md#debug-log-file)). |
|
|
660
662
|
| Stores | `reminder_store.rb` (`ReminderStore`), `recap_store.rb` (`RecapStore`) | A session's reminders, and its idle recap (`recap.json`). |
|
|
661
|
-
| Schedules | `schedules.rb` (`Schedules`, its `Entry`, `Tick
|
|
663
|
+
| Schedules | `schedules.rb` (`Schedules`, its `Entry`, `Tick`; the tick walks chains over one `SessionChain::Links`), `schedule_command.rb` (`ScheduleCommand`) | Durable schedules that outlive every worker: versioned `<state dir>/schedules.json` and its `schedules.lock`; rewrites preserve unknown keys and entries missing required members. The tick's busy check (a live worker asked over the Bridge's `GET /activity`, the files when there is none), the chain prune. `chi schedule` is this machine only. See [Scheduling](scheduling.md). |
|
|
662
664
|
| Reply waits | `reply_wait.rb` (`ReplyWait`, `GONE_AFTER`: the one dead-worker rule), `reply_wait/poll.rb` (`ReplyWait::Poll`, one look per poll), `reply_wait/target.rb` (`ReplyWait::Target`: which turn a wait binds, cursor, baseline, `owner_grace`; `first_message`, `message`, `wait_only`, `answer`, `participant`, `from_cursor`), `reply_wait/liveness.rb` (`ReplyWait::Liveness`: one owner and link read per look; `#owner?` for gone, `#worker_owned?` for an open question) | `chi send --wait`, `chi answer`, a participant's wait, the delegate tools and delegate reports wait through `ReplyWait.call(id, **target.to_h, …)` ([sub-agent.md](sub-agent.md)). |
|
|
663
665
|
| Session rows | `session_row.rb` (`SessionRow`) | A session as the lists see it: scalar facts only, built by `SessionManager.session_rows` (one owner, link, recap and analytics read each), `#to_summary_h` the summaries route's body and `.from_summary_h` a remote's rows read back, `#cli_line` the one `chi sessions list` line, `.running_or_starting?` the delegates' and Verify fresh's "running" (a 15 s grace for a worker on its way). A leaf: never session_manager or web. |
|
|
664
666
|
| Setup and update | `bootstrap_command.rb`, `bootstrap/`, `update_command.rb`, `gem_update.rb` | `chi bootstrap` (first config.yml, system bundle, core profile) and `chi update` (the gem, shipped bundles, the macOS helper). |
|
data/docs/cli.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- `chi --attach <session-id>` — attach the terminal to a session's worker (e.g. one started from the Web UI), waking one if it has exited
|
|
12
12
|
- A session id can be shortened to any unique prefix (like git): `chi --attach 2ea8`. `--resume`, `--attach`, `sessions stop`, `sessions archive` and `sessions delete` take one; an ambiguous prefix lists the sessions it matches.
|
|
13
13
|
- `chi web [--port 4567] [--open] [--scope=all] [--start-dir DIR]` — start the Web UI (single localhost port session control plane) on this project's sessions (a git repository or a `chi project init` folder; `--scope=all`, or a folder in neither: `/?scope=all`, every session); if a chi web already runs on the port, print (with `--open`, open) its page for this folder and exit. Something else on the port (an older chi web too) exits 1 with "port N is in use"
|
|
14
|
-
- `chi web --web-host lan` — the Web UI on your home network too, for your phone: a link with an access token and its QR code (see [chi web on your phone](#chi-web-on-your-phone)); `chi web --new-token` replaces the
|
|
14
|
+
- `chi web --web-host lan` — the Web UI on your home network too, for your phone: a link with an access token and its QR code (see [chi web on your phone](#chi-web-on-your-phone)); `chi web --new-token` replaces chi web's access token (the LAN link, `--tunnel tailscale` and a proxy use it too), so old links, QR codes and cookies stop working; participant grants are unaffected
|
|
15
15
|
- `chi web --start-dir DIR` (config `web.start_dir`) — the folder chi web starts in, in place of the one you run it in (`~` and a relative path work; chi web never changes its own folder): its page opens on that folder's project (the printed link, a bare `/`, the LAN link and its QR code, the Home Screen app), and a new session from the all view starts there; the header's project chip switches projects, and its picker has a `New project…` row for creating a project folder (a path inside a git repository opens that repository's project and the folder is left as it is, nothing marked). One that isn't a folder exits 1; `--start-dir` without `web` exits 2. A chi web already running in another folder keeps it (the second one says so: restart it to change it)
|
|
16
16
|
- `chi web --tunnel tailscale` — the Web UI over https on your tailnet, for your phone anywhere: Tailscale Serve (never Funnel) on this machine's `<machine>.<tailnet>.ts.net` name for this run, the owner your Tailscale login, turned off on exit (see [Tailscale Serve](configuration.md#tailscale-serve-your-tailnet)); `--tunnel` without `web` exits 2
|
|
17
17
|
- `chi web push ls [--format json]`, `chi web push rm ID`, `chi web push test [ID]` — the phones chi web pushes to (see [Phone notifications](configuration.md#phone-notifications-web-push)): list them (short id, label, origin, added, last delivery, done turns, last error; `stale` for one made on another public URL than chi web's now: never sent to), remove one, or send a test notification to ID or to every device not stale. chi web need not run; nothing printed holds a device's push address or keys. A usage error exits 2; a store others can read, a corrupt one, an unknown device or a failed test push exit 1. This machine only: `chi --remote X web push` exits 2
|
|
@@ -1057,7 +1057,11 @@ The prompt stays open while a turn runs in an attached terminal:
|
|
|
1057
1057
|
web's composer points at the × on the bubble.
|
|
1058
1058
|
- **The web composer** has a row above the text field in a session (always
|
|
1059
1059
|
there, so the composer never changes height): the keys while idle, and while
|
|
1060
|
-
the turn runs the delivery line
|
|
1060
|
+
the turn runs the delivery line (a phone has no such row: while the turn runs
|
|
1061
|
+
the line, short, and its `cut in` and `queue` chips take the session bar's
|
|
1062
|
+
left, where status, ctx and speed are, while you type or have a choice armed:
|
|
1063
|
+
the text field focused or holding text or images, a chip armed or an Apply
|
|
1064
|
+
turn held; otherwise the bar keeps them), where a message sent now goes in (`↳ goes in after this
|
|
1061
1065
|
thinking step · 0:42 · 3k chars`, `… after this tool call (execute · 0:12)`,
|
|
1062
1066
|
`… after this answer; the turn may go on`, `… once the card above is
|
|
1063
1067
|
answered`), then two links. **Enter** (or Send) is the next step;
|
|
@@ -1534,19 +1538,26 @@ access token", paste the token there (the part of the link after
|
|
|
1534
1538
|
phone. The same sheet lists the other devices (a long-turns-done switch each, Remove), and `chi web push ls|rm|test`
|
|
1535
1539
|
does it from the Mac (see [Phone notifications](configuration.md#phone-notifications-web-push)).
|
|
1536
1540
|
|
|
1537
|
-
#### The session bar
|
|
1541
|
+
#### The session bar
|
|
1538
1542
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1543
|
+
The session bar is one row at every window width, with no swiping and no second line. What doesn't fit folds into ⋯ by
|
|
1544
|
+
priority, the least needed first: the folder and the 🧰 toolkit, then model notes, the working set (or memories),
|
|
1545
|
+
participants and delegates, the model, the chain links, stop session, the speed, ⚙ (first down to its icon), continue →
|
|
1546
|
+
and the id. The status, ctx and ⋯ always stay. On a phone (600 px or less) the row is the status, ctx, the speed, ⚙ (its
|
|
1547
|
+
icon, a dot when the session set its own) and ⋯.
|
|
1541
1548
|
|
|
1542
|
-
|
|
1543
|
-
shows the full text a tooltip gives elsewhere), the working set (or the memories with `web.working_set` off), and, when the
|
|
1544
|
-
session has them, participants, chain links, the parent, delegates, model notes and an older worker's Restart;
|
|
1545
|
-
- one line with ctx, speed, the clock and the folder;
|
|
1546
|
-
- Continue, Archive (or Unarchive), Stop and Delete, under the same rules and confirmations as the wider screen's buttons.
|
|
1549
|
+
⋯ opens a popover (a bottom sheet on a phone) with what the row folded away:
|
|
1547
1550
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1551
|
+
- a row for each folded chip, each opening what its chip opens: the id (a tap copies it), the model and the 🧰 toolkit (a
|
|
1552
|
+
tap shows the full text a tooltip gives elsewhere), ⚙, the working set (or the memories with `web.working_set` off),
|
|
1553
|
+
participants, chain links, the parent, delegates, model notes and an older worker's Restart;
|
|
1554
|
+
- one line with the folded ones of the speed, the clock and the folder;
|
|
1555
|
+
- Archive (or Unarchive) and Delete always, Continue and Stop when folded, under the same rules and confirmations as the
|
|
1556
|
+
buttons on the row.
|
|
1557
|
+
|
|
1558
|
+
On a wider screen ⋯ shows how many things it holds. A dot on ⋯ says something folded behind it needs a look: the accent when
|
|
1559
|
+
the working set changed or a participant is here, the warning colour when a delegate waits or the worker runs an older chi.
|
|
1560
|
+
The attached context's chips keep their own second line under the row.
|
|
1550
1561
|
|
|
1551
1562
|
### Remote sessions
|
|
1552
1563
|
|
data/docs/configuration.md
CHANGED
|
@@ -1408,10 +1408,14 @@ launches it. It is recorded in `~/.config/samagotchi/home.json` (`$XDG_CONFIG_HO
|
|
|
1408
1408
|
"gem_path": "/Users/me/.gem/ruby/4.0.0:/Users/me/.local/share/mise/installs/ruby/4.0.7/lib/ruby/gems/4.0.0",
|
|
1409
1409
|
"mise": "/opt/homebrew/bin/mise",
|
|
1410
1410
|
"set_at": "2026-10-29T21:00:00Z",
|
|
1411
|
-
"set_by_version": "0.132.0"
|
|
1411
|
+
"set_by_version": "0.132.0",
|
|
1412
|
+
"version": 1
|
|
1412
1413
|
}
|
|
1413
1414
|
```
|
|
1414
1415
|
|
|
1416
|
+
(`version` is the file's format, `ChiHome::STATE_FORMAT`: a home.json without one is an older chi's, and a newer chi's
|
|
1417
|
+
keeps its version and the keys this chi doesn't know when the same home is set again.)
|
|
1418
|
+
|
|
1415
1419
|
- **Setting it.** `chi home set` records the Ruby your `chi` runs on and its gem path (a chruby shell's
|
|
1416
1420
|
`GEM_HOME`/`GEM_PATH` are part of it: that is where its chi lives); `chi home set --ruby PATH` records another
|
|
1417
1421
|
Ruby with its own gem dirs. Either needs samagotchi installed there (`gem install samagotchi` with that Ruby
|
|
@@ -2118,6 +2122,8 @@ The app opens on the project chi web starts in (`web.start_dir`; the header's pr
|
|
|
2118
2122
|
notifications are every project's: opening it closes the ones whose question or card is no longer open and sets its
|
|
2119
2123
|
badge for every project, whichever project the page shows.
|
|
2120
2124
|
In a browser tab the bell stays the tab's own notifications (while the tab is in the background), as before.
|
|
2125
|
+
The app uses the whole screen, under the status bar and the home indicator, and keeps its controls clear of them (the
|
|
2126
|
+
notch too, held sideways); its status bar takes the page's background, dark or light with the system.
|
|
2121
2127
|
|
|
2122
2128
|
**The devices** (the bell's sheet in the app; a bottom sheet on the phone): this device first, with its switch (off
|
|
2123
2129
|
removes it from chi web and is the same as the bell turned off), then every other device chi web pushes to: its label,
|
|
@@ -2375,7 +2381,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
|
|
|
2375
2381
|
| `execute.on_timeout` | `task` | yes | What happens to a command still running at that limit: `task` keeps it running as a background task (the result names its `task_id`; `task_wait` waits for it, `task_stop` stops it; also early, after 3 s, when a message from the user waits for the turn), `kill` stops it (and never hands over early) (`Error: command timed out after …s`). The `!cmd` bang always kills. See [Background tasks](internals/background-tasks.md). |
|
|
2376
2382
|
| `execute.description` | `true` | | `execute` offers the model an optional `description` (a few words on what the command does), shown as the tool row's title in `chi web` and in place of the command in the TUI's tool line. `false`: the parameter isn't declared, and rows show the command's first step. |
|
|
2377
2383
|
| `web.port` | `4567` | `--port` | `chi web`'s port. See [CLI](cli.md). |
|
|
2378
|
-
| `web.host` | `127.0.0.1` | yes | `127.0.0.1`, `::1` or `localhost`; `lan` (this machine's private IPv4 address) or one of its IPv4 addresses also opens `chi web` to the network, with an access token, asked of this machine's 127.0.0.1 too (its `Local:` link carries a one-time code; `chi web --new-token` replaces the token). Anything else binds `127.0.0.1` with a warning. See [CLI: chi web on your phone](cli.md#chi-web-on-your-phone). |
|
|
2384
|
+
| `web.host` | `127.0.0.1` | yes | `127.0.0.1`, `::1` or `localhost`; `lan` (this machine's private IPv4 address) or one of its IPv4 addresses also opens `chi web` to the network, with an access token, asked of this machine's 127.0.0.1 too (its `Local:` link carries a one-time code; `chi web --new-token` replaces the token; it is chi web's one access token, also used by `--tunnel` and `web.public_url`/a proxy). Anything else binds `127.0.0.1` with a warning. See [CLI: chi web on your phone](cli.md#chi-web-on-your-phone). |
|
|
2379
2385
|
| `web.markdown` | `false` | yes | Render answers as Markdown in `chi web`. |
|
|
2380
2386
|
| `web.working_set` | `true` | yes | The stage view's working set: the files, memories and URLs a turn brought into the model's context, in a rail in the stage, a footprint as each finished turn's block summary and a `set N` chip in place of the mem chip; `false` brings the mem chip back. `?working_set=1` or `?working_set=0` on the page URL overrides it for that page load. See [CLI: the working set](cli.md#the-working-set). |
|
|
2381
2387
|
| `web.reload_check` | `false` | yes | Opt-in: once each finished turn has moved into the history, the page reads the session again (one full read per turn end), draws that turn as a reload would and compares the two, strictly: a known divergence counts as a mismatch too. `chi web` logs one `reload_checked` line per check and a `reload_mismatch` line naming the kinds that differed, `excused` (the known divergences, `history_shape.js` `ACCEPTED`, that would explain them) and `explained` (all of them had one), with `turn_id`, `drawn` (the turn came back from its drawing, so a mismatch with `drawn: true` is a drawing bug), `undrawn` (how many of the reload's rows came without their turn's drawing, the page's plain fallback: 0 unless chi web missed a turn) and the worker's version: counts only, never content. The count is `grep -c reload_mismatch` over `grep -c reload_checked` in chi web's log, split by `excused`. Cards are left out: a reload places them after the render, which the check doesn't run (the e2e reload checks compare them). Every open owner tab runs the check; `chi web` logs a turn's first report only, and starts over when it restarts. |
|
data/docs/guardrails.md
CHANGED
|
@@ -114,8 +114,12 @@ answers it, since it is keyed on the whole command you saw: `git branch -D x &&
|
|
|
114
114
|
once, session and repo, while `git merge y && git push` offers once, as `git-merge` offers only once and its rule.
|
|
115
115
|
Two rules with one id (a config.yml copy of a bundle's rule) are one rule; a core ask followed by a rule's (the
|
|
116
116
|
[child boundary's](#a-delegate-childs-boundary)) keeps its own scopes.
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
The file is a list of entries, or a versioned store (`{"version": 1, "approvals": [...]}`,
|
|
118
|
+
`Approvals::FORMAT`): chi reads both, and a write keeps the shape it read (a versioned store keeps its version, the
|
|
119
|
+
keys this chi doesn't know and an entry with no `scope`). A missing file or a list is written as a list until 0.167,
|
|
120
|
+
since chi 0.165 sets a versioned store aside; from 0.167 it is written versioned (restart sessions from before 0.166).
|
|
121
|
+
A file that doesn't parse, or a versioned store whose `approvals` isn't a list, is moved aside to
|
|
122
|
+
`approvals.json.corrupt-<UTC time>` with one warning, and chi starts with no stored approvals (more asks, nothing lost).
|
|
119
123
|
`/guardrails` lists the rules and approvals; `/guardrails revoke N` removes
|
|
120
124
|
approval N. When System 1 is enabled or has judgments, it also shows this
|
|
121
125
|
session's recent auto-allows and each rule's record summary, and its heading says
|
|
@@ -339,21 +343,18 @@ else the parent's checkout). Rule `child-boundary`, source `core`; it asks when
|
|
|
339
343
|
- a call whose [targets](plugins.md#guardrails) say it writes its paths —
|
|
340
344
|
`write`, `edit`, and a plugin tool's `targets:` with `writes: true` —
|
|
341
345
|
names a path outside it (tmp dirs and memory files don't count);
|
|
342
|
-
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
`<common git dir>/worktrees/*/gitdir`) or in its common git dir
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
the child's folder. Its command's text may not be shell, so the reads a
|
|
355
|
-
shell call gets (its `git -C`/`cd` dirs, its redirects, its read-only test)
|
|
356
|
-
are left out.
|
|
346
|
+
- a shell call runs mutating git in another dir (`git -C`, `cd`, `GIT_DIR`:
|
|
347
|
+
what `git: outside_repo` matches), or a command that isn't read-only starts
|
|
348
|
+
outside it (its `cwd:`) or names a path in the repository's other checkouts
|
|
349
|
+
(the main one and sibling worktrees, read from
|
|
350
|
+
`<common git dir>/worktrees/*/gitdir`) or in its common git dir. A shell
|
|
351
|
+
call is `execute`, `task_create`, or a plugin call whose `targets:` carry a
|
|
352
|
+
`command:`;
|
|
353
|
+
- a shell call runs git that changes what every checkout shares, even from its
|
|
354
|
+
own worktree: a `git config` write (not `--get`, `--list`, `--worktree`),
|
|
355
|
+
`update-ref`, `worktree add|remove|move|prune`, `stash drop|clear|pop`,
|
|
356
|
+
creating or deleting a tag, and deleting, forcing or overwriting a branch
|
|
357
|
+
other than its own;
|
|
357
358
|
|
|
358
359
|
Read-only commands (`git -C ../app log`, `cat ../app/x`) and paths elsewhere
|
|
359
360
|
(`/usr/bin`, `~/.gem`) never ask, nor does a read-only command that writes only
|
|
@@ -738,7 +739,7 @@ guardrails:
|
|
|
738
739
|
mode: auto # or strict: also the rules tagged modes: [strict]; config.yml only
|
|
739
740
|
rules:
|
|
740
741
|
- id: git-push
|
|
741
|
-
tool: shell #
|
|
742
|
+
tool: shell # shell calls, including plugin targets with command:; or a name, glob or list
|
|
742
743
|
command: '\bgit\s+push\b' # Ruby regex on the command (data heredoc bodies left out)
|
|
743
744
|
verdict: ask # ask | deny
|
|
744
745
|
reason: git push publishes commits
|
|
@@ -15,7 +15,7 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
15
15
|
didn't know the key draws once a kept manifest is there) lists
|
|
16
16
|
who draws what: `GET /api/block_renderers`, `:owner`. `GET /api/block_renderers/:bundle/:file` serves a file, `:owner`:
|
|
17
17
|
the URL's names go through `BlockRenderers.script_path` (membership in a listed renderer's `load` before any path is
|
|
18
|
-
made), then `Provenance
|
|
18
|
+
made), then `Provenance#script_failure` (the check a context provider's scripts get too); a file with no recorded sha, a missing one or a changed one is 409
|
|
19
19
|
`renderer_changed`, each with its own reason. ETag + `no-cache`, as static files. A `block_renderers:` list that
|
|
20
20
|
doesn't parse is logged once per bundle and problem (each list request and file fetch reads it).
|
|
21
21
|
3. `block_watch.js` (`createBlockWatch`, made by `block_host.js`'s `createBlockHost`, wired in `app.js`; `participant.js`
|
data/docs/internals/bridge.md
CHANGED
|
@@ -5,6 +5,8 @@ localhost HTTP server in the worker's process, next to the `Engine` it reads and
|
|
|
5
5
|
terminal are its clients; no browser reaches it. [architecture.md](../architecture.md) places it among the layers;
|
|
6
6
|
this page is the surface: what it keeps, how a client joins and catches up, and every route.
|
|
7
7
|
|
|
8
|
+
Bridge Engine calls are listed with their reasons in `Bridge::ENGINE_CALLS`; add each new Engine call there.
|
|
9
|
+
|
|
8
10
|
## What a Bridge keeps
|
|
9
11
|
|
|
10
12
|
`Bridge#start` binds a port (OS-assigned, `127.0.0.1`), then subscribes four persistent observers to the Engine
|
|
@@ -52,8 +54,7 @@ Three other users: `replay_events(turn)` turns a `current_turn` back into the li
|
|
|
52
54
|
`turn_started` also carries `at`, `cut_after` and every author key, then a `turn_enqueued` per queued prompt and a
|
|
53
55
|
`command_queued` per waiting command), which chi web's `GET /api/sessions/:id` sends as `replay` from the worker's
|
|
54
56
|
snapshot (`from_wire` symbolizes it), so any worker's snapshot gives the page the same events
|
|
55
|
-
(`spec/shared/turn_snapshot.json` pins it
|
|
56
|
-
release); `messages_of` gives a
|
|
57
|
+
(`spec/shared/turn_snapshot.json` pins it); `messages_of` gives a
|
|
57
58
|
plugin's `ctx.messages` the turn so far (`Engine#running_turn_messages`); `participant_turn?` tells `POST /turn` that
|
|
58
59
|
a participant's review turn runs, so the owner's input queues behind it.
|
|
59
60
|
|
|
@@ -448,7 +449,7 @@ The Bridge exposes:
|
|
|
448
449
|
`leaving_exit` / `leaving_delete` / `leaving_restart` when another client's exit of another kind is already taken
|
|
449
450
|
(`Worker#claim_exit`, claimed before a stop-all; the words are `WorkerIdleExit::LEAVING_WORDS`). A second exit of
|
|
450
451
|
the kind already taken is answered `200` as that one.
|
|
451
|
-
- `GET /session/:id/state` — `session_state_snapshot` (JSON).
|
|
452
|
+
- `GET /session/:id/state` — `session_state_snapshot` (JSON), read under the event lock so its `event_seq`/`event_id` match the state.
|
|
452
453
|
- `GET /session/:id/stats` — `Engine#stats_snapshot` for attached `/stats`: the metrics, with the context window and prompt profile asked from the server before the first turn.
|
|
453
454
|
- `GET /session/:id/activity` — `Worker#activity_snapshot`: `{session_id, turn_running, input_pending, awaiting_continue, open_streams, reminders, tasks_holding}` — what a `chi schedule tick` asks a live worker before it fires (the tick runs out of process and cannot read a worker's memory). Read-only and small (under 300 bytes). `501 activity_unavailable` when this Bridge was built without an `on_activity:` step; the worker advertises it in `Bridge::FEATURES` (`activity`). See [scheduling.md](../scheduling.md).
|
|
454
455
|
- `GET /session/:id/snapshot` — the snapshot frame's content as one request (the web server renders
|
|
@@ -567,6 +568,12 @@ A worker without `/tail` (an older chi; `404 not_found`) is read through `/snaps
|
|
|
567
568
|
shape; any other failure (no worker, a 500, a timeout) reads the disk, trimmed to the newest
|
|
568
569
|
turn's records.
|
|
569
570
|
|
|
571
|
+
**Recorded per release.** `rake release:bump` records this Bridge's replies to `GET state`, `snapshot` (idle and
|
|
572
|
+
mid-turn) and `tail` in the compat corpus (`spec/compat/X.Y.Z/wire/`, [testing.md](../testing.md#compatibility-corpus)),
|
|
573
|
+
and the next release's clients read them (`spec/compat/wire_readers_spec.rb`). Change these replies additively: a key
|
|
574
|
+
renamed or moved fails that spec against the previous release's worker, which a newer chi web or terminal still talks
|
|
575
|
+
to until it is restarted.
|
|
576
|
+
|
|
570
577
|
Every route goes through `Bridge#dispatch`: an id other than the bridge's own session is
|
|
571
578
|
`404 unknown_session`, and a handler that raises answers `500 bridge_error` (logged as
|
|
572
579
|
`handler_failed`) rather than dropping the connection.
|
data/docs/internals/bundles.md
CHANGED
|
@@ -179,8 +179,10 @@ its removal, so no edit is lost, and the record isn't written, so a retry is the
|
|
|
179
179
|
failed run already placed stay, and the intent journal says they are the bundle's.
|
|
180
180
|
|
|
181
181
|
**The intent journal.** After `check_named_files` and before the first write, a real run with a manifest writes
|
|
182
|
-
`.bundles/<name>/pending.json` (`Provenance#write_pending`, atomically like the record): `{"
|
|
183
|
-
"scope": "project", "target_dir": "/path/to/project-memories", "files": {"a.md": ["<sha256>"]}}
|
|
182
|
+
`.bundles/<name>/pending.json` (`Provenance#write_pending`, atomically like the record): `{"pending_format": 1,
|
|
183
|
+
"version": "2.0.0", "scope": "project", "target_dir": "/path/to/project-memories", "files": {"a.md": ["<sha256>"]}}`
|
|
184
|
+
(`pending_format` is its `StateFormat`, `PENDING_FORMAT`: a journal without it is an older chi's, the same members; a
|
|
185
|
+
newer chi's keeps its format and unknown keys through a retry's write, and the release corpus records one): the target
|
|
184
186
|
`version` is the latest run's target version, while `files` holds the union of incoming shas recorded by interrupted
|
|
185
187
|
runs for that scope/target directory. A retry of another version in the same target adds its incoming shas; a journal
|
|
186
188
|
for another scope directory is ignored. `Provenance#write` removes it with the record write; an uninstall's `rm_rf`
|
|
@@ -57,6 +57,10 @@ Pure Ruby, no web, no Engine. `parse(source)` returns a `Result`: `ok?`, `type`,
|
|
|
57
57
|
`next` or a `goto` goes. This is a mend, not a second lenient pass (`Tree#folds`, `Schema#text`).
|
|
58
58
|
- **Normalised.** Ids are strings, unknown keys are dropped, a repeated key is last-wins (`Tree#mapping`), optional values are absent rather than null, and text is
|
|
59
59
|
stripped. The page never sees model junk.
|
|
60
|
+
- **A row id never starts a command.** Fill reply puts a picks row's id first in the composer, so a leading `!` (a
|
|
61
|
+
shell line) or `/` (a session command), with the spaces between them, is dropped from it (`Schema#row_id`,
|
|
62
|
+
`COMMAND_LEAD`): `!touch x` is the id `touch x`, the Result `lenient?`, a mend like a fold. An id of nothing else is
|
|
63
|
+
refused, and the uniqueness check sees the mended ids. A walk's ids never reach the composer and stay as written.
|
|
60
64
|
|
|
61
65
|
### The schemas
|
|
62
66
|
|
|
@@ -125,7 +129,10 @@ session switch, a turn's end, Revise's clones, the stage's hand-off to `#history
|
|
|
125
129
|
|
|
126
130
|
**The only way out is composer text.** Fill reply builds `id: option (note) · …` from the picked rows (a row with no
|
|
127
131
|
pick is left out) and hands it to app.js's `fillComposer`, after a typed draft on a new line (`withDraft`; the draft
|
|
128
|
-
is kept). It never sends: the owner reads the text and sends it or not.
|
|
132
|
+
is kept). It never sends: the owner reads the text and sends it or not. `replyText` drops a leading `!` or `/` from
|
|
133
|
+
an id too (an id of only those is its row's number), so the filled text never starts a shell line or a session command
|
|
134
|
+
even from data the normaliser didn't mend; the draft before it is the owner's own. The row's `wp-id` chip shows that
|
|
135
|
+
same cleaned id (`rowId`, one rule for both), so what is drawn is what fills. A walk has no way out at all. The model's
|
|
129
136
|
strings reach the page through `textContent` and attributes only, never `innerHTML`, so a step reading
|
|
130
137
|
`<img src=x onerror=…>` shows as those characters.
|
|
131
138
|
|
|
@@ -130,7 +130,7 @@ the session commands*. Keep that table in step with `SessionAccessRoutes`.
|
|
|
130
130
|
`{error, detail, message, …fields}`: `detail` is the page's wording, `message` is the exception's own text, and the
|
|
131
131
|
fields are those the class is built from (`session_id`, `reason`, `ids`, `busy_id`, `version`).
|
|
132
132
|
`Remote#raise_refusal` rebuilds the class that Local's callee raises: `Session::NotFound` for a `404 not_found`
|
|
133
|
-
whose detail is `no session X
|
|
133
|
+
whose detail is `no session X`, a plain
|
|
134
134
|
`ArgumentError` for another `not_found`, `Session::AmbiguousId`,
|
|
135
135
|
`SessionManager::OwnedByTUI` / `DeleteRefused` / `ArchiveRefused` / `RestartRefused`, `SessionContinue::Refused`,
|
|
136
136
|
and `ModelProfile::MissingModel` for `invalid_model` (no model there, or `--model`'s host unknown there: "could not
|