Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ $agmsg
### シェル(任意のエージェント)

```bash
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> "<message>" [--force]
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> --stdin [--force]
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> --body-file <path> [--force]
~/.agents/skills/<cmd>/scripts/inbox.sh <team> <agent_id>
~/.agents/skills/<cmd>/scripts/history.sh <team> [agent_id] [limit]
~/.agents/skills/<cmd>/scripts/team.sh <team>
Expand All @@ -325,7 +326,19 @@ $agmsg
~/.agents/skills/<cmd>/scripts/reset.sh <project_path> <type> [agent_id]
```

`send.sh` は4つの位置引数 `<team> <from> <to> "<message>"` に加えて、末尾に任意で `--force` を取る。シェルが1つの引数として認識するようメッセージはクォートすること — クォートされていないスペース入りメッセージは誤って分割される。`from`・`to` はどちらも `<team>` に事前登録済みである必要があり、未登録の名前は(登録済み一覧を添えて)エラーになる — 意図的な事前登録前送信をしたい場合のみ `--force` でこのチェックを迂回できる。
`send.sh` は `<team> <from> <to>` に続けてメッセージを取り、末尾に任意で `--force` を取る。`from`・`to` はどちらも `<team>` に事前登録済みである必要があり、未登録の名前は(登録済み一覧を添えて)エラーになる — 意図的な事前登録前送信をしたい場合のみ `--force` でこのチェックを迂回できる。

メッセージは `--stdin` または `--body-file <path>` で渡す。どちらもファイルディスクリプタから本文をそのまま読むため、本文がシェルを通ることも argv に載ることもない。ヒアドキュメントの区切り子は、本文中に単独行として現れ得ないものを選ぶこと — 本文に `AGMSG_BODY` だけの行があるとそこでヒアドキュメントが終わり、残りがシェルコマンドとして実行されてしまう。それを排除できない場合は `--body-file` を使う:

```bash
~/.agents/skills/<cmd>/scripts/send.sh myteam alice bob --stdin <<'AGMSG_BODY'
ここに書いた内容はバイト単位でそのまま届く — バッククォートも $(...) もクォートもそのまま
AGMSG_BODY

~/.agents/skills/<cmd>/scripts/send.sh myteam alice bob --body-file ./message.txt
```

従来の位置引数形式 — `send.sh <team> <from> <to> "<message>"` — も引き続き動作するが、**非推奨**である(#378)。このメッセージは agmsg が受け取る前にシェルが解釈するため、本文中のバッククォートや `$(...)` がそこで評価されうる。さらに Windows では MSYS の argv 変換によって長い本文が 8186 バイトで無言のうちに切り詰められる。**エージェントが組み立てたメッセージでは使ってはならない**。本文がちょうど `--`・`--stdin`・`--body-file`・`--force` そのものである場合は、直前に `--` を置くこと: `send.sh <team> <from> <to> -- --stdin`(本文が `--` なら `-- --`)

## FAQ / 設計メモ

Expand Down Expand Up @@ -406,7 +419,7 @@ DBとチーム設定は保持される。更新されるのはスクリプトと

```bash
# 独立したストアに対して実行
AGMSG_STORAGE_PATH=/tmp/agmsg-sandbox ./scripts/send.sh myteam alice bob "hi"
printf 'hi' | AGMSG_STORAGE_PATH=/tmp/agmsg-sandbox ./scripts/send.sh myteam alice bob --stdin
```

### サンドボックス互換性(Claude Code)
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ See [docs/opencode.md](docs/opencode.md) for full setup instructions.
### Shell (any agent)

```bash
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> "<message>" [--force]
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> --stdin [--force]
~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> --body-file <path> [--force]
~/.agents/skills/<cmd>/scripts/inbox.sh <team> <agent_id>
~/.agents/skills/<cmd>/scripts/history.sh <team> [agent_id] [limit]
~/.agents/skills/<cmd>/scripts/team.sh <team>
Expand All @@ -339,7 +340,19 @@ See [docs/opencode.md](docs/opencode.md) for full setup instructions.
~/.agents/skills/<cmd>/scripts/reset.sh <project_path> <type> [agent_id]
```

`send.sh` takes four positional arguments — `<team> <from> <to> "<message>"` — plus an optional trailing `--force`. Quote the message so the shell sees it as one argument; an unquoted message with spaces will be misparsed. Both `from` and `to` must already be registered in `<team>`; an unregistered name errors out (listing the currently registered names) instead of silently storing an undeliverable message. Pass `--force` to bypass this check for an intentional pre-registration send.
`send.sh` takes `<team> <from> <to>`, then the message, then an optional trailing `--force`. Both `from` and `to` must already be registered in `<team>`; an unregistered name errors out (listing the currently registered names) instead of silently storing an undeliverable message. Pass `--force` to bypass this check for an intentional pre-registration send.

Give the message via `--stdin` or `--body-file <path>`. Both read the body verbatim from a file descriptor, so it never passes through your shell and never becomes an argv entry. Pick a heredoc delimiter the body cannot contain on a line by itself — a body with a bare `AGMSG_BODY` line would end the heredoc early and the rest would run as shell commands. When you cannot rule that out, use `--body-file`.

```bash
~/.agents/skills/<cmd>/scripts/send.sh myteam alice bob --stdin <<'AGMSG_BODY'
whatever you write here arrives byte-for-byte — backticks, $(...), quotes and all
AGMSG_BODY

~/.agents/skills/<cmd>/scripts/send.sh myteam alice bob --body-file ./message.txt
```

The older positional form — `send.sh <team> <from> <to> "<message>"` — still works, but it is **deprecated** (#378). Your shell parses that message before agmsg ever sees it, so backticks or `$(...)` in the body can be evaluated there, and on Windows a long body is silently truncated at 8186 bytes by MSYS's argv conversion. A message composed by an agent **must not** use it. If your body happens to be literally `--`, `--stdin`, `--body-file`, or `--force`, put `--` in front of it: `send.sh <team> <from> <to> -- --stdin` — and for a body of `--`, that is `-- --`.

## FAQ / Design notes

Expand Down Expand Up @@ -425,7 +438,7 @@ The message store path resolves as **`AGMSG_STORAGE_PATH` (env) > built-in defau

```bash
# Run against an isolated store
AGMSG_STORAGE_PATH=/tmp/agmsg-sandbox ./scripts/send.sh myteam alice bob "hi"
printf 'hi' | AGMSG_STORAGE_PATH=/tmp/agmsg-sandbox ./scripts/send.sh myteam alice bob --stdin
```

### Sandbox compatibility (Claude Code)
Expand Down
23 changes: 21 additions & 2 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Cross-agent messaging via SQLite. Send messages between Claude Code

**IMPORTANT: Always use the provided scripts. NEVER directly read or edit config files, DB, or team data. There is NO register.sh — use join.sh to join a team.**

**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/agmsg/scripts/send.sh myteam alice bob "hello"'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).
**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/agmsg/scripts/inbox.sh myteam alice'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).

## How to use

Expand Down Expand Up @@ -58,9 +58,28 @@ Do NOT manually edit config files. Always use join.sh. If the name was recently
# Check inbox (marks messages as read) — DEFAULT action
~/.agents/skills/agmsg/scripts/inbox.sh <team> <agent_id>

# Send a message (from/to must already be registered in <team>; add --force to bypass)
# Send a message (from/to must already be registered in <team>; add --force to bypass).
# Pass the body via --stdin or --body-file. Both read it verbatim from a file
# descriptor, so it never goes through a shell and never becomes an argv entry.
# Pick a delimiter the body cannot contain on a line by itself — a body with a
# bare AGMSG_BODY line would end the heredoc early and the rest would run as
# shell commands. When you cannot rule that out, use --body-file.
~/.agents/skills/agmsg/scripts/send.sh <team> <from_agent> <to_agent> --stdin [--force] <<'AGMSG_BODY'
message body goes here, verbatim — backticks, $(...), quotes all pass through untouched
AGMSG_BODY
~/.agents/skills/agmsg/scripts/send.sh <team> <from_agent> <to_agent> --body-file /path/to/body.txt [--force]

# DEPRECATED — do NOT use for a message you compose yourself (#378). A positional
# message goes through YOUR shell before agmsg ever sees it, so backticks or
# $(...) in the body can be evaluated there, and on Windows a long body is
# silently truncated at 8186 bytes. It still works, for callers that predate the
# flags above; new sends use --stdin or --body-file.
~/.agents/skills/agmsg/scripts/send.sh <team> <from_agent> <to_agent> "<message>" [--force]

# A body that IS `--` or one of the flag names still works — put `--` before it.
~/.agents/skills/agmsg/scripts/send.sh <team> <from_agent> <to_agent> -- --stdin
~/.agents/skills/agmsg/scripts/send.sh <team> <from_agent> <to_agent> -- --

# Message history
~/.agents/skills/agmsg/scripts/history.sh <team> [agent_id] [limit]

Expand Down
7 changes: 6 additions & 1 deletion docs/building-on-agmsg.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ flows use:

| Action | Script |
|---|---|
| Send a message | `scripts/send.sh <team> <from> <to> <body>` |
| Send a message | `scripts/send.sh <team> <from> <to> --stdin` (body on stdin) or `--body-file <path>` |
| Join a team / register an agent | `scripts/join.sh <team> <name> <type> <project>` |
| Rename an agent | `scripts/rename.sh <team> <old> <new>` |
| Remove an agent from a team | `scripts/leave.sh <team> <name>` |
| Check delivery mode | `scripts/delivery.sh status [<type> <project>]` |
| Set delivery mode | `scripts/delivery.sh set <mode> <type> <project>` |

`send.sh` also still accepts the message as a positional argument, but that
form is **deprecated** (#378): the caller's shell parses the body before
agmsg sees it, and on Windows MSYS truncates a long one at 8186 bytes. A body
your integration composes MUST NOT use it — pass it on stdin or from a file.

These are the same scripts `/agmsg` (or your configured command) itself
shells out to — there is no more-privileged internal path. Treat them as the
only sanctioned way to mutate agmsg state; nothing outside `scripts/` should
Expand Down
18 changes: 15 additions & 3 deletions scripts/drivers/types/antigravity/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ description: Cross-agent messaging via SQLite. Send messages between Claude Code

Agent messaging command. **IMPORTANT: Always use the provided scripts. NEVER directly read or edit config files, DB, or team data. There is NO register.sh — use join.sh to join a team.**

**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/__SKILL_NAME__/scripts/send.sh myteam alice bob "hello"'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).
**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/__SKILL_NAME__/scripts/inbox.sh myteam alice'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).

**Sending a message:** pass the body on stdin with `--stdin`, or from a file with `--body-file <path>`. Both read it verbatim from a file descriptor, so nothing you write is re-parsed by a shell or capped by an argv limit. The older positional form — `send.sh <team> <from> <to> "<message>"` — is **deprecated** (#378): your shell parses that message before agmsg ever sees it, so backticks or `$(...)` in the body can be evaluated there, and on Windows a long body is silently truncated at 8186 bytes. **A message you compose MUST NOT use the positional form.** If the body is literally `--`, `--stdin`, `--body-file`, or `--force`, put `--` in front of it: `send.sh <team> <from> <to> -- --stdin` — and for a body of `--`, that is `-- --`. Pick a heredoc delimiter the body cannot contain on a line by itself — a body with a bare `AGMSG_BODY` line would end the heredoc early and the rest would run as shell commands. When you cannot rule that out, use `--body-file`.

## Identity

Expand Down Expand Up @@ -82,7 +84,12 @@ Four possible outputs:
1. **IMMEDIATELY** run inbox check for each TEAM: `~/.agents/skills/__SKILL_NAME__/scripts/inbox.sh $TEAM $AGENT`
2. Do NOT ask the user what to do — just run the inbox check.
3. If there are messages, read and respond appropriately. To reply:
`~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> "<message>"`

```bash
~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> --stdin <<'AGMSG_BODY'
<message>
AGMSG_BODY
```

If argument is "history":
1. Run: `~/.agents/skills/__SKILL_NAME__/scripts/history.sh $TEAM $AGENT`
Expand All @@ -93,7 +100,12 @@ If argument is "team":
If argument starts with "send" (e.g. "send misaki check the server"):
1. Parse target agent and message from the arguments
2. Determine which team the target agent belongs to, then run:
`~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> "<message>"`

```bash
~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> --stdin <<'AGMSG_BODY'
<message>
AGMSG_BODY
```

If argument is "config":
1. Run: `~/.agents/skills/__SKILL_NAME__/scripts/config.sh show`
Expand Down
18 changes: 15 additions & 3 deletions scripts/drivers/types/claude-code/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ description: Agent messaging — check inbox, send messages, view history

Agent messaging command. **IMPORTANT: Always use the provided scripts. NEVER directly read or edit config files, DB, or team data. There is NO register.sh — use join.sh to join a team.**

**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/__SKILL_NAME__/scripts/send.sh myteam alice bob "hello"'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).
**Shell requirement:** All agmsg scripts are Bash scripts. Always execute them via `bash`, never via PowerShell or cmd directly. If your default shell is not Bash (e.g. PowerShell on Windows), wrap every command with `bash -lc '...'`. Example: `bash -lc '~/.agents/skills/__SKILL_NAME__/scripts/inbox.sh myteam alice'`. Do NOT construct DB paths manually — the scripts handle path resolution internally. If you need to redirect storage, use `AGMSG_STORAGE_PATH` (the supported override).

**Sending a message:** pass the body on stdin with `--stdin`, or from a file with `--body-file <path>`. Both read it verbatim from a file descriptor, so nothing you write is re-parsed by a shell or capped by an argv limit. The older positional form — `send.sh <team> <from> <to> "<message>"` — is **deprecated** (#378): your shell parses that message before agmsg ever sees it, so backticks or `$(...)` in the body can be evaluated there, and on Windows a long body is silently truncated at 8186 bytes. **A message you compose MUST NOT use the positional form.** If the body is literally `--`, `--stdin`, `--body-file`, or `--force`, put `--` in front of it: `send.sh <team> <from> <to> -- --stdin` — and for a body of `--`, that is `-- --`. Pick a heredoc delimiter the body cannot contain on a line by itself — a body with a bare `AGMSG_BODY` line would end the heredoc early and the rest would run as shell commands. When you cannot rule that out, use `--body-file`.

## Identity

Expand Down Expand Up @@ -119,7 +121,12 @@ The allowlist merges across scopes and takes effect immediately — no restart n
1. **IMMEDIATELY** run inbox check for each TEAM: `~/.agents/skills/__SKILL_NAME__/scripts/inbox.sh $TEAM $AGENT`
2. Do NOT ask the user what to do — just run the inbox check.
3. If there are messages, read and respond appropriately. To reply:
`~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> "<message>"`

```bash
~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> --stdin <<'AGMSG_BODY'
<message>
AGMSG_BODY
```

If argument is "history":
1. Run: `~/.agents/skills/__SKILL_NAME__/scripts/history.sh $TEAM $AGENT`
Expand All @@ -130,7 +137,12 @@ If argument is "team":
If argument starts with "send" (e.g. "send misaki check the server"):
1. Parse target agent and message from the arguments
2. Determine which team the target agent belongs to, then run:
`~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> "<message>"`

```bash
~/.agents/skills/__SKILL_NAME__/scripts/send.sh $TEAM $AGENT <to_agent> --stdin <<'AGMSG_BODY'
<message>
AGMSG_BODY
```

If argument starts with "actas" followed by an agent name (e.g. "actas alice"):
1. Parse the new role name. If none was given (e.g. bare "actas", or the user asks you to suggest one), run `~/.agents/skills/__SKILL_NAME__/scripts/team.sh <team>` for each TEAM to see the current roster. Look for a naming convention already in play (e.g. a shared base name with role/number suffixes like `aggie-cc1`/`aggie-cc2`, or names derived from the team name) and, when one exists, propose 2-3 unused names that extend it; otherwise propose 2-3 short, distinctive identity names (not a bare tool-type label). Either way, names must not collide with the roster. Ask the user to pick one or type their own before continuing.
Expand Down
Loading
Loading