CodexWrapper.Review (CodexWrapper v0.4.0)

Copy Markdown View Source

Review command -- code review with git integration.

Wraps codex exec review with review-specific CLI flags.

Usage

config = CodexWrapper.Config.new(working_dir: "/path/to/repo")

# Review uncommitted changes
review = CodexWrapper.Review.new()
  |> CodexWrapper.Review.uncommitted()
  |> CodexWrapper.Review.model("o3")

{:ok, result} = CodexWrapper.Review.execute(review, config)

# Review against a base branch
CodexWrapper.Review.new()
|> CodexWrapper.Review.base("main")
|> CodexWrapper.Review.execute(config)

# Review a specific commit
CodexWrapper.Review.new()
|> CodexWrapper.Review.commit("abc123")
|> CodexWrapper.Review.execute(config)

# Ask for structured review output
CodexWrapper.Review.new()
|> CodexWrapper.Review.uncommitted()
|> CodexWrapper.Review.output_schema("/path/to/schema.json")
|> CodexWrapper.Review.execute(config)

Summary

Functions

Compare against a base branch.

Review a specific commit.

Add a config override (key=value).

Bypass all approvals and sandbox. Use with extreme caution.

Run enabled hooks without requiring persisted hook trust. Use with extreme caution.

Disable a feature.

Enable a feature.

Enable ephemeral mode (no session persistence).

Execute the review command synchronously, returning a parsed %Result{}.

Execute the review command with --json and return parsed NDJSON events.

Enable full-auto mode.

Do not load user or project execpolicy .rules files.

Do not load $CODEX_HOME/config.toml.

Enable JSON output.

Set the model.

Create a new review command.

Set the output-last-message path.

Set the output schema path.

Set an optional prompt for additional review context.

Set the sandbox mode.

Skip the git repo check.

Execute the review command and return a lazy Stream of %JsonLineEvent{}.

Error out when config.toml contains fields this Codex version does not recognize.

Set the PR/review title.

Review uncommitted changes.

Types

sandbox_mode()

@type sandbox_mode() :: :read_only | :workspace_write | :danger_full_access

t()

@type t() :: %CodexWrapper.Review{
  base: String.t() | nil,
  commit: String.t() | nil,
  config_overrides: [String.t()],
  dangerously_bypass_approvals_and_sandbox: boolean(),
  dangerously_bypass_hook_trust: boolean(),
  disabled_features: [String.t()],
  enabled_features: [String.t()],
  ephemeral: boolean(),
  full_auto: boolean(),
  ignore_rules: boolean(),
  ignore_user_config: boolean(),
  json: boolean(),
  model: String.t() | nil,
  output_last_message: String.t() | nil,
  output_schema: String.t() | nil,
  prompt: String.t() | nil,
  sandbox: sandbox_mode() | nil,
  skip_git_repo_check: boolean(),
  strict_config: boolean(),
  title: String.t() | nil,
  uncommitted: boolean()
}

Functions

base(r, branch)

@spec base(t(), String.t()) :: t()

Compare against a base branch.

commit(r, sha)

@spec commit(t(), String.t()) :: t()

Review a specific commit.

config(r, kv)

@spec config(t(), String.t()) :: t()

Add a config override (key=value).

dangerously_bypass_approvals_and_sandbox(r)

@spec dangerously_bypass_approvals_and_sandbox(t()) :: t()

Bypass all approvals and sandbox. Use with extreme caution.

dangerously_bypass_hook_trust(r)

@spec dangerously_bypass_hook_trust(t()) :: t()

Run enabled hooks without requiring persisted hook trust. Use with extreme caution.

Hook trust is what stops a repository from running arbitrary commands the user never approved. Only appropriate for automation that already vets where its hooks come from.

disable(r, feature)

@spec disable(t(), String.t()) :: t()

Disable a feature.

enable(r, feature)

@spec enable(t(), String.t()) :: t()

Enable a feature.

ephemeral(r)

@spec ephemeral(t()) :: t()

Enable ephemeral mode (no session persistence).

execute(review, config)

@spec execute(t(), CodexWrapper.Config.t()) ::
  {:ok, CodexWrapper.Result.t()} | {:error, term()}

Execute the review command synchronously, returning a parsed %Result{}.

execute_json(review, config)

@spec execute_json(t(), CodexWrapper.Config.t()) ::
  {:ok, [CodexWrapper.JsonLineEvent.t()]} | {:error, term()}

Execute the review command with --json and return parsed NDJSON events.

Forces --json on the command, runs synchronously, then parses each NDJSON line from stdout.

full_auto(r)

@spec full_auto(t()) :: t()

Enable full-auto mode.

Deprecated upstream. Emits -c sandbox_mode="workspace-write", the config-key form of what the Codex CLI now tells you to use in place of --full-auto. An explicit sandbox/2 call is more specific and wins over this.

ignore_rules(r)

@spec ignore_rules(t()) :: t()

Do not load user or project execpolicy .rules files.

ignore_user_config(r)

@spec ignore_user_config(t()) :: t()

Do not load $CODEX_HOME/config.toml.

Auth still resolves through CODEX_HOME; only the config file is skipped. Pair with config/2 overrides for a run that does not pick up the developer's personal settings.

json(r)

@spec json(t()) :: t()

Enable JSON output.

model(r, model)

@spec model(t(), String.t()) :: t()

Set the model.

new()

@spec new() :: t()

Create a new review command.

output_last_message(r, path)

@spec output_last_message(t(), String.t()) :: t()

Set the output-last-message path.

output_schema(r, path)

@spec output_schema(t(), String.t()) :: t()

Set the output schema path.

prompt(r, prompt)

@spec prompt(t(), String.t()) :: t()

Set an optional prompt for additional review context.

sandbox(r, mode)

@spec sandbox(t(), sandbox_mode()) :: t()

Set the sandbox mode.

Emits -c sandbox_mode="<mode>" rather than --sandbox <mode>: the flag is accepted by codex exec only, and codex exec review rejects it with unexpected argument. The config key is the supported equivalent and takes the same three values.

skip_git_repo_check(r)

@spec skip_git_repo_check(t()) :: t()

Skip the git repo check.

stream(review, config)

@spec stream(t(), CodexWrapper.Config.t()) :: Enumerable.t()

Execute the review command and return a lazy Stream of %JsonLineEvent{}.

Reads NDJSON output line-by-line through the configured CodexWrapper.Runner. Forces --json on the command.

strict_config(r)

@spec strict_config(t()) :: t()

Error out when config.toml contains fields this Codex version does not recognize.

Turns a silently-ignored typo in a config file into a failed run, which is usually what a programmatic caller wants.

title(r, title)

@spec title(t(), String.t()) :: t()

Set the PR/review title.

uncommitted(r)

@spec uncommitted(t()) :: t()

Review uncommitted changes.