samagotchi 0.186.0 → 0.188.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 (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -1
  3. data/bin/chi +4 -0
  4. data/docs/architecture.md +8 -4
  5. data/docs/bundles.md +124 -120
  6. data/docs/cli.md +26 -5
  7. data/docs/configuration.md +4 -4
  8. data/docs/context.md +18 -162
  9. data/docs/guardrails.md +3 -1
  10. data/docs/hooks.md +2 -1
  11. data/docs/internals/attached-context.md +19 -37
  12. data/docs/internals/bridge.md +1 -0
  13. data/docs/internals/engine.md +2 -2
  14. data/docs/internals/inline-widgets.md +18 -0
  15. data/docs/internals/llm-context-forget.md +5 -6
  16. data/docs/internals/objectives.md +1 -0
  17. data/docs/internals/pages.md +175 -0
  18. data/docs/internals/peers.md +149 -0
  19. data/docs/internals/remote-sessions.md +7 -4
  20. data/docs/internals/web-frontend.md +65 -40
  21. data/docs/internals/web-push.md +1 -1
  22. data/docs/memory.md +8 -1
  23. data/docs/pages.md +151 -0
  24. data/docs/peers.md +141 -0
  25. data/docs/plugins.md +52 -27
  26. data/docs/sessions.md +8 -4
  27. data/docs/sub-agent.md +5 -5
  28. data/lib/samagotchi/bridge.rb +3 -3
  29. data/lib/samagotchi/bundle_command/api_calls.rb +2 -1
  30. data/lib/samagotchi/bundle_command/check.rb +1 -1
  31. data/lib/samagotchi/bundles/claude-peer/manifest.yml +11 -18
  32. data/lib/samagotchi/bundles/claude-peer/plugin.rb +22 -16
  33. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +48 -39
  34. data/lib/samagotchi/bundles/claude-peer/scripts/pair +15 -73
  35. data/lib/samagotchi/bundles/claude-peer/skill_claude_peer.md +16 -16
  36. data/lib/samagotchi/bundles/codex-peer/manifest.yml +11 -15
  37. data/lib/samagotchi/bundles/codex-peer/plugin.rb +35 -24
  38. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +51 -40
  39. data/lib/samagotchi/bundles/codex-peer/scripts/pair +18 -54
  40. data/lib/samagotchi/bundles/codex-peer/skill_codex_peer.md +16 -16
  41. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  42. data/lib/samagotchi/bundles/skills/manifest.yml +2 -2
  43. data/lib/samagotchi/bundles/skills/plugin.rb +14 -8
  44. data/lib/samagotchi/bundles/system/manifest.yml +5 -2
  45. data/lib/samagotchi/bundles/system/self_map.md +5 -1
  46. data/lib/samagotchi/bundles/system/skill_pages.md +93 -0
  47. data/lib/samagotchi/client_id.rb +15 -1
  48. data/lib/samagotchi/config.rb +8 -7
  49. data/lib/samagotchi/context_absorber.rb +23 -277
  50. data/lib/samagotchi/context_sources.rb +17 -69
  51. data/lib/samagotchi/engine/messages.rb +12 -1
  52. data/lib/samagotchi/engine/plugins.rb +1 -1
  53. data/lib/samagotchi/engine.rb +7 -6
  54. data/lib/samagotchi/engine_peers.rb +0 -3
  55. data/lib/samagotchi/guardrail_wiring.rb +2 -0
  56. data/lib/samagotchi/guardrails/chi_dirs.rb +4 -3
  57. data/lib/samagotchi/guardrails/parent_approvals.rb +6 -5
  58. data/lib/samagotchi/guardrails/protected_paths.rb +6 -3
  59. data/lib/samagotchi/inline_widgets.rb +73 -0
  60. data/lib/samagotchi/log_line.rb +1 -1
  61. data/lib/samagotchi/note_move.rb +3 -1
  62. data/lib/samagotchi/page_command.rb +243 -0
  63. data/lib/samagotchi/pages/builder.rb +186 -0
  64. data/lib/samagotchi/pages/launch.rb +193 -0
  65. data/lib/samagotchi/pages/runner.rb +154 -0
  66. data/lib/samagotchi/pages/store.rb +152 -0
  67. data/lib/samagotchi/pages.rb +119 -0
  68. data/lib/samagotchi/peer_command.rb +192 -0
  69. data/lib/samagotchi/peer_continue.rb +99 -0
  70. data/lib/samagotchi/peer_exchanges.rb +3 -3
  71. data/lib/samagotchi/peer_mailbox.rb +360 -0
  72. data/lib/samagotchi/peer_note.rb +208 -0
  73. data/lib/samagotchi/peer_receipts.rb +247 -0
  74. data/lib/samagotchi/peer_registry.rb +44 -0
  75. data/lib/samagotchi/peer_roster.rb +79 -0
  76. data/lib/samagotchi/peer_say.rb +168 -0
  77. data/lib/samagotchi/plugin/api.rb +29 -21
  78. data/lib/samagotchi/plugin/context.rb +7 -0
  79. data/lib/samagotchi/plugin/loader.rb +3 -3
  80. data/lib/samagotchi/plugin/peer.rb +175 -64
  81. data/lib/samagotchi/plugin/peers.rb +70 -0
  82. data/lib/samagotchi/run_options.rb +3 -1
  83. data/lib/samagotchi/schedule_command.rb +10 -3
  84. data/lib/samagotchi/schedule_display.rb +32 -0
  85. data/lib/samagotchi/session_access/contract.rb +19 -2
  86. data/lib/samagotchi/session_access/local.rb +132 -14
  87. data/lib/samagotchi/session_access/remote.rb +4 -2
  88. data/lib/samagotchi/session_access/remote_peers.rb +75 -0
  89. data/lib/samagotchi/session_continue.rb +12 -0
  90. data/lib/samagotchi/session_inbox_delivery.rb +5 -2
  91. data/lib/samagotchi/session_manager/delivery.rb +5 -3
  92. data/lib/samagotchi/session_manager/removal.rb +2 -0
  93. data/lib/samagotchi/session_manager/spawn.rb +2 -1
  94. data/lib/samagotchi/session_manager.rb +1 -0
  95. data/lib/samagotchi/session_stores.rb +17 -0
  96. data/lib/samagotchi/steer.rb +1 -1
  97. data/lib/samagotchi/system_prompt.rb +1 -1
  98. data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
  99. data/lib/samagotchi/terminal_ui/formatting.rb +4 -1
  100. data/lib/samagotchi/testing/boundary.rb +4 -13
  101. data/lib/samagotchi/testing/bundle.rb +40 -5
  102. data/lib/samagotchi/testing/install.rb +4 -4
  103. data/lib/samagotchi/testing/recording_api.rb +2 -1
  104. data/lib/samagotchi/tools/context_read.rb +0 -14
  105. data/lib/samagotchi/tools/list_schedules.rb +8 -3
  106. data/lib/samagotchi/version.rb +1 -1
  107. data/lib/samagotchi/web/app.rb +7 -18
  108. data/lib/samagotchi/web/message_display.rb +4 -2
  109. data/lib/samagotchi/web/page_routes.rb +116 -0
  110. data/lib/samagotchi/web/peer_routes.rb +133 -0
  111. data/lib/samagotchi/web/public/app.js +35 -95
  112. data/lib/samagotchi/web/public/bubbles.js +2 -2
  113. data/lib/samagotchi/web/public/cards_place.js +20 -1
  114. data/lib/samagotchi/web/public/context_chips.js +45 -46
  115. data/lib/samagotchi/web/public/history_reveal.js +4 -1
  116. data/lib/samagotchi/web/public/history_shape.js +3 -2
  117. data/lib/samagotchi/web/public/index.html +16 -0
  118. data/lib/samagotchi/web/public/notify.js +1 -1
  119. data/lib/samagotchi/web/public/page_blocks.js +58 -0
  120. data/lib/samagotchi/web/public/page_links.js +33 -0
  121. data/lib/samagotchi/web/public/page_model.js +68 -0
  122. data/lib/samagotchi/web/public/page_route.js +24 -0
  123. data/lib/samagotchi/web/public/page_table.js +74 -0
  124. data/lib/samagotchi/web/public/page_table_model.js +76 -0
  125. data/lib/samagotchi/web/public/page_view.js +219 -0
  126. data/lib/samagotchi/web/public/pages.css +77 -0
  127. data/lib/samagotchi/web/public/pages_group.js +65 -0
  128. data/lib/samagotchi/web/public/peer_chip.js +60 -74
  129. data/lib/samagotchi/web/public/peer_data.js +13 -11
  130. data/lib/samagotchi/web/public/peer_links.js +12 -7
  131. data/lib/samagotchi/web/public/peer_mailbox_api.js +20 -0
  132. data/lib/samagotchi/web/public/peer_note.js +7 -3
  133. data/lib/samagotchi/web/public/peer_text.js +4 -4
  134. data/lib/samagotchi/web/public/quiet_notes.js +199 -0
  135. data/lib/samagotchi/web/public/revise_stack.js +4 -3
  136. data/lib/samagotchi/web/public/session_view.js +2 -2
  137. data/lib/samagotchi/web/public/stream_handlers.js +3 -2
  138. data/lib/samagotchi/web/public/turn_block.js +7 -3
  139. data/lib/samagotchi/web/public/turn_events.js +6 -0
  140. data/lib/samagotchi/web/public/views.js +161 -0
  141. data/lib/samagotchi/web/push/attention.rb +3 -2
  142. data/lib/samagotchi/web/session_access_routes.rb +3 -20
  143. data/lib/samagotchi/web/viewer.rb +1 -1
  144. data/lib/samagotchi/worker/leave.rb +3 -0
  145. data/lib/samagotchi/worker/mail.rb +73 -0
  146. data/lib/samagotchi/worker/startup.rb +3 -0
  147. data/lib/samagotchi/worker/wake_turns.rb +20 -5
  148. data/lib/samagotchi/worker.rb +12 -6
  149. data/lib/samagotchi/worker_inbound/mail.rb +214 -0
  150. data/lib/samagotchi/worker_inbound.rb +43 -46
  151. data/lib/samagotchi/worker_wakes.rb +26 -21
  152. metadata +39 -2
  153. data/lib/samagotchi/peer_sources.rb +0 -58
@@ -149,7 +149,7 @@ the top and in `pending_question` / `pending_card`, strings in `last_turn`), `no
149
149
  3. a top-level turn whose `last_turn["ended_at"]` changed (a delegated child's is its parent's to report):
150
150
  a newly recorded verdict is `verdict`, keyed by `"<sid>:<check_turn_id>"`; otherwise `failed`, or `done` when
151
151
  `completed` and `seconds` ≥ `DONE_MIN_SECONDS` 10 or its origin is in `UNWATCHED_ORIGINS`
152
- (`delegate_report`, `context`, `task`), keyed by `"<sid>:<ended_at>"`. A verdict wins over the done/no-event
152
+ (`delegate_report`, `context`, `task`, `peer`: a peer's message's wake turn), keyed by `"<sid>:<ended_at>"`. A verdict wins over the done/no-event
153
153
  rule, including for a short turn. A reminder turn follows the same rules (no reminder event of its own).
154
154
  - `WAITING` (approval, question, continue, card) are the reasons that stay open until answered: badged, in `open`,
155
155
  cleaned up, and pushed only while still open. A failed, done or verdict turn has nothing to answer.
data/docs/memory.md CHANGED
@@ -439,7 +439,14 @@ It is a memory like any other: `memory_read`, `chi --mute skill_release`,
439
439
  skills`, [docs/bundles.md](bundles.md#the-skills-bundle)) adds `/skill save`,
440
440
  `/skill list`, `/skill show`, `/skill diff`, keeps older versions with a
441
441
  one-line diff after each update, and nudges a model that skips a failing
442
- step instead of fixing the skill.
442
+ step instead of fixing the skill; a skill a bundle ships is skipped.
443
+
444
+ chi ships one skill itself: `skill_pages` in the system bundle
445
+ (`lib/samagotchi/bundles/system/skill_pages.md`), how to make, check and link a
446
+ page ([docs/pages.md](pages.md#asking-chi-for-a-page)). Its index line is in
447
+ every prompt; its text is read only when a page is asked for. It tells chi not
448
+ to edit it (a shipped file: a local edit would have to be merged at the next
449
+ upgrade) but to say what differed.
443
450
 
444
451
  ## Toolkit memories
445
452
 
data/docs/pages.md ADDED
@@ -0,0 +1,151 @@
1
+ # Pages: scripts that say what to show
2
+
3
+ A page is a Ruby script that gets its data any way a script can (another program's `--format json`, a file, the
4
+ session files) and hands rows and text to `ui`. `chi page run NAME` runs it and stores what it built; what shows a
5
+ page draws from that stored result, so showing it runs nothing. Pages run from the terminal and show in chi web, where
6
+ Refresh runs them again ([In chi web](#in-chi-web)).
7
+
8
+ **A page is code you trust.** It runs as you, with your files and your network, like any Ruby script chi writes for
9
+ you. There is no sandbox.
10
+
11
+ ## Asking chi for a page
12
+
13
+ Say what you want to see and that you want it kept: "make me a page of …", "I'd like to reopen this in the web: …",
14
+ "keep this as a page". chi follows its shipped pages skill (`skill_pages`, [docs/memory.md](memory.md#skills)): it
15
+ finds the pages folder with `chi self`, writes `NAME.rb` there, runs `chi page run NAME`, compares the stored rows
16
+ with where they came from, fixes what failed, and answers in a line or two with the link `[Title](#/p/NAME)` (with
17
+ Markdown off, the link is plain text: the page is in All sessions, under Pages). "Change the page …" edits the script
18
+ and runs it again; "remove the page …" is `chi page rm NAME`.
19
+
20
+ - It uses `chi page list`, the read tool, `chi page run` and `chi page rm`, never a shell command that names the pages
21
+ folder (those ask you, and a turn nobody watches stops there).
22
+ - **Strict mode** (`guardrails.mode: strict`): writing the script asks (`write-outside-repo`: you, or whoever may
23
+ answer for the session, such as a parent agent or System 1); if it is denied, chi says so and stops.
24
+ - A participant's turn ([chi share](cli.md)) can't write chi's config folder or run chi commands: a page asked for
25
+ there is refused.
26
+
27
+ ## A page
28
+
29
+ ```ruby
30
+ # ~/.config/samagotchi/pages/usage.rb
31
+ page "Usage, last 7 days" do |ui|
32
+ data = JSON.parse(`chi-usage --days 7 --format json`)
33
+ ui.text "Stored cost per model. #{data["totals"]["turns"]} turns."
34
+ ui.table data["groups"].map { |model, g| g.merge("model" => model) },
35
+ columns: { "model" => "Model", "turns" => "Turns", "cost" => "Stored" },
36
+ format: { "cost" => :money }, key: %w[turns cost],
37
+ total: { "model" => "Total", "turns" => data["totals"]["turns"], "cost" => data["totals"]["cost"] }
38
+ end
39
+ ```
40
+
41
+ ```
42
+ $ chi page run usage
43
+ page usage: "Usage, last 7 days" (0.4 s)
44
+ - text: Stored cost per model. 412 turns.
45
+ - table, 3 rows, columns: Model, Turns, Stored
46
+ claude:sonnet-5-5 | 96 | $14.2210
47
+ openrouter:deepseek-v4 | 141 | $3.9042
48
+ splash:qwen3.8-flash-next | 175 | $0.0000
49
+ total: Total | 412 | $18.1252
50
+ ```
51
+
52
+ The file is `NAME.rb` under `~/.config/samagotchi/pages/` (`$XDG_CONFIG_HOME/samagotchi/pages/`). A name is lowercase
53
+ letters, digits and hyphens, a letter or a digit first, at most 40. `json` is loaded; `require` anything else you use.
54
+
55
+ ## What `ui` takes
56
+
57
+ A script calls `page "Title" do |ui| … end` once: a second call, or none, fails the run. The blocks show in the order
58
+ the script adds them, at most 20.
59
+
60
+ - **`ui.text(markdown)`**: a text block, Markdown. At most 16 KB.
61
+ - **`ui.table(rows, columns:, format: {}, key: nil, total: nil)`**: a table.
62
+ - `rows`: a list of Hashes (string or symbol keys). At most 500 are kept; the rest are dropped and the page says how
63
+ many.
64
+ - `columns:` (required) a Hash `key => label` in the order to show, or a list of keys (the label is the key). At most
65
+ 12.
66
+ - `format:` `key => :money` (`$14.2210`) or `:count` (`1.2k`, `3.4M`). Nothing else: format other columns as text
67
+ yourself. The stored cell stays the number, so the column still sorts as numbers.
68
+ - `key:` the columns a phone shows before a row is opened, besides the first column, which always shows. Without it:
69
+ the first two columns whose cells are all numbers or empty.
70
+ - `total:` a Hash by column key, shown as a last row.
71
+ - A cell: a number stays a number, `nil` shows blank (`—` in the terminal), `true`/`false` stay, anything else is
72
+ its text (NaN and Infinity too). A cell over 300 characters is cut with `…`.
73
+ - **`ui.walk(title:, actors:, steps:)`** (or one Hash): a scenario walk, the same data and rules as a `chi-ui` walk in
74
+ an answer ([inline widgets](internals/inline-widgets.md#the-schemas)), drawn by the same widget. A walk the schema
75
+ refuses fails the run with its reason.
76
+
77
+ A rule broken fails the run with a message naming the block and the limit: `table 2: column "cost" has format
78
+ :percent (use :money or :count)`, `table 1 has 13 columns (at most 12)`.
79
+
80
+ ## Running
81
+
82
+ - `chi page run NAME` runs the script in a Ruby process of its own and prints a summary of each block: a text's first
83
+ lines, a table's labels, first rows and total, a walk's step count. `--format json` prints the stored page.
84
+ - A run that fails (the script raised, has a syntax error, called `exit`, broke a limit, or printed more than 256 KB of
85
+ blocks) prints `error: line 9: undefined method 'fetch' for nil`, the last lines of what the script wrote to stderr,
86
+ and exits 1. **The result of the last good run is kept**: a bad edit never blanks the page.
87
+ - A run still going at **30 s** is stopped, with everything it started; the error says so. One that finished just as
88
+ the cut fires keeps its result. If what started the run
89
+ dies first (a killed terminal or chi web), the run stops itself a few seconds after its 30 s and records the same
90
+ error. Its output then has nowhere to go: a script that prints a lot may fail with `Broken pipe` instead (the last
91
+ good result is kept).
92
+ - One run of a page at a time: a second `chi page run usage` meanwhile exits 1 with `page usage is already running`.
93
+ - `chi page list` shows each page's title and `ran 2 min ago`, `failed 1 h ago (line 9)` or `(never ran)`, with
94
+ `changed` when the script changed since its result was made (the result came from an older script; nothing ran). `chi page rm NAME` removes the script and its result.
95
+
96
+ Exit codes: 0 ran, 1 failed (or no such page, or already running), 2 the command line itself (an unknown flag, a name
97
+ that breaks the rule). See [the CLI](cli.md#commands).
98
+
99
+ ## In chi web
100
+
101
+ - **Finding a page.** All sessions has a **Pages** group at its top, in every project scope (pages are global): one row
102
+ of cards that scrolls sideways, each with the page's title and `ran 2 min ago`, `failed 1 h ago` or `never ran`. The
103
+ search field filters it too, by name and title. With no page (or none the search matches) there is no group. A
104
+ `#/p/usage` link in chi's answer opens the page in the same tab; a reload or a copied `…/#/p/usage` link opens it
105
+ too.
106
+ - **The page** shows in place of the session area: Back (to where it was opened from, else All sessions), the title,
107
+ when it ran and how long it took, **Refresh** and `⋯` with Delete (it asks once, then removes the script and its
108
+ result). Opening it shows the stored result at once and runs nothing.
109
+ - **Refresh** runs the script as `chi page run` does and redraws when the run ends; the button reads "Running…" and
110
+ can't be pressed twice. A run already going (from a terminal, another tab) says "already running". Stopping chi web
111
+ stops a Refresh. A Refresh holds its request until the run ends, up to about 32 s (the 30 s cut and its grace): behind
112
+ an auth proxy ([configuration.md](configuration.md#behind-an-auth-proxy)), its timeout must allow that.
113
+ - **A failed run** keeps the last result, dimmed, under "The script failed at line 9: … Showing the result from 21
114
+ Nov, 14:02." with **Copy the error** (the line, the message and the script's last words on stderr).
115
+ - **The script changed** since the result on screen was made: a line says so; nothing has run. "Changed" means the
116
+ result came from an older script.
117
+ - **A table**: a column header sorts by it (numbers as numbers, blanks last, the total stays at the bottom); a wide
118
+ table scrolls sideways in its own box. On a phone each row shows the first column and the key columns (`key:`);
119
+ a tap opens the rest as label and value lines; rows keep the script's order there.
120
+ - **A walk** is drawn by the same widget as in an answer; its lanes scroll sideways inside it.
121
+ - **Markdown off** (`web.markdown`, the default): a text block shows as plain text, and a link in chi's answer is plain
122
+ text too, so the Pages group is the way in. A fenced block inside a text block (a `chi-ui` or a mermaid one) stays
123
+ source on a page.
124
+ - **Not live**: the group is read when All sessions opens, a page when it opens and after its own Refresh or Delete.
125
+ A run from a terminal shows after the next open or a reload.
126
+ - Pages are the owner's: a participant ([chi share](cli.md)) sees no Pages group, no page, and no page route answers
127
+ their link.
128
+
129
+ ## Where a run happens
130
+
131
+ - **The working folder is the pages folder.** A chi command a script runs sees that folder's project: if
132
+ `~/.config` sits in a git repository, that repository. Pass `--scope=all` to the session commands
133
+ (`chi sessions list --scope=all --format json`) for every project.
134
+ - **The environment is yours**, as a session's worker gets it: the XDG folders absolute, chi's own session markers and
135
+ guardrails settings left out, and `PWD` the pages folder; chi web's Refresh runs chi web's own chi. `CHI_REMOTE`, a worker's `SAMAGOTCHI_WORKER_*` keys and
136
+ the agent markers (`CLAUDECODE`, `CODEX_THREAD_ID`, `AI_AGENT`) are left out too: a run is always on this machine,
137
+ and a `chi send` from a script is yours, even when chi was started from an agent's pane. Name `chi` plainly; name other programs by absolute path:
138
+ a Refresh in chi web runs with chi web's `PATH`, which may not be your shell's.
139
+ - What the script prints to stdout is its own: the result goes through the stored file. Its stderr shows under a
140
+ failure.
141
+ - **A child that leaves the process group survives the 30 s cut** (a `setsid` or a daemon). A program the script
142
+ starts (`spawn`, `system`, backticks) never keeps the page "already running"; a Ruby `fork` (or `Process.daemon`)
143
+ that lives on does, until it ends. A script that `exec`s another program hands the run to it: the 30 s cut still
144
+ applies, but if what started the run dies, nothing stops that program. Anything that stays in the group is stopped.
145
+
146
+ ## Where things are stored
147
+
148
+ - The script: `~/.config/samagotchi/pages/NAME.rb`.
149
+ - The result: `~/.local/state/samagotchi/pages/NAME/output.json` (`$XDG_STATE_HOME`): the title, the blocks of the last
150
+ good run, when it ran, how long it took, the sha256 of the script that made it, and the last failure since, if any.
151
+ Its shape is in [internals/pages.md](internals/pages.md).
data/docs/peers.md ADDED
@@ -0,0 +1,141 @@
1
+ # Peers: another agent beside chi
2
+
3
+ A **peer** is another agent's session the user works with beside chi: a Claude Code session (the claude-peer
4
+ bundle) or a Codex CLI session (codex-peer). chi sends it a part of its work (`claude_send`, `/claude validate`),
5
+ and the peer answers into chi. Each answer is a **message** in the session's **mailbox**: its own note in the
6
+ conversation, in order, with its text. chi says what it did with each one, on the peer's terminal and in the
7
+ peer chip. How it is built: [internals/peers.md](internals/peers.md).
8
+
9
+ ## Pairing
10
+
11
+ The peer pairs from its side, with its `chi-peer` skill (`/claude install-skill` or `/codex install-skill`
12
+ installs it). Its pair script runs one command:
13
+
14
+ ```sh
15
+ chi peer pair claude <session id> --address <where chi sends> --from "<who paired>"
16
+ ```
17
+
18
+ - `--address` is where chi's sends go: Claude Code's inbox socket, Codex's thread id. A pairing without one
19
+ answers only: the peer can say, chi can't send to it (a peer on another machine with no forwarded socket).
20
+ - Pairing again only replaces the address (a Claude Code restart gives it a new socket).
21
+ - `chi peer unpair claude <id>` ends the pairing. Its messages stay, and chi still reads those it hasn't. The
22
+ peer chip's **Unpair** does the same.
23
+ - `chi peer pair` refuses a session whose live worker is older than the mailbox ("restart the session"), and a
24
+ session that was continued (it names the new id).
25
+
26
+ Which agents are peers is the bundles' to say (`chi.peer NAME` in plugin code), never a file's. A message from
27
+ a name no loaded bundle declared is refused with "no bundle in that session declares peer NAME".
28
+
29
+ ## Saying something: `chi peer say`
30
+
31
+ ```sh
32
+ chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8 <<'EOF'
33
+ <the full answer>
34
+ EOF
35
+ ```
36
+
37
+ - `--wake` or `--nowake` is required: `--wake` asks chi to run a turn for it (a validate's answer, a question's,
38
+ a message chi should act on now); `--nowake` leaves it as a note for chi's next turn.
39
+ - `--re` names the send it answers (the `ref:` line of chi's message); leave it out for a message the peer starts.
40
+ - `--summary` is one line (200 characters); the text is stdin, or `-m TEXT`, up to 1 MiB.
41
+ - `--wait SECONDS` (0 to 30) waits for chi's answer; the skills use 8.
42
+
43
+ It prints one line, which the skills tell the agent to quote to its user:
44
+
45
+ | What chi did | The line |
46
+ |---|---|
47
+ | started a turn | `#12 received · woke chi` |
48
+ | held it | `#12 received · held: 3 peer turns in a row (peer.turns) · waits for the user's next message` |
49
+ | took it as background | `#12 received · noted` |
50
+ | can't say yet | `#12 received · chi is in a turn: it reads this when the turn ends`, `chi is stopped: …`, `this session is archived: …`, `chi's worker isn't running and couldn't be started from here: …` |
51
+ | nothing within the wait | `#12 received · no answer from chi yet` |
52
+ | refused | `refused: no bundle in that session declares peer claude` (exit 1) |
53
+
54
+ Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A held message is not
55
+ lost: it is a note, and the user's next message lets chi read it. The skills say not to send it again, and not to
56
+ `chi send` past it.
57
+
58
+ A say is refused, with nothing written, for: no such session; a session being deleted; a continued one (`this
59
+ session was continued as <id>: say it there`); not paired (`not paired: run the pair script`); an older worker
60
+ (`restart the session`); 200 messages chi hasn't read yet.
61
+
62
+ Through `--remote NAME` (or `CHI_REMOTE`) the remote's chi web does the say and the wait, and returns the line.
63
+
64
+ ## What chi does with a message: the receipts
65
+
66
+ The worker takes the peer's messages in order, between turns, and writes one receipt per message:
67
+
68
+ - `woke` (a turn started for it), `held` with a reason, `noted` (it asked for no turn), `refused`;
69
+ - then `read` once a turn starts with it in the conversation, and `completed`, `failed` or `stopped` when that
70
+ turn ends.
71
+
72
+ Held reasons: `off` (`peer.turns` is 0), `paused` (after a failed wake turn), `continue` (a continue offer waits),
73
+ `max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
74
+
75
+ `chi peer ls <id>` lists each peer, its pairing and its newest messages with their receipts; the peer chip's list
76
+ shows the same words (`held · peer turns`, `read`, `completed`).
77
+
78
+ ## The budget: `peer.turns`
79
+
80
+ A peer's messages may wake chi `peer.turns` times in a row (default 3) with nothing typed by the user, within
81
+ `session.max_wakes`. Past it they wait as notes, the say's line says so, and the TUI and the web say it once. A
82
+ message whose summary ends its round with `VERDICT OK` wakes chi once more to close it, held only by
83
+ `session.max_wakes`. Only input typed in the web or a TUI resets the count: `chi send` does not, since a peer can
84
+ run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` is attached context's only.
85
+
86
+ `peer.turns` replaced `context.peer_turns` (no alias): rename it in config.yml.
87
+
88
+ ## Limits
89
+
90
+ - A message's text up to 1 MiB, its summary one line of 200 characters.
91
+ - In the conversation, a note that wakes chi holds the text up to the tool output cap (10,000 characters by
92
+ default); one that doesn't, up to 2,000. A longer one points at the `claude_read` / `codex_read` tool
93
+ (`serial`, `offset`, `limit`), which pages it.
94
+ - 200 messages chi hasn't read: further says are refused until it reads them.
95
+ - The mailbox keeps every message chi hasn't taken, and the newest 50 it has.
96
+
97
+ ## Continuing a session
98
+
99
+ A continue leaves the pairing and the mailbox with the previous link:
100
+
101
+ - the new link's `/claude` init task posts the peer a `moved` message with the new id, and the peer pairs again
102
+ with it, the way it paired before (its skill knows how);
103
+ - a say to the old id is refused, naming the new id;
104
+ - the messages the previous link hadn't read (never taken, or held or noted and not yet read by a turn) reach the
105
+ new link as **one** note, each text in its peer block.
106
+
107
+ ## Codex's sandbox
108
+
109
+ Codex's default sandbox writes only where its config allows, and `chi peer pair` and `say` write the mailbox:
110
+
111
+ ```toml
112
+ [sandbox_workspace_write]
113
+ writable_roots = ["<state>/samagotchi/mailbox"]
114
+ ```
115
+
116
+ `/codex install-skill` shows the exact line and makes the folder, so the root exists when Codex restarts. A config
117
+ from an older skill names `…/samagotchi/context`: change it. A say from inside the sandbox can't start a stopped
118
+ worker; it prints "couldn't be started from here", and chi reads the message at its next start.
119
+
120
+ ## Who can write the mailbox
121
+
122
+ The mailbox is `<state>/samagotchi/mailbox/<session id>/<peer>/`, apart from the sessions folder: the only folder a
123
+ sandboxed peer writes, so it holds nothing chi trusts. chi's own record of each message (the receipts) is in the
124
+ session's own folder, written only by its worker. Every message file is checked before it is read.
125
+
126
+ The say is unauthenticated, as a context push is: any process that can write the mailbox can send as a peer. A
127
+ writer of the mailbox folder can also plant a file with the largest serial and use up a peer's serials (later
128
+ says then fail with "serials are used up"); the folder's writers are trusted that far, as they can delete its
129
+ files. chi's own tools can't write there (the `chi-mailbox` guardrail), and a shell command naming it asks.
130
+
131
+ ## Upgrading from an older peer bundle
132
+
133
+ The claude-peer and codex-peer bundles paired through two attached context sources (`<peer>-inbox`,
134
+ `<peer>-outbox`). That is gone, with no compatibility:
135
+
136
+ 1. `chi update` (or `chi bundle upgrade claude-peer`); an older bundle that still declares `chi.peer_source` fails
137
+ to load with "upgrade this bundle", and chi starts without it.
138
+ 2. In Claude Code: `/claude install-skill`, then **Replace**; in Codex: `/codex install-skill` and change the
139
+ `writable_roots` line.
140
+ 3. Pair again. Until then `/claude` says "paired the old way: pair again", and a push to an old `claude-outbox`
141
+ source is an ordinary context note.
data/docs/plugins.md CHANGED
@@ -862,29 +862,33 @@ index = Samagotchi::Tools::ToolIndex
862
862
  names itself (an mcp bundle before 0.7.0 has `find_mcp_tools` and
863
863
  `mcp_call`) keeps them; with no source, `full` declares neither of chi's.
864
864
 
865
- ### `chi.peer_source(name, label:)`
865
+ ### `chi.peer(name)`
866
866
 
867
- Declares a context source as a peer agent's answers: the peer bundles'
868
- `claude-outbox` and `codex-outbox`. Such a source, when it is a pushed source
869
- of the session's own, wakes the session by the peer loop's rules instead of
870
- the 10-minute window: up to `context.peer_turns` wake turns in a row, one
871
- closing wake (outside that count) for an answer whose verdict is `VERDICT OK`,
872
- and a wake line that names the peer and keeps the turn within the user's task (see [Waking: peer
873
- sources](context.md#peer-sources-the-peer-loop)).
867
+ Declares a peer agent this bundle speaks for: the peer bundles' `claude` and
868
+ `codex`. Its messages in the session's mailbox (`chi peer say NAME`,
869
+ [peers.md](peers.md)) become its notes and may wake the session by the peer
870
+ loop's rules: up to `peer.turns` wake turns in a row, one closing wake
871
+ (outside that count) for a message whose verdict is `VERDICT OK`, and a wake
872
+ line that names the peer and keeps the turn within the user's task.
874
873
 
875
874
  ```ruby
876
- chi.peer_source "codex-outbox", label: "Codex"
875
+ chi.peer "codex"
877
876
  ```
878
877
 
879
- - `name`: a context source name (as `chi context add` takes it). Another
880
- bundle's is a load error.
881
- - `label:`: the peer's name, said in chi's own lines ("your peer agent
882
- Codex"): a capital letter, then up to 23 letters and spaces.
878
+ - `name`: a lowercase letter, then lowercase letters and digits, up to 24.
879
+ Another bundle's is a load error. The peer's label is its name capitalised
880
+ ("Codex").
883
881
 
884
- The declaration lives in the session's process only, like a tool: a source
885
- file can't make itself a peer's, and uninstalling the bundle ends it.
886
- Subclasses of `Samagotchi::Plugin::Peer` (below) declare their `OUTBOX`
887
- source. Needs chi 0.67.0 (guard it with `chi.respond_to?(:peer_source)`).
882
+ The declaration lives in the session's process only, like a tool: a file in
883
+ the mailbox can't make its writer a peer, and uninstalling the bundle ends it
884
+ (a message from a name no loaded bundle declared is refused, and delivered
885
+ once one does). Subclasses of `Samagotchi::Plugin::Peer` (below) declare their
886
+ `PEER`. Needs the next chi (guard it with `chi.respond_to?(:peer)`).
887
+
888
+ `chi.peer_source(name, label:)` (the context-source peers of chi 0.67.0 to
889
+ 0.187.0) is gone: it raises "chi.peer_source is gone: upgrade this bundle
890
+ (chi bundle install <name> --force)", so an older peer bundle fails to load
891
+ and chi starts without it.
888
892
 
889
893
  ### `chi.judgment(name, questions:, positive: nil, negative: nil)`
890
894
 
@@ -1567,7 +1571,7 @@ ctx.context.decline(url: "https://github.com/acme/app/pull/42") # => "pr-42"
1567
1571
  ctx.context.propose(url: "https://github.com/acme/app/pull/42", title: "#42 Make the thing", mentions: ["#42", "feat/x"])
1568
1572
  ctx.context.candidates # => [#<data Candidate name="pr-42", url="https://…", title="#42 Make the thing", …>]
1569
1573
  ctx.context.withdraw("pr-42") # => true
1570
- ctx.context.left_behind # => [#<data Left name="claude-inbox", hint="/tmp/…sock", from="3f2a9c1e-…">]
1574
+ ctx.context.left_behind # => [#<data Left name="notes", hint="…", from="3f2a9c1e-…">]
1571
1575
  ```
1572
1576
 
1573
1577
  [Attached context](context.md) for the session the plugin runs in: chi runs
@@ -1616,8 +1620,7 @@ gets a note when its text changes.
1616
1620
  session left with the previous link ([Movable
1617
1621
  context](context.md#movable-context)): `ContextSources::Left` values with
1618
1622
  `name`, `hint` (the last pushed one, else the source's) and `from` (the
1619
- previous link's id); `[]` for a session that isn't a continue's. The peer
1620
- bundles read it to ask their peer to pair again (below).
1623
+ previous link's id); `[]` for a session that isn't a continue's.
1621
1624
  - The source is the session's (not the project's), marked
1622
1625
  `added_by: plugin:<bundle>`. It is plugin code, so it isn't asked about as
1623
1626
  the agent's `chi context add --cmd` is.
@@ -1634,6 +1637,23 @@ gets a note when its text changes.
1634
1637
  The [github-pr bundle](bundles.md#the-github-pr-bundle) proposes the branch's PR from
1635
1638
  a quiet `chi.init` task.
1636
1639
 
1640
+ ## Peers: `ctx.peers`
1641
+
1642
+ ```ruby
1643
+ ctx.peers.link("claude") # => #<data PeerLink peer="claude", address="/tmp/…sock", paired_at="…", from="…"> or nil
1644
+ ctx.peers.left_behind("claude") # the previous link's pairing, in a continue's new link; else nil
1645
+ ctx.peers.message("claude", 12) # => #<data PeerMessage serial=12, text="…", summary="…", wake=true, re="s-ab12cd", at="…"> or nil
1646
+ ctx.peers.last_message("claude") # the newest message still in the mailbox, or nil
1647
+ ```
1648
+
1649
+ What a peer bundle reads of its peer's side of the session (the mailbox,
1650
+ [peers.md](peers.md)): the pairing (`address` nil: the peer answers only) and
1651
+ the peer's messages. Read only: the peer pairs and says through `chi peer`,
1652
+ and the worker takes the messages. A continue leaves the pairing with the
1653
+ previous link, so a new link's `link` is nil until the peer pairs again;
1654
+ `left_behind` is the one the previous link kept (`Plugin::Peer#tell_moved`
1655
+ tells the peer the new id there). Needs the next chi.
1656
+
1637
1657
  ### Context providers in the manifest
1638
1658
 
1639
1659
  A bundle can turn URLs into sources for every process, without loading
@@ -1741,16 +1761,18 @@ that calls it, or for a real external bundle that does. No method on the chance
1741
1761
  `Samagotchi::Plugin::Secrets::Busy` and `Samagotchi::Plugin::Secrets::Unavailable` (a bundle rescues them by name).
1742
1762
  2. `Samagotchi::Plugin::Peer` as a base class. A subclass defines `post`,
1743
1763
  `check_hint!`, `paired_lines`, `transport_line`, `peer_dir` and
1744
- `setup_paragraph` (optionally `skill_substitutions`), and sets `NAME`,
1745
- `APP`, `COMMAND`, `USAGE`, `OUTBOX` and `SCRIPTS_DIRS`. These constants are
1746
- read as `self.class::X`. The base names each send: `Peer.send_id(kind, title, text, salt)` (`s-` and 6 hex
1764
+ `setup_paragraph` (optionally `skill_substitutions` and `skill_installed`), and sets `PEER`, `NAME`,
1765
+ `APP`, `COMMAND`, `TOOL`, `READ_TOOL`, `USAGE`, `LEGACY_INBOX`, `LEGACY_OUTBOX` and `SCRIPTS_DIRS`. These
1766
+ constants are read as `self.class::X`. It declares the peer (`chi.peer PEER`), the send tool and
1767
+ `<peer>_read` (a long message by its number, paged), and sends to the pairing's address
1768
+ (`ctx.peers.link`). The base names each send: `Peer.send_id(kind, title, text, salt)` (`s-` and 6 hex
1747
1769
  of SHA-256 over the args as given and the send's salt: the tool run's `ctx.tool_id`, a random one for a
1748
1770
  `/<peer>` command's, so each send has its own id; a nil salt gives an older chi's id, over the args alone) is the
1749
1771
  message's second line (`ref: <id>`), the tool row's `peer` ref (display only, no actions; computed from the args
1750
1772
  and the run's id before the call runs, a two-arg `refs:`, so a send that then fails has it too) and the last
1751
- send's `id`; the peer's answer echoes it as `re` ([context.md](context.md#the-command-contract)).
1752
- Successful sends and transport failures are recorded in the session's peer exchange log; answer pushes add
1753
- summaries, not answer texts. The log does not enter the model's context.
1773
+ send's `id`; the peer's answer names it (`chi peer say --re`).
1774
+ Successful sends and transport failures are recorded in the session's peer exchange log; the answers are the
1775
+ mailbox's messages. The log does not enter the model's context.
1754
1776
  See the [claude-peer](bundles.md#the-claude-peer-bundle) and
1755
1777
  [codex-peer](bundles.md#the-codex-peer-bundle) bundles.
1756
1778
  3. `Samagotchi::Tools::ToolIndex::Tool` and `Samagotchi::Tools::ToolIndex::Group`
@@ -1838,6 +1860,9 @@ bundle.set(usage: { tool_calls: 40, active_ms: 600_000 }) # ctx.usage: { turns:,
1838
1860
  bundle.set(turn_author: "p:p_0123abcd") # a participant's turn: ctx.turn_author, and author: on every event
1839
1861
  bundle.set(session_settings: { "cap" => 1 }) # the session's --set values (Bundle.load takes session_settings: too)
1840
1862
  bundle.tool_loads.last.names # ctx.load_tools calls; set(load_tools_staged: [...]) limits what they stage
1863
+ bundle.pair_peer("claude", address: "/tmp/c.sock") # a peer's side, as chi peer pair writes it (ctx.peers.link); address: nil answers only
1864
+ bundle.peer_says("claude", "VERDICT OK", summary: "s") # a message in the mailbox, as chi peer say writes it (ctx.peers.message)
1865
+ bundle.unpair_peer("claude") # chi peer unpair; bundle.peer_registry.names: the chi.peer declarations
1841
1866
  bundle.shutdown
1842
1867
  ```
1843
1868
 
@@ -1913,7 +1938,7 @@ docs/testing.md). **Minitest:** `require "samagotchi/testing/minitest"` and subc
1913
1938
  checked: a bundle whose `requires_chi` this chi doesn't meet raises `InstallError` unless `force: true`)
1914
1939
  and loads the installed copy with chi's own loaders. It returns `warnings` (the Installer's),
1915
1940
  `plugin_failures` / `hook_failures` (each with the `location` in your source, `plugin.rb:12`) and `registered`
1916
- (commands, tools, hooks per event, inits, toolkits, tool and peer sources). A name chi ships raises
1941
+ (commands, tools, hooks per event, inits, toolkits, tool sources and peers). A name chi ships raises
1917
1942
  `MemoryBundle::Installer::InstallError` unless `force: true`.
1918
1943
  - **From the command line:** `chi bundle test [PATH]` runs a bundle's `test/**/*_test.rb` (or `spec/`) on the
1919
1944
  Ruby and lib chi runs on, and `chi bundle check [PATH] [--fix]` runs `Install` (and the manifest, sha and
data/docs/sessions.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  Sessions are plain files — no DB. Each session is `~/.local/state/samagotchi/sessions/<uuid>.json` (XDG-aware via `XDG_STATE_HOME`) plus a sidecar dir `<uuid>/` with `input/`/`notes/`/`output/`/`owner.lock`/`bridge.json` (`Session.session_dir`), `turn_drawings.jsonl` once a turn ended with a Bridge or in a one-shot run (each finished turn as live drew it, which the web's reload draws: [bridge.md](internals/bridge.md#turndrawings); a fork starts with its parent's lines for the turns its seed keeps unchanged, a continue with none: its turns, and any without a line, are drawn from their messages), and `tool_output/` once a long `execute` result was cut: its whole output, which the cut result names (`ToolOutputFiles`, the newest 50 kept; see [Tool output guardrails](internals/tool-output-limits.md#the-runners-cut-max_tool_output_chars)). Its keys are in [the Session file table](#session-file). A file from before `used_memory_names`, `preloaded_memory_names`, `muted_memory_names`, `parent_id` or `continues` reads those as empty lists, no parent and no previous link.
4
4
 
5
- The sidecar's `peer_exchanges.jsonl` records peer sends, transport failures
6
- and answer summaries, never answer text. It stays with the previous link on a
7
- continue; the new link starts empty. See [context storage](context.md#storage).
5
+ The sidecar's `peer_exchanges.jsonl` records peer sends and transport
6
+ failures, never their text, and `peer_receipts.json` what the worker did with
7
+ each peer message (its worker writes it alone); the messages themselves are in
8
+ the mailbox, `$XDG_STATE_HOME/samagotchi/mailbox/<uuid>/<peer>/`, apart from
9
+ the sessions folder. All three stay with the previous link on a continue (its
10
+ unread messages reach the new link as one note); a delete removes them. See
11
+ [peers.md](peers.md).
8
12
 
9
13
  **Message times:** an entry of `messages` may carry `at`, when it happened: a local-offset ISO time with milliseconds (`2026-10-24T14:32:05.120+02:00`). User prompts, lines merged into a turn and steers, reminders, context and task notes, and the model's replies have one (a note's is its `created_at`); tool results, `!cmd` messages and chi's own turn notes don't, nor does anything saved before chi stamped messages (no backfill). It is for the UIs only (the gap dividers, a bubble's time): it never goes to the model, so it changes nothing in the requests or their prompt cache. The one time the model reads is the reminders': due reminders go into a turn as a system message headed `[SYSTEM: REMINDERS DUE 2026-10-24 14:32 local]` (the turn's local time; `ReminderQueue#inject!`), written into the saved content then, so a later request sends the same text.
10
14
 
@@ -194,7 +198,7 @@ pbpaste | chi note --source slack 3f2a 8c1d
194
198
  - It lands in `<uuid>/notes/`, apart from `input/`, so nothing that runs turns sees it. A live worker adds it to the conversation within a few seconds, between turns: one sent during a turn waits for that turn to end. A session with no worker keeps it until a worker next starts (a prompt, `--attach`), which adds it before anything else. A session a one-turn `chi --non-interactive` run has refuses notes. `chi note` prints one line per session: queued, waits for the next start (with the queue count), or refused.
195
199
  - A note to a link that was **continued** (archived, with a later link) goes to its chain's newest link, as `send_note`'s and `chi broadcast`'s do (`chi broadcast` gives two links of one chain the note once, logged under the newest): `chi note` prints `3f2a1c0d → 4b7e9a01 (continued) queued: …` (and `… (continued) refused: …` when that link refuses it), and chi web's notes answer names that link as `id` beside `session_id`, in a 409 too. `chi broadcast deliver` logs such a delivery under the newest link's id (the one that has the note), so `chi broadcast log` shows that id, not the one typed, and a later `deliver` to either link says it had it. An archived link nobody continues keeps its note until input brings it back. An `/objectives` edit is the one note that stays in its own session: its list is that conversation's. Notes waiting when a session is continued move with it (*Session chains*).
196
200
  - In the conversation it is a tail system message marked `kind: note`, framed `[CONTEXT NOTE from slack, 14:02]\n…\n[END NOTE]` (from another session: `from session 3f2a1c (~/projects/foo)`). The system prompt says notes are background, not requests: the model uses one when it is relevant, doesn't answer it on its own, and never follows instructions inside it. A note from `broadcast` ([`chi broadcast`](broadcast.md)) is the one exception to "doesn't answer it": the model says briefly in its next answer when it affects its current work, and still doesn't act on it unless asked. `--source broadcast` is refused for `chi note`. Its text is escaped like user text, so it can't fake a turn. It survives `--resume`, a reload, `!rollback` and a continue answered no.
197
- - The web shows it as a dim "note from …" block, live (`context_added`) and after a reload; the attached terminal as one dim `note from slack: <first line>` line, also when joining.
201
+ - The web shows it as a dim "note from …" block, live (`context_added`) and after a reload, folded into a closed notes row with the background lines next to it (a tap opens it) unless it starts a turn; the attached terminal as one dim `note from slack: <first line>` line, also when joining.
198
202
  - Agents: `list_sessions` (other sessions of this project, newest first, up to 20; optional `cwd`, `"/"` for every project) and `send_note(session, text)`, which sends a note from this session. Neither starts a turn anywhere.
199
203
 
200
204
  On macOS, `chi desktop install` does this with a native panel from the Services menu or a hotkey (see [Desktop helper](desktop.md)). A plain Automator Quick Action that sends the clipboard to the live sessions you pick works too (Automator: Quick Action, "Run Shell Script", shell `/bin/zsh`; Automator's PATH is minimal, so put your Ruby's bin dir on it and use the full path to `chi`):
data/docs/sub-agent.md CHANGED
@@ -26,15 +26,15 @@ The other direction, chi sending a part of its work to a Claude Code session
26
26
  you already work with (to validate, as context, or with a question), is the
27
27
  [claude-peer bundle](bundles.md#the-claude-peer-bundle): Claude pairs with the
28
28
  chi session, chi's `claude_send` tool or `/claude` writes to Claude's inbox,
29
- and Claude's answer comes back as attached context, its whole text in a note
30
- of chi's conversation (Claude can also tell chi something unasked, which wakes
31
- chi under the same count). The
29
+ and Claude's answer comes back with `chi peer say` as a message in the
30
+ session's mailbox, its whole text in a note of chi's conversation, and the
31
+ say prints what chi did with it (Claude can also tell chi something unasked,
32
+ which wakes chi under the same count). The
32
33
  [codex-peer bundle](bundles.md#the-codex-peer-bundle) does the same with a
33
34
  Codex CLI session (`codex_send`, `/codex`, through `codex queue`). The peer's
34
35
  answers wake chi in a short loop (fix or disagree, send again) until it says
35
36
  `VERDICT OK` (one closing wake: chi carries on or tells you what was agreed)
36
- or after `context.peer_turns` turns: [Waking: peer
37
- sources](context.md#peer-sources-the-peer-loop).
37
+ or after `peer.turns` turns: [peers.md](peers.md).
38
38
 
39
39
  A client with no chi of its own (an iOS Shortcut, a script) can do the same
40
40
  over HTTP: one `POST …/ask` to chi web, then a wait token until the answer
@@ -44,6 +44,7 @@ require_relative "working_set"
44
44
  require_relative "relay_verifier"
45
45
  require_relative "relay_watcher"
46
46
  require_relative "reply_wait"
47
+ require_relative "peer_mailbox"
47
48
  require_relative "task_transcript"
48
49
  require_relative "tools/task_runtime"
49
50
 
@@ -796,8 +797,7 @@ module Samagotchi
796
797
  # participant_revise: a participant's Revise draft is kept, and the
797
798
  # Engine checks it at the stamp (ParticipantRevise): what chi web needs
798
799
  # to pass one on (ReviseAnchor::PARTICIPANT_FEATURE).
799
- # activity: GET /activity answers with Worker#activity_snapshot, so
800
- # `chi schedule tick` can ask a live worker what it is busy with.
800
+ # activity: GET /activity answers with Worker#activity_snapshot (chi schedule tick asks a live worker's).
801
801
  # participant_client_id: it reads a participant's client id as
802
802
  # participant:<id>; chi web sends a worker without it review:<id>
803
803
  # (Delivery::PARTICIPANT_ID_FEATURE).
@@ -810,7 +810,7 @@ module Samagotchi
810
810
  WorkerLink::ACTIVITY_FEATURE, ObjectivesTrack::FEATURE, Delivery::OWN_TURN_STEER_FEATURE,
811
811
  Delivery::CANCEL_TURN_ID_FEATURE, ReviseAnchor::PARTICIPANT_FEATURE, Delivery::PARTICIPANT_ID_FEATURE,
812
812
  WorkingSet::ITEM_FEATURE, BlockFix::FEATURE, Delivery::AGENT_FEATURE,
813
- Delivery::ASK_FEATURE, ReplyFor::FEATURE].freeze
813
+ Delivery::ASK_FEATURE, ReplyFor::FEATURE, PeerMailbox::FEATURE].freeze
814
814
 
815
815
  # The routes, by method and what follows /session/:id/: a handler takes
816
816
  # the session id and the request body and returns [headers, status, body].
@@ -24,7 +24,8 @@ module Samagotchi
24
24
  # Resolved on use: Sessions alone loads ~150 files.
25
25
  MEMBERS = {
26
26
  "Plugin::Api" => { ctx: "Plugin::Context" },
27
- "Plugin::Context" => { sessions: "Plugin::Sessions", context: "Plugin::AttachedContext", http: "Plugin::Http",
27
+ "Plugin::Context" => { sessions: "Plugin::Sessions", context: "Plugin::AttachedContext", peers: "Plugin::Peers",
28
+ http: "Plugin::Http",
28
29
  judgments: "Plugin::Judgments", cost: "SessionMetrics::Cost", usage: "SessionMetrics::Usage",
29
30
  log: "Plugin::Context::Logger", secrets: "Plugin::Secrets" }
30
31
  }.freeze
@@ -464,7 +464,7 @@ module Samagotchi
464
464
  end
465
465
  end
466
466
  { "init" => registered.inits, "toolkit" => registered.toolkits, "tool source" => registered.tool_sources,
467
- "peer source" => registered.peer_sources, "prompt section" => registered.prompt_sections }.each do |what, names|
467
+ "peer" => registered.peers, "prompt section" => registered.prompt_sections }.each do |what, names|
468
468
  names.each { |name| add(:info, :registered, plugin, "#{what} #{name}") }
469
469
  end
470
470
  end
@@ -1,28 +1,21 @@
1
1
  ---
2
2
  name: claude-peer
3
- version: 0.6.1
3
+ version: 0.7.0
4
4
  scope: system
5
- description: "Pair this session with a Claude Code session you work with: the claude_send tool and /claude send it a part of the work (a plan step, a diff, a finding) to validate or as context, and Claude's answer comes back as a note with its text (claude-outbox); /claude install-skill installs Claude's chi-peer skill, which pairs"
5
+ description: "Pair this session with a Claude Code session you work with: the claude_send tool and /claude send it a part of the work (a plan step, a diff, a finding) to validate or as context, and Claude's answer comes back as a message with its text (chi peer say); /claude install-skill installs Claude's chi-peer skill, which pairs"
6
6
  trust_level: reviewed
7
7
  files:
8
8
  skill_claude_peer.md:
9
- sha256: sha256:cd8ba89d5cbe37a90c85ad8eb354dfc3d2651fc6150fe3047fd4b5ed6a73a004
10
- description: "Send a part of the work to the paired Claude Code session (claude_send): only when the user asks, or to reply to its answer in a peer turn; validate, context or question; Claude's answer comes as a note with its text (claude-outbox)"
9
+ sha256: sha256:d376b42d3a6ece86e53bc58afef8fd5dc0bfbaf06d0e988faed304b05ca72b45
10
+ description: "Send a part of the work to the paired Claude Code session (claude_send): only when the user asks, or to reply to its answer in a peer turn; validate, context or question; Claude's answer comes as a message with its text"
11
11
  plugin:
12
12
  file: plugin.rb
13
- sha256: sha256:a1020fd0ce9e8d68918605a23562dc1039f65d6f45b9ceb00e4f011cd000072a
13
+ sha256: sha256:a7fa566ff03f6e63d2889196539acbc2fa0c3615aa3a75c1282c91d062bc5e6f
14
14
  scripts:
15
15
  pair-remote: sha256:d7681f87a194e540b629564f84cad9f2d0a763197502c74614276ef88a8920cc
16
- pair: sha256:23d79bb8cf37517d20d15b6716f6666038858a4c5c09d3b85085d1e98475d6b3
17
- chi-peer-SKILL.md: sha256:8d2266d3a13e9fe8091e0e431c08555eaf1b48fe154a6250ce171c8b0bd2d947
18
- # The plugin needs Samagotchi::Plugin::Peer and chi.peer_source (chi 0.67.0).
19
- # An agreeing answer's closing wake (the skills say an OK wakes chi once)
20
- # and the plugin's OUTBOX (Plugin::Peer's rename of REVIEW) need chi 0.70.0.
21
- # The skill's `re` (the answered send) needs nothing newer: an older chi
22
- # ignores the unknown key, and sends no `ref:` line for the skill to echo.
23
- requires_chi: ">= 0.185.0"
24
- # The next chi: the installed skill's __CHI_PEER_PAIR_REMOTE__ placeholder
25
- # (scripts/pair-remote's path), which only its Plugin::Peer
26
- # #skill_target_and_text fills; an older chi would install the skill with it
27
- # left in. Also the memory and the tool's words say a peer's note holds its
28
- # text (chi's ContextAbsorber peer block), which the next chi adds.
16
+ pair: sha256:98cddde54801f49b123cd0269f9ddc834b2566fde4ad241c07a50f3b794fedd0
17
+ chi-peer-SKILL.md: sha256:90132948e1198c450bd6fd3fcadbfad410c429b0d55ef4d7aede21a9f0e47b2f
18
+ # The plugin needs Samagotchi::Plugin::Peer on the mailbox: chi.peer and
19
+ # ctx.peers, and the skill's chi peer pair|say, are the next chi's (an older
20
+ # chi has no chi.peer: the plugin fails to load there).
21
+ requires_chi: ">= 0.188.0"