opencode-crosstalk 0.0.0-stage → 0.3.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +539 -2
  3. package/assets/CursorGuard.png +0 -0
  4. package/assets/Wren.png +0 -0
  5. package/assets/avatars/ATTRIBUTION.md +18 -0
  6. package/assets/avatars/female/01-explorer-eeb4a4.png +0 -0
  7. package/assets/avatars/female/02-manager-b16a5b.png +0 -0
  8. package/assets/avatars/female/02-manager-e7a391.png +0 -0
  9. package/assets/avatars/female/03-coder-92594b.png +0 -0
  10. package/assets/avatars/female/03-coder-e5a07e.png +0 -0
  11. package/assets/avatars/female/05-analyst-b16a5b.png +0 -0
  12. package/assets/avatars/female/05-analyst-eeb4a4.png +0 -0
  13. package/assets/avatars/female/08-tester-d78774.png +0 -0
  14. package/assets/avatars/female/08-tester-eeb4a4.png +0 -0
  15. package/assets/avatars/female/10-builder-92594b.png +0 -0
  16. package/assets/avatars/female/10-builder-e5a07e.png +0 -0
  17. package/assets/avatars/female/13-researcher-92594b.png +0 -0
  18. package/assets/avatars/female/13-researcher-e7a391.png +0 -0
  19. package/assets/avatars/female/14-writer-623d36.png +0 -0
  20. package/assets/avatars/female/14-writer-e5a07e.png +0 -0
  21. package/assets/avatars/female/16-fixer-e7a391.png +0 -0
  22. package/assets/avatars/female/17-deployer-92594b.png +0 -0
  23. package/assets/avatars/female/17-deployer-e5a07e.png +0 -0
  24. package/assets/avatars/female/23-mentor-b16a5b.png +0 -0
  25. package/assets/avatars/female/23-mentor-e7a391.png +0 -0
  26. package/assets/avatars/female/25-pioneer-d78774.png +0 -0
  27. package/assets/avatars/female/26-strategist-b16a5b.png +0 -0
  28. package/assets/avatars/female/31-gardener-e5a07e.png +0 -0
  29. package/assets/avatars/female/33-simplifier-b16a5b.png +0 -0
  30. package/assets/avatars/female/33-simplifier-eeb4a4.png +0 -0
  31. package/assets/avatars/female/34-optimizer-92594b.png +0 -0
  32. package/assets/avatars/female/34-optimizer-e7a391.png +0 -0
  33. package/assets/avatars/female/36-integrator-d78774.png +0 -0
  34. package/assets/avatars/female/36-integrator-eeb4a4.png +0 -0
  35. package/assets/avatars/female/37-compiler-b16a5b.png +0 -0
  36. package/assets/avatars/female/37-compiler-e7a391.png +0 -0
  37. package/assets/avatars/female/40-formatter-b16a5b.png +0 -0
  38. package/assets/avatars/female/42-shipper-623d36.png +0 -0
  39. package/assets/avatars/female/46-steward-623d36.png +0 -0
  40. package/assets/avatars/female/46-steward-d78774.png +0 -0
  41. package/assets/avatars/female/47-shepherd-b16a5b.png +0 -0
  42. package/assets/avatars/female/47-shepherd-eeb4a4.png +0 -0
  43. package/assets/avatars/female/48-tinkerer-92594b.png +0 -0
  44. package/assets/avatars/female/50-wrangler-eeb4a4.png +0 -0
  45. package/assets/avatars/index.html +4 -0
  46. package/assets/avatars/male/01-explorer-d78774.png +0 -0
  47. package/assets/avatars/male/06-planner-92594b.png +0 -0
  48. package/assets/avatars/male/06-planner-e7a391.png +0 -0
  49. package/assets/avatars/male/07-reviewer-623d36.png +0 -0
  50. package/assets/avatars/male/07-reviewer-e5a07e.png +0 -0
  51. package/assets/avatars/male/09-migrator-b16a5b.png +0 -0
  52. package/assets/avatars/male/09-migrator-e7a391.png +0 -0
  53. package/assets/avatars/male/11-debugger-623d36.png +0 -0
  54. package/assets/avatars/male/11-debugger-d78774.png +0 -0
  55. package/assets/avatars/male/12-designer-b16a5b.png +0 -0
  56. package/assets/avatars/male/12-designer-eeb4a4.png +0 -0
  57. package/assets/avatars/male/15-editor-d78774.png +0 -0
  58. package/assets/avatars/male/15-editor-eeb4a4.png +0 -0
  59. package/assets/avatars/male/16-fixer-b16a5b.png +0 -0
  60. package/assets/avatars/male/18-scout-623d36.png +0 -0
  61. package/assets/avatars/male/18-scout-d78774.png +0 -0
  62. package/assets/avatars/male/19-architect-b16a5b.png +0 -0
  63. package/assets/avatars/male/19-architect-eeb4a4.png +0 -0
  64. package/assets/avatars/male/20-operator-92594b.png +0 -0
  65. package/assets/avatars/male/20-operator-e7a391.png +0 -0
  66. package/assets/avatars/male/21-coordinator-623d36.png +0 -0
  67. package/assets/avatars/male/21-coordinator-e5a07e.png +0 -0
  68. package/assets/avatars/male/22-auditor-d78774.png +0 -0
  69. package/assets/avatars/male/22-auditor-eeb4a4.png +0 -0
  70. package/assets/avatars/male/25-pioneer-623d36.png +0 -0
  71. package/assets/avatars/male/26-strategist-eeb4a4.png +0 -0
  72. package/assets/avatars/male/28-librarian-623d36.png +0 -0
  73. package/assets/avatars/male/28-librarian-e5a07e.png +0 -0
  74. package/assets/avatars/male/30-tracker-b16a5b.png +0 -0
  75. package/assets/avatars/male/30-tracker-e7a391.png +0 -0
  76. package/assets/avatars/male/31-gardener-92594b.png +0 -0
  77. package/assets/avatars/male/32-refactorer-623d36.png +0 -0
  78. package/assets/avatars/male/32-refactorer-d78774.png +0 -0
  79. package/assets/avatars/male/35-profiler-623d36.png +0 -0
  80. package/assets/avatars/male/35-profiler-e5a07e.png +0 -0
  81. package/assets/avatars/male/38-parser-92594b.png +0 -0
  82. package/assets/avatars/male/38-parser-e5a07e.png +0 -0
  83. package/assets/avatars/male/39-linter-623d36.png +0 -0
  84. package/assets/avatars/male/39-linter-d78774.png +0 -0
  85. package/assets/avatars/male/40-formatter-eeb4a4.png +0 -0
  86. package/assets/avatars/male/41-patcher-92594b.png +0 -0
  87. package/assets/avatars/male/41-patcher-e7a391.png +0 -0
  88. package/assets/avatars/male/42-shipper-e5a07e.png +0 -0
  89. package/assets/avatars/male/43-maintainer-d78774.png +0 -0
  90. package/assets/avatars/male/43-maintainer-eeb4a4.png +0 -0
  91. package/assets/avatars/male/44-guardian-b16a5b.png +0 -0
  92. package/assets/avatars/male/44-guardian-e7a391.png +0 -0
  93. package/assets/avatars/male/45-sentinel-92594b.png +0 -0
  94. package/assets/avatars/male/45-sentinel-e5a07e.png +0 -0
  95. package/assets/avatars/male/48-tinkerer-e7a391.png +0 -0
  96. package/assets/avatars/male/49-hacker-623d36.png +0 -0
  97. package/assets/avatars/male/49-hacker-e5a07e.png +0 -0
  98. package/assets/avatars/male/50-wrangler-d78774.png +0 -0
  99. package/assets/avatars/manifest.json +1202 -0
  100. package/index.ts +11 -0
  101. package/package.json +65 -4
  102. package/src/config.ts +180 -0
  103. package/src/core/avatar.ts +92 -0
  104. package/src/core/claims.ts +302 -0
  105. package/src/core/clock.ts +31 -0
  106. package/src/core/directory.ts +48 -0
  107. package/src/core/format.ts +409 -0
  108. package/src/core/mailbox.ts +245 -0
  109. package/src/core/mesh.ts +800 -0
  110. package/src/core/registry.ts +306 -0
  111. package/src/deliverer.ts +88 -0
  112. package/src/events.ts +66 -0
  113. package/src/index.ts +323 -0
  114. package/src/rpc.ts +52 -0
  115. package/src/storage.ts +105 -0
  116. package/src/tools/args.ts +132 -0
  117. package/src/tools/claim.ts +87 -0
  118. package/src/tools/continue.ts +68 -0
  119. package/src/tools/heartbeat.ts +152 -0
  120. package/src/tools/inbox.ts +76 -0
  121. package/src/tools/index.ts +96 -0
  122. package/src/tools/peers.ts +101 -0
  123. package/src/tools/reply.ts +73 -0
  124. package/src/tools/send.ts +102 -0
  125. package/src/tools/status.ts +148 -0
  126. package/src/tools/types.ts +72 -0
  127. package/src/tools/wait.ts +96 -0
  128. package/src/tui/avatar.ts +188 -0
  129. package/src/tui/focus.ts +34 -0
  130. package/src/tui/index.tsx +219 -0
  131. package/src/types.ts +147 -0
  132. package/tui.ts +8 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christoph Döllinger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,540 @@
1
- # Temporary Holding Version
1
+ # opencode-crosstalk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Let the OpenCode sessions on one server **see each other, talk to each other, and
4
+ lease the files they are editing**.
5
+
6
+ Two agents in the same repository cannot discover each other, cannot say "I'm in
7
+ `src/auth/` right now", and — most expensively — cannot stop each other from
8
+ writing the same file at the same time. Which means the second agent usually
9
+ discovers the first one's work by reading a half-applied diff during the
10
+ postmortem. This plugin adds nine tools that make all three ordinary.
11
+
12
+ ```
13
+ crosstalk_status declare your role and see who else is here
14
+ crosstalk_peers who is running, what they declared, what they hold
15
+ crosstalk_send message a peer, a role, or everyone; attach a task brief
16
+ crosstalk_reply answer a message by its id, addressed to its actual sender
17
+ crosstalk_continue steer an existing session by exact id, preserving context
18
+ crosstalk_inbox read replies, optionally blocking until one arrives
19
+ crosstalk_claim take an exclusive, expiring lease on a file
20
+ crosstalk_wait block until a peer is idle or a file is released
21
+ crosstalk_heartbeat send a message to a peer on a repeating interval
22
+ ```
23
+
24
+ All nine share one namespace and one permission action (`crosstalk`), so a
25
+ project can allow or deny coordination with a single rule instead of nine.
26
+
27
+ ## In action
28
+
29
+ Two real sessions in one checkout, with nobody relaying between them.
30
+ `CursorGuard` wants `src/app/app/app.hpp`. `Wren` is standing on it. The entire
31
+ negotiation:
32
+
33
+ ![The CursorGuard session: a crosstalk_peers call, a lease on src/app/app/app.hpp with a note and a 900s TTL, a request sent to Wren, and Wren's reply landing in an already-running turn](assets/CursorGuard.png)
34
+
35
+ ![The Wren session, the other half of the same exchange: the request it received, its answer naming CursorGuard, and the edit it is making in its own file while it still holds app.hpp](assets/Wren.png)
36
+
37
+ Neither session stalled, and neither came to ask a human. One requested, one
38
+ answered with a hold and a warning about the three defaults it had already
39
+ shuffled — and both went back to their own files while the answer was in flight.
40
+ The lease is what made that a sentence instead of a silent overwrite; the
41
+ interesting part of these screenshots is the thing that *didn't* happen. Both
42
+ panes also carry the sidebar portrait, the role glyph, and the live summary each
43
+ session declared ([TUI avatars](#tui-avatars) below).
44
+
45
+ ## Install
46
+
47
+ ```sh
48
+ git clone https://github.com/MrDoe/opencode-crosstalk
49
+ cd opencode-crosstalk && npm install
50
+ ```
51
+
52
+ ### Every project on your machine
53
+
54
+ ```sh
55
+ npm run setup # symlink this checkout into ~/.opencode/plugins/crosstalk
56
+ npm run uninstall # remove the link again
57
+ ```
58
+
59
+ The global `plugins/` directory is discovered automatically, so this needs no
60
+ config edit, no manifest entry, and no negotiation with the plugin loader. It
61
+ activates the plugin for every project and workspace on the machine, and it links
62
+ rather than copies, so your edits to `src/` are live after a reload. The host
63
+ resolves the linked directory through its root `index.ts`, so that file stays:
64
+ remove it and the plugin is dropped silently, with no error and no opinion.
65
+
66
+ Verify with `opencode api get /api/plugin` (expect `opencode.crosstalk` active);
67
+ `opencode plugin list` shows it as `local`. The cheapest instrument is
68
+ `crosstalk_status` itself, which ends in a self-check line — see
69
+ [TUI avatars](#tui-avatars).
70
+
71
+ Install into exactly one global root. Linking both loads the plugin twice per
72
+ location; the second load detects the first through `globalThis`, warns, and
73
+ registers nothing, so nothing explodes — but you are now running two installs
74
+ that each think they own the job, which is the exact failure mode this plugin
75
+ exists to prevent. `npm run setup` uses `~/.opencode/plugins/`; the root the V2
76
+ docs name, `<config>/plugins/` (`~/.config/opencode/plugins/`), is honored as
77
+ well. Set `CROSSTALK_PLUGINS_DIR` to target another directory.
78
+
79
+ The package is also published to npm as
80
+ [`opencode-crosstalk`](https://www.npmjs.com/package/opencode-crosstalk); release
81
+ tags track that version. The symlink install above stays the recommended path
82
+ for a checkout you edit, because your edits are live after a reload.
83
+
84
+ ### One specific project
85
+
86
+ Point a project at it:
87
+
88
+ ```jsonc title="opencode.jsonc"
89
+ {
90
+ "$schema": "https://opencode.ai/config.json",
91
+ "plugins": ["../opencode-crosstalk"]
92
+ }
93
+ ```
94
+
95
+ Or drop the package into `.opencode/plugins/` and it is discovered with no
96
+ configuration at all:
97
+
98
+ ```text
99
+ your-project/.opencode/plugins/crosstalk/ → symlink or copy this package here
100
+ ```
101
+
102
+ ### Permissions
103
+
104
+ No permission rule is needed to *use* the tools: OpenCode's base policy allows
105
+ every action, so `crosstalk` already resolves to allow. Add a rule when you want
106
+ to control the plugin rather than enable it — one rule covers all nine tools:
107
+
108
+ ```jsonc title="opencode.jsonc"
109
+ {
110
+ "permissions": [{ "action": "crosstalk", "resource": "*", "effect": "deny" }]
111
+ }
112
+ ```
113
+
114
+ Note that a rule which *blocks* the action does not prompt and then decline — it
115
+ removes the tools from the catalog, and the model never learns they existed. If
116
+ you want a dialog box instead of silence, use `ask`.
117
+
118
+ No build step: the host resolves the plugin directory through the root `index.ts`,
119
+ a thin re-export of `src/index.ts`. There is no `dist/`, no bundler, and no
120
+ sourcemap archaeology.
121
+
122
+ ## Using it
123
+
124
+ An agent that knows other sessions exist uses this on its own — the plugin
125
+ briefs every session in its system prompt. A session that is currently alone
126
+ gets a compact declaration nudge, so it acquires a name and a role before a peer
127
+ appears (an undeclared session is not addressable); as soon as one peer or one
128
+ active lease exists, the full coordination briefing takes over. A typical
129
+ exchange:
130
+
131
+ ```text
132
+ crosstalk_status { name: "Riley", role: "migrator", goal: "port auth off sessions",
133
+ summary: "moving the token handlers now" }
134
+ crosstalk_peers {}
135
+ → crosstalk peers (scope project, 1 found, 1 running):
136
+ - ses_9f2 (Alex) running role=reviewer summary="checking the token flow" "check my auth changes" claims /repo/src/auth/session.ts
137
+
138
+ crosstalk_peers { overlap: ["src/auth/session.ts"] }
139
+ → crosstalk peers (scope project, 1 found, 1 running, overlap src/auth/session.ts):
140
+ - ses_9f2 (Alex) ... claims /repo/src/auth/session.ts
141
+
142
+ crosstalk_claim { action: "claim", resources: ["src/auth/session.ts"] }
143
+ → crosstalk claim: refused — 1 resource already leased
144
+ - src/auth/session.ts held by ses_9f2 (reviewing), free in 4m
145
+ wait for them with crosstalk_wait, signal them with crosstalk_send, or pass force: true to steal.
146
+ nothing was claimed (atomic request).
147
+
148
+ crosstalk_send { to: "Alex", kind: "request",
149
+ text: "I need to rewrite session.ts. Are you done?" }
150
+
151
+ crosstalk_wait { for: "peer_idle", sessionID: "ses_9f2", timeoutSeconds: 120 }
152
+ → crosstalk wait: peer idle after 1.2s — ses_9f2
153
+ ```
154
+
155
+ A message is stored in the recipient's mailbox and, when the session is live,
156
+ injected into its current turn — so the other agent finds out without anyone
157
+ having to poll, remember to poll, or schedule a poll. The wait returned in 1.2
158
+ seconds because it had something to wait on.
159
+
160
+ ### Talking to sessions by name
161
+
162
+ Names are there for the user, too. Once the sessions declare themselves, you can
163
+ route work in plain language — *"Talk to Ada about this first."* — and the agent
164
+ you are talking to will address that session by name with
165
+ `crosstalk_send { to: "Ada", … }`. A name is unique among the peers a session
166
+ can see (a taken one is refused, with the holder named), shows up in
167
+ `crosstalk_peers` and in the sidebar, and travels with every message, so the
168
+ inbox always says who is speaking. Underneath the name, nothing changes: identity
169
+ is still the session id, and that is what stops one session releasing another's
170
+ leases. The nickname is a label, never a licence.
171
+
172
+ ### TUI avatars
173
+
174
+ Sessions that declare themselves get a cartoon avatar in the OpenCode TUI
175
+ sidebar, with their name, their role, and their live status summary below it —
176
+ `🔧 CursorGuard` and `🔬 Wren` in the screenshots at the top.
177
+
178
+ The avatar is picked from a bundled pool of 92 characters (DiceBear *Personas*,
179
+ CC BY 4.0 — see [`assets/avatars/ATTRIBUTION.md`](assets/avatars/ATTRIBUTION.md);
180
+ browse the pool by opening `assets/avatars/index.html` in a browser):
181
+
182
+ - `crosstalk_status { name: "Rita", role: "coder", avatar: "👩" }` — the emoji is
183
+ a hint, not a request: 👩/👨 pick the character pool, and the skin tone is
184
+ baked into the art. There is no further negotiation.
185
+ - `crosstalk_status { summary: "Rewriting the session store so a reload keeps its leases." }`
186
+ — the live status line under the avatar: one or two short sentences (200
187
+ characters) on what the session is doing *right now*. It is wrapped to the
188
+ avatar's width, falls back to the declared goal until a summary is written,
189
+ and lands in `crosstalk_peers` output for the other sessions. Because it is
190
+ pushed to the TUI on every declaration (the same debounced `changed` event,
191
+ see below), refreshing it with the next `crosstalk_status` call updates the
192
+ sidebar within a second — keep it current as your task moves. Write it for the
193
+ peer who will read it, not for the user, who can already see your tabs.
194
+ - Freshness is visible, not enforced. A peer line annotates its summary's age
195
+ once it is more than five minutes old — `summary="handlers half done" (14m
196
+ ago)` — so a reader can tell a current summary from a stale one, and the
197
+ sidebar dims the same summary after a quarter hour of no refresh (a 30s
198
+ background tick, so it dims even for a session that emits nothing). A summary
199
+ restored from a snapshot written before this feature carries no age: it is
200
+ shown, annotated with nothing, and never dimmed. Archaeology at least admits to
201
+ being archaeology.
202
+ - The declaring session sees its own summary's age in `crosstalk_status` output
203
+ from five minutes on, and is nudged — *"your summary is 15m old — refresh
204
+ it"* — once it crosses the same quarter-hour the sidebar dims at. A session
205
+ that never declared a summary is still told to declare one. Being nagged is
206
+ the enforcement mechanism; there is no other.
207
+ - Every `crosstalk_status` call also returns a **self-check line**, so an
208
+ install problem is visible without reading server logs:
209
+ `self-check: snapshot v2 · storage crosstalk/fb18e52f…cd2d · 4 locations owned`.
210
+ It names the snapshot format the running store reports, the storage key (or
211
+ `persistence off`), and how many locations this process owns in-process.
212
+ Once the instance guard has turned a duplicate load away, the line grows a
213
+ `2 refused loads` tail — the tell for a plugin installed in two places at
214
+ once, which otherwise only shows up as one install silently clobbering the
215
+ other, hours later, in the worst possible way.
216
+ - `crosstalk_peers { overlap: ["src/auth/session.ts"] }` answers *who else
217
+ touches these paths* in one call: a peer matches when it holds a lease on the
218
+ exact key or listed the path in `workingOn`. Keys are exact, like every claim
219
+ key — asking about a directory never matches the files inside it — and each
220
+ side is normalized against its own directory, so `src/x.ts` typed by a
221
+ session in another worktree does not match this one. An empty result says
222
+ how many sessions were on the channel to begin with, so "nobody overlaps" is
223
+ never confused with "nobody is here".
224
+ - An avatar appears when the session has a task: the first `crosstalk_status`
225
+ that carries a role or a goal freezes one portrait onto the session, and
226
+ nothing changes it afterwards — a later role, name, or avatar hint cannot
227
+ move the artwork. Agents do not get a mid-session glow-up.
228
+ - The declared role picks the character when it matches a pool seed (`coder`,
229
+ `reviewer`, `explorer`, …); otherwise the name hashes to a stable one. The
230
+ portrait is stored on the session record, so it survives reloads and
231
+ restarts.
232
+ - Every avatar also carries an **emoticon** — one curated glyph for its role
233
+ (`coder` → 💻, `librarian` → 📚, 46 roles), chosen from tools, objects, and
234
+ people and never a smiley. It is derived from the manifest entry, so the same
235
+ character always shows the same glyph.
236
+ - That glyph is shown beside the avatar's name in the sidebar **and** written
237
+ into the session title, because the tab header has no slot a plugin can render
238
+ into — its label *is* the title. `💻 Refactor the session store`.
239
+
240
+ The title write is deliberately narrow: only a session that declared a name, and
241
+ only one in the TUI's own directory or below it, is retitled; the write is
242
+ idempotent (a title already carrying its glyph is left alone, so the
243
+ `session.renamed` event it causes is a no-op), a stale glyph is replaced rather
244
+ than stacked, and an emoji you typed yourself is never stripped. Renames are
245
+ durable server state, so a decorated title outlives the TUI that wrote it — and
246
+ outlives several of the bugs it could have had.
247
+
248
+ The server plugin exposes the session directory over RPC (a `directory` method
249
+ plus a debounced `changed` event); the CLI plugin in `tui.ts` / `src/tui/`
250
+ renders it, location-scoped, into `sidebar.content`. The image uses OpenTUI's
251
+ **block** renderer on purpose: `sidebar.content` sits inside a scrollbox and the
252
+ terminal we target (VS Code) announces sixel support but never paints the
253
+ payload — it is confidently and loudly wrong. On a kitty-graphics terminal,
254
+ switching `protocol` in `src/tui/index.tsx` from `blocks` to `auto` gives crisp
255
+ pixels.
256
+
257
+ ### Task briefs and replies
258
+
259
+ An assignment is one message with an optional evidence contract: `writeScope`
260
+ (exact files one owner may edit), `validation` (the gate command) and `evidence`
261
+ (what must be shown to prove completion). They ride in the message's `meta.task`
262
+ and appear in the recipient's `crosstalk_inbox` as a `brief:` line. A session
263
+ that cannot take the work replies with `kind: "decline"` — no answer is demanded
264
+ and the coordinator reroutes instead of resending it unchanged.
265
+
266
+ Use `crosstalk_reply { messageId, text }` to answer a specific message: the
267
+ recipient is read from that message, not chosen by the caller, and the thread
268
+ topic is inherited. Use `crosstalk_continue { sessionID, prompt }` to reuse an
269
+ existing session's context instead of starting a new lane. With `loopGuard`
270
+ enabled, the third byte-identical `send`/`reply` warns and the sixth is blocked;
271
+ `inbox`, leases, status and waits are never blocked.
272
+
273
+ ### Drop-in AGENTS.md snippet
274
+
275
+ Copy this block into a project's `AGENTS.md` to teach its sessions how to
276
+ coordinate without stalling. The `<!-- … -->` markers make it easy to find and
277
+ replace later, so upgrading this file later is a find-and-replace rather than an
278
+ archaeological dig.
279
+
280
+ ```markdown
281
+ <!-- opencode-crosstalk:begin -->
282
+ ## OpenCode Crosstalk
283
+
284
+ Other OpenCode sessions in this workspace are reachable through the
285
+ `opencode-crosstalk` plugin: `crosstalk_status`, `crosstalk_peers`,
286
+ `crosstalk_send`, `crosstalk_reply`, `crosstalk_continue`, `crosstalk_inbox`,
287
+ `crosstalk_claim`, `crosstalk_heartbeat`, `crosstalk_wait`.
288
+ Write in **English only** and keep everything token-tight: one short sentence
289
+ per status, message, or claim note (who, what, where) — no reports, no
290
+ summaries, no pleasantries. Keep working; only stop for coordination that
291
+ prevents a real collision.
292
+
293
+ - **Declare once — briefly — then keep moving.** `crosstalk_status` sets a unique
294
+ human name (so the user can say "tell George…" and peers can address you), your
295
+ role, and a goal of a few words; `crosstalk_peers` shows active sessions and
296
+ their leases. Work that does not overlap theirs needs no coordination.
297
+ - **Keep a live summary under your avatar.** `crosstalk_status { summary: … }` —
298
+ one or two short sentences on what you are doing right now — is shown under
299
+ your avatar in the sidebar and read by peers through `crosstalk_peers`, so
300
+ refresh it whenever your task changes.
301
+ - **Talk before you collide — as a notice, not an essay.** If you need something a
302
+ peer holds, `crosstalk_send` one short precise sentence (`to: "George"` or a
303
+ session id) and continue elsewhere; replies are injected into live turns (use
304
+ `crosstalk_inbox` to catch up). Never force a claim.
305
+ - **Answer by message id, continue by session id.** `crosstalk_reply { messageId, text }`
306
+ addresses the real sender; `crosstalk_continue { sessionID, prompt }` reuses a
307
+ peer's context. Send `kind: "decline"` with a reason when work is outside your lane.
308
+ - **Lease what you are editing now.** `crosstalk_claim` takes an exclusive
309
+ expiring lease on exact paths — no globs (`resources`, `note`, `ttlSeconds`);
310
+ keep the note to a few words. `renew` if the work runs long, `release` when
311
+ done; a refusal names the holder.
312
+ - **Only sessions in this project are reachable** — peers marked "not addressable"
313
+ (location unknown or a different project) cannot receive mail, so do not try.
314
+
315
+ Installed globally — `opencode api get /api/plugin` shows `opencode.crosstalk`
316
+ active.
317
+ <!-- opencode-crosstalk:end -->
318
+ ```
319
+
320
+ ## Design notes
321
+
322
+ **Discovery is event-driven.** The V2 plugin context exposes a narrow slice of
323
+ the session API: no `session.list()`, no `session.active()`.
324
+ `ctx.event.subscribe()` is the only way a plugin learns that other sessions
325
+ exist, so the presence registry is a reducer over `session.created`,
326
+ `session.status`, `session.execution.*`, `session.idle`, `session.renamed`,
327
+ `session.moved`, `session.forked`, and `session.deleted`. One consequence worth
328
+ knowing: a session that was already mid-turn when the plugin loaded stays
329
+ invisible until it emits something, and it shows up on its next event. It is a
330
+ slow handshake, not a handshake failure.
331
+
332
+ **Delivery is retried, not just queued.** A plugin instance belongs to one
333
+ location, so injecting into a session owned by another location can fail. The
334
+ message stays in the recipient's mailbox, and every crosstalk tool first retries
335
+ any injection that is still outstanding for the calling session — so a peer
336
+ recovers the moment it does anything at all, without anyone polling. Retries are
337
+ bounded (50 per session) and expire with the message TTL. Mail older than a day
338
+ is not news, it is noise with a timestamp.
339
+
340
+ **Liveness has two thresholds.** An agent can sit inside one model call for
341
+ minutes without emitting anything, so a peer is only flagged *stale* after
342
+ `staleAfterMs` (10 min) and only *evicted* after `evictAfterMs` (1 h). Silence
343
+ is not evidence.
344
+
345
+ **A claim is a hard lease, not a note.** Paths are normalized
346
+ (`./src/a.ts` = `src//a.ts`, and relative paths resolve against the holder's
347
+ directory so two worktrees do not shadow each other), leases expire, and a batch
348
+ request is atomic: one busy file means nothing is taken. The all-or-nothing part
349
+ is the entire point — a partial claim is a claim you have to remember you hold.
350
+
351
+ **A claim key is an exact path, not a glob.** This is the section people skip
352
+ and then lose an hour to. There is no pattern matching: `src/auth/**` is stored
353
+ as the literal key `/repo/src/auth/**` and protects nothing underneath it, so
354
+ list the files you mean — or claim the directory itself and accept that it is
355
+ one key, not a subtree. Leasing a directory covers the directory and nothing
356
+ inside it, which is a sentence worth reading twice.
357
+
358
+ **Messages are not persisted.** Peers and leases survive a plugin reload through
359
+ `ctx.storage`; mailboxes do not. Replaying stale mail after a restart is worse
360
+ than an empty inbox: the recipient cannot tell a fresh request from a two-hour-old
361
+ one, and will act on the wrong one with complete confidence.
362
+
363
+ **Sessions carry a human name, but identity stays the session id.** A session
364
+ may give itself a unique nickname with `crosstalk_status { name: "George" }` so
365
+ the user can say "tell George…" and peers can address it by name in
366
+ `crosstalk_send`. Names are case-insensitively unique among visible peers — a
367
+ taken name is refused and names the holder — and travel with each message
368
+ (`fromName`), so the inbox shows who is talking even mid-session.
369
+
370
+ **The channel is walled to sessions provably in your project.** `scope` still
371
+ controls what a *listing* shows, but communication is stricter: a peer is
372
+ addressable only when its project (or directory, under `scope: "location"`) is
373
+ provably equal to yours. Unknown locations stay listed — marked
374
+ "not addressable" — but sends, role/`all` broadcasts, `crosstalk_wait`, and
375
+ injection retries all refuse them, so a session in another project folder can
376
+ neither be messaged nor have mail injected into it. Listing is permissive;
377
+ communication is not.
378
+
379
+ ## Options
380
+
381
+ All optional; set them with the object form of `plugins`:
382
+
383
+ ```jsonc
384
+ {
385
+ "plugins": [
386
+ {
387
+ "package": "../opencode-crosstalk",
388
+ "options": {
389
+ "scope": "project",
390
+ "claimTtlMs": 300000,
391
+ "codemode": false
392
+ }
393
+ }
394
+ ]
395
+ }
396
+ ```
397
+
398
+ | Option | Default | Meaning |
399
+ | --- | --- | --- |
400
+ | `namespace` | `crosstalk` | Tool namespace. Dots are rejected: the host rewrites them to `_`. |
401
+ | `permission` | `crosstalk` | Permission action for all nine tools. |
402
+ | `codemode` | `false` | Expose the tools through Code Mode instead of directly. |
403
+ | `scope` | `project` | Peer visibility: `project`, `location`, or `server`. |
404
+ | `staleAfterMs` | `600000` | Silence after which a peer is flagged stale. |
405
+ | `evictAfterMs` | `3600000` | Silence after which a peer is dropped. Never below `staleAfterMs`. |
406
+ | `maxMessages` | `100` | Retained messages per mailbox. |
407
+ | `messageTtlMs` | `86400000` | Message lifetime. |
408
+ | `claimTtlMs` | `300000` | Default lease duration. |
409
+ | `maxWaitMs` | `120000` | Ceiling on any blocking call. |
410
+ | `pollMs` | `1000` | Poll interval for the barrier waits. |
411
+ | `heartbeatMs` | `10000` | Progress heartbeat while blocked; `0` disables. |
412
+ | `persist` | `true` | Persist peers and leases through `ctx.storage`. |
413
+ | `storageKey` | `crosstalk` | Storage key prefix. |
414
+ | `announce` | `true` | Brief every session in the system prompt; compact while the session is alone. |
415
+ | `loopGuard` | `false` | Warn on the 3rd and block the 6th byte-identical `send`/`reply` call; other tools never blocked. |
416
+
417
+ Bad values degrade to the default with a warning; a typo never costs an agent
418
+ its tools mid-session. `parseOptions` never throws — a missing bracket is a log
419
+ line, not an outage, because losing your tools halfway through a turn is a worse
420
+ outcome than losing a setting.
421
+
422
+ ### How the permission action and `codemode` are used
423
+
424
+ Both were confirmed against the host's own tool snapshot, which reads roughly
425
+ `tool.options?.permission ?? <effective tool name>` when it filters the catalog,
426
+ and splits tools on `options.codemode === false` (direct) versus everything else
427
+ (Code Mode catalog). So:
428
+
429
+ - `permission: "crosstalk"` makes the action that gates all nine tools. Without
430
+ it, the action would fall back to the effective tool name — `crosstalk_status`,
431
+ `crosstalk_claim`, and so on — needing nine rules instead of one.
432
+ - `codemode: false` is what makes the tools directly callable. Setting it to
433
+ `true` moves them into the Code Mode catalog only, where they are reached
434
+ through `execute` rather than called by name. That adds a second gate: the
435
+ `execute` action with resource `*` decides whether Code Mode is available at
436
+ all, so blocking either one is enough to make the tools unreachable.
437
+ - A rule that *blocks* the action keeps the tools out of the catalog entirely,
438
+ so the model never sees them — no prompt, no fallback, just a plugin-shaped
439
+ silence. `ask` behaves as usual and prompts.
440
+
441
+ ## Development
442
+
443
+ ```sh
444
+ npm install
445
+ npm run check # the gate: typecheck + 280 unit tests, both always run
446
+ npm run test:e2e # live smoke test, needs OPENCODE_E2E=1 and a usable model
447
+ npm run setup # link the plugin in globally
448
+ ```
449
+
450
+ `npm run check` is the whole gate and is what to keep green before pushing. It
451
+ calls `scripts/check.mjs`, which runs the typecheck and the test suite
452
+ **independently** — one failing never suppresses the other's output — and exits
453
+ non-zero if either failed, naming both codes. `npm test` and `npm run typecheck`
454
+ remain available for a single leg. The tests need no network and no server.
455
+
456
+ The e2e test skips with a reason — rather than failing — when the configured
457
+ provider cannot serve the request, so a credits problem never looks like a
458
+ plugin regression. It spawns real `opencode run` sessions and spends real money,
459
+ so it stays behind `OPENCODE_E2E=1` and wants `OPENCODE_E2E_MODEL` pointed at a
460
+ specific model.
461
+
462
+ `src/core` imports nothing from OpenCode: the presence registry, mailboxes, and
463
+ claim table take an injected clock and are tested directly. `src/index.ts`
464
+ (server) and `src/tui/index.tsx` (CLI) are the only places that talk to the
465
+ host; `src/rpc.ts` is the shared contract and imports only types. `scripts/setup.mjs`
466
+ and `scripts/check.mjs` are plain JavaScript sitting outside `tsconfig.json`,
467
+ so neither is part of the typecheck.
468
+
469
+ ### Releasing
470
+
471
+ Release publishing is staged by CI and approved by a human, using npm
472
+ **trusted publishing** — no long-lived token, and no terminal 2FA prompt:
473
+
474
+ ```sh
475
+ npm version minor # bumps package.json + package-lock.json
476
+ git push --follow-tags # the tag triggers .github/workflows/publish.yml
477
+ ```
478
+
479
+ The workflow installs npm 12, runs `npm run check`, verifies that the tag
480
+ matches `package.json`, and runs `npm stage publish` with an OIDC token.
481
+ Approve the staged version in the npm web UI (2FA in the browser). Staging never
482
+ needs 2FA; approving always does.
483
+
484
+ One-time setup on [npmjs.com](https://www.npmjs.com/package/opencode-crosstalk):
485
+ package **Settings → Trusted publishing → GitHub Actions**, with
486
+ `MrDoe` / `opencode-crosstalk` / `publish.yml`. Staged publishing is always
487
+ allowed for a trusted publisher; direct `npm publish` is a separate opt-in.
488
+ A new trusted publisher must complete its first publish within **2 days** or the
489
+ configuration expires.
490
+
491
+ `workflow_dispatch` stages whatever version is in `package.json`, without a tag.
492
+ `npm stage list` and `npm stage approve` require interactive authentication, so
493
+ they cannot run from the workflow — use them locally only where an OTP works.
494
+
495
+ ## Skills
496
+
497
+ `.opencode/skills/` carries the project skills OpenCode advertises to every
498
+ session here; load one with the `skill` tool when it fits:
499
+
500
+ | Skill | Use it for |
501
+ | --- | --- |
502
+ | `crosstalk-coordination` | running several sessions — assigning phases, relaying findings, push waves |
503
+ | `crosstalk-team-workflow` | executing an assignment — leases, a green gate, honest landing reports |
504
+ | `crosstalk-doctor` | diagnosing tool visibility, scope and a refused twin install from `crosstalk_status` |
505
+ | `crosstalk-tester` | focused verification without editing source; findings with file:line |
506
+ | `crosstalk-reviewer` | reading landed commits before the next phase opens; never edits |
507
+ | `crosstalk-scout` | read-only reconnaissance; returns findings, takes no leases |
508
+ | `crosstalk-integrator` | the one owner of shared files (`README.md`, `AGENTS.md`, config) |
509
+ | `test-driven-development` | any new code: failing test first, watch it fail, then minimal code |
510
+ | `requesting-code-review` | dispatching a reviewer on a commit range before merging |
511
+
512
+ The `crosstalk-*` skills are written for this repository. The last two are
513
+ vendored from [obra/superpowers](https://github.com/obra/superpowers) under MIT;
514
+ each file carries its attribution footer and any edits made while vendoring.
515
+ `.opencode/skills/roles.md` is the roster with the canonical lowercase role
516
+ labels used by `crosstalk_send { role: "tester" }`; `.opencode/skills/brief-format.md`
517
+ is the shared assignment card. `.opencode/skills/README.md` is the index.
518
+
519
+ ## Release notes
520
+
521
+ ### 0.3.0
522
+
523
+ - **Two new tools:** `crosstalk_reply` (answer a message by id, addressed to its
524
+ real sender) and `crosstalk_continue` (reuse a session by exact id).
525
+ - **Task briefs:** `send` carries `writeScope`, `validation` and `evidence`;
526
+ recipients see them as a `brief:` line in their inbox. `kind: "decline"` asks
527
+ for no answer.
528
+ - **Self-check:** `crosstalk_status` reports scope, permission action,
529
+ direct/Code Mode and pending injections; a `crosstalk-doctor` skill explains
530
+ how to read it.
531
+ - **Optional `loopGuard`** warns on repeated identical sends and blocks the
532
+ sixth (default off); retrieval tools are never blocked.
533
+ - **Click-to-focus:** named peers in this TUI's place can be focused from the
534
+ sidebar avatar.
535
+ - **Role kit:** `roles.md`, `brief-format.md` and skills for tester, reviewer,
536
+ scout, integrator and doctor.
537
+
538
+ ## License
539
+
540
+ MIT © 2026 Christoph Döllinger — see [LICENSE](LICENSE).
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ # Avatar attribution
2
+
3
+ The avatar images in this directory are generated with [DiceBear](https://www.dicebear.com/)
4
+ from the **Personas** style.
5
+
6
+ - **Style:** Personas by [Draftbit](https://draftbit.com/) — <https://personas.draftbit.com/>
7
+ - **License:** [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
8
+ - **Remix:** via [DiceBear](https://www.dicebear.com/styles/personas/) (`@dicebear/styles@10.6.0`)
9
+
10
+ Each PNG was generated deterministically from a role seed (e.g. `coder`, `reviewer`),
11
+ a gender pool (female / male) and a skin tone from the Personas palette. The resolved
12
+ style options for every file are recorded in `manifest.json`.
13
+
14
+ Generation parameters: DiceBear `personas` (`@dicebear/styles@10.6.0`), 256 px,
15
+ transparent background, one of 50 role seeds, a gender pool (female = long-hair
16
+ variants with no facial hair; male = short-hair variants with 65% facial hair),
17
+ and a skin tone from the Personas palette. The pool was curated by hand after
18
+ generation.