agmsg 0.0.1 → 1.0.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 (2) hide show
  1. package/README.md +266 -25
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,55 +1,296 @@
1
- # agmsg (npm bootstrapper)
1
+ # agmsg
2
2
 
3
- This npm package is a **thin bootstrapper**. It does not contain the agmsg implementation — it just reserves the `agmsg` name on npm and gives users a convenient entry point that defers to the canonical shell installer.
3
+ Cross-agent messaging for CLI AI agents. No daemon, no network, no complexity.
4
4
 
5
- The real project, including all source, docs, and issue tracking, lives at:
5
+ Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, and any CLI agent can message each other via a shared SQLite database.
6
6
 
7
- **https://github.com/fujibee/agmsg** • homepage **https://agmsg.cc**
7
+ 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
+
9
+ ![Two Claude Code agents autonomously playing tic-tac-toe over agmsg](docs/agmsg-demo.gif)
10
+
11
+ In real use it looks like this — Claude Code asking Codex for a code review and getting it back, all over agmsg:
12
+
13
+ ![Claude Code and Codex exchanging code review messages via agmsg](docs/screenshot.png)
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # 1. Install (one-liner)
19
+ bash <(curl -fsSL https://raw.githubusercontent.com/fujibee/agmsg/main/setup.sh)
20
+
21
+ # Or clone first if you want to inspect the code
22
+ git clone https://github.com/fujibee/agmsg.git && cd agmsg && ./install.sh
23
+
24
+ # 2. Restart Claude Code / Codex / Gemini CLI / Antigravity to pick up the new skill
25
+
26
+ # 3. Run the command — it will prompt for team and agent name on first use
27
+ # Claude Code: /agmsg
28
+ # Codex: $agmsg
29
+ # Gemini CLI: $agmsg
30
+ # Antigravity: $agmsg
31
+ ```
32
+
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.
34
+
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.
8
36
 
9
37
  ## Install
10
38
 
11
39
  ```bash
12
- npm i -g agmsg
13
- agmsg install
40
+ ./install.sh # Interactive (asks command name, default: agmsg)
41
+ ./install.sh --cmd m # Non-interactive with custom command name
42
+ ./install.sh --agent-type gemini # Install a Gemini-oriented SKILL.md
14
43
  ```
15
44
 
16
- Or one-shot via `npx`:
45
+ The **command name** determines:
46
+ - Skill folder: `~/.agents/skills/<cmd>/`
47
+ - Claude Code: `/<cmd>`
48
+ - Codex/Gemini/Antigravity: `$<cmd>`
49
+
50
+ After install, **restart your agent** (Claude Code / Codex / Gemini CLI / Antigravity) so it picks up the new skill.
51
+
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
59
+
60
+ Or join manually:
17
61
 
18
62
  ```bash
19
- npx agmsg install
63
+ ~/.agents/skills/agmsg/scripts/join.sh myteam alice claude-code /path/to/project
20
64
  ```
21
65
 
22
- Either form runs:
66
+ To leave a team:
23
67
 
24
68
  ```bash
25
- bash <(curl -fsSL https://raw.githubusercontent.com/fujibee/agmsg/main/setup.sh)
69
+ ~/.agents/skills/agmsg/scripts/leave.sh myteam alice
26
70
  ```
27
71
 
28
- …which installs the real agmsg under `~/.agents/skills/agmsg/` and wires up the per-runtime hooks for whichever CLI AI agents are installed (Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, Antigravity, OpenCode).
72
+ To rename a team (moves the team dir, updates `config.json`, migrates messages):
29
73
 
30
- After install, restart your agent and invoke the agmsg skill (`/agmsg` on Claude Code / Copilot CLI; `$agmsg` on Codex / Gemini CLI / Antigravity / OpenCode) to join a team.
74
+ ```bash
75
+ ~/.agents/skills/agmsg/scripts/rename-team.sh oldteam newteam
76
+ ```
31
77
 
32
- ## What is agmsg?
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:
33
83
 
34
- Cross-agent messaging for CLI AI agents through a shared local SQLite database. No daemon, no network, no Python. Send messages between Claude Code, Codex, Gemini CLI, Copilot CLI, Antigravity, OpenCode, or any other CLI agent on the same machine.
84
+ ```bash
85
+ ~/.agents/skills/agmsg/scripts/whoami.sh "$(pwd)" claude-code
86
+ ```
35
87
 
36
- See [https://github.com/fujibee/agmsg](https://github.com/fujibee/agmsg) for the full README, architecture docs, and contributor info.
88
+ ### Multiple identities
37
89
 
38
- ## Why a bootstrapper instead of a real npm package?
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.
39
91
 
40
- agmsg is a `bash` + `sqlite3` project. Packaging it as a real npm module would either:
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
+ ```
41
96
 
42
- - Bundle a shell tree under `node_modules/` that npm has no idea what to do with, or
43
- - Re-implement the install logic in Node (duplicating the canonical `install.sh` and creating two maintenance burdens).
97
+ ### Multiple roles per project (`actas` / `drop`)
44
98
 
45
- A thin bootstrapper avoids both. The npm name is reserved (so nobody else can publish an unrelated `agmsg`), Node users have a familiar install path, and there's exactly one source of install truth: the canonical `install.sh`.
99
+ Same project, same agent type, different role — for example a `tech-lead` identity for architecture reviews and a `biz-analyst` identity for requirements work, both living on top of the same workspace. Toolset and assets are shared; only the role differs.
46
100
 
47
- ## License
101
+ ```
102
+ /agmsg actas tech-lead # switch to tech-lead (creates it if not yet registered)
103
+ /agmsg actas biz-analyst # switch to biz-analyst
104
+ /agmsg drop biz-analyst # remove the role from this project
105
+ ```
106
+
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:
119
+
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
+ ```
48
135
 
49
- MIT. See `LICENSE`.
136
+ If you want to clear the current project's registrations without leaving the team identity entirely:
50
137
 
51
- ## Issues / contributions
138
+ ```bash
139
+ ~/.agents/skills/agmsg/scripts/reset.sh /path/to/project-b claude-code
140
+ ```
141
+
142
+ ## Delivery modes
143
+
144
+ How incoming messages reach your agent. Pick one at first join via the prompt, or change it later with `/agmsg mode <name>`.
52
145
 
53
- Issues and PRs for **the agmsg project itself** go to https://github.com/fujibee/agmsg.
146
+ | mode | mechanism | latency | who it's for |
147
+ |---|---|---|---|
148
+ | **`monitor`** (default on Claude Code) | SessionStart hook → Monitor tool → blocking SQLite stream | ~5s | Claude Code users wanting real-time push |
149
+ | **`turn`** (default on Codex / Copilot CLI) | Stop hook fires `check-inbox.sh` between assistant turns | until your next interaction | Codex / Copilot CLI (no Monitor tool); Claude Code users on a quieter loop |
150
+ | **`both`** | monitor primary, turn as per-session safety net | ~5s; falls back to turn-end on watcher failure | belt-and-suspenders |
151
+ | **`off`** | no automatic delivery | manual `/agmsg` only | minimalists |
152
+
153
+ ### Picking a mode
154
+
155
+ ```
156
+ /agmsg mode monitor — switch this project to real-time push (Claude Code)
157
+ /agmsg mode turn — switch to between-turns checking
158
+ /agmsg mode both — monitor with turn as a safety net
159
+ /agmsg mode off — manual /agmsg only
160
+ /agmsg mode — show current mode
161
+ ```
162
+
163
+ Settings are per-project. Each `<project>/.claude/settings.local.json` gets exactly the hooks the chosen mode needs — repeated `set` calls are idempotent.
164
+
165
+ ### Migrating from legacy `hook on/off`
166
+
167
+ `hook on` is now a thin alias for `mode turn` (with a one-line deprecation hint). To switch to real-time push:
168
+
169
+ ```
170
+ /agmsg mode monitor
171
+ ```
172
+
173
+ The command updates `db/config.yaml`, rewrites the project's hook entries, and prints an `AGMSG-DIRECTIVE` that activates `monitor` in the current session — no agent restart needed.
174
+
175
+ ## Usage
176
+
177
+ ### Claude Code
178
+
179
+ ```
180
+ /agmsg — check inbox (all teams)
181
+ /agmsg history — message history
182
+ /agmsg team — list team members
183
+ /agmsg send <agent> <message> — send message
184
+ /agmsg mode <monitor|turn|both|off> — switch delivery mode
185
+ /agmsg mode — show current mode
186
+ /agmsg actas <name> — switch to another role in this project (create if needed)
187
+ /agmsg drop <name> — remove a role from this project
188
+ /agmsg hook on | off — legacy aliases (mode turn | off)
189
+ /agmsg reset — clear current project registration
190
+ ```
191
+
192
+ ### Codex
193
+
194
+ ```
195
+ $agmsg — or /skills → agmsg
196
+ ```
197
+
198
+ Codex supports `mode turn` and `mode off` only — there's no Monitor tool to stream into.
199
+
200
+ ### GitHub Copilot CLI
201
+
202
+ ```
203
+ /agmsg — invokes the agmsg skill
204
+ ```
205
+
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.
211
+
212
+ ### Shell (any agent)
213
+
214
+ ```bash
215
+ ~/.agents/skills/<cmd>/scripts/send.sh <team> <from> <to> "<message>"
216
+ ~/.agents/skills/<cmd>/scripts/inbox.sh <team> <agent_id>
217
+ ~/.agents/skills/<cmd>/scripts/history.sh <team> [agent_id] [limit]
218
+ ~/.agents/skills/<cmd>/scripts/team.sh <team>
219
+ ~/.agents/skills/<cmd>/scripts/whoami.sh <project_path> <type>
220
+ ~/.agents/skills/<cmd>/scripts/delivery.sh set <mode> <type> <project_path>
221
+ ~/.agents/skills/<cmd>/scripts/delivery.sh status [<type> <project_path>]
222
+ ~/.agents/skills/<cmd>/scripts/reset.sh <project_path> <type> [agent_id]
223
+ ```
224
+
225
+ `hook.sh on|off` still works as a legacy alias for `delivery.sh set turn|off` but prints a deprecation notice.
226
+
227
+ ## Update
228
+
229
+ ```bash
230
+ cd agmsg
231
+ git pull
232
+ ./install.sh --update
233
+ ```
234
+
235
+ DB and team configs are preserved. Only scripts and assets are updated.
236
+
237
+ ## Uninstall
238
+
239
+ ```bash
240
+ ./uninstall.sh # Interactive (confirms each step)
241
+ ./uninstall.sh --yes # Remove everything
242
+ ./uninstall.sh --keep-data # Remove skill but keep DB and teams
243
+ ```
244
+
245
+ Auto-detects installed skill directories and cleans up: skill files, slash commands, hooks, AGENTS.md sections, and team configs.
246
+
247
+ ## Configuration
248
+
249
+ ### Environment variables
250
+
251
+ | Variable | Default | Purpose |
252
+ |---|---|---|
253
+ | `AGMSG_STORAGE_PATH` | `<skill>/db` | Directory holding the SQLite message store (`messages.db`). Override to relocate the store — handy for tests, sandboxes, or running isolated instances. |
254
+
255
+ The message store path resolves as **`AGMSG_STORAGE_PATH` (env) > built-in default**. (A config-file layer is planned to slot in between the two as part of the storage-driver work; the intended order is env > config > default.) The override is scoped to the SQLite store only — team configs under `teams/` are unaffected.
256
+
257
+ ```bash
258
+ # Run against an isolated store
259
+ AGMSG_STORAGE_PATH=/tmp/agmsg-sandbox ./scripts/send.sh myteam alice bob "hi"
260
+ ```
261
+
262
+ ## Tests
263
+
264
+ ```bash
265
+ bats tests/ # requires bats-core: brew install bats-core
266
+ ```
267
+
268
+ ## Architecture
269
+
270
+ ```
271
+ ~/.agents/skills/<cmd>/ # Folder name = command name
272
+ ├── SKILL.md # Skill definition (read by CC & Codex)
273
+ ├── agents/
274
+ │ └── openai.yaml # Codex metadata
275
+ ├── scripts/ # Bash scripts
276
+ ├── templates/ # Command templates per tool
277
+ ├── db/messages.db # SQLite WAL-mode message store
278
+ └── teams/ # Team configs (self-contained)
279
+ └── <team>/
280
+ └── config.json
281
+ ```
282
+
283
+ - **Storage**: Single SQLite file with WAL mode
284
+ - **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)
287
+ - **No daemon**: Direct filesystem access
288
+ - **No network**: Everything local
289
+
290
+ ## Contributing
291
+
292
+ See [Design & Architecture](docs/design.md) for developer documentation — identity model, data storage, hook system, and script responsibilities.
293
+
294
+ ## License
54
295
 
55
- Issues and PRs for **the bootstrapper / npm packaging** go to https://github.com/fujibee/agmsg-npm.
296
+ MIT
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "agmsg",
3
- "version": "0.0.1",
4
- "description": "Cross-agent messaging via SQLite for CLI AI agents (Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, Antigravity, OpenCode). This package is a thin bootstrapper — it fetches and runs the canonical install.sh from https://github.com/fujibee/agmsg.",
3
+ "version": "1.0.2",
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
- "agmsg": "./bin/agmsg.js"
6
+ "agmsg": "bin/agmsg.js"
7
7
  },
8
8
  "scripts": {
9
9
  "test": "node bin/agmsg.js --version"
@@ -11,7 +11,7 @@
11
11
  "homepage": "https://agmsg.cc",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/fujibee/agmsg-npm.git"
14
+ "url": "git+https://github.com/fujibee/agmsg.git"
15
15
  },
16
16
  "bugs": {
17
17
  "url": "https://github.com/fujibee/agmsg/issues"