Skip to content

Commit 164a6be

Browse files
MrFlounderclaude
andauthored
feat: agent-agnostic codex support + bats test framework (#52)
## Summary - **Agent abstraction layer**: Crabcode now natively supports codex alongside claude. Projects configure `agent: codex` (or `agent: claude`, the default) in their YAML config - **~180 LOC helper functions** centralize all agent-specific CLI differences (command building, session resume, system prompts, non-interactive mode) - **All callsites updated**: workspace open/continue, WIP save/restore/list, session start/resume, review, handoff — all use the new helpers - **Bats-core test framework** vendored as git submodules with 36 unit tests for the agent layer - **CI workflow** runs unit tests + shellcheck on every PR ## Agent CLI mapping | Operation | Claude | Codex | |---|---|---| | Base command | `claude --dangerously-skip-permissions` | `codex --full-auto` | | Continue session | `--continue` | `codex resume --last` | | Resume specific | `--resume <id>` | `codex resume <id>` | | Non-interactive | `claude --print` | `codex exec` | | System prompt | `.claude/CLAUDE.md` | `AGENTS.md` | ## Out of scope - Court review (hardcoded Claude judge + Codex reviewer B) — separate PR ## Test plan - [x] 36 bats unit tests pass locally (`make test-unit`) - [x] Bash syntax check passes (`bash -n src/crabcode`) - [ ] CI runs on this PR (first run — watch it) - [x] Backward compat: existing projects without `agent:` field default to claude - [x] Source guard enables testing without executing main 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a3421e commit 164a6be

8 files changed

Lines changed: 900 additions & 125 deletions

File tree

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: test
2+
run-name: tests by @${{ github.actor }}
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
push:
8+
branches: [main]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: test-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
unit:
19+
name: Unit tests (bats)
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
26+
- name: Install yq
27+
run: |
28+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
29+
sudo chmod +x /usr/local/bin/yq
30+
31+
- name: Run unit tests
32+
run: make test-unit
33+
34+
lint:
35+
name: Shellcheck
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Run shellcheck
41+
run: shellcheck --severity=error src/crabcode

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "tests/bats"]
2+
path = tests/bats
3+
url = https://github.com/bats-core/bats-core.git
4+
[submodule "tests/test_helper/bats-support"]
5+
path = tests/test_helper/bats-support
6+
url = https://github.com/bats-core/bats-support.git
7+
[submodule "tests/test_helper/bats-assert"]
8+
path = tests/test_helper/bats-assert
9+
url = https://github.com/bats-core/bats-assert.git

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
.PHONY: test test-docker test-e2e install lint help
1+
.PHONY: test test-unit test-integration test-docker test-e2e install lint help
22

33
help:
44
@echo "Crabcode Makefile"
55
@echo ""
66
@echo "Commands:"
7-
@echo " make test Run unit tests"
8-
@echo " make test-docker Run tests in Docker"
9-
@echo " make test-e2e Run end-to-end tests in Docker (full promptfoo-cloud simulation)"
10-
@echo " make install Install crabcode to /usr/local/bin"
11-
@echo " make lint Run shellcheck"
7+
@echo " make test Run all tests (unit + integration)"
8+
@echo " make test-unit Run bats unit tests only"
9+
@echo " make test-integration Run integration tests only"
10+
@echo " make test-docker Run integration tests in Docker"
11+
@echo " make test-e2e Run end-to-end tests in Docker (full promptfoo-cloud simulation)"
12+
@echo " make install Install crabcode to /usr/local/bin"
13+
@echo " make lint Run shellcheck"
1214
@echo ""
1315

14-
test:
16+
test: test-unit test-integration
17+
18+
test-unit:
19+
@git submodule update --init --recursive tests/bats tests/test_helper/bats-support tests/test_helper/bats-assert 2>/dev/null || true
20+
@./tests/bats/bin/bats tests/unit/
21+
22+
test-integration:
1523
@chmod +x tests/run.sh
1624
@./tests/run.sh
1725

0 commit comments

Comments
 (0)