Skip to content

Codex and OpenCode support#43

Open
tpaulshippy wants to merge 16 commits intoMiniCodeMonkey:mainfrom
tpaulshippy:feature/opencode-support-v2
Open

Codex and OpenCode support#43
tpaulshippy wants to merge 16 commits intoMiniCodeMonkey:mainfrom
tpaulshippy:feature/opencode-support-v2

Conversation

@tpaulshippy
Copy link

@tpaulshippy tpaulshippy commented Mar 6, 2026

Summary

Adds support for Codex and OpenCode AI agents as alternatives to Claude Code.

  • New providers: CodexProvider and OpenCodeProvider in internal/agent/
  • New parsers: Output parsers for Codex and OpenCode JSON formats in internal/loop/
  • Provider resolution: Automatic detection via --agent flag, config file, or CHIEF_AGENT env var

Changes

Agent Providers

  • internal/agent/codex.go - Codex CLI integration
  • internal/agent/opencode.go - OpenCode CLI integration
  • internal/agent/resolve.go - Provider resolution logic

Output Parsers

  • internal/loop/codex_parser.go - Parse Codex stream-json output
  • internal/loop/opencode_parser.go - Parse OpenCode output

Configuration

  • Add agent.provider and agent.cliPath to config
  • Support --agent codex|opencode|claude flag
  • Support CHIEF_AGENT environment variable

Testing

  • All existing tests pass (9 packages)
  • New tests for Codex and OpenCode providers (16 tests)
  • New tests for parsers (27 tests)
  • Lint: 81 issues (fewer than main's 84)

Usage

Use OpenCode

chief --agent opencode run my-prd

Or configure in .chief/config.yaml

agent:
  provider: opencode

Credit

Thanks to @Simon-BEE for coming up with this approach and writing the bulk of this code including 100% of the codex piece.

Resolves #12 and #23

Simon-BEE and others added 16 commits February 25, 2026 09:38
Introduce an agent abstraction to support Claude and OpenAI Codex CLIs. Added internal/agent providers (ClaudeProvider, CodexProvider), resolution and installation checks (Resolve, CheckInstalled), and tests. Wire provider selection via --agent / --agent-path flags, CHIEF_AGENT env vars, and .chief/config.yaml (agent.provider, agent.cliPath). Propagate the provider into TUI, new, edit, and convert flows; convert and fix-json now run through the provider. Added Codex JSONL parser for the loop output and accompanying tests. Updated config struct, docs (README, installation, configuration, troubleshooting), and various command code to use the provider abstraction. Key new files: internal/agent/*.go, internal/cmd/convert.go, internal/loop/codex_parser*.go and tests; updated main.go, cmd handlers, prd conversion wiring and docs to reflect multi-agent support.
Propagate errors from provider commands and improve provider resolution flow.

- Extended loop.Provider ConvertCommand and FixJSONCommand to return an error and updated implementations (Claude, Codex) to follow the new signature. Codex now returns explicit errors when temp files cannot be created.
- Updated callers (internal/cmd/convert.go, runFixJSONWithProvider, loop tests, agent tests) to handle the new error return values.
- Changed Resolve to return (loop.Provider, error) and make unknown providers produce a clear error; added mustResolve helper in tests and a TestResolve_unknownProvider.
- Added resolveProvider helper in cmd/chief to load config and resolve the provider (exiting on error), and improved CLI flag parsing for --agent/--agent-path (support both --flag value and --flag=value). Minor test and docstring tweaks to reflect agent-agnostic language.
Add runtime validation and better error handling across CLI and loop components. Key changes:

- cmd/chief: validate presence of values for --agent and --agent-path flags (print error and exit) and handle config.Load errors with a clear message.
- internal/cmd: enforce non-nil Provider for RunNew, RunEdit and runInteractiveAgent (return explicit errors) and add corresponding tests that assert provider is required. Minor comment/spacing cleanups in option structs.
- internal/cmd/convert: ensure temporary output files are removed on failed command start to avoid leftover artifacts.
- internal/loop: return an error if Loop.Run is invoked without a configured provider; require provider for Manager.Start; add tests for both failure cases. Also minor struct field alignment and test provider method formatting.

These changes make failures explicit and fail fast with clearer messages, and ensure temporary files are cleaned up on early command failures.
Remove the deprecated --output-last-message option from CodexProvider CLI invocations and simplify error messages in WaitWithSpinner and WaitWithPanel from "Claude failed" to the more generic "agent failed" for compatibility and clearer messaging. Changes in internal/agent/codex.go and internal/prd/generator.go.
@tpaulshippy tpaulshippy marked this pull request as ready for review March 6, 2026 13:19
@tpaulshippy tpaulshippy changed the title Feature/opencode support v2 Codex and OpenCode support Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: opencode support

2 participants