@webinson/peer 0.2.1 → 0.2.2

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 (3) hide show
  1. package/README.md +3 -2
  2. package/bin/peer.mjs +20 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,12 +15,13 @@ and the commands `/peer` and `/peer-list` in `~/.claude/commands`.
15
15
  In a Claude Code thread:
16
16
 
17
17
  - `/peer` shares this thread in your workspace.
18
+ - `/peer <message>` shares it and passes the message on to the agent as your prompt.
18
19
  - `/peer stop` ends sharing. Ending the session ends it too.
19
20
  - `/peer-list` lists the people who share threads, each thread's state and what it works on,
20
21
  and the threads that stopped in the last hours.
21
22
 
22
- The three commands are answered by the hook before the prompt reaches the model, so they cost no
23
- tokens. `peer list` prints the same list in a terminal.
23
+ `/peer`, `/peer stop` and `/peer-list` are answered by the hook before the prompt reaches the model,
24
+ so they cost no tokens. `peer list` prints the same list in a terminal.
24
25
 
25
26
  ## What is shared
26
27
 
package/bin/peer.mjs CHANGED
@@ -33,7 +33,8 @@ const HELP = `peer: share chosen agent threads with your team
33
33
  peer uninstall remove them from Claude Code
34
34
  peer logout forget the sign-in on this computer
35
35
 
36
- In Claude Code: /peer shares the thread, /peer stop ends it, /peer-list shows the list.
36
+ In Claude Code: /peer shares the thread (/peer <message> also sends the message on), /peer stop
37
+ ends it, /peer-list shows the list.
37
38
  Only threads where /peer was typed are shared, and only their repository, branch and state:
38
39
  never prompts, answers or summaries.`;
39
40
 
@@ -225,16 +226,17 @@ async function hook(event) {
225
226
  await report(saved, session, "stopped", input.cwd).catch(() => {});
226
227
  return block("Peer: this thread is no longer shared.");
227
228
  }
228
- if (argument) return block("Peer: use /peer to share this thread, /peer stop to end it, /peer-list for the list.");
229
+ // `/peer <message>` shares the thread and lets the message through: the command hands it to the model.
229
230
  writeJson(marker, { workspace: saved.workspace, sharedAt: new Date().toISOString() });
230
231
  const where = workingOn(input.cwd);
231
- try {
232
- await report(saved, session, "idle", input.cwd);
233
- } catch (error) {
234
- return block(`Peer: shared, but the hub did not answer yet (${error.message}). The next turn tries again.`);
235
- }
236
232
  const what = [where.repository, where.branch].filter(Boolean).join(" @ ");
237
- return block(`Peer: this thread is shared in ${saved.workspace}${what ? ` as ${what}` : ""}. Teammates see its repository, branch and state, nothing of the conversation. /peer stop ends it.`);
233
+ const sharedText = `Peer: this thread is shared in ${saved.workspace}${what ? ` as ${what}` : ""}. Teammates see its repository, branch and state, nothing of the conversation. /peer stop ends it.`;
234
+ let hubError;
235
+ await report(saved, session, argument ? "working" : "idle", input.cwd).catch((error) => (hubError = error));
236
+ const said = hubError ? `Peer: shared, but the hub did not answer yet (${hubError.message}). The next turn tries again.` : sharedText;
237
+ if (!argument) return block(said);
238
+ log("answered /peer with a message: shared, message passed on");
239
+ return answer({ hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: `${SHARED_NOTE}\n${said}` } });
238
240
  }
239
241
  if (shared) await reportQuietly(session, "working", input.cwd);
240
242
  return;
@@ -260,14 +262,19 @@ async function reportQuietly(session, state, cwd) {
260
262
  const SETTINGS = path.join(CLAUDE, "settings.json");
261
263
  const COMMANDS = path.join(CLAUDE, "commands");
262
264
 
265
+ // The hook's note to the model when `/peer <message>` shares a thread; peer.md looks for it.
266
+ const SHARED_NOTE = "[Peer's hook ran]";
267
+
263
268
  const COMMAND_FILES = {
264
269
  "peer.md": `---
265
- description: Share this thread on Peer (/peer), or stop sharing it (/peer stop)
266
- argument-hint: "[stop]"
270
+ description: Share this thread on Peer (/peer), share it and go on (/peer <message>), or stop sharing it (/peer stop)
271
+ argument-hint: "[message | stop]"
267
272
  ---
268
- Peer's hook handles this command before it reaches you, so you should not be reading it. If you are,
269
- the hook did not run or did not answer in time: tell the person to run \`peer doctor\` in a terminal, which says why.
270
- Do nothing else.
273
+ $ARGUMENTS
274
+
275
+ (From Peer, not from the person: if a note from Peer's hook, starting with ${SHARED_NOTE}, says this thread is now
276
+ shared, say so in one short line, then treat the text above as the person's message. If there is no such note, the
277
+ hook did not run or did not answer in time: tell the person to run \`peer doctor\` in a terminal, which says why.)
271
278
  `,
272
279
  "peer-list.md": `---
273
280
  description: List the people in your Peer workspace and the agent threads they share
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webinson/peer",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Share chosen Claude Code threads with your team: who has agents running and on what.",
5
5
  "license": "MIT",
6
6
  "type": "module",