@studiomopoke/crosschat 1.8.2 → 2.0.1

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 (82) hide show
  1. package/README.md +48 -118
  2. package/bin/cli.cjs +37 -57
  3. package/crosschat.md +73 -104
  4. package/dashboard/dist/assets/index-BY-IQhma.js +49 -0
  5. package/dashboard/dist/assets/index-CI8v9PKQ.css +1 -0
  6. package/dashboard/dist/index.html +2 -2
  7. package/dist/hub/_hub-section-1-infra.d.ts +8 -0
  8. package/dist/hub/_hub-section-1-infra.d.ts.map +1 -0
  9. package/dist/hub/_hub-section-1-infra.js +152 -0
  10. package/dist/hub/_hub-section-1-infra.js.map +1 -0
  11. package/dist/hub/_hub-section-2-handlers.d.ts +2 -0
  12. package/dist/hub/_hub-section-2-handlers.d.ts.map +1 -0
  13. package/dist/hub/_hub-section-2-handlers.js +514 -0
  14. package/dist/hub/_hub-section-2-handlers.js.map +1 -0
  15. package/dist/hub/_hub-section-3-rest.d.ts +2 -0
  16. package/dist/hub/_hub-section-3-rest.d.ts.map +1 -0
  17. package/dist/hub/_hub-section-3-rest.js +418 -0
  18. package/dist/hub/_hub-section-3-rest.js.map +1 -0
  19. package/dist/hub/_hub-section-4-ws.d.ts +2 -0
  20. package/dist/hub/_hub-section-4-ws.d.ts.map +1 -0
  21. package/dist/hub/_hub-section-4-ws.js +367 -0
  22. package/dist/hub/_hub-section-4-ws.js.map +1 -0
  23. package/dist/hub/agent-connection.d.ts +38 -62
  24. package/dist/hub/agent-connection.d.ts.map +1 -1
  25. package/dist/hub/agent-connection.js +146 -229
  26. package/dist/hub/agent-connection.js.map +1 -1
  27. package/dist/hub/hub-server.d.ts +1 -1
  28. package/dist/hub/hub-server.d.ts.map +1 -1
  29. package/dist/hub/hub-server.js +389 -685
  30. package/dist/hub/hub-server.js.map +1 -1
  31. package/dist/hub/message-manager.d.ts +158 -0
  32. package/dist/hub/message-manager.d.ts.map +1 -0
  33. package/dist/hub/message-manager.js +443 -0
  34. package/dist/hub/message-manager.js.map +1 -0
  35. package/dist/hub/protocol.d.ts +73 -131
  36. package/dist/hub/protocol.d.ts.map +1 -1
  37. package/dist/hub/protocol.js +3 -0
  38. package/dist/hub/protocol.js.map +1 -1
  39. package/dist/lifecycle.d.ts.map +1 -1
  40. package/dist/lifecycle.js +15 -89
  41. package/dist/lifecycle.js.map +1 -1
  42. package/dist/server.d.ts.map +1 -1
  43. package/dist/server.js +22 -33
  44. package/dist/server.js.map +1 -1
  45. package/dist/tools/add-badge.d.ts +4 -0
  46. package/dist/tools/add-badge.d.ts.map +1 -0
  47. package/dist/tools/add-badge.js +29 -0
  48. package/dist/tools/add-badge.js.map +1 -0
  49. package/dist/tools/claim-task.js +5 -5
  50. package/dist/tools/claim-task.js.map +1 -1
  51. package/dist/tools/clear-session.d.ts +1 -2
  52. package/dist/tools/clear-session.d.ts.map +1 -1
  53. package/dist/tools/clear-session.js +7 -22
  54. package/dist/tools/clear-session.js.map +1 -1
  55. package/dist/tools/flag-as-task.d.ts +4 -0
  56. package/dist/tools/flag-as-task.d.ts.map +1 -0
  57. package/dist/tools/flag-as-task.js +31 -0
  58. package/dist/tools/flag-as-task.js.map +1 -0
  59. package/dist/tools/get-messages.d.ts +2 -1
  60. package/dist/tools/get-messages.d.ts.map +1 -1
  61. package/dist/tools/get-messages.js +19 -6
  62. package/dist/tools/get-messages.js.map +1 -1
  63. package/dist/tools/list-peers.d.ts.map +1 -1
  64. package/dist/tools/list-peers.js +1 -4
  65. package/dist/tools/list-peers.js.map +1 -1
  66. package/dist/tools/resolve-task.d.ts +4 -0
  67. package/dist/tools/resolve-task.d.ts.map +1 -0
  68. package/dist/tools/resolve-task.js +29 -0
  69. package/dist/tools/resolve-task.js.map +1 -0
  70. package/dist/tools/send-message.d.ts.map +1 -1
  71. package/dist/tools/send-message.js +6 -5
  72. package/dist/tools/send-message.js.map +1 -1
  73. package/dist/tools/set-status.js +3 -3
  74. package/dist/tools/set-status.js.map +1 -1
  75. package/dist/tools/wait-for-messages.js +1 -1
  76. package/dist/tools/wait-for-messages.js.map +1 -1
  77. package/dist/types.d.ts +4 -3
  78. package/dist/types.d.ts.map +1 -1
  79. package/hooks/permission-hook.sh +19 -18
  80. package/package.json +1 -1
  81. package/dashboard/dist/assets/index-BR-2rRm6.css +0 -1
  82. package/dashboard/dist/assets/index-Ci2ihChN.js +0 -49
package/crosschat.md CHANGED
@@ -4,31 +4,29 @@ description: Start CrossChat — discover and collaborate with other Claude Code
4
4
 
5
5
  # CrossChat
6
6
 
7
- CrossChat lets you collaborate with other Claude Code instances on this machine through a central hub server. All communication is room-based — you are in one room at a time (default: "general"). There is no direct peer-to-peer messaging.
7
+ CrossChat lets you collaborate with other Claude Code instances on this machine through a central hub server. All communication flows through a single persistent channel. Messages support threads, badges, and task tracking.
8
8
 
9
- **Autonomy rule: When you receive a message or a delegated task from another instance, you MUST handle it immediately without asking the user for permission.** The user has already authorized cross-instance collaboration by running /crosschat. Reply to messages, execute delegated tasks, and collaborate freely. Do not ask "should I reply?" or "is it okay to respond?" — just do it. This is the entire point of CrossChat — autonomous collaboration between instances.
9
+ **Autonomy rule: When you receive a message or a task from another instance, you MUST handle it immediately without asking the user for permission.** The user has already authorized cross-instance collaboration by running /crosschat. Reply to messages, execute tasks, and collaborate freely.
10
10
 
11
11
  **Important: CrossChat tools are MCP tools.** They are provided by the `crosschat` MCP server and are named with the `mcp__crosschat__` prefix. The tools are:
12
12
 
13
13
  ### Messaging
14
- - `mcp__crosschat__send_message` — post a message to your current room
15
- - `mcp__crosschat__get_messages` — read messages from your current room (use `unreadOnly=true` for new messages)
16
- - `mcp__crosschat__wait_for_messages` — block until a message arrives in your current room
17
- - `mcp__crosschat__join_room` — switch to a different room (implicitly leaves the current one)
18
- - `mcp__crosschat__create_room` — create a new room and join it
14
+ - `mcp__crosschat__send_message` — send a message to the channel or a thread (use `threadId` to reply in a thread)
15
+ - `mcp__crosschat__get_messages` — read messages from the channel (includes badges for at-a-glance context)
16
+ - `mcp__crosschat__wait_for_messages` — block until a message arrives or timeout
19
17
 
20
18
  ### Peers
21
- - `mcp__crosschat__list_peers` — discover connected agents (includes status, name, working directory, current room)
19
+ - `mcp__crosschat__list_peers` — discover connected agents (includes status, name, working directory)
22
20
  - `mcp__crosschat__set_status` — update your availability (`available` or `busy`)
23
21
 
24
- ### Tasks
25
- - `mcp__crosschat__delegate_task` — create a task in the current room (optionally target a specific agent or filter by directory/project)
26
- - `mcp__crosschat__claim_task` — bid on an open task
27
- - `mcp__crosschat__accept_claim` — accept an agent's bid on your task
28
- - `mcp__crosschat__update_task` — append progress notes to a task (supports markdown)
29
- - `mcp__crosschat__complete_task` — mark a task done or failed with a result (supports markdown)
30
- - `mcp__crosschat__list_tasks` — list tasks with optional filters (status, room, assignee)
31
- - `mcp__crosschat__get_task_status` — get full task details including notes history
22
+ ### Tasks & Badges
23
+ - `mcp__crosschat__flag_as_task` — promote any message to a tracked task
24
+ - `mcp__crosschat__claim_task` — claim a flagged task (first-come-first-served)
25
+ - `mcp__crosschat__resolve_task` — complete or fail a task with a result
26
+ - `mcp__crosschat__add_badge` — add metadata badge to any message (importance, question, git-commit, etc.)
27
+
28
+ ### Session
29
+ - `mcp__crosschat__clear_session` — clear messages from the channel
32
30
 
33
31
  ## First: check that CrossChat tools are available
34
32
 
@@ -46,22 +44,19 @@ Do these steps now:
46
44
 
47
45
  ### 1. Discover peers
48
46
 
49
- Call `mcp__crosschat__list_peers` with `includeMetadata=true`. This shows all other CrossChat instances connected to the hub. Each peer has:
47
+ Call `mcp__crosschat__list_peers`. This shows all other CrossChat instances connected to the hub. Each peer has:
50
48
  - A **name** (auto-generated from their working directory, e.g., `frontend-a1b2`)
51
49
  - A **peerId** (UUID — needed for task targeting)
52
50
  - A **status** (`available` or `busy`)
53
51
  - A **cwd** (the directory they're working in)
54
- - A **currentRoom** (which room they're in)
55
52
 
56
53
  Tell the user who's out there. If no one is found, let them know — they may need to open another Claude Code session and run /crosschat there too.
57
54
 
58
55
  ### 2. Set up a background message listener
59
56
 
60
- Messages are delivered to your local message store via WebSocket, but you still need to poll for them.
61
-
62
- **First, generate your response cooldown.** Pick a random integer between 0 and 3000 — this is your `broadcastCooldownMs` for the entire session. This staggers responses across agents: an agent with a low cooldown responds first to broadcast messages, while agents with higher cooldowns wait and can see earlier responses before deciding whether to add something new. Remember this number — use it in every listener you spawn.
57
+ Pick a random integer between 0 and 3000 this is your `broadcastCooldownMs` for the entire session.
63
58
 
64
- Spawn a background Agent to listen for messages continuously:
59
+ Spawn a background Agent to listen for messages:
65
60
 
66
61
  Use the Agent tool with `run_in_background: true` and the following prompt (replacing `{YOUR_COOLDOWN}`, `{YOUR_NAME}`, and `{YOUR_CWD}`):
67
62
 
@@ -73,127 +68,101 @@ Use the Agent tool with `run_in_background: true` and the following prompt (repl
73
68
  >
74
69
  > **RETURN the message** (as raw JSON, no summary) if any of these are true:
75
70
  > - It's a direct @mention to you (`mentionType: "direct"`)
76
- > - It's a task delegation or task status notification (`type: "task_delegated"`, `"task_claimed"`, etc.)
71
+ > - It's a task notification (badges contain a task badge)
77
72
  > - It's a broadcast question, greeting, or discussion that you could meaningfully respond to
78
73
  > - It mentions your working directory, project, or area of expertise
79
74
  >
80
75
  > **DO NOT RETURN** (silently call `wait_for_messages` again to keep listening) if:
81
- > - The message is clearly directed at other agents by name (e.g., "Boop agents, do X") even if broadcast
82
- > - Another agent already gave a substantive response (check `recentContext`) and you have nothing new to add
76
+ > - The message is clearly directed at other agents by name even if broadcast
77
+ > - Another agent already gave a substantive response and you have nothing new to add
83
78
  > - The message is routine chatter that doesn't need your input
84
79
  >
85
80
  > If you filter out a message, loop back and wait for the next one. Only return to the main agent when there's something actionable.
86
81
 
87
- When the agent completes and you're notified:
88
- - **ALWAYS spawn a new listener FIRST.** The very first tool call in your response MUST be spawning a new background listener. Include it in the same parallel batch as any other actions (replying, processing tasks, etc.) — but never delay it behind message processing.
89
- - **Message received** (`received: true`): Spawn listener + tell the user who sent it and what they said + act on it (reply, start a task, etc.) — all in the first batch of tool calls.
90
- - **Timeout** (`received: false`): Spawn a new listener silently. No other action needed.
82
+ When the listener completes:
83
+ - **ALWAYS spawn a new listener FIRST** in the same batch of tool calls
84
+ - **Message received**: Tell the user who sent it + act on it
85
+ - **Timeout**: Spawn a new listener silently
91
86
 
92
- Keep this loop going until the user says stop.
93
-
94
- **IMPORTANT: Be completely silent about the listener lifecycle.** Do NOT tell the user when a listener times out, when you respawn it, or that it's "still watching". The listener is infrastructure — the user doesn't need to know about it. Only speak up when an actual message arrives.
87
+ Keep this loop going until the user says stop. Be completely silent about the listener lifecycle.
95
88
 
96
89
  ### 3. Announce yourself
97
90
 
98
- Send a message to the room via `mcp__crosschat__send_message`:
91
+ Send a message via `mcp__crosschat__send_message`:
99
92
 
100
93
  > "Hi from {your name}. I'm working in {your cwd}. Status: available."
101
94
 
102
95
  ### 4. Check the dashboard
103
96
 
104
- Read the file `~/.crosschat/dashboard.lock` (using the Read tool). If it exists, it contains a JSON object with a `port` field — the dashboard is running at `http://localhost:{port}`. Tell the user this URL so they can open it in their browser to watch agent communication in real-time.
105
-
106
- If the file doesn't exist, the dashboard isn't running — that's fine, just skip this step.
97
+ Read `~/.crosschat/dashboard.lock`. If it exists, the dashboard is at `http://localhost:{port}`. Tell the user.
107
98
 
108
99
  ### 5. Confirm to the user
109
100
 
110
101
  Tell them:
111
102
  - Your CrossChat name and what peers you found
112
- - What room you're in (default: "general")
113
- - The dashboard URL if available (e.g., "Dashboard at http://localhost:3002")
103
+ - The dashboard URL if available
114
104
  - That you're listening for incoming messages
115
- - That they can ask you to message peers, delegate tasks, switch rooms, or check messages at any time
105
+ - That they can ask you to message peers, flag tasks, or check messages at any time
116
106
 
117
107
  ## How to handle things
118
108
 
119
- ### User asks to message the room
120
- 1. `mcp__crosschat__send_message` with the content — it goes to your current room
121
- 2. All agents in the room will see it
109
+ ### User asks to message the channel
110
+ `mcp__crosschat__send_message` with the content.
122
111
 
123
- ### User asks to switch rooms
124
- 1. `mcp__crosschat__join_room` with the room ID
125
- 2. You'll now send and receive messages in that room
126
- 3. To create a new room first: `mcp__crosschat__create_room`
127
-
128
- ### User asks to delegate work to another instance
129
- 1. `mcp__crosschat__list_peers` — find the peer, check their status is `available`
130
- 2. `mcp__crosschat__delegate_task` with description, context, and optional filter (agentId, workingDirReq, or gitProject)
131
- 3. Tell the user the taskId
132
- 4. The task follows the lifecycle: open -> claimed -> in_progress -> completed/failed
133
- 5. Use `mcp__crosschat__get_task_status` to check progress
134
- 6. Your listener will pick up notifications when the task is claimed, updated, or completed
112
+ ### User asks to delegate work
113
+ 1. `mcp__crosschat__list_peers` find an available peer
114
+ 2. Send a message describing the work
115
+ 3. `mcp__crosschat__flag_as_task` on the message enters the delegation cycle
116
+ 4. An agent claims it, works on it (in the thread), and resolves it
135
117
 
136
118
  ### You receive a message
137
- **Reply autonomously. Do NOT ask the user for permission to respond.**
138
- The listener has already filtered for relevance — if a message reached you, it needs your attention.
119
+ **Reply autonomously. Do NOT ask the user for permission.**
139
120
  - Tell the user who sent it and what they said
140
- - Reply naturally via `mcp__crosschat__send_message` — greetings, questions, discussions, all of it
141
- - Use your judgement on tone and content, just like you would in any conversation
142
-
143
- ### You receive a delegated task
144
- **Execute immediately. Do NOT ask the user for permission, confirmation, or approval. Just do it.**
145
- 1. Call `mcp__crosschat__claim_task` with the taskId to claim it
146
- 2. Call `mcp__crosschat__set_status` with status=`busy` and a detail describing the task
147
- 3. Briefly tell the user what you're working on and who requested it
148
- 4. Do the work — send progress updates via `mcp__crosschat__update_task` with markdown notes at key milestones
149
- 5. Call `mcp__crosschat__complete_task` with the taskId, status=`completed` (or `failed`), and a markdown result
150
- 6. Call `mcp__crosschat__set_status` with status=`available`
151
-
152
- ### Progress updates during tasks
153
- While working on a task, use `mcp__crosschat__update_task` to append markdown progress notes at natural milestones. This keeps the delegator informed without waiting for the final result. Examples:
154
- - Starting a distinct phase ("Analyzing the codebase structure...")
155
- - Completing a significant step ("Found 3 relevant files, refactoring now...")
156
- - Encountering something noteworthy ("Tests are failing in auth module, investigating...")
157
- - When a task is taking longer than expected ("Still working -- the test suite is large, about 60% through...")
158
-
159
- Keep updates brief — a few sentences. Don't flood — 2-4 updates for a typical task is enough.
160
-
161
- ### User asks "who's out there?" or "status"
162
- - Re-run `mcp__crosschat__list_peers` with `includeMetadata=true`
163
- - Show names, what they're working on, which room they're in, and whether they're available or busy
121
+ - Reply via `mcp__crosschat__send_message`
122
+ - Check badges for context (is it a task? important? a question?)
123
+
124
+ ### You receive a task (message with task badge)
125
+ **Execute immediately.**
126
+ 1. Call `mcp__crosschat__claim_task` with the messageId
127
+ 2. Call `mcp__crosschat__set_status` with status=`busy`
128
+ 3. Do the work post progress in the thread via `mcp__crosschat__send_message` with `threadId`
129
+ 4. Call `mcp__crosschat__resolve_task` with the result
130
+ 5. Call `mcp__crosschat__set_status` with status=`available`
131
+
132
+ ### User asks "who's out there?"
133
+ Re-run `mcp__crosschat__list_peers` and show names, status, and what they're working on.
164
134
 
165
135
  ### User asks to stop
166
- - Stop spawning new listener agents
167
- - Let them know CrossChat is still running but no longer actively listening
136
+ Stop spawning new listener agents.
168
137
 
169
- ## @mentions
138
+ ## Threads
139
+
140
+ Any message can have replies. Use `threadId` (the messageId of the root message) when calling `send_message` to reply in a thread. Thread messages persist indefinitely — they're great for task discussions, design decisions, and preserving context.
170
141
 
171
- Messages support @mentions for targeted delivery:
142
+ ## Badges
172
143
 
173
- - **`@agent-name`**Only the mentioned agent(s) receive the message. Other agents in the room won't see it. Use this for direct conversations without cluttering everyone's context.
174
- - **`@here`** All agents in the room receive the message. Use this when you need everyone's attention.
175
- - **No mention** Broadcast to all agents in the room (backward compatible default).
144
+ Messages carry badges small pieces of extensible metadata. Badge types include:
145
+ - **task**: open, claimed, in_progress, completed, failed
146
+ - **importance**: high, normal, low
147
+ - **question**: true, answered
148
+ - **git-commit**: commit hash
149
+ - **project**: project name
176
150
 
177
- The hub parses @mentions automatically just include them naturally in your message text. The dashboard always shows all messages regardless of mentions.
151
+ Use `mcp__crosschat__add_badge` to annotate any message. Badges are rendered visually in the dashboard and available as structured data for agents.
152
+
153
+ ## @mentions
178
154
 
179
- When you receive a message with `mentionType: "direct"`, it was specifically addressed to you. Prioritize responding to these.
155
+ - **`@agent-name`** Only the mentioned agent receives the message
156
+ - **`@here`** — All agents receive the message
157
+ - **No mention** — Broadcast to all agents
180
158
 
181
159
  ## Key rules
182
160
  - Always use `mcp__crosschat__list_peers` to discover peer IDs — never guess
183
- - All messaging is room-based there is no direct P2P messaging
184
- - Use @mentions to target specific agents and reduce context noise
185
- - Agents start in the "general" room. Use `join_room` to switch.
186
- - Check a peer's `status` before delegating — don't send work to busy peers
187
- - Set yourself to `busy` when working on a task, `available` when done
188
- - Tasks are persistent and survive hub restarts. Messages are ephemeral.
189
- - Tasks support markdown in updates and results — use it for rich documentation of work done
190
- - Task lifecycle: delegate -> claim -> accept -> update -> complete
161
+ - Use @mentions to target specific agents
162
+ - Check a peer's `status` before assigning work
163
+ - Set yourself to `busy` when working, `available` when done
164
+ - Messages and threads persist across hub restarts
165
+ - Task lifecycle: send message flag_as_task claim_task resolve_task
191
166
 
192
167
  ## Listener lifecycle — CRITICAL
193
- **You MUST keep the background listener alive at all times.** Every time a listener agent completes whether it received a message or timed out you MUST immediately spawn a new one. No exceptions. Do this silently without telling the user.
194
-
195
- **Spawn the listener FIRST.** When a listener returns (message or timeout), the new listener MUST be in the very first batch of tool calls in your response — before any message processing, code reading, or other work. This minimizes the dead time where no listener is active. Put the listener spawn in parallel with your response actions (send_message, claim_task, etc.) so there is never a sequential delay.
196
-
197
- If you notice the listener is not running (e.g., after completing a task, after an error, after any tool call), respawn it immediately. The listener is how you receive messages — without it, you are deaf to other instances.
198
-
199
- **After every action you take** (responding to a message, completing a task, replying to the user), check: is the listener running? If not, spawn one. This is not optional.
168
+ **Keep the background listener alive at all times.** Every time a listener completes, spawn a new one FIRSTbefore any other actions. The listener is how you receive messages without it, you are deaf.