samagotchi 0.142.0 → 0.143.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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -7
  3. data/README.md +1 -0
  4. data/docs/architecture.md +13 -6
  5. data/docs/bundle-authoring.md +6 -6
  6. data/docs/bundles.md +1232 -0
  7. data/docs/cli.md +36 -6
  8. data/docs/configuration.md +11 -12
  9. data/docs/context.md +10 -10
  10. data/docs/guardrails.md +7 -9
  11. data/docs/hooks.md +19 -2
  12. data/docs/internals/attached-context.md +2 -3
  13. data/docs/internals/bundles.md +5 -3
  14. data/docs/internals/engine.md +9 -3
  15. data/docs/internals/prompt-caching.md +12 -12
  16. data/docs/internals/web-push.md +1 -1
  17. data/docs/memory.md +2 -2
  18. data/docs/plugins.md +26 -1251
  19. data/docs/sessions.md +2 -2
  20. data/docs/sub-agent.md +6 -6
  21. data/docs/system-one.md +2 -2
  22. data/lib/samagotchi/bundle_command/api_calls.rb +132 -0
  23. data/lib/samagotchi/bundle_command/check.rb +50 -34
  24. data/lib/samagotchi/bundle_command/installed_check.rb +86 -0
  25. data/lib/samagotchi/bundle_command/scaffold.rb +1 -0
  26. data/lib/samagotchi/bundle_settings_check.rb +58 -0
  27. data/lib/samagotchi/bundles/agents-md/manifest.yml +4 -2
  28. data/lib/samagotchi/bundles/agents-md/plugin.rb +1 -1
  29. data/lib/samagotchi/bundles/btw/manifest.yml +4 -2
  30. data/lib/samagotchi/bundles/btw/plugin.rb +1 -1
  31. data/lib/samagotchi/bundles/check-in/manifest.yml +7 -6
  32. data/lib/samagotchi/bundles/check-in/plugin.rb +7 -14
  33. data/lib/samagotchi/bundles/claude-peer/manifest.yml +3 -3
  34. data/lib/samagotchi/bundles/claude-peer/plugin.rb +1 -1
  35. data/lib/samagotchi/bundles/claude-peer/scripts/pair +1 -1
  36. data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
  37. data/lib/samagotchi/bundles/codex-peer/plugin.rb +1 -1
  38. data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
  39. data/lib/samagotchi/bundles/coordinator/plugin.rb +1 -1
  40. data/lib/samagotchi/bundles/core/manifest.yml +2 -2
  41. data/lib/samagotchi/bundles/cost-cap/manifest.yml +6 -3
  42. data/lib/samagotchi/bundles/cost-cap/plugin.rb +5 -7
  43. data/lib/samagotchi/bundles/github-pr/manifest.yml +3 -1
  44. data/lib/samagotchi/bundles/known-names/manifest.yml +3 -1
  45. data/lib/samagotchi/bundles/loop-guard/manifest.yml +4 -2
  46. data/lib/samagotchi/bundles/loop-guard/plugin.rb +1 -1
  47. data/lib/samagotchi/bundles/mcp/manifest.yml +4 -2
  48. data/lib/samagotchi/bundles/mcp/plugin.rb +2 -2
  49. data/lib/samagotchi/bundles/ruby/manifest.yml +2 -2
  50. data/lib/samagotchi/bundles/ruby/plugin.rb +1 -1
  51. data/lib/samagotchi/bundles/skills/manifest.yml +4 -2
  52. data/lib/samagotchi/bundles/skills/plugin.rb +1 -1
  53. data/lib/samagotchi/bundles/slow-commands/manifest.yml +4 -2
  54. data/lib/samagotchi/bundles/slow-commands/plugin.rb +1 -1
  55. data/lib/samagotchi/bundles/source-links/manifest.yml +3 -1
  56. data/lib/samagotchi/bundles/system/config_modification_protocol.md +1 -1
  57. data/lib/samagotchi/bundles/system/manifest.yml +3 -3
  58. data/lib/samagotchi/bundles/system/self_map.md +2 -2
  59. data/lib/samagotchi/bundles/work-cap/manifest.yml +6 -3
  60. data/lib/samagotchi/bundles/work-cap/plugin.rb +11 -13
  61. data/lib/samagotchi/context_candidate_choice.rb +12 -3
  62. data/lib/samagotchi/context_candidates.rb +4 -1
  63. data/lib/samagotchi/context_candidates_log.rb +11 -0
  64. data/lib/samagotchi/context_status.rb +1 -2
  65. data/lib/samagotchi/engine.rb +33 -68
  66. data/lib/samagotchi/extension_load.rb +8 -2
  67. data/lib/samagotchi/hook_routes.rb +37 -2
  68. data/lib/samagotchi/hooks/bundle_loader.rb +20 -4
  69. data/lib/samagotchi/hooks/registry.rb +23 -5
  70. data/lib/samagotchi/host_model.rb +3 -3
  71. data/lib/samagotchi/host_registry.rb +14 -7
  72. data/lib/samagotchi/kernel_loop.rb +7 -2
  73. data/lib/samagotchi/llm/chat_loop.rb +5 -0
  74. data/lib/samagotchi/llm/stray_tool_call.rb +23 -16
  75. data/lib/samagotchi/memory_bundle/builder.rb +4 -2
  76. data/lib/samagotchi/memory_bundle/installed_bundle.rb +9 -2
  77. data/lib/samagotchi/memory_bundle/installed_copy.rb +92 -0
  78. data/lib/samagotchi/memory_bundle/installer.rb +2 -0
  79. data/lib/samagotchi/memory_bundle/manifest.rb +23 -13
  80. data/lib/samagotchi/memory_bundle/provenance.rb +4 -1
  81. data/lib/samagotchi/memory_bundle/shipped_update.rb +13 -1
  82. data/lib/samagotchi/model_catalog.rb +3 -2
  83. data/lib/samagotchi/models_command.rb +1 -1
  84. data/lib/samagotchi/plugin/api.rb +14 -11
  85. data/lib/samagotchi/plugin/context.rb +10 -0
  86. data/lib/samagotchi/plugin/loader.rb +4 -2
  87. data/lib/samagotchi/plugin/peer.rb +17 -22
  88. data/lib/samagotchi/plugin_session_state.rb +32 -5
  89. data/lib/samagotchi/prompt_warmup.rb +1 -9
  90. data/lib/samagotchi/session_access/local.rb +1 -1
  91. data/lib/samagotchi/session_access/remote.rb +3 -3
  92. data/lib/samagotchi/session_archive_command.rb +3 -3
  93. data/lib/samagotchi/session_commands.rb +4 -4
  94. data/lib/samagotchi/session_config.rb +9 -3
  95. data/lib/samagotchi/session_continue.rb +1 -1
  96. data/lib/samagotchi/session_manager.rb +15 -6
  97. data/lib/samagotchi/system_one/judgments.rb +8 -25
  98. data/lib/samagotchi/system_one/log.rb +21 -0
  99. data/lib/samagotchi/system_one/recording.rb +1 -1
  100. data/lib/samagotchi/terminal_ui/attach_link.rb +2 -2
  101. data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -1
  102. data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
  103. data/lib/samagotchi/terminal_ui/local_link.rb +1 -1
  104. data/lib/samagotchi/terminal_ui/remote_link.rb +1 -2
  105. data/lib/samagotchi/testing/judgments.rb +0 -9
  106. data/lib/samagotchi/update_command.rb +49 -16
  107. data/lib/samagotchi/version.rb +1 -1
  108. data/lib/samagotchi/web/app.rb +1 -0
  109. data/lib/samagotchi/web/auto_update.rb +79 -49
  110. data/lib/samagotchi/web/auto_update_record.rb +59 -0
  111. data/lib/samagotchi/web/public/app.js +8 -4
  112. data/lib/samagotchi/web/public/hash_intent.js +24 -0
  113. data/lib/samagotchi/web/public/index.html +3 -1
  114. data/lib/samagotchi/web/public/revise_stack.js +14 -5
  115. data/lib/samagotchi/web/session_control.rb +3 -3
  116. data/lib/samagotchi/web/update_check.rb +7 -6
  117. data/lib/samagotchi/web/update_ops.rb +80 -25
  118. metadata +8 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a85be5a5307b395bec2801e6ef026217134a6012989388a24dde0068bbc411cf
4
- data.tar.gz: a9619ea7ae5b97ce7fa11929468c04f617ec948566a8aeba19d70ffcc0e48bd6
3
+ metadata.gz: 0403d20c85725cdd309a9b0ff24cc997c3effd60f37e42c9258de568b5e89944
4
+ data.tar.gz: aa1345c31e6d3ee3dbf578d6ed7298ec98f5c32caf67f304b75ac3caf3f2f886
5
5
  SHA512:
6
- metadata.gz: 29f21b2213ec66f61cb410ad7f68bedcf76e05f46249f28f56952f83797eb11bd50069484096c2d8f3d5745293446b2c8fc0977f41a709828cfe59beb349cff7
7
- data.tar.gz: 63fb61ada67c933d764ec1c5f6a3e692bfd24faee0af91d666ccb32f6b60f17a3ee06494a3713531659229cfeb1d378d2ac38db3709801fefd7dd6e5a5e6e5a5
6
+ metadata.gz: 528d2c989d71eb722a9e66ede6c2ddd4a57387e74842034bf019a671abb2f3b7d50cb759c8628f6d86d611434a6772a9a3fc75f5886d7f42eea98f3b54bcef1c
7
+ data.tar.gz: d5078148478d31d778cb973d8ae7dac52696e5cfa9909f96b5ea33185d3c920f067aeea64417b7f64de1785047fc74f9c24bca3f4d4bfda75b792342c712ae22
data/CHANGELOG.md CHANGED
@@ -7,6 +7,64 @@ and commands may change between minor versions. How releases are made:
7
7
  [docs/releasing.md](docs/releasing.md).
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.143.0] - 2026-11-01
11
+
12
+ ### Added
13
+
14
+ - `chi update` checks the bundles chi doesn't ship, such as one from GitHub, against the new chi, and adds a row for each warning or error: a `requires_chi` it fails, a plugin or
15
+ hook that no longer loads, a `ctx` call the API lacks, a reference to chi's internals. It never changes them, and these rows don't fail the update (`--json`: a new `level` field). `--no-bundles` skips
16
+ it, and `--dry-run` with a newer gem to install says `not checked`, as only that chi could answer. See [docs/cli.md](docs/cli.md#updating).
17
+ - `chi bundle check` warns (`api`) on a `ctx.*` or `chi.*` call, or a keyword, that this chi's API lacks, at its line:
18
+ `ctx.settingz`, `ctx.sessions.nope`, `ctx.card(titel:)`. It reads the plugin's source, so a path no test runs counts too.
19
+ - `ctx.session_dir`: a session's own folder for a bundle, created on use, removed with the session, so a bundle no longer
20
+ builds that path itself. cost-cap, work-cap and check-in now keep their state there (`state.json`); a running session's
21
+ file moves in by itself. `chi update` gets them (cost-cap 0.2.4, work-cap 0.1.4, check-in 0.3.1).
22
+ - A manifest may list `settings:`, the keys config.yml's `bundles: <name>:` takes, with `session_settings:`' types. A key it rules out warns
23
+ when a session starts, in every UI, and so does a `bundles:` name no installed bundle has. Only a warning: the session goes on.
24
+ The shipped bundles with settings list theirs (`chi update`).
25
+ - A plugin's `chi.on` handler that raises now tells you, once per event in a worker, in the TUI and the web
26
+ (`plugins> plugin.rb (bundle x) before_turn hook failed (…)`). Before, only the log knew. The hook is still skipped, and the log
27
+ still has each failure.
28
+ - A bundle's `hooks/*.rb` file that raises now tells you the same way, once per hook in a worker, whatever its `on_error` —
29
+ including the default `skip`, which logged nothing at all. A guard bundle that broke (`chi-nah`, say) used to fail quietly;
30
+ now `plugins> guard.rb (bundle chi-nah) before_tool_call hook failed (…)` says so. `on_error` still decides logging and
31
+ the deny; the notice is only added, and config.yml's own hooks are unchanged.
32
+
33
+ ### Changed
34
+
35
+ - With System 1 on the model's own local server, its asks now run during your turn as on any other host: toolkit suggestions (audit, the
36
+ deferred switch and the worker's warm-up, all skipped there before), context candidates (held to the turn's end before) and bundles' judgments (skipped before).
37
+ Measured on Splash, they don't push out the session's cached prompt. Each costs the running generation about 0.15 s.
38
+
39
+ ### Removed
40
+
41
+ - `shared_host:` on `chi.judgment`, the `:shared_host` reason, and `shared_host_busy` in the bundle test kit: a bundle still passing `shared_host:` fails to load, with an
42
+ `ArgumentError`. check-in 0.3.1 no longer passes it, so run `chi update`.
43
+
44
+ ### Fixed
45
+
46
+ - `chi sessions delete` now also drops the session's lines from `context_candidates.jsonl` (its `judged` lines keep 200
47
+ characters of its prompts), as it already purges that session's System 1 runs.
48
+ - A reply that is only a tool call the host could not read is now caught when the block has nothing inside it
49
+ (`<function=task_list></function>`, `<tool_call>{"name":"x"}</tool_call>`), and its close must be the tag that opened it.
50
+ - A Stop that arrives on a reply that is only a tool call the host could not read ends the turn cancelled. It used to fail
51
+ it with "the reply came back as a ... block the host could not read, twice in a row".
52
+ - With `update.auto: install`, "chi updated to X" counts the sessions the old chi web restarted (it said 0 of them), and a run
53
+ chi web is restarted in the middle of still tries the sessions it had left.
54
+ - With `update.auto: install`, an error in one step (a full disk, a hiccup reading the sessions) no longer stops automatic updates until
55
+ chi web restarts: the step is tried again 5 minutes later.
56
+ - With `update.auto: install` and `update.restart: idle`, sessions that were busy or recently used at the update really are tried again for
57
+ a day, as documented. They used to stay on the old chi once chi web had restarted. The extra tries respect the idle rule, and the page only hears of one that restarts a session.
58
+ - A hung `chi update` run by chi web (the **Update** button, `update.auto: install`) is stopped after 30 minutes and reported as failed. It used to answer "update running" to every later update until chi web restarted.
59
+ - Web: a hash that names no session (`#/`, or none) while one is open now leaves it, as the **+** button does. It used to change
60
+ only the URL: the page kept showing that session, and Send went into it.
61
+ - `chi bundle check`'s `requires-chi-floor` knows the calls and keywords it was missing: `ctx.context.propose`, `candidates`, `withdraw` and
62
+ `left_behind`, `ctx.review?`, `ctx.continues`, `ctx.context.attach(movable:)` and others, so a bundle using them with a lower `requires_chi` is told.
63
+ - `/context attach` and `/context decline`, typed in or from audit or off mode, no longer show a "closed" card when no offer card was open.
64
+ - Web: on a phone, a Revise stub's "superseded by vN" stays readable, so two stubs that open with the same line can be told apart.
65
+
66
+ Update with `chi update` (the core profile 0.4.2): check-in 0.3.1, cost-cap 0.2.4 and work-cap 0.1.4 keep their state in `ctx.session_dir`, and check-in no longer passes `shared_host:` (the older check-in 0.3.0 fails to load on this chi until it is updated). btw, agents-md, claude-peer, codex-peer, coordinator, github-pr, known-names, loop-guard, mcp, ruby, skills, slow-commands and source-links only list their settings or have small fixes.
67
+
10
68
  ## [0.142.0] - 2026-11-01
11
69
 
12
70
  ### Added
@@ -1011,7 +1069,7 @@ Update with `chi update` (the system bundle 0.118.0), then restart `chi web`.
1011
1069
  - `/exit` in an attached terminal **asks what to do with what still runs** when only things you can stop keep the
1012
1070
  worker up (reminders, a watched background task, a delegate with a live worker): keep running in the background,
1013
1071
  stop them and exit, or go back. Anything else that holds the worker (a running turn, queued prompts, another UI)
1014
- still refuses as before, and a delegate never holds the idle exit. See [cli.md](docs/cli.md#attached-terminal).
1072
+ still refuses as before, and a delegate never holds the idle exit. See [cli.md](docs/cli.md#sharing-a-session).
1015
1073
  - The web's `stop session` asks the same first: a sheet (a bottom sheet on a phone) counts what still runs and offers
1016
1074
  **Stop all**, **Stop session only** (the stop as it was: background tasks and delegates keep running) or
1017
1075
  **Cancel**; with nothing to stop it is one tap as before. See [Sessions](docs/sessions.md).
@@ -1650,7 +1708,7 @@ Update with `chi update`.
1650
1708
  and active minutes across turns, the bound a session whose step-limit Continue keeps being answered otherwise
1651
1709
  lacks. At a cap the turn pauses on Continue / Stop, the question naming the session's totals; `/workcap` shows or
1652
1710
  sets it, `chi send --new --set work-cap.tool_calls=400` caps a child. Inert until a cap is set. See
1653
- [docs/plugins.md](docs/plugins.md#the-work-cap-bundle).
1711
+ [docs/bundles.md](docs/bundles.md#the-work-cap-bundle).
1654
1712
 
1655
1713
  ### Fixed
1656
1714
 
@@ -1786,7 +1844,7 @@ Update with `chi update` (the system bundle 0.95.0), then restart `chi web`.
1786
1844
  - The `model-notes` bundle (0.1.0, in the `dev` profile, now 0.7.0): reviewed model notes, for now
1787
1845
  `model_notes_deepseek` for DeepSeek V4 / V4.1 (`models: *deepseek-v4*`). A same-name note you already have is
1788
1846
  skipped and keeps loading; to take the bundle's, remove yours and install again. See
1789
- [docs/plugins.md](docs/plugins.md#the-model-notes-bundle).
1847
+ [docs/bundles.md](docs/bundles.md#the-model-notes-bundle).
1790
1848
 
1791
1849
  ### Changed
1792
1850
 
@@ -3610,7 +3668,7 @@ Update with `chi update` (mcp 0.6.1).
3610
3668
  instructions. Guardrail rules on `mcp_<server>_<tool>` names still match (`mcp_call` acts as that tool), and the
3611
3669
  question names `<server>: <tool>`; approvals stored under the old names don't carry over. Hooks and loop-guard's
3612
3670
  `ignore_tools` see `mcp_call`. `/mcp` lists the tools as `<server>/<tool>` and says what every request carries.
3613
- Needs chi 0.37.0. See [docs/plugins.md](docs/plugins.md#the-mcp-bundle).
3671
+ Needs chi 0.37.0. See [docs/bundles.md](docs/bundles.md#the-mcp-bundle).
3614
3672
 
3615
3673
  ### Fixed
3616
3674
 
@@ -3662,7 +3720,7 @@ Update with `chi update` (mcp 0.5.1).
3662
3720
  rebuild (the split, your decisions, its verdicts, follow-ups), its status in the index description, and resumes
3663
3721
  from it in a new session after checking git and the session list; `/coordinate resume` picks up an open handoff.
3664
3722
  When the work is done it marks the handoff DONE and asks whether to remove it. See
3665
- [docs/plugins.md](docs/plugins.md#the-coordinator-bundle).
3723
+ [docs/bundles.md](docs/bundles.md#the-coordinator-bundle).
3666
3724
  - The guardrails bundle (0.8.0) asks before every memory removal (`memory-remove`, once at a time). Guardrail rules
3667
3725
  take `memory: remove`.
3668
3726
  - In the web, a file reference in an answer (`lib/foo.rb:28`, `lib/foo.rb:28-34`, in inline code too) links to that
@@ -3671,7 +3729,7 @@ Update with `chi update` (mcp 0.5.1).
3671
3729
  at the PR's head. Display only; `bundles: github-pr: line_links: false` turns it off (github-pr 0.2.0; run
3672
3730
  `chi update`). See [docs/context.md](docs/context.md#line-links).
3673
3731
  - `/mcp` shows roughly how many tokens each MCP server's tool definitions take in every request, and the total
3674
- (mcp 0.5.0; run `chi update`). See [docs/plugins.md](docs/plugins.md#the-mcp-bundle).
3732
+ (mcp 0.5.0; run `chi update`). See [docs/bundles.md](docs/bundles.md#the-mcp-bundle).
3675
3733
 
3676
3734
  ### Fixed
3677
3735
 
@@ -5423,7 +5481,8 @@ and long-lived sessions.
5423
5481
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
5424
5482
  hotkey panel that send selected text or the clipboard to your sessions.
5425
5483
 
5426
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.142.0...HEAD
5484
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.143.0...HEAD
5485
+ [0.143.0]: https://github.com/dm1try/samagotchi/compare/v0.142.0...v0.143.0
5427
5486
  [0.142.0]: https://github.com/dm1try/samagotchi/compare/v0.141.0...v0.142.0
5428
5487
  [0.141.0]: https://github.com/dm1try/samagotchi/compare/v0.140.0...v0.141.0
5429
5488
  [0.140.0]: https://github.com/dm1try/samagotchi/compare/v0.139.1...v0.140.0
data/README.md CHANGED
@@ -218,6 +218,7 @@ once, for the session, for the repo, or for the whole rule in the repo.
218
218
  - [Guardrails](docs/guardrails.md): allow / ask / deny for tool calls, rules, approvals
219
219
  - [Hooks](docs/hooks.md): plugin hooks and bundle hooks
220
220
  - [Plugins](docs/plugins.md): bundle plugins (commands, tools, hooks)
221
+ - [Bundles](docs/bundles.md): what each shipped bundle does (btw, mcp, cost-cap, claude-peer, skills…), its commands and settings
221
222
  - [Writing a bundle](docs/bundle-authoring.md): `chi bundle new`, `test`, `check`, `try`, `install --dev`
222
223
  - [Testing](docs/testing.md): specs, affected specs, lint, worktrees
223
224
  - [Architecture](docs/architecture.md): Engine, TerminalUI, bridge, web
data/docs/architecture.md CHANGED
@@ -365,7 +365,8 @@ The owner's update routes publish progress and results as `chi_update` events wi
365
365
  `version` and may include a progress line. The hub retains the latest event for a reconnecting
366
366
  tab's snapshot. `POST /api/update` decides itself whether this install can take a gem
367
367
  (`UpdateCheck.blocked_reason`: a checkout, Bundler, an unwritable gem dir → 409 `update_blocked`), so
368
- it holds with `update.notify: off`; a child that prints no rows fails with its own last line, and a
368
+ it holds with `update.notify: off`; a child that prints no rows fails with its own last line, a child still running after
369
+ 30 minutes (`UpdateOps::UPDATE_TIMEOUT`; it has a process group of its own) is stopped with what it started and fails the same way, and a
369
370
  done install refreshes the hub's installed version (`SessionHub#refresh_installed`) before its `done`.
370
371
  Worker restarts target every worker older than the version installed now (refreshed the same way)
371
372
  and publish per-session results. Only one of an install, a worker restart pass and a web restart runs
@@ -385,17 +386,23 @@ and installs it through `UpdateOps#install(wait: true, auto: true)` when the ins
385
386
  runs, no hub summary has `status: running` or a `pending_question`, and the version isn't in `auto_failed` or
386
387
  already in the `auto` record (one automatic try per version). Its frames carry `auto: true` (the page: "Automatic
387
388
  chi update in progress", "(automatic)" in the sheet's title). Its record is `update_check.json`'s `auto`:
388
- `{version, from, at, kept, phase: installed|workers|web|done|failed, workers: {restarted, left}, detail, pushed}`.
389
+ `{version, from, at, kept, phase: installed|workers|web|retrying|done|failed, workers: {restarted, left}, detail, pushed}`,
390
+ in Ruby the value object `Web::AutoUpdateRecord`, which owns that shape (`from_h`, `to_store`).
389
391
  With `update.restart: never` the run ends at the install (`chi_notice` `installed`). With `idle` it goes on
390
- (`phase` `installed` → `workers` → `web` → `done`): `UpdateOps#restart_workers(select:)` over the stale workers whose
392
+ (`phase` `installed` → `workers` → `web` → `retrying` → `done`): `UpdateOps#restart_workers(select:)` over the stale workers whose
391
393
  summary is idle with no question and `updated_at` at least 10 minutes old (`QUIET`; the others are `skipped` rows;
392
- the worker's own atomic refusal still applies), the left ones retried each step for 24 h (`RETRY_FOR`); then, with no
394
+ the worker's own atomic refusal still applies); then, with no
393
395
  turn running, `Server.restart_preflight` (the restart's command with `--version`, 20 s, killed on a timeout; it must
394
396
  print a chi at least the release) and, if it passes, the record's `phase: web` is written **before**
395
397
  `UpdateOps#restart_web`. A failed preflight, or a refused restart, publishes `restart_failed` and ends the run
396
398
  (`failed`). `AutoUpdate#stop` waits `STOP_WAIT` (25 s, longer than the preflight's timeout) for its thread, and a
397
399
  preflight that ends after a stop leads to nothing (no `web`, no exec): the next start takes the run up again. The restarted chi web's AutoUpdate (first step after 5 s) finds `phase: web`, checks it runs the
398
- release, counts the workers once more and publishes `updated`, then `done`. Results reach the phone as `chi_notice`
400
+ release, counts the workers once more and publishes `updated`, then `done`, or `retrying` while workers are left. Those are
401
+ retried each step until none is left or 24 h (`RETRY_FOR`) have passed since the install, under the same filter, and from
402
+ whichever chi web is up (`workers` before the restart, `retrying` after it, and a restart mid-retry reads it from the
403
+ record). The time is checked before each pass, so a run always ends. A later pass is `quiet:`: no `chi_update` frames (each
404
+ is a sticky toast) unless a worker restarts, and no further `chi_notice`. `retrying` isn't an open phase for the install
405
+ gate: a newer release installs under its usual gate, and its record replaces this one, its own passes taking the workers over. A step that raises is logged (`auto_update_failed`) and taken again at the next poll; each one saves the record before it publishes, so the owner hears it once. Results reach the phone as `chi_notice`
399
406
  hub events (`SessionHub#publish_notice`), see [internals/web-push.md](internals/web-push.md).
400
407
 
401
408
  The page's scope is in its URL, and the server picks the default: `?dir=<folder>` is that folder's
@@ -602,7 +609,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
602
609
  | Bundle authoring | `bundle_command.rb` (`BundleCommand`), `bundle_command/{scaffold,check,test_run}.rb`, `bundle_command/try/{run,sandbox,trace}.rb`, `testing.rb` + `testing/` (the test kit) | `chi bundle new`, `check`, `test` and `try`, and the kit a bundle's tests load it with ([bundle-authoring.md](bundle-authoring.md), [internals/bundles.md](internals/bundles.md)). |
603
610
  | Session config (`--set`) | `session_config.rb` (`SessionConfig`, `SessionConfig::Settings`) | A session's own settings as one value (`Session#settings`, `SessionSetup#settings`): `core`, the `--set KEY=VALUE` values of the core keys marked `session: true` (`Config::Entry`), typed by `Config.coerce!` and read first through `Config.get(key, session:)` (`RecapSetup`; `Engine#session=` rebuilds the recap job, `IdleScheduler#replace_job`), file key `config_settings`; `bundles`, the `--set BUNDLE.KEY=VALUE` values, checked against the manifest's `session_settings:`, laid over `bundles: <name>:` in `ctx.settings` ([plugins.md](plugins.md)), file key `bundle_settings`. `SessionConfig.clash` refuses a bundle setting named like a core one (install, `chi bundle check`). See [configuration.md](configuration.md#per-session-settings). |
604
611
  | Plugin API | `plugin/api.rb` (`Plugin::Api`), `plugin/tool_spec.rb` (`Plugin::ToolSpec`: a checked tool declaration, how it is registered), `plugin/loader.rb`, `plugin/context.rb` (`ctx`), `plugin/http.rb` + `plugin/http_transport.rb` (`ctx.http`), `plugin/card.rb` (`Plugin::Card`) | What a bundle's plugin registers: tools, commands, annotation actions, hooks, services, toolkits, peer sources; what its handlers get as `ctx` ([plugins.md](plugins.md)). |
605
- | Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`) | What claude-peer and codex-peer share (the send tool, the command, the cards, payloads); each bundle's subclass sets its strings and transport ([plugins.md](plugins.md#the-claude-peer-bundle)). |
612
+ | Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`) | What claude-peer and codex-peer share (the send tool, the command, the cards, payloads); each bundle's subclass sets its strings and transport ([bundles.md](bundles.md#the-claude-peer-bundle)). |
606
613
  | Shipped bundles | `bundles/` (`mcp`, `github-pr`, `loop-guard`, `skills`, `source-links`, …) | Bundles that ship with chi. |
607
614
  | Hooks | `hooks/registry.rb` (`Hooks::Registry`), `hooks/loader.rb`, `hook_routes.rb` (`HookRoutes`), `event_routes.rb` (`EventRoutes`) | Hook registration and dispatch; what a hook or plugin does beyond reading its event (notice, question, stop, steer) routed to the UIs (cards and notices through one set of routes) ([hooks.md](hooks.md)). |
608
615
  | Guardrails | `guardrails.rb`, `guardrails/shell_lex.rb`, `guardrails/data_readers.rb`, `guardrails/rules.rb`, `guardrails/protected_paths.rb`, `guardrails/parent_policy.rb` + `guardrails/parent_approvals.rb`, `guardrail_wiring.rb` | The gate before every tool call: shell lexing (and the commands that only read a heredoc as data), YAML rules, the core checks on chi's own files, approvals, what a parent agent may answer (`guardrails.parent_answers`) ([guardrails.md](guardrails.md)). |
@@ -2,7 +2,7 @@
2
2
 
3
3
  Read this first when someone asks for new chi functionality "as a bundle". It is the short path: the loop, the
4
4
  files, what a hook sees, how to test, and what goes wrong. The full references are in this same `docs/` folder:
5
- [plugins.md](plugins.md) (the `chi.*` API and `ctx`) and [hooks.md](hooks.md) (every event's fields).
5
+ [plugins.md](plugins.md) (the API), [hooks.md](hooks.md) (event fields), [bundles.md](bundles.md) (shipped bundles).
6
6
 
7
7
  ## The loop
8
8
 
@@ -59,8 +59,8 @@ plugin:
59
59
  `plugin.rb` defines `class Plugin` with `register(chi)`; `initialize(settings)` (optional) gets config.yml
60
60
  `bundles: my-bundle:` as a Hash with string keys, once, when the plugin loads. A value a session may set
61
61
  (`chi --set my-bundle.KEY=V`, listed in the manifest's `session_settings:`, typed with `{KEY: number}` so a
62
- value of another type is refused) is read from `ctx.settings` at call
63
- time. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting.
62
+ value of another type is refused) is read from `ctx.settings` at call time. List what config.yml may set in `settings:`
63
+ (`[greeting]`, or `{greeting: string}`): a typo there then warns. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting.
64
64
 
65
65
  ## What a hook sees
66
66
 
@@ -89,7 +89,7 @@ Match on `result:`, not `output:`. An execute's result is its `stdout:` and `std
89
89
  empty), then `exit: N` (`exit: 0 (no output)` when both were empty); a non-zero exit makes `status:` `"error"`.
90
90
  Act through `ctx`: `ctx.notify(text, level: :warn)`, `ctx.steer(text)` (a line the model reads before its next
91
91
  step), `ctx.card(…)`, `ctx.stop_turn(reason)`, `ctx.ask_user(…)`, `ctx.data_dir` (the bundle's state folder),
92
- `ctx.cwd`, `ctx.log`. In a test, each recorded notice, steer or stop names its hook as `"plugin.rb (bundle
92
+ `ctx.session_dir` (this session's, removed with it), `ctx.cwd`, `ctx.log`. In a test, each recorded notice, steer or stop names its hook as `"plugin.rb (bundle
93
93
  my-bundle)"`, the plugin's label (a `hooks/x.rb` file's is `"x.rb (bundle my-bundle)"`).
94
94
 
95
95
  ## Testing it
@@ -133,14 +133,14 @@ class, a hand-built `ctx`), that is a gap in the kit: say so to the user rather
133
133
  newer than the floor (`ctx.http` needs 0.80.0, `ctx.cost` 0.83.0, `ctx.usage` 0.100.0, `ctx.sessions.children` 0.34.0). A keyword added
134
134
  later counts too (`ctx.ask_model(model:)` 0.80.0, `ctx.sessions.send(delivery:)` 0.64.0, `chi.toolkit(prompt:)`
135
135
  0.72.0, `chi.toolkit(groups:)` 0.121.0), when the call is written on `ctx` / `chi` itself (not through a variable).
136
+ - **A typo in an API call.** `check` warns (`api`) on a call or keyword this chi lacks, on any path; for a newer chi on purpose, guard it with `ctx.respond_to?(:name)`.
136
137
  - **trust_level.** Leave it out. `reviewed` / `trusted` are for someone who reviewed the bundle, not its author.
137
138
  - **Restart.** A session loads bundles when it starts: after an install or a settings change, the user starts a
138
139
  new session (or `chi sessions restart ID`).
139
140
  - **chi's internals.** A bundle may use `chi.*`, `ctx` and the names
140
141
  [plugins.md, Stable for bundles](plugins.md#stable-for-bundles) lists; any other `Samagotchi::` name may change
141
142
  in any release (`check` warns: `boundary`).
142
- - **Load errors.** A plugin that raises at load is skipped and the session goes on: `check` shows the error at its
143
- `plugin.rb:LINE`.
143
+ - **Load errors.** A plugin that raises at load is skipped and the session goes on: `check` shows the error at its `plugin.rb:LINE`.
144
144
 
145
145
  ## Verifying it live
146
146