jj-mailbox: File-Based Agent Messaging
You have access to a jj-mailbox — a shared file-based messaging system that lets you communicate with other agents. Messages are JSON files in a jj (Jujutsu) version-controlled repo.
Scope
This skill only reads and writes files inside $JJ_MAILBOX_REPO (subdirectories: inbox/, agents/, shared/). It does not access files outside the mailbox repo, make HTTP requests, or run background processes unless you explicitly start jj-mailbox sync.
Prerequisites
- -
jj-mailbox CLI — included as jj-mailbox.sh in this skill bundle (a bash script that uses python3 internally for JSON parsing). Copy it to your PATH or run directly. jj and git — Jujutsu version control with git backend.- Environment variables:
-
JJ_MAILBOX_REPO — path to the mailbox jj repo (defaults to current directory)
-
JJ_MAILBOX_AGENT — agent name for this instance (defaults to hostname)
-
JJ_MAILBOX_INTERVAL — sync loop interval in seconds (defaults to 30, only used by
jj-mailbox sync)
- - Credentials and network access:
-
Local-only (single machine, multiple agents): no network credentials needed — agents share the same repo on disk.
-
Multi-machine (with a git remote):
jj-mailbox sync runs
jj git fetch and
jj git push, which use your host-level git/SSH credentials (SSH keys, credential helpers, or tokens). Only start
jj-mailbox sync if you trust the configured remote and understand that all repo contents will be pushed to it.
How It Works
- - Each agent has an inbox directory: INLINECODE18
- To send a message, write a JSON file to the recipient's inbox
- To receive messages, read files from your own inbox
- The
jj-mailbox sync command handles jj git fetch/push in a loop — this is opt-in and only needed for multi-machine setups; it never starts automatically
Your Identity
Your agent name is set by the environment variable JJ_MAILBOX_AGENT.
Your mailbox repo is at the path set by JJ_MAILBOX_REPO.
Sending a Message
Use the jj-mailbox CLI:
CODEBLOCK0
Or write the file directly:
CODEBLOCK1
Checking Your Inbox
CODEBLOCK2
Or read files directly from inbox/${JJ_MAILBOX_AGENT}/new/ (sorted by filename = sorted by time).
Processing a Message
After reading a message, move it to processed/:
CODEBLOCK3
Seeing Other Agents
CODEBLOCK4
Or check agents/ directory — each subdirectory is an agent with profile.json and status.json.
Shared Space
Write to shared/ for content all agents can access:
- -
shared/tasks/ — shared task board - INLINECODE31 — shared knowledge base
- INLINECODE32 — shared outputs (files, reports, etc.)
Rules
- 1. Never modify another agent's processed messages — they are immutable history
- Always include
from, to, subject, body in messages - Use
refs to link replies to original messages for threading - Keep messages small — for large content, write to
shared/artifacts/ and reference the path - Check your inbox regularly — other agents may be waiting for your reply
- Update your status in
agents/{name}/status.json when starting/finishing tasks - Never put secrets, credentials, or sensitive data in the mailbox repo — if a git remote is configured, all repo contents may be pushed to that remote
jj-mailbox:基于文件的智能体消息传递
你可以访问jj-mailbox——一个基于文件的共享消息系统,让你能够与其他智能体进行通信。消息是存储在jj(Jujutsu)版本控制仓库中的JSON文件。
范围
此技能仅读取和写入$JJMAILBOXREPO(子目录:inbox/、agents/、shared/)内的文件。除非你显式启动jj-mailbox sync,否则它不会访问邮箱仓库外的文件、发起HTTP请求或运行后台进程。
前置条件
- - jj-mailbox CLI——作为jj-mailbox.sh包含在此技能包中(一个内部使用python3进行JSON解析的bash脚本)。将其复制到你的PATH中或直接运行。
- jj和git——使用git后端的Jujutsu版本控制。
- 环境变量:
- JJ
MAILBOXREPO——邮箱jj仓库的路径(默认为当前目录)
- JJ
MAILBOXAGENT——此实例的智能体名称(默认为主机名)
- JJ
MAILBOXINTERVAL——同步循环间隔(秒,默认为30,仅由jj-mailbox sync使用)
-
仅本地(单机,多个智能体):无需网络凭证——智能体共享磁盘上的同一仓库。
-
多机(使用git远程仓库):jj-mailbox sync运行jj git fetch和jj git push,使用你的主机级git/SSH凭证(SSH密钥、凭证助手或令牌)。仅在你信任已配置的远程仓库并理解所有仓库内容将被推送到该远程仓库时,才启动jj-mailbox sync。
工作原理
- - 每个智能体都有一个收件箱目录:inbox/{agent-name}/new/
- 发送消息时,将JSON文件写入收件人的收件箱
- 接收消息时,从自己的收件箱读取文件
- jj-mailbox sync命令在循环中处理jj git fetch/push——这是可选加入的,仅在多机设置时需要;它永远不会自动启动
你的身份
你的智能体名称由环境变量JJMAILBOXAGENT设置。
你的邮箱仓库位于JJMAILBOXREPO设置的路径。
发送消息
使用jj-mailbox CLI:
bash
jj-mailbox send <收件人> <主题> <正文>
或直接写入文件:
bash
cat > inbox/<收件人>/new/$(date -u +%Y-%m-%dT%H-%M-%SZ)${JJMAILBOXAGENT}msg-$(head -c4 /dev/urandom | xxd -p).json <
{
version: 0.1,
id: msg-$(head -c4 /dev/urandom | xxd -p),
timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ),
from: ${JJMAILBOXAGENT},
to: <收件人>,
type: message,
subject: <主题>,
body: <正文>,
refs: [],
metadata: {}
}
EOF
检查你的收件箱
bash
jj-mailbox inbox
或直接从inbox/${JJMAILBOXAGENT}/new/读取文件(按文件名排序=按时间排序)。
处理消息
读取消息后,将其移动到processed/:
bash
mv inbox/${JJMAILBOXAGENT}/new/<文件名>.json inbox/${JJMAILBOXAGENT}/processed/
查看其他智能体
bash
jj-mailbox status
或检查agents/目录——每个子目录都是一个智能体,包含profile.json和status.json。
共享空间
写入shared/以存储所有智能体可访问的内容:
- - shared/tasks/——共享任务板
- shared/knowledge/——共享知识库
- shared/artifacts/——共享输出(文件、报告等)
规则
- 1. 绝不修改其他智能体已处理的消息——它们是不可变的历史记录
- 始终在消息中包含from、to、subject、body
- 使用refs 将回复链接到原始消息以形成线程
- 保持消息简短——对于大型内容,写入shared/artifacts/并引用路径
- 定期检查你的收件箱——其他智能体可能在等待你的回复
- 在开始/完成任务时更新agents/{name}/status.json中的状态
- 绝不将机密、凭证或敏感数据放入邮箱仓库——如果配置了git远程仓库,所有仓库内容可能会被推送到该远程仓库