Skip to content

feat: Exec command and Result struct #2

@joshrotenberg

Description

@joshrotenberg

Summary

The primary interface: CodexWrapper.exec/2 wraps codex exec <prompt>.

  • CodexWrapper.Exec struct with builder functions for all exec options
  • CodexWrapper.Result struct: stdout, stderr, exit_code, success
  • Type definitions for SandboxMode (:read_only, :workspace_write, :danger_full_access)
  • Type definitions for ApprovalPolicy (:untrusted, :on_request, :never)

Exec options to support

  • prompt (positional, required)
  • model, sandbox, approval_policy (ask_for_approval)
  • full_auto, dangerously_bypass_approvals_and_sandbox
  • cd, skip_git_repo_check, add_dir (list)
  • search, ephemeral, output_schema
  • json, output_last_message
  • image (list), config (list of key=value)
  • enable/disable (list)

Convenience API

# Simple
CodexWrapper.exec("implement the feature", working_dir: "/path/to/repo")

# Full control
CodexWrapper.Exec.new("implement the feature")
|> CodexWrapper.Exec.model("o3")
|> CodexWrapper.Exec.sandbox(:danger_full_access)
|> CodexWrapper.Exec.dangerously_bypass_approvals_and_sandbox()
|> CodexWrapper.Exec.execute(config)

Acceptance criteria

  • Exec.new/1 and builder functions for all options
  • Exec.execute/2 runs codex CLI, returns {:ok, Result.t()} | {:error, term()}
  • CodexWrapper.exec/2 convenience function
  • SandboxMode and ApprovalPolicy types with string conversion
  • Result.from_cmd/2 parses System.cmd output
  • Tests with mock binary or integration tests

Depends on

Reference

  • codex-wrapper (Rust): src/command/exec.rs
  • claude_wrapper: lib/claude_wrapper/query.ex, lib/claude_wrapper/result.ex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions