Skip to content

Commit 40a4cb4

Browse files
committed
feat: code review action
1 parent 758d3eb commit 40a4cb4

4 files changed

Lines changed: 763 additions & 1 deletion

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Codex Autonomous Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
review:
13+
name: Run Codex review
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout PR
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install codex from PyPI (system Python)
22+
run: |
23+
python3 -m pip install --upgrade pip
24+
python3 -m pip install --upgrade codex-python
25+
26+
- name: Run Codex autonomous code review
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
30+
CODEX_MODEL: gpt-5
31+
CODEX_REASONING_EFFORT: medium
32+
DEBUG_CODEREVIEW: 5
33+
run: |
34+
python3 scripts/codex_autoreview.py

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `codex/` – Python package (public API in `__init__.py`, config, client, protocol models).
5+
- `crates/codex_native/` – PyO3 native extension built with maturin (pinned upstream deps).
6+
- `tests/``pytest` tests (`test_*.py`).
7+
- `scripts/` – codegen helpers (e.g., `generate_protocol_py.py`).
8+
- `.generated/ts/` – transient TypeScript protocol types. Do not commit hand edits.
9+
- Generated file: `codex/protocol/types.py` – do not edit; run `make gen-protocol`.
10+
11+
## Build, Test, and Development Commands
12+
- Create venv: `make venv` then `. .venv/bin/activate`.
13+
- Format: `make fmt` (ruff format).
14+
- Lint: `make lint` (ruff check --fix + mypy).
15+
- Test: `make test` (pytest; skips if no native ext).
16+
- Build sdist/wheel: `make build` (uv build).
17+
- Native dev install: `make dev-native` (maturin develop or build+pip install).
18+
- Generate protocol: `make gen-protocol` (TS → Pydantic models).
19+
- Prebuild Linux wheels: `make wheelhouse-linux` (manylinux/musllinux via Docker).
20+
21+
## Coding Style & Naming Conventions
22+
- Python 3.12+; type hints required. Line length target: 100.
23+
- Run `make fmt && make lint` before commits.
24+
- Ruff rules: `E,F,I,B,UP` (imports sorted). Mypy: strict-ish (no untyped defs).
25+
- Naming: modules `snake_case.py`, classes `PascalCase`, functions/vars `snake_case`.
26+
- Pydantic v2: prefer `BaseModel`; place `model_config = ConfigDict(extra='allow')` at class end.
27+
28+
## Testing Guidelines
29+
- Framework: `pytest`. Test files: `tests/test_*.py`.
30+
- Write fast, deterministic tests; mock external I/O. Native-dependent tests already skip when the extension is unavailable.
31+
- Example: `uv run --group dev pytest -q` (or `make test`).
32+
33+
## Commit & Pull Request Guidelines
34+
- Use Conventional Commits (e.g., `feat:`, `fix:`, `ci:`, `chore:`). Keep subject ≤72 chars.
35+
- PRs should include: clear description, linked issues, tests (or rationale), and docs/`CHANGELOG.md` updates when user‑visible.
36+
- Keep diffs focused; avoid touching generated files.
37+
38+
## Security & Configuration Tips
39+
- Respect sandbox defaults; avoid introducing commands that assume unrestricted host access.
40+
- Publishing uses UV/PyPI tokens: `UV_PUBLISH_TOKEN` or `PYPI_API_TOKEN` (see `make publish`).
41+
- For local previews, you may set `CODEX_HOME` to a temp dir to isolate state.

Makefile

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dev-native:
9696
# pip install --only-binary=:all: --no-index --find-links wheelhouse codex-python
9797
# Requires Docker; for cross-arch builds ensure binfmt/qemu is enabled.
9898
# -----------------------------------------------------------------------------
99-
.PHONY: wheelhouse-linux wheelhouse-clean
99+
.PHONY: wheelhouse-linux wheelhouse-clean wheelhouse-linux-amd64 wheelhouse-linux-arm64 wheelhouse-musl-amd64 wheelhouse-musl-arm64
100100

101101
WHEELHOUSE ?= wheelhouse
102102
MANYLINUX_X86 ?= quay.io/pypa/manylinux2014_x86_64
@@ -147,3 +147,43 @@ wheelhouse-linux: wheelhouse-clean
147147
$$P -m pip install -U pip maturin && \
148148
PATH=$$HOME/.cargo/bin:$$PATH $$P -m maturin build --release -m /io/crates/codex_native/Cargo.toml -i $$P --compatibility musllinux_1_2 -o /io/$(WHEELHOUSE)'
149149
@echo "Wheelhouse contents:" && ls -al $(WHEELHOUSE)
150+
151+
# Build only manylinux x86_64 (useful to avoid cross-arch emulation)
152+
wheelhouse-linux-amd64: wheelhouse-clean
153+
@mkdir -p $(WHEELHOUSE)
154+
docker run --rm --platform linux/amd64 -v "$(PWD)":/io $(MANYLINUX_X86) \
155+
bash -lc 'set -e; (command -v curl >/dev/null 2>&1 || yum -y install curl); \
156+
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; \
157+
. $$HOME/.cargo/env; P=$$(ls -1 /opt/python/cp312*/bin/python | head -n1); \
158+
$$P -m pip install -U pip maturin; \
159+
PATH=$$HOME/.cargo/bin:$$PATH $$P -m maturin build --release -j $$(( $$(nproc) )) -m /io/crates/codex_native/Cargo.toml -i $$P -o /io/$(WHEELHOUSE)'
160+
161+
# Build only manylinux aarch64 (fast on Apple Silicon; slow on x86_64)
162+
wheelhouse-linux-arm64: wheelhouse-clean
163+
@mkdir -p $(WHEELHOUSE)
164+
docker run --rm --platform linux/arm64 -v "$(PWD)":/io $(MANYLINUX_ARM) \
165+
bash -lc 'set -e; (command -v curl >/dev/null 2>&1 || yum -y install curl); \
166+
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; \
167+
. $$HOME/.cargo/env; P=$$(ls -1 /opt/python/cp312*/bin/python | head -n1); \
168+
$$P -m pip install -U pip maturin; \
169+
PATH=$$HOME/.cargo/bin:$$PATH $$P -m maturin build --release -j $$(( $$(nproc) )) -m /io/crates/codex_native/Cargo.toml -i $$P -o /io/$(WHEELHOUSE)'
170+
171+
# Build only musllinux x86_64 (Alpine)
172+
wheelhouse-musl-amd64: wheelhouse-clean
173+
@mkdir -p $(WHEELHOUSE)
174+
docker run --rm --platform linux/amd64 -v "$(PWD)":/io $(MUSLLINUX_X86) \
175+
bash -lc 'set -e; (command -v curl >/dev/null 2>&1 || apk add --no-cache curl); \
176+
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; \
177+
. $$HOME/.cargo/env; P=$$(ls -1 /opt/python/cp312*/bin/python | head -n1); \
178+
$$P -m pip install -U pip maturin; \
179+
PATH=$$HOME/.cargo/bin:$$PATH $$P -m maturin build --release --compatibility musllinux_1_2 -j $$(( $$(nproc) )) -m /io/crates/codex_native/Cargo.toml -i $$P -o /io/$(WHEELHOUSE)'
180+
181+
# Build only musllinux aarch64 (Alpine)
182+
wheelhouse-musl-arm64: wheelhouse-clean
183+
@mkdir -p $(WHEELHOUSE)
184+
docker run --rm --platform linux/arm64 -v "$(PWD)":/io $(MUSLLINUX_ARM) \
185+
bash -lc 'set -e; (command -v curl >/dev/null 2>&1 || apk add --no-cache curl); \
186+
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal; \
187+
. $$HOME/.cargo/env; P=$$(ls -1 /opt/python/cp312*/bin/python | head -n1); \
188+
$$P -m pip install -U pip maturin; \
189+
PATH=$$HOME/.cargo/bin:$$PATH $$P -m maturin build --release --compatibility musllinux_1_2 -j $$(( $$(nproc) )) -m /io/crates/codex_native/Cargo.toml -i $$P -o /io/$(WHEELHOUSE)'

0 commit comments

Comments
 (0)