ClaudeCode.Adapter.Port.Resolver (ClaudeCode v0.32.2)

View Source

Resolves the Claude CLI binary for the local adapter.

This module handles finding the CLI binary using one of three resolution modes:

  • :bundled (default) -- Uses the binary in priv/bin/. Auto-installs if missing. Verifies version matches the SDK's pinned version and re-installs on mismatch.
  • :global -- Finds an existing system install via PATH or common locations. No auto-install.
  • "/path/to/claude" -- Uses that exact binary path.

Can also be configured via application config:

config :claude_code, cli_path: :global

Summary

Functions

Finds the claude binary using the configured resolution mode.

Validates that the Claude CLI is properly installed and accessible.

Functions

find_binary(opts \\ [])

@spec find_binary(keyword()) :: {:ok, String.t()} | {:error, term()}

Finds the claude binary using the configured resolution mode.

Resolution Modes

The :cli_path option (or app config) determines how the binary is found:

  • :bundled (default) -- Use priv/bin/ binary. Auto-installs if missing. Verifies the installed version matches Installer.configured_version() and re-installs on mismatch.
  • :global -- Finds an existing system install via PATH or common locations. Does not auto-install. Returns {:error, :not_found} if not found.
  • "/path/to/claude" -- Uses that exact binary. Returns {:error, :not_found} if it doesn't exist.

Examples

iex> ClaudeCode.Adapter.Port.Resolver.find_binary()
{:ok, "/path/to/priv/bin/claude"}

iex> ClaudeCode.Adapter.Port.Resolver.find_binary(cli_path: :global)
{:ok, "/usr/local/bin/claude"}

iex> ClaudeCode.Adapter.Port.Resolver.find_binary(cli_path: "/custom/path/claude")
{:ok, "/custom/path/claude"}

validate_installation(opts \\ [])

@spec validate_installation(keyword()) :: :ok | {:error, term()}

Validates that the Claude CLI is properly installed and accessible.