Skip to content

Commit 5f4f1e8

Browse files
committed
feat(baseline): init
1 parent 9b444ca commit 5f4f1e8

137 files changed

Lines changed: 29661 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/architecture.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Architecture
2+
3+
## Transport and Backend Model
4+
5+
The SDK supports two built-in execution backends:
6+
7+
1. `exec` backend (`codex exec`)
8+
2. `app-server` backend (`codex app-server`)
9+
10+
## Backend Routing Rules
11+
12+
- `Query(...)` auto-selects backend from enabled options.
13+
- Uses `exec` when all selected options are supported there.
14+
- Routes to `app-server` when required by selected options.
15+
- `QueryStream(...)` uses app-server semantics unless `WithTransport(...)` injects custom transport.
16+
- `Client.Start(...)` uses app-server transport semantics.
17+
18+
Capability selection/validation logic lives in:
19+
20+
- `internal/config/capability.go`
21+
22+
## High-Level Components
23+
24+
- `query.go`: one-shot and query-stream orchestration
25+
- `client.go` + `client_impl.go`: stateful client interface + implementation
26+
- `with_client.go`: lifecycle helper wrapper
27+
- `mcp.go`: `Tool` interface and `NewTool` constructor for SDK-defined tools
28+
- `internal/subprocess/`: process and app-server adapters
29+
- `internal/protocol/`: JSON-RPC/session controller, dynamic tool dispatch
30+
- `internal/message/`: parsing + public message mapping
31+
- `internal/config/`: options, `DynamicTool` type, and backend capability policy
32+
- `internal/session/`: SQLite-based session metadata lookup
33+
- `internal/mcp/`: MCP server integration and status
34+
35+
## Change Impact Guidance
36+
37+
When changing options, transport, or session behavior:
38+
39+
- verify backend capability mapping in `internal/config/capability.go`
40+
- update related tests (capability, query/client behavior)
41+
- keep docs aligned (`README.md`, package docs, CLAUDE rules where needed)

.claude/rules/boundaries.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Boundaries
2+
3+
## Always
4+
5+
- Follow existing patterns in neighboring code before introducing new patterns.
6+
- Keep behavior changes covered by tests in the same PR.
7+
- Run relevant tests for changed code; run `go test ./...` for substantial changes.
8+
- Keep user-facing and agent-facing docs aligned when public behavior changes.
9+
10+
## Ask First
11+
12+
- Adding exported API surface (new public functions/types/options).
13+
- Changing transport interfaces or protocol semantics.
14+
- Adding new third-party dependencies.
15+
- Making breaking behavior changes to existing option semantics.
16+
17+
## Never
18+
19+
- Leave errors unchecked.
20+
- Store `context.Context` in structs.
21+
- Mix naming that implies another SDK/provider when describing this codebase.
22+
- Bypass backend capability checks for options.

.claude/rules/build-and-test.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Build and Test
2+
3+
## Default Commands
4+
5+
```bash
6+
go build ./...
7+
go test ./...
8+
go test -race ./...
9+
go test -v -run TestQuery ./...
10+
go test -tags=integration ./integration/...
11+
golangci-lint run
12+
go run ./examples/quick_start
13+
```
14+
15+
## Command Usage
16+
17+
- Use targeted tests first while iterating (single package or `-run` pattern).
18+
- Before finishing substantial code changes, run `go test ./...`.
19+
- Run `go test -race ./...` for concurrency-sensitive changes.
20+
- Run `golangci-lint run` before finalizing when Go files changed.
21+
22+
## Integration Test Notes
23+
24+
- Integration tests require Codex CLI availability and a working runtime setup.
25+
- If integration tests are not runnable in the current environment, call that out explicitly.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Coding Conventions
2+
3+
## Core Style
4+
5+
- Keep package and naming consistent with existing code (`codexsdk`).
6+
- Keep context as the first parameter for blocking operations.
7+
- Use functional options (`WithXxx(...)`) for configurable behavior.
8+
- Re-export public-facing types from root package when following existing pattern.
9+
10+
## Logging
11+
12+
- Use structured `slog` logging.
13+
- Prefer context-aware logging calls when a relevant context is available in that path.
14+
- Keep log messages concise and action-oriented.
15+
16+
## Errors
17+
18+
- Wrap errors with `%w` so callers can use `errors.Is`/`errors.As`.
19+
- Prefer typed or sentinel errors from `errors.go` for stable checks.
20+
- Do not suppress or ignore returned errors.
21+
22+
## API and Option Changes
23+
24+
- Keep public option constructors in `options.go`.
25+
- If option behavior differs by backend, update capability policy in `internal/config/capability.go`.
26+
- Ensure unsupported combinations fail with `ErrUnsupportedOption`.
27+
28+
## Repo Structure
29+
30+
- Keep implementation details in `internal/`.
31+
- Avoid introducing generic catch-all packages (`utils`, `helpers`, `common`).
32+
- Follow nearby file patterns before introducing new structure.

.claude/rules/project-overview.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Project Overview
2+
3+
## Identity
4+
5+
- Repository: `github.com/ethpandaops/codex-agent-sdk-go`
6+
- Primary package: `codexsdk`
7+
- Go version: `1.26+`
8+
- Minimum Codex CLI version: `0.103.0+` (see `version.go`)
9+
10+
## What This SDK Exposes
11+
12+
- One-shot query API: `Query(ctx, prompt, opts...)`
13+
- Streaming input query API: `QueryStream(ctx, messages, opts...)`
14+
- Stateful client API: `NewClient()` + `Client` methods
15+
- Lifecycle helper: `WithClient(ctx, fn, opts...)`
16+
- Session metadata API: `StatSession(ctx, sessionID, opts...)`
17+
18+
## Primary Public Surface Areas
19+
20+
- `options.go`: all `WithXxx(...)` constructors
21+
- `mcp.go`: `Tool` interface, `NewTool` constructor, and `WithSDKTools` tool registration
22+
- `client.go`: `Client` interface
23+
- `query.go`: top-level query functions
24+
- `session_stat.go`: `SessionStat` struct and `StatSession()` function
25+
- `types.go`: re-exported message/content/config types
26+
- `errors.go`: typed and sentinel errors
27+
28+
## Documentation Sync Expectations
29+
30+
When public APIs or options change, update in the same PR:
31+
32+
- `README.md` (user-facing)
33+
- `doc.go` (package docs)
34+
- `CLAUDE.md` / `.claude/rules/*` if agent guidance changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"
11+
12+
- package-ecosystem: gomod
13+
directory: /
14+
schedule:
15+
interval: weekly
16+
groups:
17+
go-dependencies:
18+
patterns:
19+
- "*"

.github/typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[files]
2+
extend-exclude = ["go.mod", "go.sum"]

.github/workflows/check-typos.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Typos
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
typos:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
16+
- name: Check for typos
17+
uses: crate-ci/typos@0f0ccba9ed1df83948f0c15026e4f5ccfce46109 # v1.32.0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Setup Go'
2+
description: 'Set up Go environment with caching'
3+
4+
inputs:
5+
go-version:
6+
description: 'Go version to use'
7+
required: false
8+
default: '1.25'
9+
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Set up Go
14+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
15+
with:
16+
go-version: ${{ inputs.go-version }}
17+
cache: true

.github/workflows/go-test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
19+
- name: Setup Go
20+
uses: ./.github/workflows/go-setup
21+
22+
- name: Build
23+
run: go build ./...
24+
25+
- name: Test
26+
run: go test -race ./...

0 commit comments

Comments
 (0)