ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 eighteyes

ubc

一個 Claude Code 外掛,讓任何 shell 向指定的 Claude Code 工作階段傳送訊息,再由該工作階段用訊息開始一輪工作。

eighteyes@eighteyes

eighteyes/universal-backchannel/tree/main/mod/ubc

已翻譯

關於這個 mod

universal-backchannel

"Slip a note under the door"

ubc 是通往 Claude Code 的後門通道。任何 shell 都可以丟下一則訊息,目標工作階段會用它開始一輪工作。

ubc "the build is green, go ahead and tag it"

在 shell 中執行 ubc,它會找到該 shell 所屬的工作階段:同一個 herdr 分頁、同一個專案資料夾,或你指定的名稱。傳入 --agent <uuid> 可以跳過猜測。如果符合多個工作階段,ubc 會列出它們並以 3 結束,因此絕不會擅自猜測。可以使用 /ubc name api 為工作階段命名;每則訊息都會先從收件匣移出,再進行讀取,以確保只傳遞一次。工作階段進行中抵達的訊息會排隊,等工作階段結束後合併成一個提示詞送達。

安裝

git clone https://github.com/eighteyes/universal-backchannel
cd universal-backchannel
ln -s "$PWD/bin/ubc" ~/.local/bin/ubc        # the CLI
claude --plugin-dir "$PWD/mod/ubc"           # a session with the mod loaded

要在每個工作階段載入外掛,請將 mod/ubc 路徑加入 ~/.claude/settings.json 的 env 區塊中的 CLAUDE_CODE_PLUGIN_DIRS。

需要:bash、jq(只有在沒有 --agent 時用來尋找工作階段),以及會載入 hooks-module 外掛的 Claude Code 建置。

外掛不會繪製任何內容:它輪詢收件匣並開始工作階段。/ubc 會印出工作階段 id 和一行可以直接貼上的傳送指令。狀態存放在 ~/.ubc 下(inbox、read、sessions),設定 UBC_DIR 可以移動整棵目錄樹。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add eighteyes/universal-backchannel
claude plugin install ubc
原文 / README

universal-backchannel

"Slip a note under the door"

Your Claude Code sessions are islands. A build script, a cron job, another agent or you in a spare shell can't reach a session without typing into its window. To reach one from outside we need an address and a mailbox: anything writes, the session reads.

ubc is a backchannel into Claude Code. Any shell drops a message, and the session it's meant for starts a turn with it.

ubc "the build is green, go ahead and tag it"
The ubc plugin sent a message:
ubc message from my-repo:
the build is green, go ahead and tag it

Features

no uuid needed

Run ubc from a shell and it finds the session that shell belongs to: same herdr tab, same project folder, or a name you gave it. Pass --agent <uuid> to skip the guessing.

never guesses

When more than one session matches, ubc lists them and exits 3. Pick one with --agent or --to.

names

/ubc name api in a session, then ubc --to api "deploy done" from anywhere.

delivered once

The mod claims each message by moving it out of the inbox before it reads it. Two polls or two sessions can't deliver the same message twice.

queues behind a busy turn

A message that lands mid-turn waits for that turn to finish. Several waiting messages arrive as one prompt.

pipes

make test 2>&1 | tail -20 | ubc sends the output. --from ci signs it.

no pane

The mod draws nothing. It polls an inbox and starts turns. /ubc prints the session's id and a ready-to-paste send line.

It's a folder of text files and a 1.5 second poll, but it's replaced a lot of copy-pasting between my windows.

Installation

git clone https://github.com/eighteyes/universal-backchannel
cd universal-backchannel
ln -s "$PWD/bin/ubc" ~/.local/bin/ubc        # the CLI
claude --plugin-dir "$PWD/mod/ubc"           # a session with the mod loaded

To load the mod in every session, add the mod/ubc path to CLAUDE_CODE_PLUGIN_DIRS in the env block of ~/.claude/settings.json.

Needs: bash, jq (only for finding a session without --agent), and a Claude Code build that loads hooks-module mods.

Incomplete Implementations

Codex, Desktop, others: nothing yet. The mod needs Claude Code's $.prompt.submit to start a turn.

Hot reload: a mod folder under ~/.claude/dev-mods/ that's a symlink loads once and then ignores edits. Copy it in, or use --plugin-dir.

Implementation

CLI

ubc "hi there from ubc"                    # to the session this shell belongs to
ubc --to api "deploy done"                 # to a session named with /ubc name api
ubc --agent <uuid> "hi"                    # by id
echo "build failed" | ubc                  # message from stdin
ubc --from ci "deploy done"                # sign it (default: this folder's name)
ubc --who                                  # which session a send would reach
ubc --list                                 # live sessions

Finding the session

With no --agent, the first rule that matches wins:

rule                      matches
--to <name>               a live session named with /ubc name <name>
$CLAUDE_CODE_SESSION_ID   set in shells Claude itself starts (Bash tool, hooks)
$HERDR_TAB_ID             a live session in the same herdr tab
$HERDR_WORKSPACE_ID       a live session in the same herdr workspace
$PWD                      a live session whose cwd is this folder, above it or below it

Several matches narrow to those whose cwd nests with $PWD, then to an exact cwd. A session is live for 150s after its last heartbeat (UBC_LIVE_SECS).

Mod

event           does
session.start   registers /ubc; polls the inbox every 1.5s; heartbeats every 60s
command.run     /ubc prints id, send line and waiting count; /ubc name <x> names it, /ubc name - drops it

/ubc can't deliver: Claude Code doesn't allow a prompt submit from a command hook, so delivery always comes from the poll.

Layout

~/.ubc/inbox/<uuid>/*.msg      waiting; the CLI writes a dotfile and renames it
~/.ubc/read/<uuid>/*.msg       delivered; never pruned
~/.ubc/sessions/<uuid>.json    heartbeat: cwd, herdr ids, name, time

A message is from: <name>, a blank line, then the body. UBC_DIR moves the tree; UBC_FROM sets the default sender.

Trust

Nothing is authenticated. Anything that can write to ~/.ubc can prompt your sessions, the same as anything that can type into your terminal.

Tests

claude plugin test mod/ubc

Contributions

Are welcome. I wanted agents and scripts to tap each other on the shoulder without a server, a socket or a pane, and a mailbox on disk turned out to be enough.

更多類似作品