samagotchi 0.93.0 → 0.95.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -1
  3. data/README.md +8 -8
  4. data/bin/chi +6 -2
  5. data/docs/architecture.md +4 -5
  6. data/docs/cli.md +4 -4
  7. data/docs/configuration.md +49 -86
  8. data/docs/hooks.md +2 -2
  9. data/docs/internals/bundles.md +1 -1
  10. data/docs/internals/context-telemetry.md +1 -1
  11. data/docs/internals/engine.md +7 -4
  12. data/docs/memory.md +26 -1
  13. data/docs/plugins.md +37 -0
  14. data/docs/releasing.md +2 -2
  15. data/docs/sessions.md +1 -1
  16. data/docs/testing.md +16 -11
  17. data/lib/samagotchi/bootstrap/config_writer.rb +1 -5
  18. data/lib/samagotchi/bootstrap_command.rb +1 -0
  19. data/lib/samagotchi/bundle_command/try/sandbox.rb +8 -2
  20. data/lib/samagotchi/bundle_command.rb +1 -0
  21. data/lib/samagotchi/bundles/dev/manifest.yml +2 -1
  22. data/lib/samagotchi/bundles/model-notes/manifest.yml +11 -0
  23. data/lib/samagotchi/bundles/model-notes/model_notes_deepseek.md +7 -0
  24. data/lib/samagotchi/bundles/model-notes/notes/README.md +37 -0
  25. data/lib/samagotchi/bundles/system/config_modification_protocol.md +6 -7
  26. data/lib/samagotchi/bundles/system/manifest.yml +3 -3
  27. data/lib/samagotchi/bundles/system/self_map.md +1 -1
  28. data/lib/samagotchi/client.rb +59 -196
  29. data/lib/samagotchi/config.rb +74 -15
  30. data/lib/samagotchi/engine.rb +7 -7
  31. data/lib/samagotchi/host_config.rb +20 -27
  32. data/lib/samagotchi/host_registry.rb +8 -8
  33. data/lib/samagotchi/kernel_loop.rb +46 -8
  34. data/lib/samagotchi/memory_bundle/profile.rb +22 -4
  35. data/lib/samagotchi/memory_bundle/shipped_update.rb +5 -1
  36. data/lib/samagotchi/model_profile.rb +2 -3
  37. data/lib/samagotchi/self_report.rb +0 -2
  38. data/lib/samagotchi/system_prompt.rb +7 -21
  39. data/lib/samagotchi/terminal_ui/thinking_line.rb +2 -4
  40. data/lib/samagotchi/testing/sandbox.rb +26 -0
  41. data/lib/samagotchi/thinking.rb +35 -2
  42. data/lib/samagotchi/thinking_notices.rb +11 -4
  43. data/lib/samagotchi/update_command.rb +1 -1
  44. data/lib/samagotchi/version.rb +1 -1
  45. data/lib/samagotchi/vision_support.rb +0 -3
  46. data/lib/samagotchi/web/public/app.js +15 -82
  47. data/lib/samagotchi/web/public/dock_reserve.js +103 -0
  48. data/lib/samagotchi/web/public/index.html +3 -3
  49. data/lib/samagotchi/web/public/toast_place.js +1 -1
  50. metadata +5 -1
data/docs/plugins.md CHANGED
@@ -1186,6 +1186,13 @@ bundle.shutdown
1186
1186
  `chi.*` calls `register` made, in order, as made), `bundle.namespace`, `bundle.hook_names(event)`,
1187
1187
  `bundle.run_inits`, `sandbox.write_memory(name, text, scope:)` / `memory_dir`, `sandbox.fake_executable(name,
1188
1188
  body)` (first on `PATH`), `wait_until { }`.
1189
+ - **Model notes:** `sandbox.model_notes_for(model_id, small: nil, cwd: nil)` lists the model notes chi would load
1190
+ into the prompt for a bare model id (`deepseek/deepseek-v4.1-flash`, no host prefix), from the sandbox's
1191
+ memories (an installed bundle's included), matched as chi matches them: each `models:` glob against the id and
1192
+ its model key; `small:` says whether the model counts as small for a `small` entry (nil: chi's own rule). The
1193
+ notes come in prompt order, and each answers four methods, its whole contract: `name`, `scope` (`"system"` or
1194
+ `"project"`), `chars` (the body's length) and `body` (what the prompt carries, the `models:` line left out). `sandbox.model_note_limits` gives the sizes chi
1195
+ warns over (`note:`, `total:`).
1189
1196
  - **`ctx.http` is faked.** `bundle.http.stub(method, url_or_regexp, status: 200, headers: {}, body: nil, json: nil,
1190
1197
  error: nil) { |request| … }` answers it: a String URL matches exactly (query included), a Regexp the full URL, later
1191
1198
  stubs win, and a stub answers every matching call (a block that counts makes a sequence). `error: :refused` or
@@ -2297,6 +2304,36 @@ gem.
2297
2304
  - Guardrail rules keyed by a tool's name apply to plugin tools, as they do to
2298
2305
  chi's own tools; path and command rules see what `targets:` says.
2299
2306
 
2307
+ ## The model-notes bundle
2308
+
2309
+ `chi bundle install model-notes` (or the `dev` profile) installs reviewed
2310
+ [model notes](memory.md#model-notes) into the system scope: working habits
2311
+ for one model family, loaded into the prompt only for the models a note's
2312
+ `models:` line names. It has no plugin or hook. It ships one note:
2313
+
2314
+ | note | models | for |
2315
+ |---|---|---|
2316
+ | `model_notes_deepseek` | `*deepseek-v4*` | DeepSeek V4 / V4.1: explore briefly then act, commit one item at a time, stop digging, `memory_read` for memories, file tools rather than heredocs that guardrail rules ask about |
2317
+
2318
+ - **Reviewed before it ships.** A note is generic (no repo or machine facts),
2319
+ says nothing the harness already does (a tool's description, an alias),
2320
+ talks to the model as "you", stays under 1,500 characters, and the user
2321
+ approves its text. A model may propose one; it never edits the bundle.
2322
+ `notes/README.md` in the bundle records each note's sources, the
2323
+ `script/model_notes_report.rb` numbers and the approval.
2324
+ - **Globs per measured version.** A glob is tried against the id with no host
2325
+ prefix and against its model key, case-insensitively, and `*` also matches
2326
+ `/`: `*deepseek-v4*` covers `deepseek/deepseek-v4.1-flash` on any provider,
2327
+ MLX and GGUF names, but not `deepseek-ai/DeepSeek-R1-Distill-Qwen-32B`.
2328
+ - **Tested.** `spec/model_ids.yml` lists real id forms and the exact notes
2329
+ each loads (negative rows included); the spec installs the bundle and
2330
+ resolves each through `sandbox.model_notes_for`
2331
+ ([Testing a bundle](#testing-a-bundle-experimental)). It also checks each
2332
+ note's shape, size and that the tools it names are ones chi declares.
2333
+ - **Your own notes:** a same-name note you have wins and keeps its place
2334
+ through upgrades; other notes stack with the bundle's
2335
+ ([Model notes](memory.md#model-notes)).
2336
+
2300
2337
  ## The bundle commands
2301
2338
 
2302
2339
  - `chi bundle install <dir>`: copies the plugin to
data/docs/releasing.md CHANGED
@@ -13,7 +13,7 @@ can run the whole release; the user approves the notes before the tag and the
13
13
  and `rake release:check` enforce it). The system bundle upgrades itself when
14
14
  chi starts.
15
15
  - **Every other shipped bundle** (btw, check-in, guardrails, known-names,
16
- loop-guard, mcp, skills, slow-commands, agents-md, cost-cap, source-links, github-pr, coordinator, claude-peer, codex-peer, ruby, and the profiles core and dev) has its own semver in its
16
+ loop-guard, mcp, skills, slow-commands, agents-md, cost-cap, source-links, github-pr, coordinator, claude-peer, codex-peer, ruby, model-notes, and the profiles core and dev) has its own semver in its
17
17
  `manifest.yml` and, when it needs a newer chi, a `requires_chi:` line. They never upgrade by themselves: users run
18
18
  `chi update` (all of them, with the gem) or `chi bundle upgrade NAME`. So:
19
19
  - a change to a bundle's files bumps that bundle's `version:`
@@ -66,7 +66,7 @@ as the GitHub release body.
66
66
  | `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. |
67
67
  | `rake release:draft_changelog` | A draft Unreleased section from the commit subjects since the last tag, grouped. Stdout only. |
68
68
  | `rake release:bump[X.Y.Z]` | VERSION, the system manifest, Gemfile.lock, CHANGELOG, and `requires_chi: ">= X.Y.Z"` for each bundle marked `requires_chi_next` (the marker dropped). No commit. |
69
- | `rake release:check` | Clean tracked tree, VERSION == system bundle, a CHANGELOG section, no `requires_chi_next` left, `bundles:check`, `rake lint` (RuboCop), 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). |
69
+ | `rake release:check` | Clean tracked tree, VERSION == system bundle, a CHANGELOG section, no `requires_chi_next` left, `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). |
70
70
  | `rake release:notes[X.Y.Z]` | Prints the CHANGELOG section (default: the current VERSION). |
71
71
 
72
72
  ## Runbook
data/docs/sessions.md CHANGED
@@ -88,7 +88,7 @@ chi sessions clean --dry-run --days 7 # test sessions older than 7 da
88
88
  - `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.
89
89
  - Web UI (`chi web`): the page's scope is in its URL. Started in a git repo, `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 without `?dir` (every session; a new session there starts in the server's own folder, shown on the start page, and cards name their folder; `← <project>` goes back to the project view it came from, or to the server's own 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. 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) 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`, with a search over preview, id and status (Esc or Back returns). 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)`, 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 copies `chi --attach <id>` for a terminal. 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 `llm ctx` chip names the LLM context strategy the next turn runs under (`llm ctx stale,forget · session`, in the accent colour when the session set its own; the tooltip gives each value's source), and its popover sets the session's own strategy, apply rule and budget, or follows the model again, by running `/llm-context` in the worker (the reply shows as a command bubble); `GET /api/sessions/:id`'s `session.llm_context` carries the values (the live worker's, else resolved from the session file), and a `command_ran` that changed them carries the new ones. Its `think` chip does the same for the thinking level (`/thinking`), and on a chat host its `reasoning` chip for the reasoning history (`reasoning all · session`, `/reasoning-history`; `session.reasoning_history`, null on a native host). A `/thinking` or `/reasoning-history` change that restarts the prompt cache asks first: the reply bubble has an **Apply (restarts the cache)** button that sends its `--yes` line (the chips' Set 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`), and `POST /api/sessions` takes `model` (blank means the default). Beside it, an `llm ctx` chip shows the LLM context the picked model starts under (each `GET /api/models` row's `llm_context`, as the info bar's); its form sets one for the new session only, sent as `POST /api/sessions`'s `llm_context` and never remembered (see [configuration.md](configuration.md#llm-context-a-sessions-own-strategy)). 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).
90
90
  - 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).
91
- - 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: 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, 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: id, status, model, chain links, chips, ctx, speed, clock, worker badge), `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 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 and the lightbox), `composer_grip.js` (the composer's grip and fold: the drag, tap and keys, the fold per visit), `strip_grip.js` (the latest-sessions strip's grip, the composer grip's twin: hides and shows the strip), `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), `notice_links.js` (a hook notice line's http(s) URLs as links), `start_page.js` (the start page's model picker and its LLM context and thinking chips, a choice for the next new session only; a fresh chain link's picker and its `/model`), `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`).
91
+ - 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: 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, 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: id, status, model, chain links, chips, ctx, speed, clock, worker badge), `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 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 and the lightbox), `composer_grip.js` (the composer's grip and fold: the drag, tap and keys, the fold per visit), `strip_grip.js` (the latest-sessions strip's grip, the composer grip's twin: hides and shows the strip), `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 and its LLM context and thinking chips, a choice for the next new session only; a fresh chain link's picker and its `/model`), `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`).
92
92
  - 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).
93
93
  - The web session page's message box folds away for room to read. Drag the grip on its top edge (the pill that shows on hover; always on a phone) down, past the box by 32 px: the pill turns accent while releasing would hide it, and on release the box folds and the info bar stays as the page's bottom edge. The grip stays as a handle on the info bar's top edge, drawn always: pull it up (8 px opens it, and the box follows the pointer in the same gesture), click or tap it (opens it and focuses the box), or just type on the page (the key lands in the box) to bring it back; Enter or Space on the focused grip folds or opens too. A draft (text or images, which folding never clears) colours the handle with the accent, a session waiting on you with the attention colour; its tooltip says so. Stop turn moves into the info bar while it is folded. The fold is remembered per browser (`chi_composer_collapsed`), an archived session opens folded for the visit, and opening it there, like the page opening it itself (a restored line, a quote, continue →'s opener), is for that visit only, and a fold forgets the height the grip set (`chi_composer_floor`): the box reopens at one line, or at its text's height. The start page's grip only resizes.
94
94
 
data/docs/testing.md CHANGED
@@ -5,6 +5,7 @@ bundle exec parallel_rspec -n 8 spec lib/samagotchi/bundles/*/spec # Ruby spec
5
5
  bundle exec rspec spec lib/samagotchi/bundles/*/spec # the same, plain
6
6
  bundle exec rake bundles:specs # the shipped bundles' own specs, on the bundle test kit alone
7
7
  npm test # web frontend specs
8
+ npm run lint # web frontend: undefined names and unused imports (ESLint; CI runs it)
8
9
  npm run e2e # web UI happy paths in Chromium, fake model (once: npx playwright install chromium)
9
10
  npx playwright test spec/e2e/stage.spec.js # one e2e file (the root playwright.config.js is the suite's)
10
11
  bundle exec rake lint # RuboCop: no offenses (CI runs it)
@@ -15,6 +16,13 @@ code's own style and has a safe autocorrect, so `-a` fixes them. What it leaves
15
16
  bug) or a broken spec: fix it, or disable that line with the reason (`# rubocop:disable Cop -- why`).
16
17
  `.rubocop.yml` says why each cop that is off is off.
17
18
 
19
+ `npm run lint` is the web frontend's twin, for the modules in `lib/samagotchi/web/public/` (not `vendor/`): ESLint
20
+ with two rules only, `no-undef` (a name used but never imported or declared: a dropped import) and `no-unused-vars`
21
+ (an import or variable left over), over the browser's globals (`eslint.config.js`). It is a missing-name guard, not a
22
+ style pass: add a rule only for a bug class it would have caught. It runs in about 2 s, in CI's `npm test` job and in
23
+ `rake release:check`; `rake lint` stays RuboCop alone (CI's rubocop job has no node). A name that is also a browser
24
+ global (`name`, `status`, `open`…) passes even when its import is gone: give an export such a name only with care.
25
+
18
26
  No spec reads your own setup. The suite points `XDG_CONFIG_HOME` and `XDG_STATE_HOME` at temp folders,
19
27
  clears your `SAMAGOTCHI_*` environment, and keeps every spec off the network (WebMock).
20
28
 
@@ -26,7 +34,7 @@ exception's text changes between Ruby versions: write the string yourself).
26
34
  The web specs run in plain node. One that loads lit-html, itself or through a module it imports (`turn_view.js`,
27
35
  `turn_html.js`, `card.js`, `copy.js`, `images.js`, `scope.js`, `command_view.js`, `diff_view.js`, `read_view.js`,
28
36
  `question_cards.js`, `stream_handlers.js`, `stage_view.js`, `bubbles.js`, `cards_place.js`, the chips, `info_bar.js`, `info_bar_model.js`, `lists_view.js`, `context_chips.js`, `families_view.js`,
29
- `chains.js`, `unqueue.js`, `toasts.js`, `notice_links.js`, `start_page.js`, `session_actions.js`, `send_turn.js`,
37
+ `chains.js`, `unqueue.js`, `toasts.js`, `notice_links.js`, `start_page.js`, `session_actions.js`, `send_turn.js`, `dock_reserve.js`,
30
38
  `vendor/lit-html.js`) needs a DOM: `import "./dom_shim.js";` as its first import (happy-dom, a devDependency only,
31
39
  never shipped; lit reads `document` as it loads). The shim's `markupOf(template)`,
32
40
  `htmlOf(nodes)` and `canon(html)` compare markup without lit's marker comments; the DOM writes text with only `&`, `<`, `>`
@@ -124,7 +132,7 @@ file's layer (any `terminal_ui/*.rb` → `spec/terminal_ui_golden_spec.rb`; `tur
124
132
  words the REPL prints, pick it by a rule), then the other name matches (a spec named after several changed files first, e.g. `engine_toolkit_spec.rb` for `engine.rb` and
125
133
  `toolkit.rb`; then one beside the file, so `plugin/context.rb` picks `spec/samagotchi/plugin/*context*` before
126
134
  `spec/guardrails/context_spec.rb`), then the specs that name a changed file's class. The default range is the merge-base with main (or origin/main) plus uncommitted and untracked files.
127
- The Ruby specs go to stdout; the node tests to run (`npm test` targets), "web changed: also run npm run e2e" and a
135
+ The Ruby specs go to stdout; the node tests to run (`npm test` targets), "web changed: also run npm run e2e" (with `npm run lint` too when a frontend module changed) and a
128
136
  hint for a hub class (named in too many specs to list) go to stderr. Nothing printed means nothing matched.
129
137
 
130
138
  It finds a change's own specs, not the regressions it causes elsewhere. So before committing, run the full suite
@@ -147,14 +155,16 @@ to install). It refuses when the folder or the branch already exists.
147
155
 
148
156
  `SAMAGOTCHI_MACOS_BUILD=1 bundle exec rspec spec/desktop` also compiles the macOS helper (`:macos_build`, needs the
149
157
  Command Line Tools) and runs `ChiHelper` against a fake kitty and, when a `tmux` is on PATH, a real one (private
150
- `-L` servers under a temp `TMUX_TMPDIR`, killed after). CI skips them, and `script/affected-specs` doesn't pick them
151
- for a Swift change: run them by hand after editing `lib/samagotchi/desktop/macos/`.
158
+ `-L` servers under a temp `TMUX_TMPDIR`, killed after). Without the variable they are filtered out (CI's runs), and
159
+ `script/affected-specs` doesn't pick them for a Swift change: run them by hand after editing
160
+ `lib/samagotchi/desktop/macos/`.
152
161
 
153
162
  ## Integration specs
154
163
 
155
164
  Examples tagged `:integration` (`spec/integration/`, the "with LLM access" part of `spec/hooks/integration_spec.rb`)
156
- run turns against a live model server. They are skipped unless `SAMAGOTCHI_INTEGRATION=1` is set, and they need the
157
- server and the model it serves:
165
+ run turns against a live model server. They are filtered out unless `SAMAGOTCHI_INTEGRATION=1` is set (a file of
166
+ them run alone prints "All examples were filtered out"; `--tag integration` without the variable selects them, and
167
+ they skip), and they need the server and the model it serves:
158
168
 
159
169
  | Variable | Meaning | Default |
160
170
  | --- | --- | --- |
@@ -163,7 +173,6 @@ server and the model it serves:
163
173
  | `SAMAGOTCHI_INTEGRATION_PORT` | model server port | `8080` |
164
174
  | `SAMAGOTCHI_INTEGRATION_MODEL` | the served model id | none: the examples skip |
165
175
  | `SAMAGOTCHI_INTEGRATION_API` | `openai` for the chat loop (`hosts.<name>.api`) | none: the native loop |
166
- | `SAMAGOTCHI_INTEGRATION_TRANSPORT` | `llama_cpp`, `mlx` or `omlx` (`server.transport`) | none: `llama_cpp` |
167
176
 
168
177
  They run under a config built from these variables alone (`default.model`, `server.host`/`port`, and one
169
178
  `hosts.integration` entry; `spec/support/integration_server.rb`), never your `~/.config/samagotchi/config.yml`: no
@@ -183,10 +192,6 @@ A run takes one to four minutes against a 35B MoE model on llama.cpp (25 example
183
192
  examples assert what the model did (the tool it called, the file it edited), not its wording, but they still depend on
184
193
  a model that follows tool instructions: a small model may fail some of them.
185
194
 
186
- `spec/integration/omlx_spec.rb` tests oMLX's model-id resolution and runs only with
187
- `SAMAGOTCHI_INTEGRATION_TRANSPORT=omlx`, against an oMLX server (a short model selector in
188
- `SAMAGOTCHI_INTEGRATION_MODEL`).
189
-
190
195
  ## The llm_context replay benchmark
191
196
 
192
197
  `ruby script/llm_context_bench.rb SESSIONS_DIR` replays stored sessions offline and scores the LLM context
@@ -39,7 +39,6 @@ module Samagotchi
39
39
  end
40
40
 
41
41
  HOSTS_LINE_RE = /\Ahosts:[ \t]*(#.*)?\z/
42
- SERVER_TRANSPORTS = ConfigFile::VALID_TRANSPORTS_FOR_CONFIG
43
42
 
44
43
  # The host part of a name: localhost/127.x → local, another IP → lan,
45
44
  # a domain → its second-level label (api.openai.com → openai).
@@ -261,10 +260,7 @@ module Samagotchi
261
260
  file = data.is_a?(Hash) ? data : {}
262
261
  host = Config.resolve("server.host", file_data: file, env: {}, cli_overrides: {}).to_s.strip
263
262
  port = Config.resolve("server.port", file_data: file, env: {}, cli_overrides: {}).to_i
264
- transport = Config.resolve("server.transport", file_data: file, env: {}, cli_overrides: {}).to_s.strip.downcase
265
- entry = { "host" => host.empty? ? "localhost" : host, "port" => port.positive? ? port : 8080 }
266
- entry["transport"] = transport if SERVER_TRANSPORTS.include?(transport) && transport != "llama_cpp"
267
- entry
263
+ { "host" => host.empty? ? "localhost" : host, "port" => port.positive? ? port : 8080 }
268
264
  end
269
265
 
270
266
  def same_server?(existing, fields)
@@ -406,6 +406,7 @@ module Samagotchi
406
406
  result.failed.each { |member, why| parts << "#{member} failed (#{why})" }
407
407
  parts << "nothing new to install" if parts.empty?
408
408
  @stdout.puts("#{result.name} bundles: #{parts.join("; ")}")
409
+ result.kept_own_lines.each { |line| @stdout.puts(" #{line}") }
409
410
  !result.failed?
410
411
  end
411
412
 
@@ -42,13 +42,19 @@ module Samagotchi
42
42
  # `chi bundle install PATH --force` for each PATH in ARGV, in one
43
43
  # process (bin/chi's start, once): an install that fails prints
44
44
  # what it printed and exits with its status; the ones before it
45
- # print nothing.
45
+ # print nothing. A config chi stops at (RemovedApi, as bin/chi
46
+ # does) prints its one line.
46
47
  INSTALL_SCRIPT = <<~RUBY
47
48
  require "stringio"
48
49
  require "samagotchi/utf8_default"
49
50
  Samagotchi::Utf8Default.apply!
50
51
  require "samagotchi/config"
51
- Samagotchi::ConfigFile.load!
52
+ begin
53
+ Samagotchi::ConfigFile.load!
54
+ rescue Samagotchi::ConfigFile::RemovedApi => e
55
+ warn e.message
56
+ exit 1
57
+ end
52
58
  require "samagotchi"
53
59
  require "samagotchi/bundle_command"
54
60
  ARGV.each do |path|
@@ -401,6 +401,7 @@ module Samagotchi
401
401
  lines << "already installed: #{result.already.join(", ")}" unless result.already.empty?
402
402
  result.skipped.each { |member, why| lines << "skipped #{member}: #{why}" }
403
403
  result.failed.each { |member, why| lines << "failed #{member}: #{why}" }
404
+ lines.concat(result.kept_own_lines)
404
405
  lines << "nothing new to install" if lines.empty?
405
406
  lines.each { |line| @stdout.puts " #{line}" }
406
407
  @stdout.puts "(dry-run: no changes written)" if dry_run
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dev
3
- version: 0.6.0
3
+ version: 0.7.0
4
4
  scope: system
5
5
  description: "Developer tools"
6
6
  trust_level: reviewed
@@ -16,3 +16,4 @@ includes:
16
16
  - claude-peer
17
17
  - codex-peer
18
18
  - ruby
19
+ - model-notes
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: model-notes
3
+ version: 0.1.0
4
+ scope: system
5
+ description: "Reviewed model notes: working habits a model family needs, loaded into the prompt only for the models each note's models: line names"
6
+ trust_level: reviewed
7
+ requires_chi: ">= 0.41.0"
8
+ files:
9
+ model_notes_deepseek.md:
10
+ sha256: sha256:0b07e40edc1a3d4a3ad6bea08d9b338913f78cab19a5809bcf4593f459f9bc5e
11
+ description: "DeepSeek V4 working habits: explore briefly then act, commit per item, stop digging, memory_read for memories, file tools over heredocs"
@@ -0,0 +1,7 @@
1
+ models: *deepseek-v4*
2
+ Working habits for this model:
3
+ - Explore briefly, then act. Once you know where the change goes, stop reading and make it; past ~20 steps without an edit, start implementing or say what blocks you.
4
+ - For multi-item tasks, finish and commit one item at a time (spec, fix, spec green, commit) before starting the next.
5
+ - When something doesn't work after a few attempts (a live check, a setup), stop digging: report what you tried and move on.
6
+ - Look up memories with memory_read (the index is in your prompt), not with shell commands on the memories folder.
7
+ - Guardrail rules match an execute command's raw text, heredocs included. Write file contents with write/edit, put commit messages in a file (`git commit -F <file>`), and if a guardrail asks, switch to the file tools instead of rewording.
@@ -0,0 +1,37 @@
1
+ # Model notes: provenance and evidence
2
+
3
+ This folder is not installed: an install takes only the top-level files the manifest lists. It records where each
4
+ shipped note came from, what it was measured against and who approved its text.
5
+
6
+ A note ships only after the review in docs/memory.md ("Shipped notes: the model-notes bundle"): generic (no repo or
7
+ machine facts), not already the harness's job, written to "you", at most 1,500 characters, no first-person lines,
8
+ and its final text approved by the user. A model may propose a note in a plan or a diff; it never edits this
9
+ bundle itself.
10
+
11
+ ## model_notes_deepseek
12
+
13
+ - **models:** `*deepseek-v4*`: DeepSeek V4 and V4.1 (`deepseek/deepseek-v4.1-flash`, `deepseek/deepseek-v4-flash`,
14
+ `deepseek/deepseek-v4.1-flash-1017`, a GGUF such as `unsloth/DeepSeek-V4-Flash-GGUF:Q4_K_M`). The note that ran
15
+ before had `deepseek/*|deepseek-*`, which also caught `deepseek-ai/DeepSeek-R1-Distill-Qwen-32B` (a Qwen
16
+ distill). Widen the glob to another version only on evidence for it. `spec/model_ids.yml` pins which ids load it.
17
+ - **Origin, 2026-10-03:** written by hand after a DeepSeek run of about 100 steps with no commit: explore briefly
18
+ then act, one item at a time with a commit each, stop digging after a few failed attempts, read memories with
19
+ `memory_read`.
20
+ - **Guardrail line, 2026-10-18:** written by DeepSeek itself (`memory_write`) in chi build #60, after guardrail rules
21
+ asked about its heredoc writes and commit messages. It was in the first person and named this repo's paths
22
+ (`tmp/commit-msg.txt`); rewritten generically for this bundle.
23
+ - **Dropped:** the "never background with `&`" line. The `execute` tool's description already says it ("Don't background with &;
24
+ use task_create"),
25
+ and the report counts 2 bare `&` calls (one session) without a note and none with it.
26
+ - **Approved:** the text as shipped, by the user, 2026-10-20 (the plan's P0).
27
+ - **Evidence:** `ruby script/model_notes_report.rb --model '*deepseek*'` (read-only, chi's sessions folder,
28
+ 2026-10-20). Medians in tool calls:
29
+
30
+ | DeepSeek V4.1 Flash via OpenRouter | n | 1st edit | 1st commit |
31
+ |---|---|---|---|
32
+ | no note (2026-10-03 to 10-08) | 11 | 47.5 | 81.5 |
33
+ | the note before this rewrite, pinned to DigitalOcean (2026-10-15 to 10-17) | 11 | 12 | 25 |
34
+
35
+ The dates and tasks differ, so this is a hint, not an A/B: an A/B is the same kind of task with the note on and
36
+ muted (`chi send --new --mute model_notes_deepseek`). The shipped text is shorter than the one measured (795
37
+ characters against 1,519) and keeps its habits.
@@ -18,7 +18,7 @@ Single registry `Samagotchi::Config` (`Config::ENTRIES` in `lib/samagotchi/confi
18
18
 
19
19
  Sections forbid `_`/`-` (`SECTION_RE` `/\A[a-z0-9]+\z/`); leaves keep `snake_case` in YAML (`base_url`) and become kebab in CLI (`base-url`) via registry derivation — no generic string split, registry lookup avoids flat vs nested collision.
20
20
 
21
- **Universal entries** (`expose: [:env,:config,:cli]`): `default.model`, `server.host/port/transport/open_timeout/read_timeout`, `server.first_token_timeout` (env and config only), `recap.model/base_url/host_ref/inactivity/timeout/min_user_turns/sentences`, `session.retention_days/max_count/keep_status/sweep_interval_hours/idle_exit_minutes`, `session.shared/keep_empty/max_children` (env and config only), `log.file/disable`, `status.line`, `context.status/window_tokens/chars_per_token/status_thresholds`, `memory.index_warn_tokens`, `thinking.turn_preamble`, `default.max_tokens`, `max_tool_output_chars`, `retry.max/base_delay/max_delay`, `read.*`, `execute.*`, `web.port/host`, `no_interrupt`, `no_default_input` etc. (`Config::ENTRIES`; `expose` says which of env/config/cli each takes). Precedence is `CLI > ENV > file > default`.
21
+ **Universal entries** (`expose: [:env,:config,:cli]`): `default.model`, `server.host/port/open_timeout/read_timeout`, `server.first_token_timeout` (env and config only), `recap.model/base_url/host_ref/inactivity/timeout/min_user_turns/sentences`, `session.retention_days/max_count/keep_status/sweep_interval_hours/idle_exit_minutes`, `session.shared/keep_empty/max_children` (env and config only), `log.file/disable`, `status.line`, `context.status/window_tokens/chars_per_token/status_thresholds`, `memory.index_warn_tokens`, `default.max_tokens`, `max_tool_output_chars`, `retry.max/base_delay/max_delay`, `read.*`, `execute.*`, `web.port/host`, `no_interrupt`, `no_default_input` etc. (`Config::ENTRIES`; `expose` says which of env/config/cli each takes). Precedence is `CLI > ENV > file > default`.
22
22
 
23
23
  Example `config.yml` (new nested form, preferred):
24
24
 
@@ -29,7 +29,6 @@ default:
29
29
  server:
30
30
  host: localhost
31
31
  port: 8080
32
- transport: llama_cpp # llama_cpp|mlx|omlx
33
32
  first_token_timeout: 120 # seconds a request may wait for its first token; 0 = off; unset: 120 for remote hosts, none for local
34
33
  recap:
35
34
  host_ref: small-box # a name under hosts:, or base_url: http://...
@@ -57,8 +56,8 @@ Only the nested form is read. An env name used as a top-level key (`SAMAGOTCHI_D
57
56
  **Excluded maps** (YAML-only, not part of the flat registry; skipped by scalar loader):
58
57
 
59
58
  - `model_aliases:` map of alias → model id (`ModelRef.parse`, through `HostRegistry#resolve`). Keys lowercased on write (`ConfigFile.write_model_alias!`). Values may be bare `model` or qualified `host:model` (hybrid; only `:` names a host, `org/model` is an id). Aliases apply once: never point an alias at another alias.
60
- - `hosts:` map of `name → {host, port | url, transport, api, api_key_env, auth, dialect, profile, first_token_timeout, vision, sampling, thinking, enabled, models}` (`ConfigFile.hosts_config`, `host_registry.rb` `HostEntry`). Names lowercased; `url:` (http/https, optional path) replaces host/port, never both; `api_key_env:` names the env var holding the API key (never write a key into config.yml); `auth:` (`bearer|x-api-key`) is the header the key goes in (default `x-api-key` on `api: anthropic`, Bearer elsewhere); `dialect:` (`fireworks`, or `standard` for the default; `api: anthropic` only) adjusts the Messages wire for that provider (Bearer by default, no thinking `display`, no `cache_control`, `x-session-affinity`; `LLM::Dialect`, docs/configuration.md "Anthropic Messages hosts"); `transport` overrides `server.transport`; `first_token_timeout` (seconds, `0` = off; a negative or non-number warns and is ignored) overrides `server.first_token_timeout` for that host; `models:` (a map of model ids, or a plain list) declares ids the host serves whatever its `/v1/models` lists: no "doesn't list" warning, and a bare id routes there as if listed (`HostModel`); an entry may hold `price: {input, output, cache_read?, cache_write?}` in USD per 1M tokens (`ModelPrice`; an unset cache rate is the input rate), which estimates a cost the provider doesn't report or reports as 0 (`cost_estimate`, shown as `~$`), and `served: [ids] | any`, the models a gateway may answer that id with (no served-model warning for them); model settings stay in the root `models:`; a worker reads `hosts:` from the file as it starts (no environment variable sets hosts).
61
- - `models:` map of model id or alias → `{profile, vision, sampling, thinking, reasoning_history}` (`ConfigFile.model_settings`). `thinking:` (here, on a host, or `thinking.level` for every model) is `off|low|medium|high|default` (`Thinking`; unquoted `off` works, `on` is not a level; `default` = send nothing). Precedence: the session's own level (`/thinking LEVEL`, saved in the session; `chi --thinking` on a session run, `chi send --new --thinking`) > `chi web --thinking`/`SAMAGOTCHI_THINKING_LEVEL` > `models:` > `hosts.<name>.thinking` > `thinking.level` in config.yml > `default`. A `sampling:` key wins over the fields a level sends (`null` drops one); `docs/configuration.md` "Thinking". `reasoning_history:` (here or on a host) is `drop|turn|all`, which of its reasoning a chat host's model gets back. Precedence: the session's own level (`/reasoning-history LEVEL`, saved in the session) > `SAMAGOTCHI_REASONING_HISTORY` > `models:` > `hosts.<name>.reasoning_history` > `turn`; `docs/configuration.md` "Reasoning history". `/thinking` and `/reasoning-history` ask before a change that restarts the prompt cache; `--yes` applies it (`chi send` commands apply directly). `sampling:` (here or on a host) is a map of request fields passed to the provider as written (`temperature`, `top_p`, `presence_penalty`, `repeat_penalty`, …; a model's fields win over its host's per field; `null` = don't send; chi's own fields like `max_tokens`/`stream` are refused with a warning; `docs/configuration.md` "Sampling"). Keys match case-insensitively. `profile` (here or on a host) is `qwen36|gemma4`: the raw prompt format for native hosts. Precedence: `--profile`/`SAMAGOTCHI_MODEL_PROFILE` > `models:` > `hosts.<name>.profile` > the llama.cpp server's chat template > the name (`qwen`/`gemma`) > `qwen36` (`ModelProfile.resolve`). Set one when a model's name hides its family (e.g. a Qwen fine-tune under another name on mlx, which has no template to read).
59
+ - `hosts:` map of `name → {host, port | url, api, api_key_env, auth, dialect, profile, first_token_timeout, vision, sampling, thinking, enabled, models}` (`ConfigFile.hosts_config`, `host_registry.rb` `HostEntry`). Names lowercased; `url:` (http/https, optional path) replaces host/port, never both; `api_key_env:` names the env var holding the API key (never write a key into config.yml); `auth:` (`bearer|x-api-key`) is the header the key goes in (default `x-api-key` on `api: anthropic`, Bearer elsewhere); `dialect:` (`fireworks`, or `standard` for the default; `api: anthropic` only) adjusts the Messages wire for that provider (Bearer by default, no thinking `display`, no `cache_control`, `x-session-affinity`; `LLM::Dialect`, docs/configuration.md "Anthropic Messages hosts"); `first_token_timeout` (seconds, `0` = off; a negative or non-number warns and is ignored) overrides `server.first_token_timeout` for that host; `models:` (a map of model ids, or a plain list) declares ids the host serves whatever its `/v1/models` lists: no "doesn't list" warning, and a bare id routes there as if listed (`HostModel`); an entry may hold `price: {input, output, cache_read?, cache_write?}` in USD per 1M tokens (`ModelPrice`; an unset cache rate is the input rate), which estimates a cost the provider doesn't report or reports as 0 (`cost_estimate`, shown as `~$`), and `served: [ids] | any`, the models a gateway may answer that id with (no served-model warning for them); model settings stay in the root `models:`; a worker reads `hosts:` from the file as it starts (no environment variable sets hosts).
60
+ - `models:` map of model id or alias → `{profile, vision, sampling, thinking, reasoning_history}` (`ConfigFile.model_settings`). `thinking:` (here, on a host, or `thinking.level` for every model) is `off|low|medium|high|default` (`Thinking`; unquoted `off` works, `on` is not a level; `default` = send nothing). Precedence: the session's own level (`/thinking LEVEL`, saved in the session; `chi --thinking` on a session run, `chi send --new --thinking`) > `chi web --thinking`/`SAMAGOTCHI_THINKING_LEVEL` > `models:` > `hosts.<name>.thinking` > `thinking.level` in config.yml > `default`. A `sampling:` key wins over the fields a level sends (`null` drops one); `docs/configuration.md` "Thinking". `reasoning_history:` (here or on a host) is `drop|turn|all`, which of its reasoning a chat host's model gets back. Precedence: the session's own level (`/reasoning-history LEVEL`, saved in the session) > `SAMAGOTCHI_REASONING_HISTORY` > `models:` > `hosts.<name>.reasoning_history` > `turn`; `docs/configuration.md` "Reasoning history". `/thinking` and `/reasoning-history` ask before a change that restarts the prompt cache; `--yes` applies it (`chi send` commands apply directly). `sampling:` (here or on a host) is a map of request fields passed to the provider as written (`temperature`, `top_p`, `presence_penalty`, `repeat_penalty`, …; a model's fields win over its host's per field; `null` = don't send; chi's own fields like `max_tokens`/`stream` are refused with a warning; `docs/configuration.md` "Sampling"). Keys match case-insensitively. `profile` (here or on a host) is `qwen36|gemma4`: the raw prompt format for native hosts. Precedence: `--profile`/`SAMAGOTCHI_MODEL_PROFILE` > `models:` > `hosts.<name>.profile` > the llama.cpp server's chat template > the name (`qwen`/`gemma`) > `qwen36` (`ModelProfile.resolve`). Set one when a model's name hides its family (e.g. a Qwen fine-tune under another name whose server publishes no template).
62
61
  - `hooks:` map of `hooks_dir` + per-event lists `{path, on_error}` (`Hooks::Loader.load`). `hooks_dir` may start with `~`.
63
62
  - `guardrails:` tool-call rules (`docs/guardrails.md`; read in `Engine#guardrail_rules`, parsed by `Guardrails::Rules.parse`): `enabled` (bool, default true; `false` drops rules and hooks' asks, a deny still applies; config.yml only, like every `guardrails` setting: no env variable), `parent_answers` (`soft`, the default: a parent agent's `chi answer` may deny, answer, Continue and give "Allow once"; `standard`: no allow; `hard`: deny, Stop and plain answers only; never a wider scope; replaces `parent_approvals` and `turn.parent_continue`; a convention for an honest parent, not a security boundary, and the user's choice: set it only when the user asks), `rules:` (list), `disable:` (a rule id or a list of them, `id` or `bundle:id`, switching off a bundle's or config rule without editing it), `small_models` (`auto`, the default: small = 32B or less read from the name; a glob or list of globs; `[]` for none). A rule takes only `id`, `tool`, `command`, `path`, `git`, `models`, `verdict`, `reason`, `scopes`: `id` required; at least one of `tool` (a name, `shell` = execute + task_create, a `File.fnmatch` glob like `"mcp_*"`, or a list), `command` (a Ruby regex on the shell command), `path` (a glob, or `outside_repo`: outside the session's repo, tmp folders and memory files excepted), `git` (only `outside_repo`: a shell call runs commit/add/reset/… in another checkout); `models` (optional: `small`, a model-name glob, or a list; without it the rule is for every model); `verdict` `ask|deny`; `scopes` (for `ask`) a subset of `once, session, repo, rule`. **Any parse error (an unknown key, a bad regex, no verdict) makes chi deny every tool call** until fixed, so validate with `YAML.safe_load` and keep the list shape. Rules are read again on the next tool call after config.yml or a bundle's rules change: no restart needed. Installed bundles' rule files (`chi bundle install guardrails`) add to them; `/guardrails` lists what loaded.
64
63
 
@@ -132,8 +131,8 @@ A key never goes into config.yml: `api_key_env: VAR` names it. chi reads `VAR` f
132
131
  ## Validations
133
132
 
134
133
  - **Model name** (`default.model` / `SAMAGOTCHI_DEFAULT_MODEL`): `ModelProfile.required_model_name` — non-empty string, otherwise harness fails fast at startup. Via `Config.get("default.model")`.
135
- - **Host api** (`hosts.<name>.api`): `llama_cpp|mlx|omlx` (raw-prompt loop; also the transport), `openai` (chat loop at `http://HOST:PORT/v1`) or `anthropic` (chat loop over the Messages API at `{url}/v1/messages`; without `url:`/`host:` it is `https://api.anthropic.com`). Absent: raw-prompt loop. It replaces the removed `backend` setting.
136
- - **Transport** (`server.transport`): enum `llama_cpp|mlx|omlx`.
134
+ - **Host api** (`hosts.<name>.api`): `llama_cpp` (raw-prompt loop over llama.cpp's own API), `openai` (chat loop at `http://HOST:PORT/v1`) or `anthropic` (chat loop over the Messages API at `{url}/v1/messages`; without `url:`/`host:` it is `https://api.anthropic.com`). Absent: raw-prompt loop. It replaces the removed `backend` setting.
135
+ - **No transport key**: `server.transport`, `hosts.<name>.transport` and `SAMAGOTCHI_SERVER_TRANSPORT` were removed (llama.cpp is the only raw-prompt server; never write them). Set to `mlx`/`omlx` (or `api: mlx`/`omlx`), chi stops at start with one line (`ConfigFile::RemovedApi`): mlx_lm.server and oMLX are `url: http://HOST:PORT/v1, api: openai` hosts. Any other value warns at start (`ConfigFile.removed_transport_problem`); remove the key.
137
136
  - **Profile** (`models.<id>.profile`, `hosts.<name>.profile`, `SAMAGOTCHI_MODEL_PROFILE`): enum `qwen36|gemma4`; an unknown one warns and is ignored.
138
137
  - **Alias name** (`write_model_alias!`):
139
138
  - required, non-empty, no whitespace, not starting with `-`, no `/`, must match `/\A[a-z0-9][a-z0-9._-]*\z/i`
@@ -141,7 +140,7 @@ A key never goes into config.yml: `api_key_env: VAR` names it. chi reads `VAR` f
141
140
  - must not point to itself (case-insensitive)
142
141
  - keys are normalized to downcase on write — `Qwen` and `qwen` collide
143
142
  - **Alias target**: non-empty string (model id).
144
- - **Hosts**: each entry needs `host` (or `url:`, an http(s) URL with an optional path, replacing `host`/`port`; never both), `port` 1-65535 (default 8080), `enabled: false` skips the entry, `transport` and `api` optional (a raw `api` must match `transport`), name must match `/\A[a-z0-9][a-z0-9._-]*\z/i`.
143
+ - **Hosts**: each entry needs `host` (or `url:`, an http(s) URL with an optional path, replacing `host`/`port`; never both), `port` 1-65535 (default 8080), `enabled: false` skips the entry, `api` optional (`llama_cpp`, `openai`, `anthropic`), name must match `/\A[a-z0-9][a-z0-9._-]*\z/i`.
145
144
  - **Hooks**: each entry must have `path` (relative to `hooks_dir`), `on_error` is `skip` (default) or `log`; `required: true` on a `before_tool_call` hook denies the call when the hook raises. Class name must match file basename snake→Pascal.
146
145
  - **Scalars via registry**: `Config.coerce` validates `String/Numeric/true/false` per `type: :string/:integer/:float/:bool/:enum`; invalid values warn and fall back to entry `default`.
147
146
  - **Keys**: `validate_yaml_sections` flags unknown keys (with a suggestion), a registry section that isn't a mapping, and env/CLI-only keys (`model.profile`).
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: samagotchi-system
3
- version: 0.93.0
3
+ version: 0.95.0
4
4
  scope: system
5
5
  description: Default system memories — identity, self map, config modification protocol, memory guide and the delegated-session rules
6
6
  files:
7
7
  identity.md: sha256:29c2f7df9f6c5acbc5ec17000a4490741e55e426af15ca0d81c8706edd9bd027
8
- self_map.md: sha256:da591d30211488eb7cff36604502b78167b0d6b64c1fbb827eca16b8703a63e7
9
- config_modification_protocol.md: sha256:f2551c71a21cc42e8b888e4b9b41f4b0909224e5393731905c1f786c704bad14
8
+ self_map.md: sha256:df3f8da539a9f5812f79e089c2c8b9894da6124a89654f292160046a6bb060da
9
+ config_modification_protocol.md: sha256:ff4efccf2bdde453fc4e6741df8c18f78da78e353f6b1a5a64d0e7a631aea258
10
10
  memory_guide.md: sha256:c48eea744db69e4f3e9bb415e9a03a8c78bbcaa1205ad3b1fb157a079f92d22e
11
11
  delegated.md: sha256:a0d6ddcd4a8be06526d964898611775fd251cfd9d145a9d16afaccaa503597bd
@@ -68,7 +68,7 @@
68
68
 
69
69
  ## Where things live (relative to the source dir)
70
70
  - `docs/`: `cli.md` (flags, subcommands, REPL commands), `configuration.md` (config.yml keys,
71
- hosts, transports), `hooks.md` (hook events table), `plugins.md` (plugin API, btw/mcp bundles),
71
+ hosts, the server api), `hooks.md` (hook events table), `plugins.md` (plugin API, btw/mcp bundles),
72
72
  `guardrails.md`, `memory.md`, `sessions.md`. `README.md` is only the quickstart.
73
73
  - `lib/samagotchi/tools/<tool>.rb`: each tool's real limits and defaults (e.g. `execute.rb`,
74
74
  `output_guardrails.rb`). Tool descriptions are summaries, not the spec.