Skip to content
Merged
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
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ name: release

# A release is published when a release pull request is merged: the merge
# changes `version` in plugin.json on main, and this workflow tags that commit
# and publishes it. Pushing a v* tag by hand still works as a fallback.
# and publishes it. A manual run can publish the version on main. Pushing a
# v* tag by hand still works as a fallback.
on:
push:
branches: [main]
paths: ["plugin/.claude-plugin/plugin.json"]
tags: ["v*"]
workflow_dispatch:

permissions:
contents: write
Expand All @@ -19,6 +21,8 @@ concurrency:

jobs:
release:
# Manual release runs must use main as their source commit.
if: github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file is shared project guidance for coding agents that read `AGENTS.md` (in

agent-quorum coordinates coding-agent sessions that share one working tree. A local daemon tracks sessions and file claims. Agent-specific hooks are adapters around a neutral wire protocol; keep agent JSON and output formats out of the daemon and core.

Codex and Claude Code hooks are implemented. Codex support lives in `internal/adapter/codex/`, its compatibility manifest is `plugin/.codex-plugin/plugin.json`, and its hook config is `plugin/hooks/codex.json`. Codex hooks currently register sessions, record prompts, guard Bash git commands, and claim paths in `apply_patch`. Antigravity and other agents do not have adapters unless one is added explicitly; do not describe them as supported based only on this shared instruction file.
Claude Code, Codex, and Antigravity hooks are implemented. Codex support lives in `internal/adapter/codex/`, its compatibility manifest is `plugin/.codex-plugin/plugin.json`, and its hook config is `plugin/hooks/codex.json`. Codex hooks currently register sessions, record prompts, guard Bash git commands, and claim paths in `apply_patch`. Antigravity support lives in `internal/adapter/antigravity/`, its manifest is `plugin/.antigravity-plugin/plugin.json`, and its hooks are in `plugin/hooks.json`; it registers lifecycle events, records prompts, guards `run_command`, and claims paths for Antigravity's file write and edit tools.

## Working in this repository

Expand Down
7 changes: 5 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

agent-quorum is local coordination for concurrent coding-agent sessions that share **one working tree** (no worktrees): it stops sessions from editing the same uncommitted file, blocks tree-wide git commands that would clobber another session's work, and lets sessions see each other.

**Current state:** the daemon, hook client, Claude Code and Codex adapters, git guard, presence and the `check --staged` pre-commit backstop are implemented. Codex hooks cover lifecycle registration, prompt notes, Bash guards and `apply_patch` claims. `PostToolUse` detection of shell edits, the notes mailbox and MCP server, and the mod are not built. Releases are published from tags by `release.yml`; `make dev` runs the local build.
**Current state:** the daemon, hook client, Claude Code, Codex and Antigravity adapters, git guard, presence and the `check --staged` pre-commit backstop are implemented. Codex hooks cover lifecycle registration, prompt notes, Bash guards and `apply_patch` claims. Antigravity hooks register sessions, refresh peer context on prompts, guard `run_command`, and claim paths for native file write/edit tools. `PostToolUse` detection of shell edits, the notes mailbox and MCP server, and the mod are not built. Releases are published from tags by `release.yml`; `make dev` runs the local build.

`docs/DESIGN.md` is the design rationale. Read the relevant section before changing behaviour, but the code wins where they differ (known differences: the hook budget is 1.5 s rather than 250 ms, and the project is no longer standard-library-only). `docs/` is in `.gitignore`, so the design doc is local-only and absent from a fresh clone and from CI. `README.md` is the public description; `CONTRIBUTING.md` holds the dev guide, the semantic versioning rules and the release SOP, which must be followed before any tag.

Expand All @@ -20,6 +20,7 @@ agent-quorum is local coordination for concurrent coding-agent sessions that sha
| `make vet` | `go vet` plus a gofmt check that fails on unformatted files |
| `make lint` | `sh -n` and shellcheck (optional locally, enforced in CI) on all scripts; `jq` on the plugin JSON |
| `make validate-plugin` | `claude plugin validate` on `./plugin` (`--strict`) and on the marketplace root |
| `make validate-antigravity-plugin` | `agy plugin validate ./plugin` (allows the expected ignored Claude hook file warning) |
| `make dev` | Build, then start Claude Code with the local plugin and `AGENT_QUORUM_BIN` pointing at the local binary |
| `make snapshot` | Cross-compile all four release archives into `./dist` |
| `make release V=1.2.3` | Check, then open the release pull request (`release/v1.2.3`). Merging it publishes the release. |
Expand Down Expand Up @@ -52,6 +53,7 @@ internal/core/ State, Session, Claim, decisions
internal/guard/ Classify(command) Risk
internal/adapter/claude/ Parse, Render
internal/adapter/codex/ Parse, Render
internal/adapter/antigravity/ Parse, Render
internal/daemon/ socket server, lock, snapshot, real Env
internal/client/ dial, start-on-demand, deadlines
internal/gitx/ thin wrappers over the git CLI
Expand Down Expand Up @@ -80,12 +82,13 @@ internal/gitx/ thin wrappers over the git CLI

The repo root is both a Claude Code and Codex marketplace (`.claude-plugin/marketplace.json`, name `agent-quorum-tools`) with one plugin at `./plugin`.

- `plugin/.claude-plugin/plugin.json` is the release version source of truth; keep its version mirrored in `plugin/.codex-plugin/plugin.json`. `make release` updates both, accepts `1.2.3` and pre-releases such as `1.2.3-rc.1`, and opens a release pull request. A version change landing on `main` is what triggers `release.yml` to tag and publish.
- `plugin/.claude-plugin/plugin.json` is the release version source of truth; keep its version mirrored in `plugin/.codex-plugin/plugin.json` and `plugin/.antigravity-plugin/plugin.json`. `make release` updates all three, accepts `1.2.3` and pre-releases such as `1.2.3-rc.1`, and opens a release pull request. A version change landing on `main` is what triggers `release.yml` to tag and publish.
- `main` is protected: every change, including a release, goes through a pull request. Never push to `main`, and never create release tags by hand.
- Marketplace channels are the branches `stable` and `latest`, moved only by `scripts/publish-channels.sh` from `release.yml` after the binaries are published. Never commit to them by hand. `CONTRIBUTING.md` (CI/CD) has the rules.
- The plugin ships shell scripts only, in `scripts/` (a top-level `bin/` is rejected by claude.ai and Cowork). The binary is downloaded from GitHub Releases to `~/.agent-quorum/bin/agent-quorum-<version>` by `install.sh`, with checksum verification and an atomic move.
- Every hook goes through `plugin/scripts/agent-quorum.sh`, which resolves `$AGENT_QUORUM_BIN`, then the versioned installed binary, then `agent-quorum` on `PATH`, and exits 0 if none exists.
- Codex hooks are declared by `plugin/.codex-plugin/plugin.json` and `plugin/hooks/codex.json`; use `${PLUGIN_ROOT}` for plugin files and keep Codex hook payload translation in `internal/adapter/codex`.
- Antigravity hooks are declared by `plugin/.antigravity-plugin/plugin.json` and `plugin/hooks.json`; keep Antigravity payload translation in `internal/adapter/antigravity` and validate the package with `make validate-antigravity-plugin` when `agy` is available.
- Hooks use exec form (`args` present) and the launcher uses `exec`, so that `getppid()` in the binary is the agent process. Liveness detection depends on this; do not insert a shell between them.
- Hooks for one event run in parallel, so install-then-register on `SessionStart` is one script (`session-start.sh`), not two hooks.
- Scripts are POSIX `sh`, must pass shellcheck, and parse `plugin.json` with `sed` (no `jq` at runtime on user machines).
Expand Down
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Thanks for helping. This file covers the dev loop, the rules the code lives by,
- `shellcheck` (optional locally, enforced in CI)
- the `claude` CLI, for `make validate-plugin` and for trying the plugin by hand
- the `codex` CLI, for installing and checking the Codex marketplace package locally
- the `agy` CLI, for validating the Antigravity plugin (`make validate-antigravity-plugin`)
- `git`, `curl`, `tar`
- macOS or Linux

Expand All @@ -30,6 +31,7 @@ Every make target:
| `make lint` | `sh -n` and shellcheck on `plugin/scripts/*.sh` and `scripts/*.sh`, and `jq empty` on the marketplace, plugin and hooks JSON. |
| `make check` | `vet`, `lint`, `test`. |
| `make validate-plugin` | Validates the Claude plugin and marketplace, then discovers and installs the Codex plugin in a temporary `CODEX_HOME`. Needs the `claude`, `codex` and `jq` CLIs. |
| `make validate-antigravity-plugin` | Runs `agy plugin validate ./plugin`. Needs the Antigravity CLI (`agy`); Antigravity reports the separate Claude hook config as an expected ignored-file warning. |
| `make snapshot` | Cross-compiles the four release archives (darwin and linux, amd64 and arm64) and `checksums.txt` into `./dist`. |
| `make dev` | `make build`, then `AGENT_QUORUM_BIN=$PWD/bin/agent-quorum claude --plugin-dir ./plugin`. |
| `make release V=1.2.3` | Runs `make check`, then `scripts/bump-version.sh`: creates `release/v1.2.3`, sets the version in `plugin.json`, commits, pushes and opens the release pull request. Merging it publishes the release. |
Expand Down Expand Up @@ -60,12 +62,14 @@ internal/core/ State, Session, Claim, decisions and the deny/contex
internal/guard/ Classify(command) Risk. Pure.
internal/adapter/claude/ Parse and Render for Claude Code hook JSON. Pure.
internal/adapter/codex/ Parse and Render for Codex hook JSON. Pure.
internal/adapter/antigravity/ Parse and Render for Antigravity hook JSON. Pure.
internal/daemon/ socket server, flock, snapshot, the real core.Env
internal/client/ dial, start-on-demand, deadlines, path normalisation
internal/gitx/ thin wrappers over the git CLI
plugin/ Claude Code and Codex manifests, hooks, scripts/*.sh, skills/status
plugin/ Claude Code, Codex and Antigravity manifests, hooks, scripts/*.sh, skills/status
scripts/ release-build.sh, bump-version.sh
testdata/hooks/claude/ Claude Code hook payload fixtures
testdata/hooks/antigravity/ Antigravity hook payload fixtures
.claude-plugin/ marketplace.json: the repo root is a marketplace for Claude Code and Codex
```

Expand Down Expand Up @@ -113,7 +117,7 @@ Do not break these. Review will check each one.

Rules:

- Do not edit the version in either `plugin/.claude-plugin/plugin.json` or `plugin/.codex-plugin/plugin.json` in an ordinary pull request. `make release` updates both manifests together; a version change on `main` publishes a release.
- Do not edit the version in `plugin/.claude-plugin/plugin.json`, `plugin/.codex-plugin/plugin.json`, or `plugin/.antigravity-plugin/plugin.json` in an ordinary pull request. `make release` updates all three manifests together; a version change on `main` publishes a release.
- Do not commit to `stable` or `latest`. They are channel branches moved by the release workflow.
- Do not force-push `main` or rewrite published tags.

Expand Down Expand Up @@ -180,7 +184,7 @@ A pre-release such as `v0.2.0-rc.1` precedes `v0.2.0` in precedence and means "c

### Where the version lives

- `plugin/.claude-plugin/plugin.json` `version` is the source of truth and `plugin/.codex-plugin/plugin.json` mirrors it. Only a release pull request, opened by `make release`, edits these fields.
- `plugin/.claude-plugin/plugin.json` `version` is the source of truth; `plugin/.codex-plugin/plugin.json` and `plugin/.antigravity-plugin/plugin.json` mirror it. Only a release pull request, opened by `make release`, edits these fields.
- The git tag is `v<version>`, annotated, created by the release workflow on the merge commit. Nobody tags by hand in the normal flow.
- Binaries are stamped at build time with `-ldflags "-X main.version=<version>"`. `scripts/release-build.sh` stamps the exact version; `make build` stamps `<version>-dev`. An unstamped `go build` reports `dev`.
- Claude Code users stay on their cached copy of a plugin until the `version` string changes, so a release is a version bump or it is nothing.
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION ?= $(shell jq -r .version plugin/.claude-plugin/plugin.json)-dev
BIN := bin/agent-quorum

.PHONY: build test vet lint check validate-plugin snapshot dev release clean
.PHONY: build test vet lint check validate-plugin validate-antigravity-plugin snapshot dev release clean

build: ## build ./bin/agent-quorum for this machine
go build -trimpath -ldflags "-X main.version=$(VERSION)" -o $(BIN) ./cmd/agent-quorum
Expand All @@ -16,14 +16,19 @@ vet:
lint: ## shell + JSON checks (shellcheck is optional locally, required in CI)
@for f in plugin/scripts/*.sh scripts/*.sh; do sh -n "$$f" || exit 1; done
@command -v shellcheck >/dev/null && shellcheck plugin/scripts/*.sh scripts/*.sh || echo "shellcheck not installed, skipped"
@jq empty .claude-plugin/marketplace.json plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json plugin/hooks/hooks.json plugin/hooks/codex.json
@jq -e -s '.[0].version == .[1].version' plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json >/dev/null
@jq empty .claude-plugin/marketplace.json plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json plugin/.antigravity-plugin/plugin.json plugin/hooks/hooks.json plugin/hooks/codex.json plugin/hooks.json
@jq -e -s '.[0].version == .[1].version and .[0].version == .[2].version' plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json plugin/.antigravity-plugin/plugin.json >/dev/null

validate-plugin: ## needs the claude and codex CLIs
claude plugin validate ./plugin --strict
claude plugin validate .
scripts/validate-codex-plugin.sh

validate-antigravity-plugin: ## needs the Antigravity CLI (`agy`)
@command -v agy >/dev/null 2>&1 || { echo "agy CLI not found" >&2; exit 1; }
# Non-strict validation allows the expected warning for Claude's separate hooks/hooks.json.
agy plugin validate ./plugin

check: vet lint test ## what CI runs

snapshot: ## cross-compile all release archives into ./dist
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![ci](https://github.com/ChristopherLiew/agent-quorum/actions/workflows/ci.yml/badge.svg)](https://github.com/ChristopherLiew/agent-quorum/actions/workflows/ci.yml)

A Claude Code and Codex plugin that lets several agent sessions work in the same repository at once without overwriting each other.
A Claude Code, Codex, and Antigravity plugin that lets several agent sessions work in the same repository at once without overwriting each other.

<p align="center">
<img src="assets/overview.svg" alt="Two agent sessions want the same file. agent-quorum lets the first edit it and blocks the second, which is told who holds the file." width="820">
Expand All @@ -31,7 +31,7 @@ agent-quorum: /src/app/auth.go is being edited by another agent session (claude:

## Install

Requires macOS or Linux and Claude Code or Codex.
Requires macOS or Linux and Claude Code, Codex, or Antigravity.

```bash
claude plugin marketplace add ChristopherLiew/agent-quorum#stable
Expand All @@ -47,8 +47,18 @@ codex plugin add agent-quorum@agent-quorum-tools

The plugin downloads its binary on the next session start and verifies it against the release checksums. Codex loads the hooks from its compatibility manifest. Review and trust the bundled hooks in Codex before they run.

For Antigravity, clone this repository and install the bundled plugin directory:

```bash
git clone https://github.com/ChristopherLiew/agent-quorum.git
agy plugin install ./agent-quorum/plugin
```

Antigravity loads the plugin hooks for session startup, prompts, file writes and edits, shell commands, and the end of an agent run. The next prompt in a still-open conversation registers again and refreshes peer context.

- **Update:** `claude plugin update agent-quorum@agent-quorum-tools`
- **Codex update:** `codex plugin marketplace upgrade agent-quorum-tools`
- **Antigravity update:** reinstall the local plugin directory after updating the repository checkout.
- **Release candidates:** add the marketplace with `#latest` instead of `#stable`.
- **Terminal CLI** (optional): the binary is installed at `~/.agent-quorum/bin/agent-quorum-<version>`. Symlink it onto your `PATH` as `agent-quorum`.

Expand All @@ -73,11 +83,11 @@ claude:3b80d4c2 pid 4310 idle 2m5s /src/app "add retry to the http client"

## How it works

The plugin adds hooks to Claude Code. Each hook call asks a small local daemon, shared by every session on your machine, whether the edit or git command is safe. The daemon starts by itself on the first hook and keeps its state in `~/.agent-quorum`.
Each agent plugin uses native hooks to ask a small local daemon, shared by every session on your machine, whether the edit or git command is safe. The daemon starts by itself on the first hook and keeps its state in `~/.agent-quorum`.

```mermaid
sequenceDiagram
participant C as Claude Code session
participant C as agent session
participant D as agent-quorum daemon
Note over C: session starts
C->>D: SessionStart (starts the daemon if it is not running)
Expand All @@ -93,10 +103,10 @@ sequenceDiagram
- **Holding a file.** The first edit takes a claim. It lasts while the holder's process is alive and the file has uncommitted changes, plus a 120 second grace period after the last edit.
- **Crashes.** If a session dies without exiting cleanly, its files free up the next time anyone asks for them.
- **Daemon restarts.** If the daemon stops, the next hook starts a new one and reloads the saved claims.
- **Fails open.** If agent-quorum is broken or missing, your agents behave as if it were not installed. It never auto-approves anything, so Claude Code's own permission prompts still apply.
- **Fails open.** If agent-quorum is broken or missing, your agents behave as if it were not installed. It never auto-approves anything, so each agent's own permission prompts still apply.
- **Privacy.** The first 80 characters of each prompt are stored locally so sessions can see what the others are working on. Nothing leaves your machine. Set `AGENT_QUORUM_NO_NOTES=1` to turn it off.

Limits: it coordinates cooperating agents and is not a security boundary. Shell writes such as `sed -i` are not intercepted, edits you make in an editor are not seen, and it works on one machine for one user. Codex file claims cover `apply_patch`; shell writes remain outside hook coverage.
Limits: it coordinates cooperating agents and is not a security boundary. Shell writes such as `sed -i` are not intercepted, edits you make in an editor are not seen, and it works on one machine for one user. Codex file claims cover `apply_patch`; Antigravity claims cover `write_to_file`, `replace_file_content`, and `multi_replace_file_content`. Shell writes remain outside hook coverage.

## Debugging

Expand Down
Loading
Loading