agmsg 1.0.2 → 1.0.3

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 +93 -79
  2. package/bin/agmsg.js +45 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,24 @@
2
2
 
3
3
  Cross-agent messaging for CLI AI agents. No daemon, no network, no complexity.
4
4
 
5
- Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, and any CLI agent can message each other via a shared SQLite database.
5
+ <a href="https://www.producthunt.com/products/agmsg?utm_source=badge-top-post-badge&utm_medium=badge" target="_blank">
6
+ <picture>
7
+ <source media="(prefers-color-scheme: dark)"
8
+ srcset="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=1165435&theme=dark&period=daily">
9
+ <img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=1165435&theme=light&period=daily"
10
+ alt="agmsg — #5 Product of the Day on Product Hunt" width="250" height="54">
11
+ </picture>
12
+ </a>
13
+
14
+ You stop being the copy-paste courier between your agents. Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, and any other CLI agent message each other directly through a shared local SQLite database — no human in the middle.
15
+
16
+ **What it isn't:**
17
+
18
+ - Not MCP. No MCP server, no extra runtime — just `bash` + `sqlite3`.
19
+ - Not subagents. agmsg connects *peer* sessions across different tools; it doesn't spawn child processes.
20
+ - Not a message queue. There's no broker. The SQLite file is the floor; agents are the players.
21
+
22
+ ## Demo
6
23
 
7
24
  Two `monitor`-mode Claude Code instances, left alone in the same team, play tic-tac-toe against each other with no human in the loop — each picks up the other's move in real time:
8
25
 
@@ -30,9 +47,13 @@ git clone https://github.com/fujibee/agmsg.git && cd agmsg && ./install.sh
30
47
  # Antigravity: $agmsg
31
48
  ```
32
49
 
33
- That's it. Once two agents have joined the same team, they can message each other. On first join, you'll be asked to pick a **delivery mode** — see [Delivery modes](#delivery-modes) below for the four options. The default on Claude Code is `monitor` (real-time push); Codex defaults to `turn` (between-turns check) because it has no Monitor tool.
50
+ That's it. The slash command prompts you for a team name and an agent name on first use, then asks you to pick a [delivery mode](#delivery-modes) (default on Claude Code: `monitor` — real-time push; Codex defaults to `turn` because it has no Monitor tool). After that, you talk to your agent naturally — see [First run](#first-run) below.
34
51
 
35
- After setup, your agent handles everything — just talk to it naturally. "Send alice a message saying the deploy is done", "check my messages", "who's on the team" all work. The shell scripts below are for reference and advanced use.
52
+ ## How it works
53
+
54
+ agmsg is a thin transport. Each agent has a hook (or a Monitor stream, depending on delivery mode) that reads from a shared SQLite file and surfaces incoming messages as text the agent can react to. Sending is a `send.sh` call that appends a row. There is no daemon, no socket, no broker — the file is the shared floor and the agents take turns on it.
55
+
56
+ The store is WAL-mode SQLite, so multiple readers and a single writer coexist without conflicts. History is durable: messages stay in the DB after the session ends, and `history.sh` can replay an old room into a fresh agent.
36
57
 
37
58
  ## Install
38
59
 
@@ -49,50 +70,24 @@ The **command name** determines:
49
70
 
50
71
  After install, **restart your agent** (Claude Code / Codex / Gemini CLI / Antigravity) so it picks up the new skill.
51
72
 
52
- ## Join a Team
53
-
54
- Agents join teams by **identity**: `(agent name, team)`. Projects are stored as registration metadata, so the same agent can re-join from multiple projects without creating duplicate identities. The easiest way:
55
-
56
- 1. Open Claude Code in your project
57
- 2. Run `/<cmd>` (e.g. `/agmsg`)
58
- 3. It detects you're not in a team and asks for team name and agent name
73
+ ## First run
59
74
 
60
- Or join manually:
75
+ Open your project in your agent (Claude Code, Codex, Gemini CLI, etc.) and run:
61
76
 
62
- ```bash
63
- ~/.agents/skills/agmsg/scripts/join.sh myteam alice claude-code /path/to/project
64
77
  ```
65
-
66
- To leave a team:
67
-
68
- ```bash
69
- ~/.agents/skills/agmsg/scripts/leave.sh myteam alice
78
+ /agmsg # Claude Code, Copilot CLI
79
+ $agmsg # Codex, Gemini CLI, Antigravity
70
80
  ```
71
81
 
72
- To rename a team (moves the team dir, updates `config.json`, migrates messages):
82
+ On first use it asks for a **team name** (joins an existing team or creates a new one) and an **agent name** for this project — that's the whole onboarding. After that, talk to your agent naturally:
73
83
 
74
- ```bash
75
- ~/.agents/skills/agmsg/scripts/rename-team.sh oldteam newteam
76
- ```
84
+ - *"send alice a message saying the deploy is done"*
85
+ - *"check my messages"*
86
+ - *"who's on the team"*
77
87
 
78
- **Effect on existing members:** all agents in the team keep their registrations
79
- and message history — only the team name changes. However, any session that has
80
- already cached the team name (e.g. a running `/agmsg` Claude Code session) will
81
- continue to use the old name until it re-resolves identity. After a rename,
82
- each member should re-run `whoami` from their project to pick up the new name:
88
+ The agent picks the right subcommand and runs it for you. You don't need to memorize anything below — the script reference further down is for automation, scripts, and CI.
83
89
 
84
- ```bash
85
- ~/.agents/skills/agmsg/scripts/whoami.sh "$(pwd)" claude-code
86
- ```
87
-
88
- ### Multiple identities
89
-
90
- You can join the same project with multiple agent names (e.g. `cc` and `reviewer`). When the command detects multiple identities, it asks which one to use for the session.
91
-
92
- ```bash
93
- ~/.agents/skills/agmsg/scripts/join.sh myteam cc claude-code /path/to/project
94
- ~/.agents/skills/agmsg/scripts/join.sh myteam reviewer claude-code /path/to/project
95
- ```
90
+ For renaming a team, leaving, joining the same team from a second project, or clearing a project's registrations, see [docs/teams.md](docs/teams.md).
96
91
 
97
92
  ### Multiple roles per project (`actas` / `drop`)
98
93
 
@@ -104,40 +99,9 @@ Same project, same agent type, different role — for example a `tech-lead` iden
104
99
  /agmsg drop biz-analyst # remove the role from this project
105
100
  ```
106
101
 
107
- Mechanics:
108
-
109
- - `actas <name>` is **exclusive across sessions**: switches both sending and receiving to `<name>`. The skill joins the role under your current team if needed, claims an exclusivity lock on `(team, name)` under the skill's run directory, then TaskStops the running `agmsg inbox stream` Monitor and relaunches one filtered to `<name>` only (via `watch.sh`'s optional 4th argument). Two effects: messages addressed to other roles stop reaching this session, and other live sessions also stop subscribing to `<name>` (their watchers exclude any pair locked by a peer at startup). If another session already holds the lock, the call refuses with a clear error — drop it from that session first. The lock is released by `drop`, by session end, or by garbage collection when the holding session is no longer alive.
110
- - `drop <name>` removes only that role's registration for this project (via `reset.sh`). If the role is no longer registered anywhere, it's also dropped from the team config. If `<name>` was the currently-active role, the watcher is restarted in default mode — no `actas` name filter, so it receives every (team, agent) pair registered for this project that isn't held by another session.
111
- - Switching is session-scoped state held by the agent. `/clear` or a new session resets back to the multiple-identities picker.
112
- - **Recovery**: `actas-claim.sh` writes the lock file before the skill TaskStops the old Monitor and launches the new one. If that subsequent dance fails (e.g. TaskStop succeeds but the new Monitor invocation errors out), the lock stays put but the session has no narrowed watcher. Run `/agmsg drop <name>` in this session, or end the session — either releases the lock so peers can pick it up.
113
- - **Liveness**: a stale lock is reclaimed when its owner session_id no longer maps to any live cc-instance, where "live" is checked via `kill -0`. PID recycling could in theory keep a long-dead session looking alive forever (and starve peers from claiming or reaching its name); this is tracked in [#67](https://github.com/fujibee/agmsg/issues/67) and not addressed in v1.
114
- - **Codex caveat**: on Codex, `$agmsg actas <name>` is **send-side only** for this session. Codex slash commands don't see a stable `session_id`, so they can't claim a peer-visible exclusivity lock — Claude Code peers will still subscribe to `<name>`. The receive side isn't actually narrowed either: `check-inbox.sh` resolves identity through `whoami.sh` (which picks the first registered agent) and has no view of the agent's in-session actas role, so Codex keeps polling whichever pair it would have without actas. The check-inbox lock filter only skips pairs *another* session owns. Treat Codex actas as a from-line override until a Codex session-id story exists. Claude Code's `/agmsg actas` does claim the lock symmetrically and is the path that exercises the full exclusivity model.
115
-
116
- #### Subscription model
117
-
118
- agmsg follows a **one CC session = one active role** model. Each watcher subscribes to a *static* set of identities decided at launch:
102
+ `actas <name>` is **exclusive across sessions**: it switches both sending and receiving to `<name>`, claims a lock that stops peer sessions from subscribing to the same name, and refuses if another session already holds it. `drop` releases the lock. If a lock gets stuck, drop the role from the holding session or end that session.
119
103
 
120
- - **Without `actas`**: the watcher subscribes to whichever `(team, agent)` pairs were registered for this `(project, agent_type)` at the moment `watch.sh` started, *minus* any pair currently locked by another live session's `actas` claim. The set is *not* re-resolved later — a peer that claims a name after this watcher launched will start receiving exclusively, but this watcher won't notice the loss until it restarts. A role joined mid-session via `actas` from another CC does *not* start arriving in CCs that were launched before it.
121
- - **After `actas <name>`**: the watcher is relaunched filtered to `<name>` only, and the lock that filter implies prevents peer watchers from ever subscribing to `<name>` while this session is live.
122
-
123
- This is intentional: it keeps each CC bound to one role's inbox, so a `tech-lead` window stays clear of `biz-analyst` traffic and vice versa, and the exclusivity holds across sessions on the same machine rather than per-session. To pick up a role added after a CC launched (without switching to it exclusively), restart the CC or `/clear` so SessionStart re-launches `watch.sh` with the fresh identity list — and with the up-to-date lock view.
124
-
125
- The send side mirrors this: every `send.sh` call from this CC uses the active role as the `from` agent, whether that's the implicit one (default) or the one set by the most recent `actas`.
126
-
127
- ### Reusing the same identity across projects
128
-
129
- If you join the same team with the same agent name from another project, agmsg keeps the same identity and adds a registration record for the new project.
130
-
131
- ```bash
132
- ~/.agents/skills/agmsg/scripts/join.sh myteam alice claude-code /path/to/project-a
133
- ~/.agents/skills/agmsg/scripts/join.sh myteam alice claude-code /path/to/project-b
134
- ```
135
-
136
- If you want to clear the current project's registrations without leaving the team identity entirely:
137
-
138
- ```bash
139
- ~/.agents/skills/agmsg/scripts/reset.sh /path/to/project-b claude-code
140
- ```
104
+ See [docs/actas.md](docs/actas.md) for the full mechanics — exclusivity model, recovery, liveness / PID recycling, Codex caveat.
141
105
 
142
106
  ## Delivery modes
143
107
 
@@ -162,6 +126,8 @@ How incoming messages reach your agent. Pick one at first join via the prompt, o
162
126
 
163
127
  Settings are per-project. Each `<project>/.claude/settings.local.json` gets exactly the hooks the chosen mode needs — repeated `set` calls are idempotent.
164
128
 
129
+ **Monitor priming**: in `monitor` mode, the receiving agent doesn't react to its first inbound message until it has taken at least one turn this session. If you've just started a fresh session and a teammate has already sent something, nudge the agent with any short message ("hi") to prime it — subsequent messages stream in real time.
130
+
165
131
  ### Migrating from legacy `hook on/off`
166
132
 
167
133
  `hook on` is now a thin alias for `mode turn` (with a one-line deprecation hint). To switch to real-time push:
@@ -203,11 +169,7 @@ Codex supports `mode turn` and `mode off` only — there's no Monitor tool to st
203
169
  /agmsg — invokes the agmsg skill
204
170
  ```
205
171
 
206
- The Copilot installer drops a `SKILL.md` at `~/.copilot/skills/agmsg/` so
207
- `/agmsg` is auto-discovered. Per-project hooks live at
208
- `<project>/.github/hooks/agmsg.json`. Copilot CLI has no Monitor-tool
209
- equivalent, so only `mode turn` and `mode off` are supported. Asking for
210
- `monitor` or `both` is rejected with an error.
172
+ The Copilot installer drops a `SKILL.md` at `~/.copilot/skills/agmsg/` so `/agmsg` is auto-discovered. Per-project hooks live at `<project>/.github/hooks/agmsg.json`. Copilot CLI has no Monitor-tool equivalent, so only `mode turn` and `mode off` are supported. Asking for `monitor` or `both` is rejected with an error.
211
173
 
212
174
  ### Shell (any agent)
213
175
 
@@ -222,8 +184,52 @@ equivalent, so only `mode turn` and `mode off` are supported. Asking for
222
184
  ~/.agents/skills/<cmd>/scripts/reset.sh <project_path> <type> [agent_id]
223
185
  ```
224
186
 
187
+ `send.sh` takes exactly four positional arguments: `<team> <from> <to> "<message>"`. Quote the message so the shell sees it as one argument; an unquoted message with spaces will be misparsed.
188
+
225
189
  `hook.sh on|off` still works as a legacy alias for `delivery.sh set turn|off` but prints a deprecation notice.
226
190
 
191
+ ## FAQ / Design notes
192
+
193
+ **Is this MCP? Do I need an MCP server?**
194
+
195
+ No. agmsg is standalone — `bash` + `sqlite3`, no server, no daemon, no network. The two stacks are orthogonal: you can run agmsg alongside any MCP setup you already have.
196
+
197
+ **Concurrent writes to the same channel — do they conflict?**
198
+
199
+ The store is SQLite in WAL mode. Multiple readers and a single writer coexist; writes are short and serialized at the file level. In practice, two agents sending into the same team don't collide.
200
+
201
+ **Does SQLite guarantee turn order? Is there a lock or token?**
202
+
203
+ SQLite guarantees the ordering of the log itself — every row has a monotonic id and timestamp. Turn-taking between agents is a protocol-level concern, not enforced by the transport. The floor is intentionally dumb; the protocol lives in your prompts.
204
+
205
+ **Two Claude Code instances grab the same task — claim/lock?**
206
+
207
+ Not in v1. If two agents are subscribed to the same name, both see the same inbound message, and you'd need a protocol-level claim/lease to decide who acts. A claim table is on the roadmap; the `actas` exclusivity lock already prevents two *sessions* from holding the same role at once, which covers the most common form of this.
208
+
209
+ **Runaway loops — where does the stop condition live?**
210
+
211
+ At the protocol/prompt level, not the transport. Common pattern: include a max-turns or explicit done-signal instruction in the kickoff prompt ("stop after N exchanges", "reply DONE when complete"). agmsg won't cut a conversation off for you.
212
+
213
+ **What's carried on a handoff — context, diffs, or just text?**
214
+
215
+ Plain text. Messages are short — a sentence, a request, a path. Agents pass *summaries and references* (file paths, commit SHAs, issue numbers), not raw context. Transport is the message; semantic packing is up to the prompt.
216
+
217
+ **What if the output exceeds the receiver's context window?**
218
+
219
+ Use the summary + file-reference pattern: write the artifact to disk, send a one-line pointer. The DB stores messages, not files.
220
+
221
+ **Does it hold up with more than 2 agents?**
222
+
223
+ Yes. Teams are N-agent. The demo is 2 for clarity; larger rooms work the same way — we run our own 8-agent team on it.
224
+
225
+ **Does context persist across sessions?**
226
+
227
+ Yes. Messages live in SQLite and survive sessions. `history.sh <team>` replays the room.
228
+
229
+ **Can I re-seed a fresh agent from an old room?**
230
+
231
+ The message store is effectively a replay log. There's no one-shot "rehydrate from room X" command yet, but `history.sh` gives you the transcript and you can prompt a new agent with it. Treat persistence as the unlock that makes that possible.
232
+
227
233
  ## Update
228
234
 
229
235
  ```bash
@@ -282,15 +288,23 @@ bats tests/ # requires bats-core: brew install bats-core
282
288
 
283
289
  - **Storage**: Single SQLite file with WAL mode
284
290
  - **Concurrency**: Multiple readers + 1 writer, no conflicts
285
- - **Dependencies**: bash, sqlite3 (no python3 required)
286
- - **Auto detection**: Stop hook checks inbox after each response (60s cooldown)
291
+ - **Dependencies**: `bash`, `sqlite3` (no Python required)
292
+ - **Auto detection**: Stop hook checks inbox after each response (60s cooldown, configurable via `hook.check_interval`)
287
293
  - **No daemon**: Direct filesystem access
288
294
  - **No network**: Everything local
289
295
 
296
+ ## Community
297
+
298
+ - **Product Hunt**: #5 Product of the Day, [2026-06-09 launch](https://www.producthunt.com/products/agmsg) — 219 upvotes, 39 comments
299
+ - **Derivative projects**: `agmsg-shogi`, `agmsg-go`, `agmsg-mcp` (community-built)
300
+ - **External contributors**: [@MiuraKatsu](https://github.com/MiuraKatsu) (Gemini support + whoami auto-detect), [@roundrop](https://github.com/roundrop) (Copilot CLI support), [@TOMONOSUKEJP](https://github.com/TOMONOSUKEJP) (native Windows / Git Bash), [@kenshin-yamada](https://github.com/kenshin-yamada) (watcher scoping fix), [@utenadev](https://github.com/utenadev) (OpenCode contribution)
301
+
290
302
  ## Contributing
291
303
 
292
304
  See [Design & Architecture](docs/design.md) for developer documentation — identity model, data storage, hook system, and script responsibilities.
293
305
 
306
+ If agmsg saves you copy-paste round-trips, a GitHub star helps other people find it.
307
+
294
308
  ## License
295
309
 
296
310
  MIT
package/bin/agmsg.js CHANGED
@@ -8,10 +8,17 @@
8
8
  // installer maintained at https://github.com/fujibee/agmsg.
9
9
  //
10
10
  // All real installation, configuration, and runtime logic lives in the
11
- // upstream repo. This bootstrapper just runs:
11
+ // canonical setup.sh. This bootstrapper fetches that script to a tempfile
12
+ // and exec's it directly — equivalent to the README's
12
13
  //
13
14
  // bash <(curl -fsSL https://raw.githubusercontent.com/fujibee/agmsg/main/setup.sh)
14
15
  //
16
+ // form, which is process-substitution and preserves the user's tty as
17
+ // stdin. We deliberately do NOT pipe the curl output into bash: piping
18
+ // makes the installer's stdin the wrapper script stream, and install.sh's
19
+ // interactive command-name prompt would `read -r` the next line of
20
+ // setup.sh as the command name. See agmsg #98.
21
+ //
15
22
  // Subcommands:
16
23
  // install Fetch and run the canonical setup.sh (default if no args).
17
24
  // --help Print this message and exit 0.
@@ -19,6 +26,7 @@
19
26
 
20
27
  const { spawnSync } = require('child_process');
21
28
  const fs = require('fs');
29
+ const os = require('os');
22
30
  const path = require('path');
23
31
 
24
32
  const SETUP_URL = 'https://raw.githubusercontent.com/fujibee/agmsg/main/setup.sh';
@@ -57,24 +65,48 @@ function printHelp() {
57
65
  ].join('\n'));
58
66
  }
59
67
 
60
- function runInstaller() {
61
- // We deliberately invoke `bash -c "curl ... | bash"` rather than piping
62
- // through Node's HTTP stack. The canonical installer is bash; that's the
63
- // path upstream tests and supports. We pass `-fsSL` so curl fails on
64
- // HTTP errors rather than piping an error page into bash.
65
- const cmd = 'curl -fsSL "' + SETUP_URL + '" | bash';
66
- const result = spawnSync('bash', ['-c', cmd], { stdio: 'inherit' });
67
- if (result.error) {
68
- console.error('agmsg: failed to launch bash:', result.error.message);
69
- process.exit(1);
68
+ function runInstaller(passthroughArgs) {
69
+ // Fetch the canonical setup.sh to a private tempdir, then exec it directly
70
+ // with bash. This keeps the installer's stdin wired to the parent process's
71
+ // tty rather than a pipe stream — which matters because install.sh has an
72
+ // interactive `Command name [agmsg]:` prompt that would otherwise read the
73
+ // next line of setup.sh as the command name. See agmsg #98 for the full
74
+ // diagnosis. install.sh now guards itself with `[ -t 0 ]` (PR #99), so this
75
+ // bootstrapper plus a still-vulnerable install.sh would also work; doing it
76
+ // correctly here is defense-in-depth and lets future interactive prompts
77
+ // in setup.sh keep working for real-tty users.
78
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agmsg-bootstrap-'));
79
+ const setupPath = path.join(tmpDir, 'setup.sh');
80
+
81
+ try {
82
+ const fetch = spawnSync('curl', ['-fsSL', '-o', setupPath, SETUP_URL], { stdio: 'inherit' });
83
+ if (fetch.error) {
84
+ console.error('agmsg: failed to launch curl:', fetch.error.message);
85
+ process.exit(1);
86
+ }
87
+ if (fetch.status !== 0) {
88
+ console.error('agmsg: curl exited ' + fetch.status + ' fetching ' + SETUP_URL);
89
+ process.exit(fetch.status || 1);
90
+ }
91
+
92
+ const result = spawnSync('bash', [setupPath, ...passthroughArgs], { stdio: 'inherit' });
93
+ if (result.error) {
94
+ console.error('agmsg: failed to launch bash:', result.error.message);
95
+ process.exit(1);
96
+ }
97
+ process.exit(result.status === null ? 1 : result.status);
98
+ } finally {
99
+ try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch (_) { /* best-effort */ }
70
100
  }
71
- process.exit(result.status === null ? 1 : result.status);
72
101
  }
73
102
 
74
103
  const args = process.argv.slice(2);
75
104
 
76
105
  if (args.length === 0 || args[0] === 'install') {
77
- runInstaller();
106
+ // Forward anything after `install` (e.g. `agmsg install --cmd m`) to
107
+ // setup.sh, which passes "$@" through to install.sh.
108
+ const passthrough = args[0] === 'install' ? args.slice(1) : args;
109
+ runInstaller(passthrough);
78
110
  } else if (args[0] === '--help' || args[0] === '-h' || args[0] === 'help') {
79
111
  printHelp();
80
112
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agmsg",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Cross-agent messaging via SQLite for CLI AI agents (Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, Antigravity, OpenCode). The npm package is a thin bootstrapper that fetches and runs the canonical bash installer at https://github.com/fujibee/agmsg.",
5
5
  "bin": {
6
6
  "agmsg": "bin/agmsg.js"