samagotchi 0.179.0 → 0.181.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +76 -1
  3. data/bin/chi +10 -0
  4. data/docs/architecture.md +1 -1
  5. data/docs/bundles.md +39 -3
  6. data/docs/cli.md +16 -9
  7. data/docs/configuration.md +25 -5
  8. data/docs/context.md +7 -0
  9. data/docs/internals/anthropic.md +4 -3
  10. data/docs/internals/background-tasks.md +4 -1
  11. data/docs/internals/block-renderers.md +11 -7
  12. data/docs/internals/bundles.md +12 -10
  13. data/docs/internals/objectives.md +9 -4
  14. data/docs/internals/web-frontend.md +127 -6
  15. data/docs/internals/working-set.md +24 -5
  16. data/docs/memory.md +3 -0
  17. data/docs/plugins.md +17 -6
  18. data/docs/sessions.md +1 -1
  19. data/docs/testing.md +5 -1
  20. data/lib/samagotchi/block_renderers.rb +22 -3
  21. data/lib/samagotchi/bundle_command.rb +9 -2
  22. data/lib/samagotchi/bundle_needs.rb +1 -1
  23. data/lib/samagotchi/bundle_settings_check.rb +5 -2
  24. data/lib/samagotchi/bundles/known-names/manifest.yml +2 -2
  25. data/lib/samagotchi/bundles/known-names/plugin.rb +4 -3
  26. data/lib/samagotchi/bundles/system/config_modification_protocol.md +3 -2
  27. data/lib/samagotchi/bundles/system/manifest.yml +2 -2
  28. data/lib/samagotchi/client.rb +8 -1
  29. data/lib/samagotchi/config.rb +6 -1
  30. data/lib/samagotchi/context_providers.rb +6 -8
  31. data/lib/samagotchi/core_notice.rb +44 -0
  32. data/lib/samagotchi/host_address.rb +7 -0
  33. data/lib/samagotchi/host_config.rb +8 -5
  34. data/lib/samagotchi/host_registry.rb +26 -8
  35. data/lib/samagotchi/installed_bundles/dir.rb +17 -55
  36. data/lib/samagotchi/installed_bundles/standing.rb +23 -3
  37. data/lib/samagotchi/installed_bundles.rb +26 -11
  38. data/lib/samagotchi/kernel_loop.rb +3 -2
  39. data/lib/samagotchi/llm/adapter_common.rb +3 -2
  40. data/lib/samagotchi/llm/adapters.rb +2 -1
  41. data/lib/samagotchi/llm/anthropic_assembly.rb +5 -0
  42. data/lib/samagotchi/llm/anthropic_messages.rb +6 -2
  43. data/lib/samagotchi/llm/chat_loop.rb +6 -5
  44. data/lib/samagotchi/llm/errors.rb +41 -3
  45. data/lib/samagotchi/llm/http.rb +85 -22
  46. data/lib/samagotchi/llm/openai_chat.rb +20 -3
  47. data/lib/samagotchi/memory_bundle/status.rb +10 -6
  48. data/lib/samagotchi/objectives.rb +7 -2
  49. data/lib/samagotchi/owner_lock.rb +2 -0
  50. data/lib/samagotchi/plugin/api.rb +4 -1
  51. data/lib/samagotchi/plugin/context.rb +9 -0
  52. data/lib/samagotchi/plugin/peer.rb +32 -15
  53. data/lib/samagotchi/plugin/tool_spec.rb +13 -2
  54. data/lib/samagotchi/row_refs.rb +14 -3
  55. data/lib/samagotchi/session_chain/delete.rb +6 -6
  56. data/lib/samagotchi/session_config.rb +15 -9
  57. data/lib/samagotchi/session_manager/removal.rb +2 -2
  58. data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
  59. data/lib/samagotchi/terminal_ui/formatting.rb +13 -3
  60. data/lib/samagotchi/terminal_ui/join_replay.rb +1 -1
  61. data/lib/samagotchi/tool_ids.rb +19 -0
  62. data/lib/samagotchi/tool_runner.rb +8 -4
  63. data/lib/samagotchi/tools/registry.rb +3 -2
  64. data/lib/samagotchi/tools/task_runtime.rb +46 -3
  65. data/lib/samagotchi/turn_stages/objectives.rb +10 -5
  66. data/lib/samagotchi/version.rb +1 -1
  67. data/lib/samagotchi/web/public/app.js +22 -14
  68. data/lib/samagotchi/web/public/block_host.js +20 -20
  69. data/lib/samagotchi/web/public/block_renderers.css +5 -5
  70. data/lib/samagotchi/web/public/context_chips.js +183 -49
  71. data/lib/samagotchi/web/public/history_shape.js +5 -3
  72. data/lib/samagotchi/web/public/images.js +1 -1
  73. data/lib/samagotchi/web/public/index.html +90 -5
  74. data/lib/samagotchi/web/public/objectives_strip.js +16 -6
  75. data/lib/samagotchi/web/public/pan_zoom.js +121 -0
  76. data/lib/samagotchi/web/public/peer_chip.js +171 -0
  77. data/lib/samagotchi/web/public/peer_data.js +131 -0
  78. data/lib/samagotchi/web/public/peer_exchange.js +83 -0
  79. data/lib/samagotchi/web/public/peer_links.js +161 -0
  80. data/lib/samagotchi/web/public/peer_note.js +49 -0
  81. data/lib/samagotchi/web/public/picture_viewer.js +304 -0
  82. data/lib/samagotchi/web/public/popover_modal.js +3 -2
  83. data/lib/samagotchi/web/public/session_view.js +10 -1
  84. data/lib/samagotchi/web/public/stream_handlers.js +17 -4
  85. data/lib/samagotchi/web/public/turn_html.js +11 -2
  86. data/lib/samagotchi/web/public/working_set.js +9 -3
  87. data/lib/samagotchi/web/public/working_set_view.js +28 -11
  88. data/lib/samagotchi/web/public/ws_cards.js +36 -10
  89. data/lib/samagotchi/web/public/ws_markdown.js +129 -0
  90. data/lib/samagotchi/web/public/ws_order.js +48 -0
  91. data/lib/samagotchi/web/public/ws_peek.js +22 -5
  92. data/lib/samagotchi/web/public/ws_preview.css +41 -1
  93. data/lib/samagotchi/web/public/ws_reader.js +35 -6
  94. data/lib/samagotchi/web/public/ws_sections.js +24 -15
  95. metadata +11 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02c5f9b0ce43fa25f771a11ec298032ffa639b9423f5df2e934b376eef808327
4
- data.tar.gz: 0ff81b27a6bea746ecc98735a23e6cff79db33abcba48684cad5421177cebe73
3
+ metadata.gz: ef194e6af0d4be30d6b98a61f1995582670d7d5823d684733b0f75175b58857a
4
+ data.tar.gz: 94467de696fd0223e72755c109f7fc0dd2c2ae6edf6fa3014ff8bde4f86748cc
5
5
  SHA512:
6
- metadata.gz: abc693ecff041c7c142742487336cd34b16e6738a260a240e3f4194a841fea77bc752ff613d2322ad850f94c0e23fe49034b4765485385d3cb46dba96f2948ea
7
- data.tar.gz: b7ad5b7323b35f7e748fbe0349f84ccdf2c046691cff8f1ac298369ca741ef0198873a1c7f25ec1cb49835277f8adb54b30e683db72fa027ca823d3e10b20163
6
+ metadata.gz: 2a019f5cddf59cf801f080f96c8b8d4579504f3f7a712f8d20a9b6010e7ac4d9218f9650c6d7f7630351329b9dadfeb3896a6a52d1b2c95782cd93514f180639
7
+ data.tar.gz: fc52dd4dda346a56abddac22161b42c65014b8bf9cd4dee5196c0412c1a751aab116d4def340f774bde911f7ff7c6e7d6249012804d90edcd67fdf8929bbdd86
data/CHANGELOG.md CHANGED
@@ -8,6 +8,79 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.181.0] - 2026-11-21
12
+
13
+ ### Added
14
+
15
+ - In the web, an attached image opens in a full-screen viewer, fitted: pinch, Ctrl/Cmd + scroll or the bar's − and +
16
+ zoom (sharp at every size), a drag or scroll moves, a double tap goes close and back, ✕ or Esc closes. A tap on
17
+ the picture no longer closes it.
18
+ - In the web, one tap on a drawn diagram (a mermaid block) opens it in that viewer, fitted to the screen, to zoom in
19
+ and move around; in the answer it stays fitted to the column (the tap no longer switches it to its natural size).
20
+ On a phone the diagram's rendered | source switch stays shown, faint.
21
+ - In the web, the working set's reader and peek show a memory and a whole read of a `.md` file as rendered
22
+ markdown, with a `rendered | source` switch on the reader's cards (the same small pill on a phone); a memory's
23
+ peek starts at its body, without the front matter. A slice of a file stays numbered source.
24
+ - chi reminds you once on stderr when no core safety bundles are installed, including in a one-shot.
25
+
26
+ ### Changed
27
+
28
+ - A background task's folder (`tmp/tasks/`) is added to the repository's `.git/info/exclude`, so `git status`
29
+ doesn't list it.
30
+ - In the web, the working set's peek and reader say an item read in the step still running shows once that step's
31
+ tools finish, rather than "Nothing of it in the conversation yet".
32
+ - `chi bundle status NAME` reports a rule or script with no recorded sha256 as `[unrecorded]`, not `[modified]`.
33
+ - The web's working-set list opens on what chi touched last: "Read in this session" first, newest first (a row's
34
+ step tag is its last touch), the conversation's row, then "From the start", folded to one line with its
35
+ `held twice` count. Rows don't move while the list is open; new ones come in on top.
36
+
37
+ ### Fixed
38
+
39
+ - The known-names guardrail no longer flags a project's class name in backticks
40
+ (`CoffeeAssistant` for `coffee_assistant`) as a typo.
41
+ - A streamed answer that stops mid-way (no text, reasoning or tool call for `stream_idle_timeout` seconds; default
42
+ 120 on remote hosts, off on local) is closed and asked again like a dropped stream, then fails with `the model's
43
+ stream stalled …`, instead of waiting on keep-alives until the read timeout.
44
+ - The objectives strip no longer shows an empty 0/0 bar when every objective is dropped, and disappears at once when
45
+ the list goes away.
46
+ - A continue no longer starts with an empty Objectives bubble when every objective was dropped.
47
+ - Deleting a session no longer sometimes refuses it as in use while chi web is checking it.
48
+ - The peer chip says when no inbox is attached, rather than blaming a remote.
49
+ - Sending a peer the same part twice no longer marks the first, answered send "not sent" in the web: each send has
50
+ its own id.
51
+
52
+ Update with `chi update` (known-names 0.2.1 carries the backtick fix).
53
+
54
+
55
+ ## [0.180.0] - 2026-11-20
56
+
57
+ ### Added
58
+
59
+ - In the web, a send to a paired peer (Claude, Codex) and its answer link to each other: the send's row says
60
+ "waiting 2m", "changes · answered after 6m" or "not sent" and jumps down to the answer; the answer is a bubble
61
+ from the peer with its verdict and summary that jumps back up to the send, chi's instruction to the model folded
62
+ away.
63
+ - In the web, a paired peer is one chip in the session bar instead of its two `-inbox`/`-outbox` chips: it says
64
+ paired, waiting 2m, answered (with the unread dot), can't send or answers only, and opens a popover with the
65
+ last exchanges (a tap jumps to the send), View latest answer, the status card and Unpair (a bottom sheet on a
66
+ phone).
67
+
68
+ ### Changed
69
+
70
+ - The terminal shows a peer's answer note as `Claude answered · <summary>` (`Codex answered · …`) instead of `note from context claude-outbox: …`.
71
+ - A bundle that needs a newer chi now gets a warning for its `bundles:` section in config.yml, and
72
+ `--set` refuses its settings saying so, whether or not it has a plugin.
73
+ - A bundle's plugin, rule or script that isn't as installed is refused in one wording and one order everywhere (the
74
+ log, the load failures, the web's errors): "bundle NAME's plugin/FILE isn't recorded / is missing / differs from
75
+ the installed one (reinstall the bundle)". A rule with no recorded sha256 now says so instead of "differs", and
76
+ `chi bundle status NAME` shows such a plugin `[unrecorded]` instead of `[modified]`.
77
+
78
+ ### Fixed
79
+
80
+ - A background task whose shell ends just as chi exits no longer stays marked running with its leftover process left behind.
81
+ - A context source from a bundle whose manifest.json doesn't read, or isn't an object, now fails its fetch with a clear
82
+ reason, instead of an internal error or running its command unchecked.
83
+
11
84
  ## [0.179.0] - 2026-11-20
12
85
 
13
86
  ### Added
@@ -6547,7 +6620,9 @@ and long-lived sessions.
6547
6620
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
6548
6621
  hotkey panel that send selected text or the clipboard to your sessions.
6549
6622
 
6550
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.179.0...HEAD
6623
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.181.0...HEAD
6624
+ [0.181.0]: https://github.com/dm1try/samagotchi/compare/v0.180.0...v0.181.0
6625
+ [0.180.0]: https://github.com/dm1try/samagotchi/compare/v0.179.0...v0.180.0
6551
6626
  [0.179.0]: https://github.com/dm1try/samagotchi/compare/v0.178.0...v0.179.0
6552
6627
  [0.178.0]: https://github.com/dm1try/samagotchi/compare/v0.177.1...v0.178.0
6553
6628
  [0.177.1]: https://github.com/dm1try/samagotchi/compare/v0.177.0...v0.177.1
data/bin/chi CHANGED
@@ -260,6 +260,10 @@ end
260
260
 
261
261
  if options[:web]
262
262
  chi_update_hint.call unless web_restarted
263
+ unless web_restarted
264
+ require "samagotchi/core_notice"
265
+ Samagotchi::CoreNotice.show
266
+ end
263
267
  require "samagotchi/web/server"
264
268
  port = options[:web_port] || Samagotchi::Config.get("web.port")
265
269
  markdown = options[:web_markdown]
@@ -416,6 +420,8 @@ if launch == :attached
416
420
  exit 1
417
421
  end
418
422
 
423
+ require "samagotchi/core_notice"
424
+ Samagotchi::CoreNotice.show
419
425
  require "samagotchi/terminal_ui/attach_launcher"
420
426
  begin
421
427
  ended = Samagotchi::TerminalUI::AttachLauncher.run(attach: options[:attach], resume: options[:resume],
@@ -445,6 +451,10 @@ end
445
451
 
446
452
  # --non-interactive: the -p prompt's one turn in this process (TerminalUI,
447
453
  # the one-shot host); bare, a no-op that creates no session.
454
+ if options[:prompt]
455
+ require "samagotchi/core_notice"
456
+ Samagotchi::CoreNotice.show
457
+ end
448
458
  require "samagotchi/cli/exit"
449
459
  require "samagotchi/terminal_ui"
450
460
  begin
data/docs/architecture.md CHANGED
@@ -623,7 +623,7 @@ of chi reads (the prompt is input + cache reads + cache writes), stop reasons to
623
623
  (`max_tokens` → `length`, `tool_use` → `tool_calls`, `end_turn` → `stop`). A stream is read by content-block index
624
624
  from the `data:` lines alone (`event:` lines are not needed); `message_start` / `message_delta` events reach
625
625
  `on_delta` with that normalized `usage`, pings not at all, and a block's start or delta counts as shown for the
626
- first-token limit. Both adapters share their model-list cache (`LLM::ModelListing`) and their HTTP plumbing
626
+ first-token and stream-idle limits (`message_delta` and `message_stop` restart the idle clock without counting). Both adapters share their model-list cache (`LLM::ModelListing`) and their HTTP plumbing
627
627
  (`LLM::AdapterCommon`: timeouts, the paged model list, the SSE line loop, JSON errors). A host's `dialect:`
628
628
  (`LLM::Dialect`, `fireworks`) changes the auth header, the thinking `display`, the cache breakpoints and a session
629
629
  header; [internals/anthropic.md](internals/anthropic.md) covers the adapter.
data/docs/bundles.md CHANGED
@@ -9,6 +9,10 @@ feature they belong to: **source-links** in [hooks.md](hooks.md#the-source-links
9
9
  every shipped bundle with code does; before known-names 0.2.0 and source-links 0.7.0 they shipped a `hooks/*.rb` file
10
10
  (chi no longer loads one: [hooks.md](hooks.md#class-file-hooks-are-retired); `chi update` removes the old file).
11
11
 
12
+ `chi bootstrap` installs the recommended `core` safety profile. If none of its members has an install record,
13
+ chi prints a reminder to stderr at a session or web launch, including a one-shot, once per state directory. See
14
+ [Bundle profiles](memory.md#bundle-profiles-core-and-dev).
15
+
12
16
  ## The btw bundle
13
17
 
14
18
  `chi bundle install btw` (or the `dev` profile) installs the bundle shipped with chi. It is written
@@ -1015,11 +1019,43 @@ Claude pairs; without one the bundle costs one tool declaration.
1015
1019
  answer's note names the send (`re`); an older skill's answer has none and
1016
1020
  works as before. The session's peer exchange log keeps sends and answer
1017
1021
  summaries, not answer texts; a new pairing starts a new log.
1022
+ - **In the web** (the owner's page), a send and its answer link to each
1023
+ other. The send's row ("sent to Claude · validate: title") says where the
1024
+ exchange is: `waiting 2m`, `changes · answered after 6m` (the verdict's
1025
+ word: `ok`, `changes`, `unsure`), `answered after 6m`, or `not sent` (the
1026
+ send didn't go out); a tap on an answered one jumps down to the answer. The
1027
+ row's line of advice to the model is its hover instead. The answer stays
1028
+ where it arrived, as a bubble from Claude: "Claude answered", the send it
1029
+ answers (a tap jumps back up to that row, opening a folded turn), its
1030
+ verdict (`VERDICT OK` with "round closed" when Claude agreed), its summary,
1031
+ and chi's instruction to the model folded under "what chi told the agent".
1032
+ The newest answer also has "Read the full answer", which opens the
1033
+ Claude chip on the outbox's text (the outbox keeps one text, so older
1034
+ answers have only their summary). An answer from an older skill (no `re`)
1035
+ links to the last waiting validate or question; one that answers no send
1036
+ has no link back. A `/claude validate …` you type gets no link in the
1037
+ conversation (command bubbles aren't kept), its answer still names it.
1038
+ - **The session bar** has one chip for the pairing, `Claude · …`, first among
1039
+ the context chips, in place of `claude-inbox` and `claude-outbox`: `paired`;
1040
+ `waiting 2m` (a validate or question has no answer yet, its age the send's);
1041
+ `answered 3m` with the unread dot (an answer the agent hasn't read);
1042
+ `can't send` (the last send didn't go through: the Claude session ended or
1043
+ restarted, pair again from Claude, which ends it; chi web can't probe the
1044
+ socket, so a dead inbox shows only after a send hits it); `answers only`, dashed (no inbox: a
1045
+ pairing through a remote). Its popover (a bottom sheet on a phone) says how
1046
+ chi sends and where it answers, lists the last exchanges (time, kind ·
1047
+ title, `waiting 2m` / `changes · 11m` / `ok · 4m` / `answered · 4m` / `no
1048
+ answer expected` / `not sent`; a tap jumps to that send's row when it is in
1049
+ the conversation), and has View latest answer, Status card (runs `/claude`)
1050
+ and Unpair (detaches both sources after one confirm; if one can't be
1051
+ detached it stops there and says which). codex-peer's is the
1052
+ same, `Codex · …`.
1018
1053
  - **The tool `claude_send(kind, title, text)`**, `kind` being `validate`,
1019
1054
  `context` or `question`, writes one JSON line to that socket. The message
1020
1055
  starts with a header, `chi <id> · <kind> · <title>`, and a second line,
1021
- `ref: <send id>` (`s-` and 6 hex, from the kind, title and text as given:
1022
- the same part sent again has the same id), which Claude's answer gives back
1056
+ `ref: <send id>` (`s-` and 6 hex, from the kind, title and text as given
1057
+ and the send itself: each send has its own id, the same part sent again
1058
+ too; an older chi's resend shared one), which Claude's answer gives back
1023
1059
  so chi can tie it to its send; the tool's row in the web carries the id too.
1024
1060
  A text up to 4,000 characters follows inline; a longer one goes to a file,
1025
1061
  `$XDG_STATE_HOME/samagotchi/plugins/claude-peer/sessions/<id>/<HHMMSS>-<slug>.md`
@@ -1153,7 +1189,7 @@ session: chi sends the Codex session you work with a part of the work to
1153
1189
  validate or as context, and Codex's answer comes back into chi. It is a copy
1154
1190
  of claude-peer with the transport swapped; what differs is below, the rest
1155
1191
  (kinds, payload files, the last send, `/codex last`, the status card, the
1156
- skill install card) works the same.
1192
+ skill install card, the web's linked send and answer: "Codex answered") works the same.
1157
1193
 
1158
1194
  - **Sending is `codex queue`.** `codex_send(kind, title, text)` and
1159
1195
  `/codex validate|context <text>` run
data/docs/cli.md CHANGED
@@ -1172,7 +1172,9 @@ A model that can see images gets them these ways:
1172
1172
  the photo library, and is hidden while a turn runs). Each shows as a chip (× removes it) and is sent with the
1173
1173
  message; an image alone is sent as `[image: name]`. A message takes up to 20
1174
1174
  images of up to 20 MB each; a toast names the files left out (over a cap, or
1175
- not an image). Messages show thumbnails; a click opens one full size.
1175
+ not an image). Messages show thumbnails; a click opens one in the
1176
+ picture viewer, fitted to the screen: pinch, Ctrl/Cmd + scroll or the bar's − + zoom, a drag or scroll moves, a
1177
+ double tap goes close and back, ✕ or Esc closes.
1176
1178
  - **`chi send --image PATH`** (repeatable, up to 20) with a message, from a
1177
1179
  script or another terminal: `chi send --image shot.png -m "why is this red?"
1178
1180
  3fa2`. The attached terminal and the web show it like an image typed there.
@@ -1409,10 +1411,13 @@ session bar shows the `mem N` chip again.
1409
1411
  (`--mute`) memories included; its dot lights when the set changed since you
1410
1412
  last opened it.
1411
1413
  - **The list** the three open (a bottom sheet on a phone): always the whole
1412
- session's set, files grouped by folder (a group opens in place), memories
1414
+ session's set, last touched first, files grouped by folder (a group opens in place), memories
1413
1415
  (used, preloaded, muted) and URLs, each with what was done to it (`read ×2`,
1414
- `read, edited`, `preloaded`) and a step tag (`t2·s3`, `prompt` for a preloaded
1415
- memory) that goes to the call. The header's `session | ‹ turn N ›` is a lens:
1416
+ `read, edited`, `preloaded`) and a step tag (`t2·s3`: where it was last touched; `prompt` for a preloaded
1417
+ memory) that goes to that call. The order is taken when the list opens and holds while it is open: what chi
1418
+ touches meanwhile comes in on top, the other rows stay put. With the session's prompt parts known, "Read in
1419
+ this session" comes first, then the conversation's row, then "From the start" (the system prompt's parts),
1420
+ folded to one line (with its `held twice` count) until you open it; a fold you set is kept for the session. The header's `session | ‹ turn N ›` is a lens:
1416
1421
  the chip opens the session, a footprint or the rail opens a turn, and `‹` `›`
1417
1422
  step through the turns. In a turn's lens the rows that turn touched are lit,
1418
1423
  with that turn's words and step tag (`s3`), the others dimmed; the line under
@@ -1440,11 +1445,13 @@ session bar shows the `mem N` chip again.
1440
1445
  stage's rail shows an add queued for its end as a dashed `+ name · next turn`
1441
1446
  line.
1442
1447
  - **What chi has of an item**: a row's `▸` in the list peeks at it (its latest edit's diff, else its newest
1443
- read's first lines); `Open the timeline` (also a tool row's `timeline` and a file ref's ▾ `What chi has`) puts
1444
- the item's timeline over the stage, newest first: reads merged into line slices over a strip of the file, edits
1445
- as diffs, what chi no longer has greyed (with `undrop` for your drop), a changed memory's `Now · diff`. `← Stage`
1446
- or Esc goes back to the same place, ↑↓ step through the set; on a phone it is full screen (`‹ Set`, `‹ ›`).
1447
- Yours only: a participant's list has no `▸`.
1448
+ read's first lines, or a memory or a whole `.md` file rendered); `Open the timeline` (also a tool row's
1449
+ `timeline` and a file ref's ▾ `What chi has`) puts the item's timeline over the stage, newest first: reads merged
1450
+ into line slices over a strip of the file, edits as diffs, what chi no longer has greyed (with `undrop` for your
1451
+ drop), a changed memory's `Now · diff`. A memory and a whole read of an `.md` file show as rendered markdown (a
1452
+ leading front matter as source above it), with a `rendered | source` switch on the card; a slice of a file stays
1453
+ numbered source, and with markdown off everything is source. `← Stage` or Esc goes back to the same place, ↑↓
1454
+ step through the set; on a phone it is full screen (`‹ Set`, `‹ ›`). Yours only: a participant's list has no `▸`.
1448
1455
 
1449
1456
  Only `read`, `edit`, `write`, `memory_read`, `memory_write` and `web_fetch`
1450
1457
  calls that succeeded count; files an `execute` touched don't.
@@ -127,7 +127,7 @@ own subsystems: `hosts:` (below), `models:` (see "Prompt profile" and
127
127
  `guardrails:` (see [Guardrails](guardrails.md)), `bundles:` (a bundle's
128
128
  settings for its hooks, see [Hooks: Settings](hooks.md#settings); a session's own
129
129
  `--set BUNDLE.KEY=VALUE`, for a key the bundle's manifest lists in `session_settings:`, lays over them, see
130
- [Per-session settings](plugins.md#per-session-settings); a name no installed bundle has, or a key its manifest's `settings:` rules out, warns at the start of the first session to find it and again only when the findings change or come back (a digest of the lines shown is stamped in `$XDG_STATE_HOME/samagotchi/bundles_warned`; the log has them from every session); `--set KEY=VALUE` does the same for a few core keys,
130
+ [Per-session settings](plugins.md#per-session-settings); a name no installed bundle has, a key its manifest's `settings:` rules out, or a bundle this chi is too old for (its `requires_chi`), warns at the start of the first session to find it and again only when the findings change or come back (a digest of the lines shown is stamped in `$XDG_STATE_HOME/samagotchi/bundles_warned`; the log has them from every session); `--set KEY=VALUE` does the same for a few core keys,
131
131
  see "Per-session settings" below),
132
132
  `memories:` and `append_system_prompt:` (see "Appended prompt files"). Their entry names (host names, model ids, aliases) are yours to
133
133
  choose. The `memories:` list is the persistent baseline for preloaded memory entries —
@@ -151,7 +151,7 @@ or `chi web` restart.
151
151
  | `default.input`, `no_default_input`, `no_interrupt` | Next CLI run | These set up that run's first prompt or turn limit. |
152
152
  | `default.max_tokens`, `max_tool_output_chars`, `memory.read_max_chars`, `read.*`, `execute.*` except `execute.description`, `image.*` | Next matching request or tool use | An operation already in progress keeps its resolved limits. |
153
153
  | `server.host`, `server.port`, `hosts.*` | Worker start | Includes host addresses, APIs, declared models and host-level settings. Commands (`chi self`, `chi models`, the session lists) and chi web (its model picker, the session cards) read `hosts:` as it is now; a running worker keeps the hosts it started with until it restarts. |
154
- | `server.open_timeout`, `server.read_timeout`, `server.first_token_timeout` | Worker start | The worker's clients retain the timeouts set when they were built. |
154
+ | `server.open_timeout`, `server.read_timeout`, `server.first_token_timeout`, `server.stream_idle_timeout` | Worker start | The worker's clients retain the timeouts set when they were built. |
155
155
  | `model_aliases` | Next model lookup | A session keeps its resolved model unless it is explicitly switched. |
156
156
  | `models.<key>.profile` | Session start or `/model` | It is resolved when that model is selected; editing it does not switch the current model's profile by itself. |
157
157
  | Other `models.<key>.*` settings | Next turn or model lookup | Sampling, thinking, vision, context, window, price and steer settings are resolved from the file for their next use. |
@@ -352,8 +352,8 @@ doesn't end in a local suffix (`gpu.example.com`). A name without a dot (`box`)
352
352
  or ending in `localhost`, `.local`, `.lan`, `.home`, `.home.arpa`, `.internal`,
353
353
  `.intranet`, `.localdomain`, `.private`, `.corp`, `.test`, `.box` (`fritz.box`)
354
354
  or `.ts.net` (Tailscale) is local: chi doesn't look names up. A remote
355
- host keeps its model list for 10 minutes, gets a 120-second first-token limit,
356
- and isn't asked for llama.cpp's `/props` (its context window and served model
355
+ host keeps its model list for 10 minutes, gets a 120-second first-token limit
356
+ and a 120-second stream-idle limit, and isn't asked for llama.cpp's `/props` (its context window and served model
357
357
  come from its model list and each turn). A local `api: openai` host has no
358
358
  `/props`, so `chi self` GETs its `/models` with the same short probe timeouts
359
359
  and reports up/down with the ids it serves. `remote: true` or `remote: false` on a
@@ -919,6 +919,24 @@ hosts:
919
919
  which applies to every host. With neither set, remote hosts (see "Remote or local" above) get 120 seconds and local
920
920
  servers no limit: a long prompt evaluation is normal there, and the read timeout catches a dead server.
921
921
 
922
+ Once a stream has shown something, a **stream-idle limit** watches the rest: the seconds it may go without showing
923
+ more text, reasoning or a tool call. Keep-alive comments don't count, so an answer that stops mid-way is no longer
924
+ held open until the read timeout. A stalled stream is closed and asked again like a dropped one (`↻ retrying
925
+ (stream dropped) …`, its partial output dropped; see "Retries" below); once those run out the turn fails with `the
926
+ model's stream stalled on host <name>: no output for 120s (stream_idle_timeout); …`. The end of an answer (a finish
927
+ reason, the usage chunk, Anthropic's `message_delta` and `message_stop`) restarts the clock too, so a slow trailing
928
+ usage chunk doesn't void a complete answer.
929
+
930
+ ```yaml
931
+ hosts:
932
+ openrouter:
933
+ stream_idle_timeout: 300 # seconds; 0 = off
934
+ ```
935
+
936
+ `hosts.<name>.stream_idle_timeout` wins over `server.stream_idle_timeout` (`SAMAGOTCHI_SERVER_STREAM_IDLE_TIMEOUT`),
937
+ which applies to every host. With neither set, remote hosts get 120 seconds and local servers no limit: a local
938
+ server may stream nothing while it buffers a long tool call's arguments.
939
+
922
940
  Every chat request carries the session's id as a `Session-Id` header (next to `User-Agent: chi/<version>`). A
923
941
  gateway that spreads requests over several providers can key on it to keep one conversation on one provider, so
924
942
  prompt caches hit and every turn is answered by the same model. Servers that don't know the header ignore it.
@@ -1114,7 +1132,8 @@ Transient network failures are retried automatically with exponential backoff.
1114
1132
  chat loop (an OpenAI-compatible host) drops the partial reply and asks again for the whole step, from the same
1115
1133
  conversation, at most twice (at most `retry.max` times when that is smaller: `retry.max: 0` turns it off), after
1116
1134
  the same backoff, reported as a retry (`↻ retrying (stream dropped) …`); once those run out the turn fails with
1117
- the error, as before. A refusal, a first-token timeout, a provider error and a cancel are never retried this way.
1135
+ the error, as before. A stream that stalled past its `stream_idle_timeout` is asked again the same way. A refusal,
1136
+ a first-token timeout, a provider error and a cancel are never retried this way.
1118
1137
  - Cancellation (`Ctrl-C`) is never retried.
1119
1138
 
1120
1139
  Configuration:
@@ -2247,6 +2266,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2247
2266
  | `server.open_timeout` | `10` | yes | Connection timeout, seconds. |
2248
2267
  | `server.read_timeout` | `600` | yes | Read timeout, seconds. |
2249
2268
  | `server.first_token_timeout` | 120 remote, off local | | Seconds to the first token; `0` = off. `hosts.<name>.first_token_timeout` wins. |
2269
+ | `server.stream_idle_timeout` | 120 remote, off local | | Seconds a stream that showed something may go without more; `0` = off. `hosts.<name>.stream_idle_timeout` wins. |
2250
2270
  | `recap.enabled` | on | | `false` (or `recap: false`) turns the idle recap off. Per session too: `--set recap.enabled=false`, or `/recap off` in the session (see "Per-session settings"). |
2251
2271
  | `recap.model` | session's | yes | Model that writes the recap: an id, alias or `host:model` (the host then picks where to ask; a bare id goes where a bare `--model` goes). |
2252
2272
  | `recap.host_ref` | session's | yes | A `hosts:` name to ask (`host:` is accepted too, also a host name, not a model ref). |
data/docs/context.md CHANGED
@@ -238,6 +238,13 @@ The web's session bar shows a chip per source (name · age; a dot when the
238
238
  agent hasn't read a change, red after a failed refresh). A chip opens the
239
239
  summary, the hint's link, the text and detach (or mute here, for a project
240
240
  source). The web attaches nothing itself: `chi context add <URL>` does.
241
+ A paired peer's two sources (`claude-inbox`, `claude-outbox`) are one chip,
242
+ drawn first: it says how the pairing stands (paired, waiting, answered,
243
+ can't send, answers only) and opens the last exchanges, the outbox's text and
244
+ Unpair ([bundles.md](bundles.md#the-claude-peer-bundle), The session bar).
245
+ A peer's answer (a note with `peer`, [Peer sources](#peer-sources-the-peer-loop)) is not drawn as a context note but
246
+ as a bubble from the peer, linked to the send it answers
247
+ ([bundles.md](bundles.md#the-claude-peer-bundle), In the web).
241
248
 
242
249
  ## Waking
243
250
 
@@ -15,7 +15,7 @@ ChatLoop::Run#generate
15
15
  → AnthropicWire.translate # system blocks + messages, cache_control placed
16
16
  → AnthropicWire.tools # function schemas → {name, description, input_schema},
17
17
  # a deferred one with defer_loading: true
18
- → POST {base}/v1/messages # LLM::HTTP: retries, cancel, first-token limit
18
+ → POST {base}/v1/messages # LLM::HTTP: retries, cancel, first-token and stream-idle limits
19
19
  → AnthropicAssembly#add per SSE event # → ChatResponse (text, reasoning, tool_calls, usage,
20
20
  # finish_reason, provider_content)
21
21
  → a signature 400 (Claude 5.x preserved thinking): AnthropicBindingRecovery#advance, then the same
@@ -90,8 +90,9 @@ A stream is read from its `data:` lines alone (a gateway that drops the `event:`
90
90
  index: `message_start` (served model, usage), `content_block_start` (text, thinking, redacted_thinking, tool_use),
91
91
  `content_block_delta` (`text_delta`, `thinking_delta`, `signature_delta`, `input_json_delta`), `message_delta`
92
92
  (stop reason, `stop_details`, usage). `AnthropicMessages#chat_streamed` passes every event but `ping` to `on_delta`,
93
- `message_start` and `message_delta` with the usage so far attached (`#with_usage`); a block's start or delta counts as shown for the first-token limit
94
- (`.shows?`). A 200 whose body is a JSON error instead of a stream raises that error (`LLM::AdapterCommon#raise_plain_error`, shared with the OpenAI adapter).
93
+ `message_start` and `message_delta` with the usage so far attached (`#with_usage`); a block's start or delta counts as shown for the first-token and stream-idle limits
94
+ (`.shows?`); `message_delta` and `message_stop` restart the stream-idle clock without counting as shown (`.ending?`), so a
95
+ slow end of a complete answer doesn't stall it. A 200 whose body is a JSON error instead of a stream raises that error (`LLM::AdapterCommon#raise_plain_error`, shared with the OpenAI adapter).
95
96
 
96
97
  `#response` is a `ChatResponse`:
97
98
 
@@ -29,6 +29,8 @@ Behavior:
29
29
 
30
30
  - `execute`, `task_create` and the `!cmd` shell bang run the command in a non-login shell: `/bin/sh -c` on Linux; on macOS, when `/bin/zsh` is there, `/bin/zsh --emulate sh +o ignore_braces +o sh_glob -o bash_rematch +o bsd_echo -c` (macOS's `/bin/sh` is bash 3.2, which can't parse an apostrophe in a heredoc inside `"$( )"`, the usual commit message shape). That mode reads no rc files and keeps POSIX word splitting, unmatched globs left as is, `{1..3}`, `[[ … =~ (…) ]]` with `BASH_REMATCH`, arrays, `$'…'`, `&>` and echo expanding `\t`. Bash-only builtins and variables (`shopt`, `BASH_VERSION`, `${!prefix*}`, `read -p`) are not there.
31
31
  - Task metadata and output are persisted under `tmp/tasks/`: each task's `tmp/tasks/<id>/task.json` is a `TaskRecord` (`lib/samagotchi/tools/task_record.rb`, a value object: `.from_file` reads it, `#to_file` is the JSON object written, an update is a `#with`). Its keys keep their order; `stderr_path` and `handed_over_by` (a handed-over execute), `stop_requested_by` (a stop under way or done) and `leftovers` (`stopped` or `detached`: what the shell left holding the log, below) are left out until set. `bundles/slow-commands` reads these files on its own, so the shape is a contract.
32
+ - When a task is created in a git worktree, chi adds its `tmp/tasks/` path relative to the repository root to the
33
+ common git directory's `info/exclude`, once. An error is logged and does not prevent the task from starting.
32
34
  - A task record keeps its process's pid and start time (`pid_started`). Before `task_stop` signals, the pid must still lead its own process group and must not have started at another time; otherwise the pid was reused by another process, nothing is signalled and the task ends as failed. A start time that can't be read at that moment (a failed `ps`) falls back to the group check, as does a record without `pid_started` (from an older chi). `task_get`, `task_list`, `task_wait`'s polls and the running-task lists (a cancelled turn's note, a worker's restart hold, the finish wake's watch) make the same check, so a task whose pid was reused reads as exited (failed) at once, not as running until a `task_stop`; on macOS that is one `ps` per running task per check (~5 ms).
33
35
  - A stop (`task_stop`, the user's Stop of an `execute`, the execute limit in kill mode) TERMs the task's process group, then KILLs it after a grace. The groups its processes started are stopped too: a GNU `timeout N cmd` (without `--foreground`) moves itself and its command to a group of its own. `ProcessGroup.stop` finds them with one `ps -A -o pid=,ppid=,pgid=` (~40 ms on macOS) before the TERM and again before the KILL, walking down from the group's members. A process whose parent already exited (reparented to init, e.g. a setsid'd `cmd &`, or a backgrounded `timeout N cmd &` after its shell exited) is not found by that walk; one still in the task's group is stopped by the leftover rule below, so only one outside the group runs on: a setsid'd `cmd &`, or a backgrounded `timeout N cmd &` (GNU `timeout` moves to a group of its own). Holding the task's log, it is reported detached.
34
36
  - Task listing is workspace-scoped (current project only).
@@ -36,7 +38,8 @@ Behavior:
36
38
  - The exit code: the command runs after an EXIT trap that writes the shell's status to the `exit_code` file (`TaskRuntime.wrapped_shell_command`, shared with `task_create`), so `exit N`, a `set -e` failure and a trailing `\` or `|` in the command all record what the shell exited with. The trap runs wherever the shell is when it exits (a `task_create` `cwd`, or a `cd` in the command), so `task_create`'s `exit_code_path` is absolute; its `output_path` stays relative (`tmp/tasks/<id>/output.log`, opened by chi in the worker's cwd before the spawn). A command that sets its own EXIT trap replaces it, and a shell killed by a signal skips it (zsh's sh mode, on TERM, INT and KILL): `execute` still reports the shell's status, and a `task_create` task or a handed-over execute gets its code from chi's waiter while the chi that started it runs (`TaskRuntime.record_exit_status`): the exit status, or `128 + the signal` (TERM → 143), with no new `stop_reason`. A record a refresh already finished without a code in between (`failed`, `process_ended_without_exit_code` or the not-chi's-process reason) is corrected, its `finished_at` kept; a stopped task (its stop flag on disk) is never touched. `process_ended_without_exit_code` is left only when the shell wrote nothing and the chi that started it was gone too.
37
39
  - `task_create` applies `execute`'s leftover rule (`Tools::Leftovers`, one implementation: `held?`, the grace, the group stop, the hint wording): `create_task` holds `output.log` with a shared `flock` across the spawn, and a handed-over execute's two logs are already held. When the task's shell exits and a process it started still holds the log (`yes >/dev/null &` with no `wait`), the task stays `running` (so the finish wake's watch and `task_wait` keep waiting) while the waiter of the chi that started it (`TaskRuntime.record_exit_status`) gives it 1.5 s (`LEFTOVER_GRACE_SEC`), then stops the group (TERM, 1 s, KILL; `Leftovers.stop_group`, only while the group still has members: a pgid isn't reused while it has any) and finishes the record in one write: the shell's status and exit code (the leftovers don't make it a failure) and `leftovers: "stopped"`. A holder outside the group with the group empty (a setsid'd `cmd &`, or a backgrounded `timeout N cmd &`: GNU `timeout` without `--foreground` moves itself and its command to a group of its own) is signalled nothing: `leftovers: "detached"`, left running, and the hint says so (`task_stop` can't reach it: kill it if it shouldn't run). A process holding no log (`nohup cmd >f 2>&1 &`) is left alone. `task_get`, `task_wait` (so the finish note too) and `task_list` add the hint line (`Leftovers.task_hint`), ``(a background process kept the task's log open and was stopped; to keep one running, run it in the foreground or end the command with `wait`)`` (or `was left running`), built from the same `Leftovers.hint` as execute's. One settler per task: while that waiter thread lives (`TaskRuntime.waiter_for`, in memory, this process only), a refresh here only reads a held record. With no waiter here (the chi that started it is gone, a worker that exited mid-grace, or another process reading), the next refresh that finds the shell dead and the log held settles it itself: a second look after 0.05 s (two `held?` probes at once read each other as holders), then the stop with a 0.5 s TERM grace and 0.5 s KILL wait (only of a group that still had members at the first look; one gone by the stop with nothing holding the log records no `leftovers`), so that read blocks up to ~1 s plus a `ps`. With no later reader of that cwd's tasks the leftovers run on; records already finished (an older chi's) are never revisited, and an older chi's record (its log never `flock`'d) reads as not held and settles as before. A `task_stop` during the grace stops the group (`Leftovers.stop_group`) and the record ends `stopped` (its stop flag wins over the waiter's write; in one process the two writes share a lock). Cost: one non-blocking `flock` try per log at shell exit (~0.2 ms), the grace only when something holds the log; a refresh of a running record whose shell is dead adds one `flock` try, and one `ps` only when the log is held.
38
40
  - On a clean exit (worker teardown or a one-shot), `Engine#shutdown` calls `TaskRuntime.settle_pending!`: this process's
39
- waiters whose shells are already reaped get time to finish their leftover grace and stop before chi exits. The wait
41
+ waiters whose shells are already reaped (the detach thread ended, the waiter settling, or the pid gone: the detach
42
+ thread runs a moment after its reap) get time to finish their leftover grace and stop before chi exits. The wait
40
43
  shares one deadline with the anytime-command joins (the later of their 3 s and ~4 s), and logs a warning if a selected waiter
41
44
  remains. A shell still running at the snapshot, including one that exits during the join, is not waited on; a crash
42
45
  or SIGKILL cannot wait either. With no later reader of that cwd, such leftovers can still run on.
@@ -17,15 +17,16 @@ model. The TUI is untouched: it shows a fence as source.
17
17
  the URL's names go through `BlockRenderers.script_path` (membership in a listed renderer's `load` before any path is
18
18
  made), then `InstalledBundles::Dir#file_refusal(:scripts, …)` (the check a context provider's scripts get too); a file with no recorded sha, a missing one or a changed one is 409
19
19
  `renderer_changed`, each with its own reason. ETag + `no-cache`, as static files. A `block_renderers:` list that
20
- doesn't parse is logged once per bundle and problem (each list request and file fetch reads it).
20
+ doesn't parse is logged once per bundle and problem (each list request and file fetch reads it); a bundle this chi is
21
+ too old for (`requires_chi`) draws nothing, logged once per bundle and version (`block_renderers_too_new`).
21
22
  3. `block_watch.js` (`createBlockWatch`, made by `block_host.js`'s `createBlockHost`, wired in `app.js`; a participant's page
22
23
  gets the core drawers only, no bundle's renderers: `block_renderers`) finds and watches the blocks; `block_host.js` is its frame drawer (`createFrameDrawer`). The watcher asks an
23
24
  ordered list of drawers, core ones first (`inline_widgets.js` for `chi-ui`: [inline-widgets.md](inline-widgets.md)), then the frame drawer, which waits for `/api/block_renderers`;
24
25
  the first that `claims` the block's language draws it, and a language none claims is left alone. The contract
25
26
  (`claims`, `needsDraw`, `draw`, its `reconsider`, `sessionChanged`) is in the module's header. The shared DOM
26
27
  helpers live there too: `failBlock` and its `.block-note` (a click copies it), `holdingView`, `rejoin`, the
27
- toggle's listener; frames, the cache, hang marks, size checks, the zoom and the theme redraw stay in
28
- `block_host.js`. One `MutationObserver` per turn root,
28
+ toggle's listener; frames, the cache, hang marks, size checks, the click that opens the picture viewer and the theme
29
+ redraw stay in `block_host.js`. One `MutationObserver` per turn root,
29
30
  filtered to `TEXTS` (`text_roots.js`), so cards, a lead-in bubble, question replies and delegate reports never draw, and
30
31
  every path that adds a block to a root is seen the same way. One `IntersectionObserver` per scroller, with an explicit `root`
31
32
  (with `root: null`, `rootMargin` doesn't pass an `overflow: auto` in between). Closed `<details>` fire on open. **A
@@ -41,9 +42,12 @@ model. The TUI is untouched: it shows a fence as source.
41
42
  shows, never markup, and not in the bubble's `textContent`, which the page's dedupe and an annotation read (`copy.js`'s rule). CSS content can't be selected, so a click on the line copies its words.
42
43
  The toggle has an icon and an `aria-label`, no text (`copy.js`'s rule). A jump into the source shows it (`revealInHistory`).
43
44
  For a screen reader: the hidden `<pre>` isn't read, so the `<img>`'s alt names the toggle that shows it ("mermaid
44
- diagram, its source under the Show the source button"). The natural size, a click on the picture, is also a
45
- `.block-zoom` button (icon, `aria-label`, `aria-pressed`) for the keyboard: before the toggle, shown on keyboard focus
46
- only, and taking no pointer while hidden, so the mouse's view is as it was.
45
+ diagram, its source under the Show the source button"). In the answer the picture is always fitted to the column. A
46
+ click on it opens the page's picture viewer (`createBlockHost`'s `openPicture`, app.js's `picture_viewer.js`;
47
+ [web-frontend.md](web-frontend.md#picture-viewer)) with its `data:` URL and its size from the viewBox, zoomable and
48
+ movable there; without `openPicture` (an older app.js) a click does nothing. The same is a `.block-zoom` button
49
+ ("Open in the viewer": icon, `aria-label`) for the keyboard: before the toggle, shown on keyboard focus only, and
50
+ taking no pointer while hidden; Esc in the viewer gives it the focus back.
47
51
  6. Cache: a `Map` on `lang + theme + source`, about 200 entries, holding the `data:` URL; a later `bubble.innerHTML` wipes the
48
52
  figure and the observer redraws in the same pass. No `crypto.subtle`: it's undefined on a plain-http LAN address. A system
49
53
  theme change redraws through the figure (a hidden `<pre>` never intersects).
@@ -56,7 +60,7 @@ model. The TUI is untouched: it shows a fence as source.
56
60
  from `DOMParser`, never a regex over model-influenced XML (exponents, a comment holding `<svg`, a `>` in an attribute, entities and
57
61
  prefixes all fooled one), and a vast one isn't decoded. Then the decoded size is checked: over the maximum, or a width or
58
62
  height of 0 (WebKit's 0 x 150 for a viewBox it can't hold), the block stays source with its line. `.block-img`'s CSS
59
- `max-height` and natural `max-width` say the same number, a backstop whatever the parsing gets wrong. The decode is bounded too
63
+ `max-height` says the same number, a backstop whatever the parsing gets wrong. The decode is bounded too
60
64
  (15 s, the mark on until it ends). A very wide picture stays at least 120 px tall and scrolls sideways instead of a sliver.
61
65
 
62
66
  ## Security model
@@ -41,8 +41,8 @@ read side, never the reverse.
41
41
  | Piece | Role |
42
42
  |---|---|
43
43
  | `InstalledBundles` (`installed_bundles.rb`) | `.each(holding:, dir:)` (each installed bundle by name, its `Record`; one whose `manifest.json` doesn't read with `error` set, and with `holding:` only those with that key, or that dir when it doesn't read), `.claimants` (which bundles own a memory file), `.dir` (`MemoryPaths.bundles_dir`) |
44
- | `InstalledBundles::Dir` (installed_bundles/dir.rb) | one bundle's `.bundles/<name>/` as the runtime reads it: `Dir.new(name:, dir:)`, `#record`, `#plugin_dir`, `#plugin_path`, `#scripts_dir`, `#guardrails_dir`, `#kept_manifest_path`, `#file_refusal(kind, file, recorded)` (the one "is this installed file as installed" check: `:plugin`, `:scripts`, `:guardrails`, each with its own order and words today, a `Refusal`). Its only state is the name and the folder; `Provenance` is one |
45
- | `InstalledBundles::Standing`, `Refusal` (installed_bundles/standing.rb) | the usability verdict: `.standings(holding:, dir:)` (the walk, each bundle's `Standing`), `.standing(name, dir:)` (one record; a `manifest.json` that doesn't parse raises), `Standing.of(name, record)`: `#refusal` is `:unreadable` (the record) or `:too_new` (requires_chi), nil when chi may use it; none of the bundle's own files is hashed (a manifest cache miss hashes the kept `manifest.yml`, as `Manifest.of` does). A `Refusal` has `kind`, `text` and, for `:file_changed`, the `actual` and `expected` shas. Each reader keeps only its reaction (below) |
44
+ | `InstalledBundles::Dir` (installed_bundles/dir.rb) | one bundle's `.bundles/<name>/` as the runtime reads it: `Dir.new(name:, dir:)`, `#record`, `#plugin_dir`, `#plugin_path`, `#scripts_dir`, `#guardrails_dir`, `#kept_manifest_path`, `#file_refusal(kind, file, recorded)` (the one "is this installed file as installed" check: `:plugin`, `:scripts`, `:guardrails`, one order (no sha recorded, missing, changed) and one wording, `bundle X's <folder>/<file> isn't recorded / is missing / differs from the installed one (reinstall the bundle)`, a `Refusal`). Its only state is the name and the folder; `Provenance` is one |
45
+ | `InstalledBundles::Standing`, `Refusal` (installed_bundles/standing.rb) | the usability verdict: `.standings(holding:, dir:)` (the walk, each bundle's `Standing`), `.standing(name, dir:)` (one record; a `manifest.json` that doesn't parse is `:unreadable`, in the walk's words), `Standing.of(name, record)`: `#refusal` is `:unreadable` (the record; `Standing.warn_unreadable` logs `bundle_unreadable` once per process per bundle and reason, whichever reader came across it, `.claimants` too) or `:too_new` (requires_chi), nil when chi may use it; none of the bundle's own files is hashed (a manifest cache miss hashes the kept `manifest.yml`, as `Manifest.of` does). A `Refusal` has `kind`, `text` and, for `:file_changed`, the `actual` and `expected` shas. Each reader keeps only its reaction (below) |
46
46
  | `InstalledBundles::Sha` (installed_bundles/sha.rb) | the record's shas: `.recorded` (either format, `""` for none), `.of_file`, `DEV` (a dev install's `sha256:dev`), `.unchecked?`, `.matches?` |
47
47
  | `BundleCommand` (`lib/samagotchi/bundle_command.rb`) | `chi bundle install/upgrade/uninstall/status/diff/list/build/trash/new/test/check/try` (`install --dev`: the Installer's `dev:`, links and `InstalledBundles::Sha::DEV`); runs the Installer, prints its summary, runs the conflict agent step; refuses a source already installed under another name (`installed_under_another_name?`: a git URL bundle recorded under its repo's name before the manifest named it). `upgrade` resolves its argument by `upgrade_source`: a git URL or an existing path, then a shipped name, then the bare name of an installed bundle — whose record's source it then uses (a git URL with its `#ref`, a dir or an archive that is still there), printed as `Upgrading NAME from SOURCE`; a dev record is refused with `Installer.dev_install_line`, a recorded source that is relative, empty or gone says so and asks for the path or URL of a copy (`Installer.source_gone_line`, the words `ManifestStanding` uses too). After an upgrade or uninstall that changed the bundle's plugin (or brought one in), one line names the sessions still running its old code (`LiveVersions.workers`, the ones whose worker takes a restart) and `chi sessions restart ID` for each: only the plugin stays in memory, since a bundle's rules reload by their stamp and its scripts run from the replaced files. |
48
48
  | `BundleCommand::Check` (bundle_command/check.rb) | `chi bundle check [PATH] [--fix] [--set K=V]`: a bundle being written, checked as an install takes it (docs/cli.md lists the codes); parses the manifest from `Shas.parseable` (a placeholder sha is a `sha` finding, not a YAML error), reads the user's installed bundles only for `clash`, and installs and loads through `Testing::Install` in a `Testing::Sandbox` with `force: true`, the log's echoes swallowed |
@@ -95,7 +95,7 @@ Readers of the installed state ask one verdict and keep only their reaction. The
95
95
  `InstalledBundles.standings` (the walk) or `.standing(name)` (one record): a `Standing` whose `refusal` is
96
96
  `:unreadable` (the record doesn't read) or `:too_new` (requires_chi), then, for a file chi loads, runs, serves or
97
97
  reads, `InstalledBundles::Dir#file_refusal(:plugin | :scripts | :guardrails, file, recorded)` (`:file_missing`,
98
- `:file_unrecorded`, `:file_changed`; each kind keeps today's order and words, so the same failure wins as before).
98
+ `:file_unrecorded`, `:file_changed`; checked not recorded, then missing, then changed, for every kind).
99
99
  What each does with a refusal stays its own:
100
100
 
101
101
  | Reader | `:unreadable` | `:too_new` | a file's refusal |
@@ -103,15 +103,17 @@ What each does with a refusal stays its own:
103
103
  | `Plugin::Loader.load_bundle` | a failure that fails closed (required) unless its kept `manifest.yml` reads and names no required plugin (`#unreadable_required?`) | a failure (required for a guardrail plugin) | a failure, the refusal's text |
104
104
  | `GuardrailWiring#bundle_rules` | a required failure | `#too_new_bundle_rules` (the rules loaded before stay) | a required failure per rule file |
105
105
  | `ContextProviders.resolve` / `.any?` | skipped | skipped, `providers_too_new` logged once (only when it declares providers) | n/a |
106
- | `ContextProviders.command_for` | not refused (a `manifest.json` that doesn't parse raises `JSON::ParserError`: D7; one that isn't an object runs: D8) | `Invalid` | `Invalid`, per recorded script |
107
- | `BlockRenderers.for_installed` / `.script_path` | lists none | skipped | `Invalid` |
108
- | `SessionConfig.availability` | left out | a note, only when it has a plugin (D2) | a note |
109
- | `BundleSettingsCheck.warnings`, `BundleNeeds.entry_markers`, `MemoryCommand.entries` | skipped | still read (D1, D5) | n/a |
110
- | `MemoryBundle::Status.plugin_status` | n/a | `requires_failure` | `missing`, else `modified` (D9) |
106
+ | `ContextProviders.command_for` | `Invalid` | `Invalid` | `Invalid`, per recorded script |
107
+ | `BlockRenderers.for_installed` / `.script_path` | lists none | skipped, `block_renderers_too_new` logged once (only when it declares renderers) | `Invalid` |
108
+ | `SessionConfig.availability` | left out | a note, plugin or not (`SessionConfig.unusable`) | a note |
109
+ | `BundleSettingsCheck.warnings` | skipped | one warning (`SessionConfig.unusable`), its keys unchecked | n/a |
110
+ | `BundleNeeds.entry_markers`, `MemoryCommand.entries` | skipped | still read (its memories are) | n/a |
111
+ | `MemoryBundle::Status.plugin_status` | n/a | `requires_failure` | `unrecorded`, `missing` or `modified` |
111
112
 
112
113
  `InstalledBundles.claimants` skips an unreadable record off the record itself (`Record#error?`), so a claimant
113
- check reads no manifest. `ContextProviders`' once-per-process log is a Set under a Mutex, like `GuardrailWiring`'s
114
- kept-rules notice. The D rows are the plan's V2 decisions; until then each reaction is pinned as it is.
114
+ check reads no manifest. Each skip is also logged once per process: an unreadable record by the verdict
115
+ (`bundle_unreadable`), a too-new bundle by the reader that skips it; every once-per-process log is a Set under a Mutex,
116
+ like `GuardrailWiring`'s kept-rules notice.
115
117
  They read shas and state off the record, and
116
118
  manifest data (requires_chi, needs, providers, renderers, settings) through `InstalledBundles::Record#manifest`
117
119
  (`InstalledBundles::Manifest`: the kept `manifest.yml` when its sha holds, else the record's mirror), as do `SessionConfig`, `BundleSettingsCheck`, `BlockRenderers`, `Status`, `BundleCommand`'s
@@ -171,8 +171,10 @@ any call. An add's text can't split on ` | `. The body names the line, for a ter
171
171
  `Objectives.view` (`List#to_view`) is what the page draws: the items, each with its last move, and `pending`, whether
172
172
  the newest list is a file still waiting. The session read (`objectives`, no key with no list) and the live
173
173
  `:objectives_updated` carry it. `Engine#announce_objectives` (under the event lock, `TurnStages::Objectives#announce` giving the event) emits when the view differs from the last: after an edit,
174
- once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A session
175
- with no list emits nothing. Between two tabs that is all it takes. A participant gets neither: the event is in
174
+ once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A list
175
+ that goes away (a rollback, or a canceled or failed turn's kept messages, past the note that set it) emits one event
176
+ with `items: nil`, and the strip's `take` clears (an N-1 page's too); a session with no list before and after emits
177
+ nothing. Between two tabs that is all it takes. A participant gets neither: the event is in
176
178
  `ParticipantView::DROPPED`.
177
179
 
178
180
  Idle, an edit lands at once: the worker's anytime path wakes the loop (`@waker.wake`, one extra pass for any anytime
@@ -185,7 +187,10 @@ command), which absorbs the file. It no longer waits for the fallback tick.
185
187
  by `forgetSession`. Its edit list is a `chip_popover.js` shell, so a phone gets the bottom sheet and the focus rules.
186
188
  Every edit is a line on the command route with `card: true`: no echo, and `commandView` hides a good `/objectives`
187
189
  answer that came with that mark, so a tap leaves no bubble, a refusal does. The strip redraws from the event, never
188
- optimistically.
190
+ optimistically. A list with only dropped objectives draws no strip, as no list (`stripItems` is empty), and
191
+ `hasList()` is false, so the history's /short button hides too. The last one dropped from inside the open edit list
192
+ keeps the list and its strip until the list closes (its Undo stays under the finger); the close redraws the strip
193
+ away. `/objectives undo <id>` brings one back meanwhile.
189
194
  - **The entry** (`objectives_entry.js`, from `turn_html.js noteBubbleTemplate`): `Objectives.entry` puts the note's items
190
195
  and, against the list before it, `changes` (`Objectives.changes`, display only) on the history item and on
191
196
  `context_added`. A first list is pills; a later one a line, `You marked O1 done`. The raw text stays the tooltip.
@@ -237,7 +242,7 @@ command), which absorbs the file. It no longer waits for the fallback tick.
237
242
  - **Continue**: `Objectives.carry`, in `SessionContinue`'s `before_spawn`, writes a second note file in the new link,
238
243
  after the carry note and any moved context's note, so the list reads as the latest word. It is not in
239
244
  `SessionChain.note_text` (capped; the last answer gets what the recap leaves). It reads the previous link fresh,
240
- with its unabsorbed newest file. A failure is only logged (`continue_objectives_failed`), because it runs inside the
245
+ with its unabsorbed newest file; a list with nothing active or done isn't carried (`List#meant?`). A failure is only logged (`continue_objectives_failed`), because it runs inside the
241
246
  continue's rollback. The previous link's other waiting notes move after it (`NoteMove.move`, the step after: moved first, the
242
247
  carry would miss a pending edit, and the stale list would be the batch's newest); its objectives notes never move,
243
248
  and the new link's worker never adopts one from it (`NoteMove.adoption`), so a list from the archived link can't