samagotchi 0.191.0 → 0.193.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 +91 -1
- data/docs/architecture.md +8 -7
- data/docs/bundles.md +46 -29
- data/docs/cli.md +37 -15
- data/docs/configuration.md +10 -4
- data/docs/context.md +8 -5
- data/docs/guardrails.md +9 -4
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/bundles.md +2 -2
- data/docs/internals/inline-widgets.md +2 -1
- data/docs/internals/pages.md +4 -4
- data/docs/internals/participants.md +6 -8
- data/docs/internals/peers.md +75 -22
- data/docs/internals/prompt-caching.md +2 -1
- data/docs/internals/remote-sessions.md +9 -0
- data/docs/internals/session-lifecycle.md +36 -21
- data/docs/internals/web-frontend.md +195 -25
- data/docs/internals/working-set.md +5 -1
- data/docs/peers.md +71 -22
- data/docs/plugins.md +7 -4
- data/docs/releasing.md +30 -2
- data/docs/scheduling.md +10 -3
- data/docs/sessions.md +3 -3
- data/docs/testing.md +36 -5
- data/docs/thin-clients.md +114 -12
- data/lib/samagotchi/bridge.rb +2 -3
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +33 -17
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +34 -17
- data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
- data/lib/samagotchi/bundles/mcp/manifest.yml +4 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +7 -405
- data/lib/samagotchi/bundles/mcp/server_config.rb +158 -0
- data/lib/samagotchi/bundles/mcp/sign_in.rb +261 -0
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +2 -19
- data/lib/samagotchi/compat.rb +6 -5
- data/lib/samagotchi/config.rb +7 -0
- data/lib/samagotchi/continue_offer.rb +13 -1
- data/lib/samagotchi/delivery.rb +3 -7
- data/lib/samagotchi/engine/models.rb +17 -0
- data/lib/samagotchi/engine/plugins.rb +2 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
- data/lib/samagotchi/jsonl_store.rb +13 -2
- data/lib/samagotchi/llm/anthropic_messages.rb +11 -0
- data/lib/samagotchi/llm/openai_chat.rb +5 -0
- data/lib/samagotchi/llm/prompt_cache.rb +5 -0
- data/lib/samagotchi/pages/launch.rb +1 -1
- data/lib/samagotchi/peer_cold.rb +92 -0
- data/lib/samagotchi/peer_command.rb +24 -9
- data/lib/samagotchi/peer_continue.rb +32 -16
- data/lib/samagotchi/peer_exchanges.rb +7 -0
- data/lib/samagotchi/peer_mailbox.rb +21 -4
- data/lib/samagotchi/peer_receipts.rb +33 -6
- data/lib/samagotchi/peer_say.rb +34 -16
- data/lib/samagotchi/plugin/api.rb +2 -1
- data/lib/samagotchi/plugin/context.rb +13 -1
- data/lib/samagotchi/plugin/peer.rb +118 -53
- data/lib/samagotchi/plugin/peers.rb +13 -6
- data/lib/samagotchi/schedule_command.rb +1 -0
- data/lib/samagotchi/schedules/prune_part.rb +32 -0
- data/lib/samagotchi/schedules.rb +14 -9
- data/lib/samagotchi/session.rb +7 -0
- data/lib/samagotchi/session_access/local.rb +98 -37
- data/lib/samagotchi/session_access/remote.rb +1 -1
- data/lib/samagotchi/session_access/remote_peers.rb +3 -3
- data/lib/samagotchi/session_chain/links.rb +8 -3
- data/lib/samagotchi/session_continue.rb +15 -7
- data/lib/samagotchi/session_lifecycle.rb +4 -0
- data/lib/samagotchi/session_manager/delivery.rb +0 -6
- data/lib/samagotchi/session_manager/lifecycle.rb +30 -17
- data/lib/samagotchi/session_manager/listing.rb +2 -1
- data/lib/samagotchi/session_manager/removal.rb +7 -5
- data/lib/samagotchi/session_manager/spawn.rb +8 -4
- data/lib/samagotchi/session_manager.rb +4 -0
- data/lib/samagotchi/session_row.rb +2 -0
- data/lib/samagotchi/session_stores.rb +16 -11
- data/lib/samagotchi/session_transition.rb +61 -15
- data/lib/samagotchi/system_one/runs.rb +5 -2
- data/lib/samagotchi/testing/boundary.rb +0 -1
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +3 -0
- data/lib/samagotchi/tools/cancel_schedule.rb +10 -6
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -1
- data/lib/samagotchi/web/ask_create.rb +138 -0
- data/lib/samagotchi/web/ask_routes.rb +56 -9
- data/lib/samagotchi/web/last_ask.rb +78 -0
- data/lib/samagotchi/web/peer_routes.rb +10 -5
- data/lib/samagotchi/web/public/agent_rows.js +206 -0
- data/lib/samagotchi/web/public/agent_runs.js +595 -0
- data/lib/samagotchi/web/public/answer_fold.js +41 -44
- data/lib/samagotchi/web/public/answer_refs.js +3 -9
- data/lib/samagotchi/web/public/answer_write.js +28 -0
- data/lib/samagotchi/web/public/app.js +75 -99
- data/lib/samagotchi/web/public/block_fix.js +30 -12
- data/lib/samagotchi/web/public/cards_place.js +6 -4
- data/lib/samagotchi/web/public/chains.js +3 -1
- data/lib/samagotchi/web/public/command_list.js +5 -3
- data/lib/samagotchi/web/public/composer.js +9 -6
- data/lib/samagotchi/web/public/composer_mount.js +18 -11
- data/lib/samagotchi/web/public/draft_keys.js +10 -0
- data/lib/samagotchi/web/public/drafts.js +278 -0
- data/lib/samagotchi/web/public/history_reveal.js +5 -2
- data/lib/samagotchi/web/public/index.html +38 -2
- data/lib/samagotchi/web/public/owner_claim.js +7 -12
- data/lib/samagotchi/web/public/page_view.js +1 -1
- data/lib/samagotchi/web/public/pages.css +1 -7
- data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
- data/lib/samagotchi/web/public/peer_note.js +4 -2
- data/lib/samagotchi/web/public/peer_row.js +37 -0
- data/lib/samagotchi/web/public/prompt_history.js +6 -0
- data/lib/samagotchi/web/public/quiet_notes.js +12 -1
- data/lib/samagotchi/web/public/revise_stack.js +5 -2
- data/lib/samagotchi/web/public/send_turn.js +62 -23
- data/lib/samagotchi/web/public/session_actions.js +80 -16
- data/lib/samagotchi/web/public/session_prefs.js +9 -3
- data/lib/samagotchi/web/public/session_view.js +7 -2
- data/lib/samagotchi/web/public/turn_block.js +4 -0
- data/lib/samagotchi/web/public/turn_events.js +0 -2
- data/lib/samagotchi/web/public/unqueue.js +22 -9
- data/lib/samagotchi/web/public/viewer_self.js +1 -6
- data/lib/samagotchi/web/public/views.js +12 -1
- data/lib/samagotchi/web/session_access_routes.rb +6 -3
- data/lib/samagotchi/web/session_control.rb +4 -2
- data/lib/samagotchi/web/session_create.rb +50 -33
- data/lib/samagotchi/web/session_hub.rb +52 -36
- data/lib/samagotchi/web/session_summary.rb +45 -7
- data/lib/samagotchi/web/start_dir.rb +6 -4
- data/lib/samagotchi/worker/mail.rb +11 -1
- data/lib/samagotchi/worker.rb +7 -5
- data/lib/samagotchi/worker_inbound/mail.rb +34 -6
- data/lib/samagotchi/worker_inbound.rb +11 -3
- data/lib/samagotchi/worker_link.rb +13 -1
- data/lib/samagotchi/worker_presence.rb +22 -6
- data/lib/samagotchi/worker_wakes.rb +33 -5
- metadata +12 -2
- data/lib/samagotchi/web/public/pages_group.js +0 -67
data/docs/releasing.md
CHANGED
|
@@ -76,7 +76,7 @@ as the GitHub release body.
|
|
|
76
76
|
| `rake lint` / `rake lint:fix` | RuboCop over the repo (must report no offenses; CI runs it) / its safe autocorrect (`rubocop -a`). |
|
|
77
77
|
| `rake gem:validate`, `gem:build`, `gem:install`, `gem:clean` | Check the gemspec; build the gem into `pkg/`; build and install it locally; remove the built gems. |
|
|
78
78
|
| `rake release:draft_changelog` | A draft Unreleased section from the commit subjects since the last tag, grouped. Stdout only. |
|
|
79
|
-
| `rake release:bump[X.Y.Z]` | VERSION, the system manifest, Gemfile.lock, CHANGELOG, a compatibility corpus at `spec/compat/X.Y.Z/` written through the current state writers (with `wire/`: a real Engine and Bridge's replies, recorded twice and refused if the two differ), refreshed `spec/shared/compat_wire/*.json` fixtures, `spec/web/public/exports_baseline.json` rebuilt from the public modules, and `requires_chi: ">= X.Y.Z"` for each bundle marked `requires_chi_next` (the marker dropped), then a profile left below a member's `requires_chi` raised to it, with a patch bump of its version (none when it moved since the last tag) and named in the CHANGELOG's "Update with `chi update`" line, and each entry an `# Unreleased` comment in `Plugin::Api::SINCE` or `BundleManifest::SINCE` names moved into the table at X.Y.Z (the comment dropped). No commit; commit the corpus, fixtures and baseline with the release. |
|
|
79
|
+
| `rake release:bump[X.Y.Z]` | VERSION, the system manifest, Gemfile.lock, CHANGELOG, a compatibility corpus at `spec/compat/X.Y.Z/` written through the current state writers (with `wire/`: a real Engine and Bridge's replies and, in `wire/remote/`, chi web's answers to `chi --remote`, recorded twice and refused if the two differ), refreshed `spec/shared/compat_wire/*.json` fixtures, `spec/web/public/exports_baseline.json` rebuilt from the public modules, and `requires_chi: ">= X.Y.Z"` for each bundle marked `requires_chi_next` (the marker dropped), then a profile left below a member's `requires_chi` raised to it, with a patch bump of its version (none when it moved since the last tag) and named in the CHANGELOG's "Update with `chi update`" line, and each entry an `# Unreleased` comment in `Plugin::Api::SINCE` or `BundleManifest::SINCE` names moved into the table at X.Y.Z (the comment dropped). No commit; commit the corpus, fixtures and baseline with the release. |
|
|
80
80
|
| `rake release:check` | Clean tracked tree, VERSION == system bundle, a CHANGELOG section, no `requires_chi_next` left, no `# Unreleased` comment left in `Plugin::Api::SINCE` or `BundleManifest::SINCE`, `bundles:check`, `rake lint` (RuboCop) + `npm run lint` (the web frontend's ESLint), rspec (both roots: `spec` and the bundles' own `spec/`) + `rake bundles:specs` + npm test, `gem build`, then a clean install into a temp GEM_HOME that runs `chi --version`, `chi self` and `chi bundle list` with a temp HOME. Needs the network (gem dependencies). |
|
|
81
81
|
| `rake release:notes[X.Y.Z]` | Prints the CHANGELOG section (default: the current VERSION). |
|
|
82
82
|
|
|
@@ -113,7 +113,18 @@ The agent does each step and stops where the user has to say yes.
|
|
|
113
113
|
(a new time, a random id, a measured number). Pin it in
|
|
114
114
|
`CompatWire.normalise` (`*_ms`, `*_ms_sum` and `age` are pinned already, as is `last_turn.seconds`;
|
|
115
115
|
an id the script chooses is better pinned at its source), check `spec/release/compat_wire_spec.rb`,
|
|
116
|
-
and run the bump again (nothing is written when it stops).
|
|
116
|
+
and run the bump again (nothing is written when it stops). `wire/remote/`
|
|
117
|
+
holds what chi web answers `chi --remote` (`script/release/compat_remote.rb`,
|
|
118
|
+
`CompatRemote`: a real `Web::App` over a fixed state folder, no worker), one
|
|
119
|
+
`{method, path, query, request, status, reply}` file per call; it is
|
|
120
|
+
recorded twice too (a remote file's difference is pinned in
|
|
121
|
+
`CompatRemote.pin`). A bump also stops when any wire file names the
|
|
122
|
+
recording's machine ("names the recording's machine (/private/)": a /private
|
|
123
|
+
realpath, a chi-compat- temp folder or the home folder the normaliser
|
|
124
|
+
missed; the temp folder is `/compat-fixture` and the chi checkout
|
|
125
|
+
`/compat-project` already), or when chi web would start a worker. Corpora
|
|
126
|
+
recorded before 0.193.0 still hold the checkout's path in their AGENTS.md
|
|
127
|
+
prompt part; they are left as released. The new
|
|
117
128
|
VERSION may pass a compat shim's `remove_after` (`Compat::SHIMS`): once the
|
|
118
129
|
shim is also at least 14 days old (`added_on`, `Compat::MIN_AGE_DAYS`),
|
|
119
130
|
`spec/compat_spec.rb` names it, and the shim goes (or its date moves)
|
|
@@ -122,6 +133,9 @@ The agent does each step and stops where the user has to say yes.
|
|
|
122
133
|
rebuilds `spec/web/public/exports_baseline.json` from every public module
|
|
123
134
|
except `vendor/`; commit both with the release. If either refresh fails, the
|
|
124
135
|
bump is already written; follow its rerun command before reviewing or committing.
|
|
136
|
+
The corpus also holds System 1's judgments log (`guardrails/judgments.jsonl`), its saved runs
|
|
137
|
+
(`system_one/runs/`) and the context candidates' record (`context_candidates.jsonl`), written by
|
|
138
|
+
`CompatMachineStores`; the bump stops when one names this machine.
|
|
125
139
|
5. **Check.** Add all release files, including the new compatibility corpus, then run it:
|
|
126
140
|
`git add -A && git commit -m "Release X.Y.Z"` and `bundle exec rake release:check`.
|
|
127
141
|
Fix anything it finds in new commits and run it again.
|
|
@@ -154,6 +168,20 @@ If the run fails before `gem push`, fix it on main, delete the tag
|
|
|
154
168
|
version that reached rubygems.org can never be pushed again: fix forward with
|
|
155
169
|
the next patch version.
|
|
156
170
|
|
|
171
|
+
## Bumping WorkerLink::PROTOCOL
|
|
172
|
+
|
|
173
|
+
`WorkerLink::PROTOCOL` (the `protocol` in a worker's `bridge.json`) is what an older chi web, terminal or schedule
|
|
174
|
+
tick refuses a newer worker on (`Skew`: 502 `worker_newer`, "Lost the session's worker", a skipped session), so a bump
|
|
175
|
+
makes every un-restarted older reader refuse every worker of the release. An additive link change (a new sidecar key,
|
|
176
|
+
Bridge route or `Bridge::FEATURES` name) is no bump: clients check a feature name, not a version. Bump only when an
|
|
177
|
+
older client would do damage driving a newer worker: a sidecar key, route or feature name removed, renamed or given a
|
|
178
|
+
new meaning, or the secret rule changed. Every bump needs the owner's OK and a CHANGELOG line ("older chi web and
|
|
179
|
+
terminals refuse workers of this release until restarted"). A worker on an older protocol is never refused (a restart
|
|
180
|
+
is suggested, never gated). `spec/worker_link_contract_spec.rb` holds each protocol's list (sidecar keys with their
|
|
181
|
+
JSON type, routes, features): it fails when an entry of the current protocol's list is missing. The fix is a bump with
|
|
182
|
+
a new list under the new number, the old list kept as history; removing the entry is not. The policy's one place in
|
|
183
|
+
code is the `PROTOCOL` comment in `lib/samagotchi/worker_link.rb`.
|
|
184
|
+
|
|
157
185
|
## One-time setup
|
|
158
186
|
|
|
159
187
|
Done once, before the first release, in one sitting (the pending publisher
|
data/docs/scheduling.md
CHANGED
|
@@ -47,8 +47,9 @@ text, and one that starts with `!` is refused by `chi schedule add` and `schedul
|
|
|
47
47
|
An entry stored with one before that fails when it fires (toward its `max_failures`),
|
|
48
48
|
before anything is started or delivered. A chi web
|
|
49
49
|
(or cron tick) still running an older chi starts chain links without the origin, so
|
|
50
|
-
restart it after updating.
|
|
51
|
-
|
|
50
|
+
restart it after updating. A participant's turn is denied the schedule tools
|
|
51
|
+
([guardrails.md](guardrails.md)): like `register_reminder`, `schedule_task` and
|
|
52
|
+
`cancel_schedule` are owner-voiced, and `list_schedules` reads the owner's schedules.
|
|
52
53
|
|
|
53
54
|
## The two modes
|
|
54
55
|
|
|
@@ -416,7 +417,13 @@ the coordinator remember, and `last:<anchor>` must keep resolving. Once the
|
|
|
416
417
|
anchor's successor is gone, nothing continues the anchor; the chain walks for
|
|
417
418
|
`last:`, `chi send` and notes cross that gap to the entry's `head`
|
|
418
419
|
(`SessionChain::Links#anchor_forward`, [sessions.md](sessions.md), *Session chains*
|
|
419
|
-
→ Which link), so the anchor stays the chain's address.
|
|
420
|
+
→ Which link), so the anchor stays the chain's address. Cancelling the schedule
|
|
421
|
+
that bridges that gap ends the bridge: `last:`, sends and notes land in the anchor
|
|
422
|
+
again, so `chi schedule cancel` says so in one more line naming the chain's newest
|
|
423
|
+
link ("3f9a1c2e's chain was pruned; its newest link is 7d2b4e10 — send there from
|
|
424
|
+
now on.", `Schedules::Cancelled`), and the `cancel_schedule` tool's answer adds the
|
|
425
|
+
same line. Another schedule still bridging the gap means no line (cancelling that
|
|
426
|
+
one says it); disabling keeps the bridge. A link a previous prune
|
|
420
427
|
already deleted is skipped, so each later firing prunes the next link behind the
|
|
421
428
|
window.
|
|
422
429
|
|
data/docs/sessions.md
CHANGED
|
@@ -114,7 +114,7 @@ chi sessions clean --dry-run --days 7 # test sessions older than 7 da
|
|
|
114
114
|
- The web header's project chip opens a picker. The start project is the default row (including its start folder); other rows show their root, session and waiting counts. **All projects** opens every session, and choosing a project drops the open-session hash while keeping `?view=`.
|
|
115
115
|
|
|
116
116
|
- `Session.list` / `SessionManager.list_sessions` / `GET /api/sessions?sort=&order=&limit=&offset=` default to `updated_at desc` (newest activity first). Also supports `created_at`, `asc`. `X-Total-Count` header when paginated.
|
|
117
|
-
- Web UI (`chi web`): the page's scope is in its URL. Started in a project (a git repository or a `chi project init` folder), `chi web` opens `/?dir=<that folder>`: that project's sessions, and new sessions start in that folder; the header chip says `<project> · all`, and `all` opens the same place as `?scope=all` (every session; a new session there starts in chi web's start folder, shown on the start page, and cards name their folder; `← <project>` goes back to the project view it came from, or to the start folder's project). A bare `/` (the LAN link, the Home Screen app) is the start folder's project too: the folder chi web runs in, or `web.start_dir` / `chi web --start-dir DIR`; outside a project (no repository or marked folder) it shows every session. A pushed notification opens its session in that session's own project (`/?dir=<its project>#/s/<id>`; `?scope=all` outside a project). One server serves every project: a second `chi web` (from another repo) finds it through `GET /api/info` and prints (with `--open`, opens) its page for its own folder instead of starting another. The 3 latest sessions sit above the chat, and the grip on the chat's top edge — the same thin handle as the composer's, its twin — puts them away and brings them back: a drag up (or a click, or Enter/Space on it) hides them, a drag down (or a click) shows them again, and the choice is remembered. A hidden strip leaves its status in the top bar (`N sessions · ● 1 live · ● 1 waiting`, from the cards), and a click on that pill opens All sessions, without showing the strip first; there the pill shows whatever the strip's state, pressed, and a click on it goes back to the chat (as Esc does). In a window under 900 px wide, where the strip scrolls sideways, the grip stays under it, outside the scroller; a window under 700 px tall hides the strip by itself, so a question or approval card in the stage keeps room, and the grip shows it until the window is tall again. A parent and its delegates are one card there: its `▸ 2 delegates · 1 live · 1 waiting` chip (the waiting part in the attention colour, the card's border too; just `▸ 2 delegates` while the rows are open: they carry the marks then) opens their rows in a popover under it (a row per delegate at any depth, indented; a click opens that one, Esc or a click outside closes it, and the strip's order holds while it is open). A fork is a card of its own, and so is a delegate whose parent isn't listed (archived, another project), with its `↳ <parent>` chip; the pill counts cards, and every live or waiting session. "All sessions" (or `/`) opens every session at `#/sessions`; its header is the top bar's right end: a search over preview, id and status, the count, an `archived` toggle and Select (on a phone a row of its own under the bar). Esc or the pressed pill returns; where the sessions are stored is a faint line under the list. A card is its title on one line (an untitled session reads `Untitled` over its first message), a line under it (its recap, else its first message) and its meta row, with one mark per state and no status dot: a waiting card has its warn outline and its `question` (or `approval`…) chip, an errored one an `error` badge, a session a worker runs the `live` badge (not on a waiting card: waiting means a worker), and idle, completed and stopped ones are unmarked; a family's and a chain's rows the same. There a parent's card holds its delegates the same way, the chip opening their rows inside the card (each with an archive button on hover), open by itself while one of them waits on you; the count says `14 · 7 delegates` (`3 / 14` while a search narrows it), a search that matches a delegate shows its parent's card with the list open and the matching rows marked, and select mode picks cards (archiving a parent takes its delegates). The open session is in the URL (`#/s/<id>`), so a reload or a copied link opens it again; the chi logo top left goes back to the empty start for a new session. The message box grows with its text; drag its top edge to keep it taller (double-click resets). A file in a tool row (a read, edit or write's title) and its diff lines are refs: hover one and click to open the current file in your editor at that line, on this machine only (`web.editor`; the browser's "always allow" for the page's port and VS Code's "allow opening local files" are asked once; see [Opening files from chi web](configuration.md#opening-files-from-chi-web)). So are an edit or write approval card's paths (at the first line the dry run changes) and its diff lines, before you approve, and the numbered lines of a read's output: `lines 40–60` under it opens the text as read, numbered, when the output is the file as-is (not the head/tail preview of a big file, an error or an image; no numbers after a cut). A `path:line` (or `path:line-line`) in an answer or a step's text is one too once the turn has ended, and after a reload, when it names a file a row or card on the page touched: the path under the session's folder, else the one touched file it ends with (a bare `app.js:12` when only one touched file is named so; two such files make it none); a path without a line counts only when it is a touched file exactly. Code blocks, links, bare URLs and inline code with more than the ref in it are left alone, and a file the session didn't touch is never linked; a link whose text is such a ref alone (github-pr's link to the PR diff) becomes a ref too, and its plain click still goes to the PR. A plugin's refs on an answer (an `after_turn` hook's, see [Refs on the answer](hooks.md#refs-on-the-answer-display-only)) are paired with its links and text whatever the rows touched: they can link a file the session didn't touch, or an issue or a commit, and add their own actions to the ref's menu. A plugin tool's row carries the refs its `refs:` gives (see [Refs on a tool's row](plugins.md#refs-on-a-tools-row)): its title opens the first, and its `▾` menu adds the others as `<ref> · <action>` (the URL on hover); their URL actions work on a phone too. A ref with more than one target shows a small `▾` on hover: it opens a menu of them, in order **PR diff** (a link's), **Open in editor**, **Show in turn** and **Copy path**, and a plain click runs the first (a link's own, else the editor, else show in turn). **Show in turn** scrolls to the tool row that touched the file (looked for in the ref's own step, then its own turn, then the rows before it, then the nearest after it; there, the last one showing the ref's line, else the last one), opens the steps, the stage's steps and the row's diff (or the read showing the line) and flashes the row and the line; an answer's or a step's ref and an approval card's path have it, not a row's own title or lines. It needs no editor, so a viewer without one (a phone on the LAN) gets an answer's refs with **Show in turn** as their click; a row's title and diff lines stay plain text there. On a touch screen a tap opens the menu. A ref with a target is a tab stop: Enter runs its first target, ↓ opens the menu (↑/↓ move, Enter picks, Esc closes back to the ref). Diff and read lines have their click only. The info bar's id copies the full session id on click ("Session id copied"), the id every CLI command takes (`chi --attach ID`, `chi send ID`). A session whose prompt carried model notes has a `notes: deepseek` chip there (the names without `model_notes_`; the tooltip lists each with its scope and size; `session.prompt_notes` in `GET /api/sessions/:id`, the live worker's, else the session file's; see [Memory](memory.md#model-notes)). Its ⚙ chip, after the model, holds the session's thinking level, reasoning history and LLM context: `⚙` alone while the session follows the model for all three, else `⚙` and what the session set, in the accent colour (`⚙ think low · ctx stale,forget`; a phone shows ⚙ with a dot; the tooltip gives each value and its source). Its panel is the start page's ⚙ panel for this session: a Thinking row (`/thinking`), on a chat host a Reasoning row (the reasoning history, `/reasoning-history`), and a Context row with its Apply and budget fields (`/llm-context`); a tap runs that row's command at once in the worker (one reply in the conversation, as a typed one) and changes that field alone, the Context row's `default` resets the strategy, apply rule and budget (`/llm-context reset`), and a tap while a turn runs is queued for after it (the panel's note says so). `GET /api/sessions/:id`'s `session.thinking`, `session.reasoning_history` (null on a native host) and `session.llm_context` carry the values (the live worker's, else resolved from the session file), and a `command_ran` that changed them carries the new ones. After ⚙, the 🧰 chip names the session's toolkit: `🧰` alone on the configured default (`toolkit.default`, `session.toolkit_default`), `🧰 lean` on another (see [Toolkits](configuration.md#toolkits); `/toolkit` changes it). A `/thinking` or `/reasoning-history` change typed in the composer that restarts the prompt cache asks first: the reply bubble has an **Apply (restarts the cache)** button that sends its `--yes` line (the ⚙ panel sends that line itself; see [Changes that restart the prompt cache](configuration.md#changes-that-restart-the-prompt-cache)). It shows the context used (`ctx 42%`) and the last generation's decode speed (`87 tok/s`, `~64 tok/s` when estimated; see `/stats` in [cli.md](cli.md#session-commands)); hovering `ctx` there or on a session card lists the session's tokens in (summed over every request, with the cached share), out (with reasoning) and the cost when the provider reports one, for this session only (one estimated from a `hosts.<name>.models` price shows with `~`: `cost: ~$0.54 ($0.42 reported, ~$0.12 estimated)`); after a `/model` switch the info bar's tooltip adds a `per model:` row per run of turns on one model above those totals (`splash:qwen3-35b · 6 turns · 96.0k in / 9.0k out · ~$0.02`, a switch's prefill under its row: `└ switch prefill 58.0k uncached prompt ≈$0.01`; the timing's `model_segments`, replaced by each `generation_completed`'s; the session cards stay as they were), and right after the switch its ctx % is the new model's window's; and the memory indexes its prompt holds (`memory index: ~3.4k tokens in this session's prompt (system 2.0k, project 1.4k)`; see [Memory](memory.md#the-indexs-size)). The start page's model picker (bottom left of the composer, the chosen name `▾`) chooses the model a new session starts on, and a fresh chain link's (see [Session chains](#session-chains); there a pick shows as a `/model` command bubble in the link); it opens a search list over the conversation (↓ or a click; downward when the start page leaves no room above): an empty search shows the last 5 picks (Recent) and then each host's model ids A–Z under the host, the default host first (an id the host declares under `hosts.<name>.models` first, noted `config`, its tooltip `served by config (hosts.<name>.models)`; a host that failed to list its models keeps those ids, greyed and noted `host down`, still pickable; a remembered or default model stays chosen even then, greyed on the button); typed words must each match the host or the id (a substring, else for 3+ characters the letters in order, so `deepseek4.1 fla` finds `openrouter · deepseek/deepseek-v4.1-flash`), ⏎ picks, Esc/Tab close, a pick puts the focus in the message box: `GET /api/models` lists the hosts' models as chi spells them (`{default, models: [{name, host, id, configured?, unavailable?, sampling?, llm_context?}], warning?}`; `configured: true` marks an id declared under `hosts.<name>.models`, listed first under its host, `unavailable: true` one whose host failed to list its models; `sampling` is the model's configured request parameters as `/model` words them, the row's tooltip in the list; bare for the default host, `host:model` for the others, from the same cached lists as `/models`, a bounded wait, a host that is down noted in `warning`; `toolkits`: `{default, suggest, kits: [{name, description?}]}`, the start page's 🧰 list: the configured `toolkit.default`, `suggest` `on` only when a new session's first message may get a suggested kit (`toolkit.suggest.mode: on`, a System 1 host, two described kits; else `audit` or `off`), and the built-in and config kits a new session can start on, without `child` or `undecided`, a kit `groups:` refuses or one that doesn't resolve (a base that is a bundle kit), the default always listed; left out when it can't be read), and `POST /api/sessions` takes `model` (blank means the default). Beside it, ⚙ opens the new session's rarely used settings (thinking and LLM context, following each `GET /api/models` row's `thinking` and `llm_context`, ; see [configuration.md](configuration.md#llm-context-a-sessions-own-strategy)), and 🧰 its toolkit: **Auto** (with `toolkit.suggest.mode: on`: the first message may get a suggested kit, else the default) or a kit from the payload's `toolkits`, sent as `POST /api/sessions`'s `toolkit` (see [configuration.md](configuration.md#toolkits)); a refused kit (`400 toolkit_refused`) is said in the list, opened again. What is set shows on the row as an accent chip (`think high`, `tools: lean`; a dot on ⚙ or 🧰 on a phone); each is for the next new session only, never remembered. The start page's first message goes as later ones do: `POST /api/sessions` with `idle: true` and `preview` (the message, which names the session until its turn is saved), then `POST /api/sessions/:id/turn`, so a failed first turn puts its prompt back in the composer too; a first line that is one of the new session's commands (`/model …`) goes to `POST /api/sessions/:id/command` instead, as later ones do. The browser remembers the last model picked; a running session's model is in the info bar and changes only with `/model`. In the composer a line is a command when it is `!…` or starts with one of the session's command names (its `commands` list; `/stats`, `/exit` and the other terminal words get the page's own reply); an unknown `/word` (`/usr/bin/env is missing`) goes to the model as a prompt, as in a terminal; a one-word `/word` no command answers (`/modle`) is not sent: the page shows `Unknown command /modle. Did you mean /model? /help lists the commands.` (the "Did you mean" part only when a name is close). A `POST /turn` (or a session's first `prompt`) that is one of the worker's commands runs as that command too (`202 {status, command_id, session_id}`), so `chi send`, `chi -p` and a page whose command list lags all get the command. ↑/↓ in the composer walk the prompt history the TUI's ↑ walks ([Persistent Prompt History](cli.md#persistent-prompt-history)): ↑ with the caret on the first line, ↓ from the last line while browsing, ↓ past the newest brings the draft back; `GET /api/history` returns `{entries: [...]}`, oldest first (the page fetches it on focus and after each send). The server records a sent line in the routes once the worker took it (`POST /turn` accepted, a `!command` through `POST /command` or as a session's first line); `"history": false` in the body keeps it out (an image-only send).
|
|
117
|
+
- Web UI (`chi web`): the page's scope is in its URL. Started in a project (a git repository or a `chi project init` folder), `chi web` opens `/?dir=<that folder>`: that project's sessions, and new sessions start in that folder; the header chip says `<project> · all`, and `all` opens the same place as `?scope=all` (every session; a new session there starts in chi web's start folder, shown on the start page, and cards name their folder; `← <project>` goes back to the project view it came from, or to the start folder's project). A bare `/` (the LAN link, the Home Screen app) is the start folder's project too: the folder chi web runs in, or `web.start_dir` / `chi web --start-dir DIR`; outside a project (no repository or marked folder) it shows every session. A pushed notification opens its session in that session's own project (`/?dir=<its project>#/s/<id>`; `?scope=all` outside a project). One server serves every project: a second `chi web` (from another repo) finds it through `GET /api/info` and prints (with `--open`, opens) its page for its own folder instead of starting another. The 3 latest sessions sit above the chat, and the grip on the chat's top edge — the same thin handle as the composer's, its twin — puts them away and brings them back: a drag up (or a click, or Enter/Space on it) hides them, a drag down (or a click) shows them again, and the choice is remembered. A hidden strip leaves its status in the top bar (`N sessions · ● 1 live · ● 1 waiting`, from the cards), and a click on that pill opens All sessions, without showing the strip first; there the pill shows whatever the strip's state, pressed, and a click on it goes back to the chat (as Esc does). In a window under 900 px wide, where the strip scrolls sideways, the grip stays under it, outside the scroller; a window under 700 px tall hides the strip by itself, so a question or approval card in the stage keeps room, and the grip shows it until the window is tall again. A parent and its delegates are one card there: its `▸ 2 delegates · 1 live · 1 waiting` chip (the waiting part in the attention colour, the card's border too; just `▸ 2 delegates` while the rows are open: they carry the marks then) opens their rows in a popover under it (a row per delegate at any depth, indented; a click opens that one, Esc or a click outside closes it, and the strip's order holds while it is open). A fork is a card of its own, and so is a delegate whose parent isn't listed (archived, another project), with its `↳ <parent>` chip; the pill counts cards, and every live or waiting session. "All sessions" (or `/`) opens every session at `#/sessions`; its header is the top bar's right end: a search over preview, id and status, the count, an `archived` toggle and Select (on a phone a row of its own under the bar). Esc or the pressed pill returns; where the sessions are stored is a faint line under the list. A card is its title on one line (an untitled session reads `Untitled` over its first message), a line under it (its recap, else its first message) and its meta row, with one mark per state and no status dot: a waiting card has its warn outline and its `question` (or `approval`…) chip, an errored one an `error` badge, a session a worker runs the `live` badge (not on a waiting card: waiting means a worker), and idle, completed and stopped ones are unmarked; a family's and a chain's rows the same. There a parent's card holds its delegates the same way, the chip opening their rows inside the card (each with an archive button on hover), open by itself while one of them waits on you; the count says `14 · 7 delegates` (`3 / 14` while a search narrows it), a search that matches a delegate shows its parent's card with the list open and the matching rows marked, and select mode picks cards (archiving a parent takes its delegates). The open session is in the URL (`#/s/<id>`), so a reload or a copied link opens it again; the chi logo top left goes back to the empty start for a new session. The message box grows with its text; drag its top edge to keep it taller (double-click resets). Each session keeps its own draft in this browser (what you type in one never shows in another, and a pick or a quote goes into the open session's); the start page (+ new) has its own, which a new session takes when it is made (a failed create keeps it); a draft's text survives a reload, and a session gone while open leaves its draft on the start page (a delete drops it); images in a draft are lost on a reload. A file in a tool row (a read, edit or write's title) and its diff lines are refs: hover one and click to open the current file in your editor at that line, on this machine only (`web.editor`; the browser's "always allow" for the page's port and VS Code's "allow opening local files" are asked once; see [Opening files from chi web](configuration.md#opening-files-from-chi-web)). So are an edit or write approval card's paths (at the first line the dry run changes) and its diff lines, before you approve, and the numbered lines of a read's output: `lines 40–60` under it opens the text as read, numbered, when the output is the file as-is (not the head/tail preview of a big file, an error or an image; no numbers after a cut). A `path:line` (or `path:line-line`) in an answer or a step's text is one too once the turn has ended, and after a reload, when it names a file a row or card on the page touched: the path under the session's folder, else the one touched file it ends with (a bare `app.js:12` when only one touched file is named so; two such files make it none); a path without a line counts only when it is a touched file exactly. Code blocks, links, bare URLs and inline code with more than the ref in it are left alone, and a file the session didn't touch is never linked; a link whose text is such a ref alone (github-pr's link to the PR diff) becomes a ref too, and its plain click still goes to the PR. A plugin's refs on an answer (an `after_turn` hook's, see [Refs on the answer](hooks.md#refs-on-the-answer-display-only)) are paired with its links and text whatever the rows touched: they can link a file the session didn't touch, or an issue or a commit, and add their own actions to the ref's menu. A plugin tool's row carries the refs its `refs:` gives (see [Refs on a tool's row](plugins.md#refs-on-a-tools-row)): its title opens the first, and its `▾` menu adds the others as `<ref> · <action>` (the URL on hover); their URL actions work on a phone too. A ref with more than one target shows a small `▾` on hover: it opens a menu of them, in order **PR diff** (a link's), **Open in editor**, **Show in turn** and **Copy path**, and a plain click runs the first (a link's own, else the editor, else show in turn). **Show in turn** scrolls to the tool row that touched the file (looked for in the ref's own step, then its own turn, then the rows before it, then the nearest after it; there, the last one showing the ref's line, else the last one), opens the steps, the stage's steps and the row's diff (or the read showing the line) and flashes the row and the line; an answer's or a step's ref and an approval card's path have it, not a row's own title or lines. It needs no editor, so a viewer without one (a phone on the LAN) gets an answer's refs with **Show in turn** as their click; a row's title and diff lines stay plain text there. On a touch screen a tap opens the menu. A ref with a target is a tab stop: Enter runs its first target, ↓ opens the menu (↑/↓ move, Enter picks, Esc closes back to the ref). Diff and read lines have their click only. The info bar's id copies the full session id on click ("Session id copied"), the id every CLI command takes (`chi --attach ID`, `chi send ID`). A session whose prompt carried model notes has a `notes: deepseek` chip there (the names without `model_notes_`; the tooltip lists each with its scope and size; `session.prompt_notes` in `GET /api/sessions/:id`, the live worker's, else the session file's; see [Memory](memory.md#model-notes)). Its ⚙ chip, after the model, holds the session's thinking level, reasoning history and LLM context: `⚙` alone while the session follows the model for all three, else `⚙` and what the session set, in the accent colour (`⚙ think low · ctx stale,forget`; a phone shows ⚙ with a dot; the tooltip gives each value and its source). Its panel is the start page's ⚙ panel for this session: a Thinking row (`/thinking`), on a chat host a Reasoning row (the reasoning history, `/reasoning-history`), and a Context row with its Apply and budget fields (`/llm-context`); a tap runs that row's command at once in the worker (one reply in the conversation, as a typed one) and changes that field alone, the Context row's `default` resets the strategy, apply rule and budget (`/llm-context reset`), and a tap while a turn runs is queued for after it (the panel's note says so). `GET /api/sessions/:id`'s `session.thinking`, `session.reasoning_history` (null on a native host) and `session.llm_context` carry the values (the live worker's, else resolved from the session file), and a `command_ran` that changed them carries the new ones. After ⚙, the 🧰 chip names the session's toolkit: `🧰` alone on the configured default (`toolkit.default`, `session.toolkit_default`), `🧰 lean` on another (see [Toolkits](configuration.md#toolkits); `/toolkit` changes it). A `/thinking` or `/reasoning-history` change typed in the composer that restarts the prompt cache asks first: the reply bubble has an **Apply (restarts the cache)** button that sends its `--yes` line (the ⚙ panel sends that line itself; see [Changes that restart the prompt cache](configuration.md#changes-that-restart-the-prompt-cache)). It shows the context used (`ctx 42%`) and the last generation's decode speed (`87 tok/s`, `~64 tok/s` when estimated; see `/stats` in [cli.md](cli.md#session-commands)); hovering `ctx` there or on a session card lists the session's tokens in (summed over every request, with the cached share), out (with reasoning) and the cost when the provider reports one, for this session only (one estimated from a `hosts.<name>.models` price shows with `~`: `cost: ~$0.54 ($0.42 reported, ~$0.12 estimated)`); after a `/model` switch the info bar's tooltip adds a `per model:` row per run of turns on one model above those totals (`splash:qwen3-35b · 6 turns · 96.0k in / 9.0k out · ~$0.02`, a switch's prefill under its row: `└ switch prefill 58.0k uncached prompt ≈$0.01`; the timing's `model_segments`, replaced by each `generation_completed`'s; the session cards stay as they were), and right after the switch its ctx % is the new model's window's; and the memory indexes its prompt holds (`memory index: ~3.4k tokens in this session's prompt (system 2.0k, project 1.4k)`; see [Memory](memory.md#the-indexs-size)). The start page's model picker (bottom left of the composer, the chosen name `▾`) chooses the model a new session starts on, and a fresh chain link's (see [Session chains](#session-chains); there a pick shows as a `/model` command bubble in the link); it opens a search list over the conversation (↓ or a click; downward when the start page leaves no room above): an empty search shows the last 5 picks (Recent) and then each host's model ids A–Z under the host, the default host first (an id the host declares under `hosts.<name>.models` first, noted `config`, its tooltip `served by config (hosts.<name>.models)`; a host that failed to list its models keeps those ids, greyed and noted `host down`, still pickable; a remembered or default model stays chosen even then, greyed on the button); typed words must each match the host or the id (a substring, else for 3+ characters the letters in order, so `deepseek4.1 fla` finds `openrouter · deepseek/deepseek-v4.1-flash`), ⏎ picks, Esc/Tab close, a pick puts the focus in the message box: `GET /api/models` lists the hosts' models as chi spells them (`{default, models: [{name, host, id, configured?, unavailable?, sampling?, llm_context?}], warning?}`; `configured: true` marks an id declared under `hosts.<name>.models`, listed first under its host, `unavailable: true` one whose host failed to list its models; `sampling` is the model's configured request parameters as `/model` words them, the row's tooltip in the list; bare for the default host, `host:model` for the others, from the same cached lists as `/models`, a bounded wait, a host that is down noted in `warning`; `toolkits`: `{default, suggest, kits: [{name, description?}]}`, the start page's 🧰 list: the configured `toolkit.default`, `suggest` `on` only when a new session's first message may get a suggested kit (`toolkit.suggest.mode: on`, a System 1 host, two described kits; else `audit` or `off`), and the built-in and config kits a new session can start on, without `child` or `undecided`, a kit `groups:` refuses or one that doesn't resolve (a base that is a bundle kit), the default always listed; left out when it can't be read), and `POST /api/sessions` takes `model` (blank means the default). Beside it, ⚙ opens the new session's rarely used settings (thinking and LLM context, following each `GET /api/models` row's `thinking` and `llm_context`, ; see [configuration.md](configuration.md#llm-context-a-sessions-own-strategy)), and 🧰 its toolkit: **Auto** (with `toolkit.suggest.mode: on`: the first message may get a suggested kit, else the default) or a kit from the payload's `toolkits`, sent as `POST /api/sessions`'s `toolkit` (see [configuration.md](configuration.md#toolkits)); a refused kit (`400 toolkit_refused`) is said in the list, opened again. What is set shows on the row as an accent chip (`think high`, `tools: lean`; a dot on ⚙ or 🧰 on a phone); each is for the next new session only, never remembered. The start page's first message goes as later ones do: `POST /api/sessions` with `idle: true` and `preview` (the message, which names the session until its turn is saved), then `POST /api/sessions/:id/turn`, so a failed first turn puts its prompt back in the composer too; a first line that is one of the new session's commands (`/model …`) goes to `POST /api/sessions/:id/command` instead, as later ones do. The browser remembers the last model picked; a running session's model is in the info bar and changes only with `/model`. In the composer a line is a command when it is `!…` or starts with one of the session's command names (its `commands` list; `/stats`, `/exit` and the other terminal words get the page's own reply); an unknown `/word` (`/usr/bin/env is missing`) goes to the model as a prompt, as in a terminal; a one-word `/word` no command answers (`/modle`) is not sent: the page shows `Unknown command /modle. Did you mean /model? /help lists the commands.` (the "Did you mean" part only when a name is close). A `POST /turn` (or a session's first `prompt`) that is one of the worker's commands runs as that command too (`202 {status, command_id, session_id}`), so `chi send`, `chi -p` and a page whose command list lags all get the command. ↑/↓ in the composer walk the prompt history the TUI's ↑ walks ([Persistent Prompt History](cli.md#persistent-prompt-history)): ↑ with the caret on the first line, ↓ from the last line while browsing, ↓ past the newest brings the draft back; `GET /api/history` returns `{entries: [...]}`, oldest first (the page fetches it on focus and after each send). The server records a sent line in the routes once the worker took it (`POST /turn` accepted, a `!command` through `POST /command` or as a session's first line); `"history": false` in the body keeps it out (an image-only send).
|
|
118
118
|
- Web notifications: when a session needs you while the tab is hidden or behind another window (a question or a guardrail approval, a plugin card with buttons during a turn such as check-in's, a failed turn, a turn done after 10 s or more; a delegated session only for its questions, a canceled turn never), the page title counts it, `(N) Chi`, until you come back to the tab. The bell at the right of the top bar also turns on OS notifications ("needs an answer", "needs approval", "needs you", "turn failed", "done in 42 s", under the session's first message; a click opens the session): its first click asks the browser for the permission, and the choice is kept per browser. Any session of the page's scope counts, not only the open one. What was already so when the page loaded never counts, and several chi tabs show one notification per event. A chi tab in front tells the others (a `BroadcastChannel`), so while you look at one, the ones behind neither notify nor count what it shows; coming back to a tab clears those events in the other tabs' titles too. The hub's `session` frames carry what this needs: `pending_question` (`{id, kind}`, kind `question` or `approval`), `pending_card` (`{id, bundle}`: the running turn's card with actions, from `pending_card.json` that the worker keeps in the session's folder while one is open; a card without actions, such as loop-guard's, never counts) and `last_turn` (`{outcome, ended_at, seconds, origin}`, saved in the session's JSON as the engine ends each turn).
|
|
119
119
|
- The web frontend is a zero-build ES-module stack in `lib/samagotchi/web/public/`: `data.js` (retrieval, typed SSE `openStream` for a session and `openEvents` for the session list), `sessions_list.js` (the list as a pure reducer over `GET /api/events`: a snapshot replaces it, an upsert keeps a known card in place, a removal drops it; `families()` groups delegates under their parent), `families_view.js` (a parent's family chip, its rows and the strip's popover; the chip and rows as lit-html templates), `keep_focus.js` (lit reuses a list's nodes by position: a redraw keeps the focus on the same item by its `data-id` / `data-name`), `chains.js` (session chains: the links from `continues`, the cards folded into the latest link's, its `#N` chip and rows as lit-html templates, the info bar's ← → links, a refused continue, and the fresh-link rule), `notify.js` (which of those events needs the user, for the notifications), `app.js` (presentation/state; a session with no live stream gets one when its `session` event says `bridge_up`, after one re-read: `event_seq` starts over in each worker, so a dropped stream is never resumed with its old cursor), `bubbles.js` (the history's bubbles between the turns' rows: output chunks, end lines, every client's prompt bubbles by `enqueued_id` with their queued/steered badges, the idle recap, guardrail warnings, hooks' notices, plugins' steers, command and note bubbles; lit-html templates, put in the history with the sticky follow by `createBubbles`), `cards_place.js` (where plugin cards and a snapshot's notices go in the history: a card added or updated in place by its id, a running turn's into its step, a snapshot's each above the first turn after it, a finished turn's notice in its step's rows and its question resolved where it was asked; a card's action buttons), `format.js` (pure formatters such as `previewOf`), `plain_line.js` (markdown out of the plain one-line places: the stage headline, a closed step's title, an answered question card's kept-reply line), `prompt_history.js` (the composer's ↑/↓ over the shared prompt history), `commands.js` (session commands: which composer lines are commands, the page's own replies, a `command_ran`'s bubble, the page's command bubbles kept across a re-read), `composer.js` (where a composer line goes, `routeComposerLine`: /cut and /queue, the start page's own replies, a session command or `!cmd`, a typo hint, else a turn; and a session command sent from the composer or a chip), `delivery_line.js` (the composer's row above the text field in a session, always there so the composer keeps its height (on a phone no row: the line lies over the session bar's left while a turn runs and you type or have a choice armed): the key hint while idle, and the delivery line while a turn runs: where a message typed now goes in, from the step's phase, clock and size, whether "cut in now" can land, and the queue link for a worker with the `delivery` feature, as a pure `deliveryLine`, its lit-html template and `createDeliveryControl`, which ticks it and keeps a choice armed from a link; see docs/cli.md, "Typing during a turn"), `restore.js` (a failed turn's prompt handed back into this tab's composer, before or after its `/turn` ack), `lists_view.js` (the session lists: the strip and its pill, all sessions with its search, count and select mode, their cards, the family and chain popovers; the cards, tile and pill as lit-html templates, drawn as new nodes each time, and the lists' orders as pure functions), `stream_handlers.js` (the open session's stream event handlers, by event type, over the page's views and hooks; a snapshot replays through them too), `stage_view.js` (the stage view: the running turn pinned above the composer, with Stop turn in its status row while it runs, then handed off into the history; its pure rules and texts in `stage_model.js`, its live slots (headline, now row, trail, ticks) in `stage_slots.js`, its cap and held height in `stage_frame.js`, the in-use watch that times the hand-off in `stage_watch.js`), `info_bar.js` (the session bar's info line as a lit-html template over a plain model, three groups with hairlines between them, on one line above a phone's width (the folder gives way first): the setup (id, status, model, the ⚙ and 🧰 chips, notes, the memory or working-set chip), the relations (chain links, the parent as `↑ <id>`, delegates, participants; only when there is one) and the telemetry (folder, ctx, speed, the session's time, worker badge)), `settings_chip.js` (the session bar's ⚙ chip and its panel over `settings_panel.js`: a tap runs that row's command, one field), `toolkit_chip.js` (the session bar's 🧰 chip: the kit against `toolkit.default`), `info_bar_model.js` (that model and the bar's buttons' states, built from the page's session state, its list and its in-flight continues and restarts (the restarting set is `version_notices.js`'s) as pure functions; `app.js`'s `updateInfoBar` applies them every second while a turn runs), `session_state.js` (what the page knows about the open session: its empty state, and `sessionStateFrom`, the fields a `GET /sessions/:id` payload sets), `refs.js` (refs: a kind and a target on the element, a plugin's ref data (label, http(s) URL actions) bound in a WeakMap by `bindRef`, the targets per kind, show in turn, one delegated set of click, key and hover listeners), `ref_menu.js` (a ref's `▾` and its menu), `ref_scan.js` (the `path:line` refs in an answer's or a step's text that name a file the session's rows touched), `answer_refs.js` (the refs a plugin attached to an answer, its `display_refs`: bound to the answer's bubble, paired with its links and text, bound with `bindRef`), `markdown_place.js` (where rendered markdown and its refs go: a text as markdown HTML, its `path:line` refs, a final answer's rendering), `images.js` (image chips in the composer: paste, drop and the image button, the upload before a turn, the thumbnails; a click on one opens it in `picture_viewer.js`), `composer_grip.js` (the composer's grip and fold: the drag, tap and keys, the fold per visit), `composer_mount.js` (the composer mounted on a page's markup: the message box and its height, the image chips from a paste, a drop or the image button, the grip and fold, ↑/↓ over the prompt history and the keys; the page's own parts come in as hooks: what Enter and Send do, keys taken first, Esc, where the history comes from, the info bar's drop while folded, typing anywhere to open it; its styles, the card it sits in (`.composer-card`, its footer and its line above the text field) included, are the shared `composer.css`, linked after `tokens.css` by `index.html`), `strip_grip.js` (the latest-sessions strip's grip, the composer grip's twin: hides and shows the strip), `strip_hidden.js` (the strip hidden or shown: the saved choice, the short window's own hide, the grip and the body's class), `storage.js` (the page's per-browser choices in localStorage, guarded: a choice that can't be read or written is not remembered), `unqueue.js` (the × on a message queued for after the turn: takes it back, its text into an empty composer or a toast), `toasts.js` (the page's toast stack: a timer each, sticky ones until acted on, the same text reusing its item), `toast_place.js` (where the toast sits: above the composer card, the stage and an open model panel), `dock_reserve.js` (what floats over the history: the history's bottom reserve (`--dock-h`) at the composer card's and the showing stage's height, a reader at the end kept there, and the toast's place measured for `toast_place.js`), `notice_links.js` (a hook notice line's http(s) URLs as links), `start_page.js` (the start page's model picker, its ⚙ panel's and 🧰 list's choices for the next new session only and their override chips; a fresh chain link's picker and its `/model`), `start_settings.js` (the start page's ⚙ panel: thinking and LLM context as rows of segments, applied at once, the Apply and budget disclosure; the override chips' words and ⚙'s dot), `settings_panel.js` (the panel's rows as lit-html templates, shared: the segments, the disclosure, a hidden row's sent-anyway line; the caller passes its rows and applies the picks), `start_toolkit.js` (the start page's 🧰 list: Auto with suggest on, the kits, the default marked; a pick closes it; its override chip and dot), `session_actions.js` (Continue, Archive and its Undo, Delete and Stop, and the start page when the open session is gone), `send_turn.js` (the composer's send: a new session first on the start page, the route, the echo, the image upload, the `/turn` ack, a fast failure's restore and each error's place). Unit-tested via `npm test` (`spec/web/public/*.test.js`).
|
|
120
120
|
- Selecting a session in the web UI is read-only: `GET /api/sessions/:id` never spawns a worker (it reads a live worker's snapshot when one runs, else the session file). A prompt (`POST /turn`) or a command (`POST /command`) wakes the worker, and `/stream` briefly waits for a freshly-spawned bridge before answering. A caught-up SSE reconnect holds the stream open; `reset` markers are only sent for reconnects behind the ring window, or with a cursor from another worker (event ids are `<event_seq>-<epoch>`, one epoch per worker).
|
|
@@ -198,7 +198,7 @@ pbpaste | chi note --source slack 3f2a 8c1d
|
|
|
198
198
|
- It lands in `<uuid>/notes/`, apart from `input/`, so nothing that runs turns sees it. A live worker adds it to the conversation within a few seconds, between turns: one sent during a turn waits for that turn to end. A session with no worker keeps it until a worker next starts (a prompt, `--attach`), which adds it before anything else. A session a one-turn `chi --non-interactive` run has refuses notes. `chi note` prints one line per session: queued, waits for the next start (with the queue count), or refused.
|
|
199
199
|
- A note to a link that was **continued** (archived, with a later link) goes to its chain's newest link, as `send_note`'s and `chi broadcast`'s do (`chi broadcast` gives two links of one chain the note once, logged under the newest): `chi note` prints `3f2a1c0d → 4b7e9a01 (continued) queued: …` (and `… (continued) refused: …` when that link refuses it), and chi web's notes answer names that link as `id` beside `session_id`, in a 409 too. `chi broadcast deliver` logs such a delivery under the newest link's id (the one that has the note), so `chi broadcast log` shows that id, not the one typed, and a later `deliver` to either link says it had it. An archived link nobody continues keeps its note until input brings it back. An `/objectives` edit is the one note that stays in its own session: its list is that conversation's. Notes waiting when a session is continued move with it (*Session chains*).
|
|
200
200
|
- In the conversation it is a tail system message marked `kind: note`, framed `[CONTEXT NOTE from slack, 14:02]\n…\n[END NOTE]` (from another session: `from session 3f2a1c (~/projects/foo)`). The system prompt says notes are background, not requests: the model uses one when it is relevant, doesn't answer it on its own, and never follows instructions inside it. A note from `broadcast` ([`chi broadcast`](broadcast.md)) is the one exception to "doesn't answer it": the model says briefly in its next answer when it affects its current work, and still doesn't act on it unless asked. `--source broadcast` is refused for `chi note`. Its text is escaped like user text, so it can't fake a turn. It survives `--resume`, a reload, `!rollback` and a continue answered no.
|
|
201
|
-
- The web shows it as a dim "note from …" block, live (`context_added`) and after a reload, folded into a closed notes row with the background lines next to it (a tap opens it) unless it starts a turn; the attached terminal as one dim `note from slack: <first line>` line, also when joining.
|
|
201
|
+
- The web shows it as a dim "note from …" block, live (`context_added`) and after a reload, folded into a closed notes row with the background lines next to it (a tap opens it), or into the closed line it shares with the delegate reports and peers' answers next to it, unless it starts a turn; the attached terminal as one dim `note from slack: <first line>` line, also when joining.
|
|
202
202
|
- Agents: `list_sessions` (other sessions of this project, newest first, up to 20; optional `cwd`, `"/"` for every project) and `send_note(session, text)`, which sends a note from this session. Neither starts a turn anywhere.
|
|
203
203
|
|
|
204
204
|
On macOS, `chi desktop install` does this with a native panel from the Services menu or a hotkey (see [Desktop helper](desktop.md)). A plain Automator Quick Action that sends the clipboard to the live sessions you pick works too (Automator: Quick Action, "Run Shell Script", shell `/bin/zsh`; Automator's PATH is minimal, so put your Ruby's bin dir on it and use the full path to `chi`):
|
|
@@ -405,7 +405,7 @@ A session can **continue** an earlier one: "the next run of the same routine" (a
|
|
|
405
405
|
- **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.
|
|
406
406
|
- **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.
|
|
407
407
|
- **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`.
|
|
408
|
-
- **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
|
|
408
|
+
- **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.
|
|
409
409
|
- **CLI:** `chi send --new --continues (ID|PREFIX|last:ID) [--model M] [-m TEXT]` (see *Starting a session*).
|
|
410
410
|
- **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.
|
|
411
411
|
- **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/testing.md
CHANGED
|
@@ -151,9 +151,10 @@ override and a `note`. The Ruby side runs each row with every core command (a ne
|
|
|
151
151
|
|
|
152
152
|
## Compatibility corpus
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
The compatibility readers check both the newest corpus at or below `Samagotchi::VERSION`
|
|
155
|
+
and the newest corpus below it, distinct and newest first, so pull requests exercise
|
|
156
|
+
the release users run today as well as the previous corpus. `spec/compat/readers_spec.rb`
|
|
157
|
+
reads those corpora through today's session, Bridge, CardStore, schedules and bundle-record readers, and the files
|
|
157
158
|
other chi versions write into a live session's folder: a queued input file, a
|
|
158
159
|
context note, a continue's intent (`continue.json`) and the stop marker (the
|
|
159
160
|
starting marker isn't recorded: a recorded one is always stale), a bundle's
|
|
@@ -169,6 +170,9 @@ A corpus after 0.168.0 also records every registered cross-version session store
|
|
|
169
170
|
(`SessionStores`): objective checks, tracks and proposal cards, delegates,
|
|
170
171
|
pending cards, reminders and parent overrides. The starting marker is the
|
|
171
172
|
documented stale-file exception.
|
|
173
|
+
A corpus after 0.192.0 also holds System 1's record (`guardrails/judgments.jsonl`: a rule whose one deny keeps it from
|
|
174
|
+
auto-allowing), its saved runs (`system_one/runs/`) and the context candidates' record (`context_candidates.jsonl`),
|
|
175
|
+
written by `CompatMachineStores` with fixture values only: a machine path in them stops the bump.
|
|
172
176
|
A corpus recorded after 0.165.0 also holds `wire/`: a worker's replies to `GET state`, `snapshot` (after a turn, and
|
|
173
177
|
mid-turn with a prompt queued behind it) and `tail`, each `{route, status, body}`, and the session file it saved,
|
|
174
178
|
plus `events.json`, the page's parsed `{type, data}` SSE replay from sequence 0, recorded from a real Engine and Bridge
|
|
@@ -184,6 +188,20 @@ show. `spec/compat/wire_readers_spec.rb` serves the recorded replies to today's
|
|
|
184
188
|
with events); `UPDATE_COMPAT_WIRE=1` rewrites them. `release:bump` runs that spec to refresh the fixtures; commit
|
|
185
189
|
`spec/shared/compat_wire/*.json` with the release. `spec/release/compat_wire_spec.rb` checks the recorder (what
|
|
186
190
|
`normalise` pins, and the two-recordings guard).
|
|
191
|
+
A corpus recorded after 0.192.0 also holds `wire/remote/`: what chi web answers `chi --remote` (`SessionAccess::Remote`),
|
|
192
|
+
one `{method, path, query, request, status, reply}` file per call (`/api/info`, resolve and its 400 `ambiguous_id`
|
|
193
|
+
and `head=1`, the brief show and its 404, summaries, wait prepare, wait and the 409 `busy`, `delete_plan`, peers,
|
|
194
|
+
a delete's 409 `tasks_running`), recorded by `script/release/compat_remote.rb` (`CompatRemote`: a real `Web::App`
|
|
195
|
+
in LAN mode over a fixed state folder `CompatRemote.with_state` writes, no worker; a worker start raises).
|
|
196
|
+
`spec/compat/remote_readers_spec.rb` checks both directions: today's `Remote` driven through the same calls
|
|
197
|
+
(`CompatRemote.drive`) on an older chi web's replies, served by request (method, path, sorted query and body; an
|
|
198
|
+
unrecorded one is the older chi web's 404), every value asserted so a parser's fallback fails; and each recorded
|
|
199
|
+
request sent to today's `Web::App`, which must answer the same status and keep every key path of the old reply with
|
|
200
|
+
its JSON type. Both skip while the newest previous corpus has none (0.192.0 and before); a third example runs both on a
|
|
201
|
+
recording made now. No golden fixture: a new answer field changes nothing. The JSON-type check sees only what the fixed state fills
|
|
202
|
+
in: a value that is null or an empty array there (`delete_plan`'s delegates and tasks lists, a show's or a summary
|
|
203
|
+
row's null fields) is not type-checked, so a field read from such a place needs a state that fills it. `CompatRemote`'s ids, times and state
|
|
204
|
+
are what both sides read, so change them only with a new release's corpus in mind.
|
|
187
205
|
A second example reads a corpus the writer records now, so a writer change that
|
|
188
206
|
today's readers can't read goes red before the release. `rake
|
|
189
207
|
release:bump[X.Y.Z]` writes `spec/compat/X.Y.Z/` using the current writers
|
|
@@ -196,8 +214,21 @@ that added it, `remove_after` (nil: the owner hasn't dated it) and its files,
|
|
|
196
214
|
each Ruby one naming it in a comment (`compat shim <id>`). `spec/compat_spec.rb`
|
|
197
215
|
fails once `Samagotchi::VERSION` passes a shim's `remove_after`, naming it:
|
|
198
216
|
remove the shim, or move its date with the owner's OK. A new shim gets a row
|
|
199
|
-
|
|
200
|
-
|
|
217
|
+
when compatibility code is needed for a previous release.
|
|
218
|
+
Every `compat shim <id>` comment in `lib/`, `script/`, `bin/` and `spec/` (Ruby files and scripts; a comment wrapped
|
|
219
|
+
onto its next `#` line counts) must name a `SHIMS` row: `spec/compat_spec.rb` lists the unregistered ids with their
|
|
220
|
+
files.
|
|
221
|
+
|
|
222
|
+
A release that changes a file format holds both directions, or it doesn't merge: N reads what N-1 writes (a reader
|
|
223
|
+
kept as a `Compat::SHIMS` row, at least 14 days), and N-1 reads what N writes (an additive shape only, or a new file
|
|
224
|
+
name). There is no unshimmed format change. No spec checks the second direction (an N-1 worker reading the new shape
|
|
225
|
+
N's chi web or CLI wrote); review does.
|
|
226
|
+
|
|
227
|
+
`spec/worker_link_contract_spec.rb` pins what an older client drives a newer worker on, per `WorkerLink::PROTOCOL`: a
|
|
228
|
+
checked-in list of the sidecar keys a real Bridge writes (with their JSON type), its `Bridge::ROUTES` and its
|
|
229
|
+
`Bridge::FEATURES`. It is removal-only: extras pass, and a missing or retyped entry fails naming it. That is a protocol
|
|
230
|
+
bump with the owner's OK, never a deleted entry (docs/releasing.md, "Bumping WorkerLink::PROTOCOL"). It runs on every
|
|
231
|
+
PR, from constants and a Bridge started in process, with no corpus.
|
|
201
232
|
|
|
202
233
|
## Levels
|
|
203
234
|
|
data/docs/thin-clients.md
CHANGED
|
@@ -16,7 +16,8 @@ safe.
|
|
|
16
16
|
|
|
17
17
|
Check that chi web has these routes first: `GET /api/info` lists `"ask"` in
|
|
18
18
|
its `features`. An older chi web lacks it (and answers 404 for `/ask`): update
|
|
19
|
-
chi there (`chi update`).
|
|
19
|
+
chi there (`chi update`). A new session answered in one call needs
|
|
20
|
+
`"ask_create"`, and your last session `"ask_last"` (both below).
|
|
20
21
|
|
|
21
22
|
## Ask
|
|
22
23
|
|
|
@@ -216,21 +217,122 @@ convention for an honest agent, not a barrier, so tell your agent to send it.
|
|
|
216
217
|
session. Its 201 carries a `token`: `POST /api/sessions/<id>/wait {"token": …}`
|
|
217
218
|
answers the first turn.
|
|
218
219
|
|
|
220
|
+
## A new session in one call
|
|
221
|
+
|
|
222
|
+
Send any of `reply_for`, `timeout` or `request_id` with the create and its 201
|
|
223
|
+
is the first message's answer, as an ask gives it:
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
curl -s -H "Authorization: Bearer $T" -H 'Content-Type: application/json' \
|
|
227
|
+
-X POST http://192.168.1.29:4567/api/sessions \
|
|
228
|
+
-d '{"prompt": "plan my day", "reply_for": "voice", "request_id": "20261128093012345"}'
|
|
229
|
+
# {"status": "done", "session_id": "…", "text": "…", "created": true, "request_id": "…", …}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
- The body takes the ask's fields (`prompt`, `timeout`, `client_id`,
|
|
233
|
+
`request_id`, `reply_for`) and the create's (`dir`, `model`, `toolkit`, …).
|
|
234
|
+
`idle` and `continues` don't go with them (400 `invalid_ask`).
|
|
235
|
+
- `dir` is optional: without it the session starts in
|
|
236
|
+
[`web.ask_dir`](configuration.md#all-settings) when that is set, else in the
|
|
237
|
+
folder chi web starts in. A `web.ask_dir` that isn't a folder is 400
|
|
238
|
+
`invalid_dir`, nothing started.
|
|
239
|
+
- The answer is the ask's (`status`, `text`, a `token` while it runs, …) with
|
|
240
|
+
`session_id`, `created` (`true`: this call started it), `model_warning` and
|
|
241
|
+
`parent_answers_warning`. A refusal after the session started (504
|
|
242
|
+
`worker_timeout`, 503 `server_stopping`) keeps its code and also carries
|
|
243
|
+
`session_id` and `created`.
|
|
244
|
+
- With a `request_id` a retry lands on the same session: the session's id
|
|
245
|
+
comes from the key, so the same create again starts nothing (`created:
|
|
246
|
+
false`) and answers the first one's turn. Use a new key for each message.
|
|
247
|
+
- A create without those fields answers as it always did (the session's
|
|
248
|
+
summary, `first_turn_id` and a `token`).
|
|
249
|
+
- An older chi web ignores the fields: its 201 is the summary, with no `text`
|
|
250
|
+
(its `status` is the session's, `idle` or `running`). Check that `features`
|
|
251
|
+
lists `"ask_create"`.
|
|
252
|
+
|
|
253
|
+
## Your last session
|
|
254
|
+
|
|
255
|
+
`POST /api/sessions/last/ask` (the ask's body) continues the session you last
|
|
256
|
+
asked from a thin client:
|
|
257
|
+
|
|
258
|
+
- What counts: your own asks (`client_id` left out, or yours) that were
|
|
259
|
+
answered, and your one-call creates. An agent's asks (`agent:NAME`), `chi
|
|
260
|
+
send`'s and a refused ask don't move it; the MCP server's don't either.
|
|
261
|
+
- A continued session's message goes to the newest link, as any ask does.
|
|
262
|
+
- When that session is gone, or archived with nothing continuing it, `last`
|
|
263
|
+
is your most recently updated session that isn't archived, a delegate, a
|
|
264
|
+
`chi scratch` one, one an agent drives (`driver`) or a test run. None: 404
|
|
265
|
+
`not_found`.
|
|
266
|
+
- Wait on a `token` with the answer's `session_id`, not `last`
|
|
267
|
+
(`…/last/wait` names no session: refused): `last` may move meanwhile.
|
|
268
|
+
- A participant's token can't use it (404).
|
|
269
|
+
|
|
270
|
+
## Pick from recent
|
|
271
|
+
|
|
272
|
+
`GET /api/sessions/summaries?limit=30&tests=0&delegates=0` lists your recent
|
|
273
|
+
sessions, newest first, as `chi sessions list` has them: each row's `desc` (its
|
|
274
|
+
folder's name · its title, or its first message), `short_id`, `id` and
|
|
275
|
+
`updated_at`.
|
|
276
|
+
`delegates=0` leaves out delegates and `chi scratch` sessions; `tests=0` test
|
|
277
|
+
runs. Ask one with `POST /api/sessions/<id or short_id>/ask`.
|
|
278
|
+
|
|
219
279
|
## iOS Shortcut recipe
|
|
220
280
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
281
|
+
One Shortcut with a menu: a new session, your last one, or one picked from
|
|
282
|
+
your recent ones. `<chi>` is your chi web's address (`https://…` through
|
|
283
|
+
[Tailscale Serve](configuration.md#tailscale-serve-your-tailnet)), and every
|
|
284
|
+
**Get Contents of URL** has method POST (GET for the list), the header
|
|
285
|
+
`Authorization: Bearer <token>` and **Request Body: JSON** (Shortcuts' default
|
|
286
|
+
is Form, which chi answers with 400 `invalid_json`). Set
|
|
287
|
+
[`web.ask_dir`](configuration.md#all-settings) so New needs no folder (or add
|
|
288
|
+
`dir` to its body).
|
|
289
|
+
|
|
290
|
+
1. **Choose from Menu** with New, Last and Pick.
|
|
291
|
+
2. In each: **Dictate Text**, then **Format Date** (Current Date, custom
|
|
292
|
+
format `yyyyMMddHHmmssSSS`) and **Set Variable** `key` to it. ISO 8601 with
|
|
293
|
+
Include Time also works (no spaces) but has second precision: two asks in
|
|
294
|
+
the same second share a key, and the second gets the first's answer. The
|
|
295
|
+
built-in Short, Medium and Long formats contain spaces: refused (400
|
|
296
|
+
`invalid_ask`).
|
|
297
|
+
- New: **Get Contents of URL** `<chi>/api/sessions` with `prompt` = the
|
|
298
|
+
dictated text, `reply_for` = `voice`, `request_id` = `key`.
|
|
299
|
+
- Last: the same body to `<chi>/api/sessions/last/ask`.
|
|
300
|
+
- Pick:
|
|
301
|
+
1. **Get Contents of URL** (GET)
|
|
302
|
+
`<chi>/api/sessions/summaries?limit=30&tests=0&delegates=0`.
|
|
303
|
+
2. **Repeat with Each** item in Contents of URL; inside it one **Text**:
|
|
304
|
+
Repeat Item → **Get Value for Key** `desc`, then ` · `, then Repeat
|
|
305
|
+
Item → `short_id`.
|
|
306
|
+
3. After **End Repeat** (not inside the loop): **Choose from List** over
|
|
307
|
+
**Repeat Results**.
|
|
308
|
+
4. **Split Text** the choice by Custom ` · ` (a space on both sides) and
|
|
309
|
+
**Get Item from List** Last Item (`desc` has a ` · ` of its own).
|
|
310
|
+
5. **Text** with that item, then **Replace Text** `\s+` (Regular
|
|
311
|
+
Expression on) with nothing: the split item can carry a trailing
|
|
312
|
+
space or line break, which breaks the URL silently.
|
|
313
|
+
6. The same body to `<chi>/api/sessions/<Updated Text>/ask`.
|
|
314
|
+
**Set Variable** `answer` to the result.
|
|
315
|
+
3. After the menu: **If** `answer`'s `error` is `worker_timeout` or
|
|
316
|
+
`server_stopping`, send the same request once more with the same `key` (it
|
|
317
|
+
answers the first one's turn, nothing sent twice) and set `answer` again.
|
|
318
|
+
Any other `error`: **Speak Text** its `detail` and stop.
|
|
319
|
+
4. **Repeat** 10 times: **If** `answer`'s `status` is `timeout`, **Get Contents
|
|
320
|
+
of URL** `<chi>/api/sessions/<answer's session_id>/wait` with `token` = the
|
|
321
|
+
answer's `token`, and set `answer` to it.
|
|
322
|
+
5. **Get Dictionary Value** `text`, then **Speak Text**. With `needs` =
|
|
232
323
|
`detail` the text says to open chi on a full screen: an approval waits.
|
|
233
324
|
|
|
325
|
+
Judge success by `text` (and `created` for New), not by `status`: an older chi
|
|
326
|
+
web's create answers a `status` of its own. Shortcuts can't catch a **Get
|
|
327
|
+
Contents of URL** that fails outright (no connection): the shortcut stops
|
|
328
|
+
there, so the `request_id` retry covers only an answer with an `error`; run
|
|
329
|
+
the shortcut again with a new message. Shortcuts doesn't stop on an HTTP error
|
|
330
|
+
answer either: chi's `{"error", "detail"}` comes back as the result, so a
|
|
331
|
+
missing **Set Variable** `answer` or an error nobody speaks looks like
|
|
332
|
+
"nothing happened". Add a **Quick Look** of Contents of URL after **Get
|
|
333
|
+
Contents of URL** to see it. This recipe was checked on an iPhone (2026-11-28,
|
|
334
|
+
chi 0.192.0).
|
|
335
|
+
|
|
234
336
|
For running chi from another agent instead (`chi send --wait`, `chi answer`),
|
|
235
337
|
see [chi as a sub-agent](sub-agent.md). The routes in full are in
|
|
236
338
|
[architecture.md](architecture.md) (chi web's routes for the session
|
data/lib/samagotchi/bridge.rb
CHANGED
|
@@ -798,9 +798,8 @@ module Samagotchi
|
|
|
798
798
|
# Engine checks it at the stamp (ParticipantRevise): what chi web needs
|
|
799
799
|
# to pass one on (ReviseAnchor::PARTICIPANT_FEATURE).
|
|
800
800
|
# activity: GET /activity answers with Worker#activity_snapshot (chi schedule tick asks a live worker's).
|
|
801
|
-
# participant_client_id:
|
|
802
|
-
#
|
|
803
|
-
# (Delivery::PARTICIPANT_ID_FEATURE).
|
|
801
|
+
# participant_client_id: the previous release's chi web checks this before
|
|
802
|
+
# sending a participant's client id as participant:<id>.
|
|
804
803
|
# working_set_item: GET working_set/item answers one item's timeline,
|
|
805
804
|
# the running turn's mid-turn (WorkingSet::ITEM_FEATURE); chi web asks
|
|
806
805
|
# an older worker for its whole snapshot instead.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: claude-peer
|
|
3
|
-
version: 0.
|
|
3
|
+
version: 0.8.0
|
|
4
4
|
scope: system
|
|
5
5
|
description: "Pair this session with a Claude Code session you work with: the claude_send tool and /claude send it a part of the work (a plan step, a diff, a finding) to validate or as context, and Claude's answer comes back as a message with its text (chi peer say); /claude install-skill installs Claude's chi-peer skill, which pairs"
|
|
6
6
|
trust_level: reviewed
|
|
@@ -14,7 +14,7 @@ plugin:
|
|
|
14
14
|
scripts:
|
|
15
15
|
pair-remote: sha256:d7681f87a194e540b629564f84cad9f2d0a763197502c74614276ef88a8920cc
|
|
16
16
|
pair: sha256:98cddde54801f49b123cd0269f9ddc834b2566fde4ad241c07a50f3b794fedd0
|
|
17
|
-
chi-peer-SKILL.md: sha256:
|
|
17
|
+
chi-peer-SKILL.md: sha256:c5e33144978b950651d71ce872b5a6916d7314954b7b01bc79936fd1948f304d
|
|
18
18
|
# The plugin needs Samagotchi::Plugin::Peer on the mailbox: chi.peer and
|
|
19
19
|
# ctx.peers, and the skill's chi peer pair|say, are the next chi's (an older
|
|
20
20
|
# chi has no chi.peer: the plugin fails to load there).
|
|
@@ -67,20 +67,34 @@ permissions.
|
|
|
67
67
|
- **context**: take it in for your own work. No reply, unless something in it
|
|
68
68
|
contradicts what you know: then reply with that.
|
|
69
69
|
- **question**: answer it briefly.
|
|
70
|
-
- **moved**: chi continued the session (below).
|
|
71
70
|
|
|
72
71
|
Tell the user in one line what came in and what you answered.
|
|
73
72
|
|
|
74
73
|
## Reply into chi
|
|
75
74
|
|
|
76
|
-
Say the answer with `chi peer say`, one message per answer
|
|
75
|
+
Say the answer with `chi peer say`, one message per answer. Write the
|
|
76
|
+
answer to a file first, then say it from the file:
|
|
77
77
|
|
|
78
78
|
```sh
|
|
79
|
-
chi
|
|
79
|
+
mkdir -p "${TMPDIR:-/tmp}/chi-peer" && cat > "${TMPDIR:-/tmp}/chi-peer/answer-s-ab12cd.md" <<'EOF'
|
|
80
80
|
<the full answer>
|
|
81
81
|
EOF
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
```sh
|
|
85
|
+
chi peer say claude <id> --wake --re s-ab12cd --summary "validate <title>: VERDICT CHANGES, 2 issues" --wait 8 < "${TMPDIR:-/tmp}/chi-peer/answer-s-ab12cd.md"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Name the file by the `ref:` you answer (`answer-<what>.md` for a message you
|
|
89
|
+
start). When the say is refused with words that say to try again (`try again
|
|
90
|
+
in a moment`, `say it again in a moment`), run the same say command again a
|
|
91
|
+
moment later, from the same file: don't write the answer again. When the
|
|
92
|
+
shell says the file isn't there (`No such file or directory`: chi never ran),
|
|
93
|
+
write the file again, then run the say. Otherwise run it again only then:
|
|
94
|
+
after a line that starts `#N received`, or another failure with no line (a
|
|
95
|
+
timeout), the message may be in chi already, so don't say it again. After a
|
|
96
|
+
`#N received` line, remove the file.
|
|
97
|
+
|
|
84
98
|
- Always give `--wake` or `--nowake`: `--wake` for a validate or a question
|
|
85
99
|
(chi asked and is waiting), and for a message you start yourself that chi
|
|
86
100
|
should act on or know now (below); `--nowake` for a reply to context and for
|
|
@@ -101,8 +115,8 @@ EOF
|
|
|
101
115
|
this when the turn ends`). If it says **held**, don't send again, and don't
|
|
102
116
|
use `chi send` to get past it: the user decides when chi goes on.
|
|
103
117
|
- A say that is **refused** (exit 1) says why: not paired (pair again), the
|
|
104
|
-
session was continued (below),
|
|
105
|
-
session).
|
|
118
|
+
session was continued (below), busy (`try again in a moment`: the same
|
|
119
|
+
command again), chi's worker is older (the user restarts the session).
|
|
106
120
|
- Never answer a chi message with `chi send`: it goes in as an agent's
|
|
107
121
|
message (yours, not the user's) and counts toward the session's wake
|
|
108
122
|
budget (`session.max_wakes`), outside the round's limit. Use it only when
|
|
@@ -122,18 +136,20 @@ note, and the line says so. Don't send one only to acknowledge.
|
|
|
122
136
|
|
|
123
137
|
## chi continued the session
|
|
124
138
|
|
|
125
|
-
chi can continue its session as a new one, with a new id
|
|
126
|
-
with
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
chi can continue its session as a new one, with a new id; your pairing goes
|
|
140
|
+
with it, so there is nothing to do. The id in a chi message's header is the
|
|
141
|
+
session to answer. A line that says `continued as <id>` names the new one
|
|
142
|
+
(the say's line ends `session continued as <id>: answer there`): answer that
|
|
143
|
+
id from then on. An older chi doesn't take the pairing along: it sends a
|
|
144
|
+
`chi <old> · moved · continued as <new id>` message instead. Don't reply to
|
|
145
|
+
it: pair again with the new id, as before (below), and answer that id.
|
|
146
|
+
|
|
147
|
+
- **A say refused** with `this session was continued as <new id>` (an older
|
|
148
|
+
chi, or a continue that couldn't take your pairing along): pair again with
|
|
149
|
+
the new id, the same way you paired before (the same `CHI_REMOTE`; over
|
|
150
|
+
SSH, `pair-remote` with the new id: the new id gets its own socket and
|
|
151
|
+
forward), then run the say again to the new id, from the same file.
|
|
152
|
+
Messages chi hadn't read yet reach the new session as one note: don't
|
|
137
153
|
send them again.
|
|
138
154
|
|
|
139
155
|
## chi on another machine over SSH
|