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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
- run: make test
- run: make build

golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v9
with:
version: v2.15.0

lint:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "2"

linters:
enable:
- revive # golint's successor: doc comments, naming, error strings
exclusions:
presets:
- std-error-handling # unchecked Close, os.Remove, fmt.Fprint*
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ agent-quorum is local coordination for concurrent coding-agent sessions that sha
| Command | What it does |
|---|---|
| `make build` | Build `./bin/agent-quorum` (version from `plugin.json` + `-dev`) |
| `make check` | `vet` + `lint` + `test`. What CI runs. |
| `make check` | `vet` + `lint` + `test`. What CI runs, except the `golangci` job (`golangci-lint run`, v2, config in `.golangci.yml`). |
| `make test` | `go test -race -count=1 ./...` |
| `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 |
Expand Down
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Thanks for helping. This file covers the dev loop, the rules the code lives by,
- `jq` (used by `make lint`, `make release` and the version stamp)
- the `gh` CLI, for `make release` to open the release pull request
- `shellcheck` (optional locally, enforced in CI)
- `golangci-lint` v2 (optional locally, enforced in CI; config in `.golangci.yml`)
- 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`)
Expand All @@ -17,7 +18,8 @@ Thanks for helping. This file covers the dev loop, the rules the code lives by,
## Dev loop

```bash
make check # vet + lint + test: exactly what CI runs
make check # vet + lint + test: what CI runs, minus golangci-lint
golangci-lint run # the CI golangci job (v2.15.0)
make dev # build, then start Claude Code with the local plugin and local binary
```

Expand Down Expand Up @@ -112,7 +114,7 @@ Do not break these. Review will check each one.
2. **Commit** with short imperative subjects, one logical change per commit: `fix: allow git stash list`, `feat: add status --json`.
3. **Run `make check` locally**, and `make validate-plugin` if you touched `plugin/` or the marketplace manifest.
4. **Open a pull request against `main`.** Describe the behaviour change and how you tested it. Call out any change to a public surface (see [Versioning](#versioning)), because it decides the next version bump.
5. **CI must be green** (`test` on Ubuntu and macOS, `lint`, `plugin`) and the pull request needs an approving review before it can merge.
5. **CI must be green** (`test` on Ubuntu and macOS, `golangci`, `lint`, `plugin`) and the pull request needs an approving review before it can merge.
6. **Squash-merge**, then delete the branch. The squash subject becomes the line in the generated release notes, so make it read well.

Rules:
Expand Down Expand Up @@ -200,6 +202,7 @@ Two workflows in `.github/workflows/`.
| Job | What it checks |
|---|---|
| `test` (Ubuntu and macOS) | `make vet`, `make test` (race detector), `make build` |
| `golangci` | `golangci-lint run` (v2.15.0) with `.golangci.yml`: the standard linters plus `revive`, golint's successor |
| `lint` | `make lint` (shellcheck, `sh -n`, JSON syntax), and that the launcher fails open when no binary exists |
| `plugin` | `make validate-plugin`: validates the Claude plugin and marketplace, then installs the Codex plugin in a temporary Codex home |

Expand Down Expand Up @@ -251,7 +254,7 @@ Run this before every tag. Do not skip steps because the change is small.

1. **Start from a clean, up-to-date `main` with CI green.** `git status` is clean, `git pull` is done, and the latest CI run on that commit passed on Ubuntu and macOS.
2. **Decide the version** (`x.y.z`, or `x.y.z-rc.N` for a candidate) from the versioning rules above, by reading the changes since the last tag (`git log <last-tag>..HEAD`). Look for anything touching the public API.
3. **`make check`.** vet, lint and race tests must pass locally. Install `shellcheck` so lint is not skipped.
3. **`make check`.** vet, lint and race tests must pass locally. Install `shellcheck` so lint is not skipped, and run `golangci-lint run`.
4. **`make validate-plugin`.** Strict validation of the plugin and of the marketplace root.
5. **`make snapshot`, then inspect `dist/`.** There must be exactly four archives (`darwin` and `linux`, `amd64` and `arm64`) and `checksums.txt`. Verify the checksums (`shasum -a 256 -c checksums.txt` inside `dist/`), unpack the archive for your platform and run `agent-quorum version`.
6. **End-to-end by hand with two real sessions** on the current Claude Code version, using `make dev`, a scratch repository and a scratch `AGENT_QUORUM_HOME`:
Expand Down
10 changes: 10 additions & 0 deletions internal/adapter/codex/codex.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ import (
"github.com/bytedance/sonic"
)

// Agent is the value of proto.Request.Agent for this adapter.
const Agent = "codex"

var plainJSON = sonic.Config{SortMapKeys: true, EscapeHTML: false, ValidateString: true}.Froze()

// Event is the parsed Codex hook call.
type Event struct {
HookEvent string
Tool string
Req proto.Request
HasReq bool
}

// Output is what the hook process writes and how it exits.
type Output struct {
Stdout []byte
Exit int
}

type hookInput struct {
SessionID string `json:"session_id"`
CWD string `json:"cwd"`
Expand All @@ -33,6 +38,9 @@ type hookInput struct {
Prompt string `json:"prompt"`
}

// Parse turns one Codex hook payload into an Event. It returns an error only
// for input that is not valid JSON. Missing sessions or unhandled events and
// tools return HasReq false (no opinion).
func Parse(raw []byte) (Event, error) {
var in hookInput
if err := sonic.ConfigStd.Unmarshal(raw, &in); err != nil {
Expand Down Expand Up @@ -122,6 +130,8 @@ type hookSpecific struct {
AdditionalContext string `json:"additionalContext,omitempty"`
}

// Render turns the daemon's answer into hook output. Only a deny on
// PreToolUse and a non-empty Context on SessionStart produce output.
func Render(ev Event, r proto.Response) Output {
if !r.OK {
return Output{}
Expand Down
5 changes: 4 additions & 1 deletion internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func TestDoAgainstRealDaemon(t *testing.T) {
t.Cleanup(func() {
cancel()
select {
case <-done:
case err := <-done:
if err != nil {
t.Errorf("daemon.Serve() = %v, want nil", err)
}
case <-time.After(5 * time.Second):
t.Error("daemon stopped within 5s = false, want true")
}
Expand Down
9 changes: 5 additions & 4 deletions internal/core/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,10 @@ func TestGuard(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
env := newEnv()
s := newState(env)
if tc.holder == "a" {
switch tc.holder {
case "a":
do(t, s, rq(proto.OpClaim, "a", 1, tc.path))
} else if tc.holder == "b" {
case "b":
do(t, s, rq(proto.OpClaim, "b", 2, tc.path))
}
if tc.setup != nil {
Expand Down Expand Up @@ -482,8 +483,8 @@ func TestHelloContextCap(t *testing.T) {
if n := utf8.RuneCountInString(resp.Context); n == 0 || n > 600 {
t.Fatalf("len(Context) = %d chars, want 1..600: %q", n, resp.Context)
}
if !strings.Contains(resp.Context, "reset --hard") ||
!(strings.Contains(resp.Context, "more") || strings.Contains(resp.Context, "files")) {
truncated := strings.Contains(resp.Context, "more") || strings.Contains(resp.Context, "files")
if !strings.Contains(resp.Context, "reset --hard") || !truncated {
t.Errorf("Context = %q, want instructions and a truncation marker", resp.Context)
}
})
Expand Down
Loading