Skip to content

Conversation

@github-actions
Copy link
Contributor

Summary

This PR introduces a preflight check mechanism for the CLI that verifies, before starting the agent, that:

  • The specified repo_path is inside a Git worktree.
  • The node binary is on PATH (and its version is logged).
  • The docker binary is on PATH (and its version is logged).

In addition, it implements support for reading a prompt from a file when --prompt is given a filepath.

Implementation Details

  • Created src/oai_coding_agent/preflight.py with:
    • is_inside_git_repo(), get_tool_version(), check_node(), check_docker() helpers.
    • run_preflight_checks() orchestrator that prints errors via typer.echo and exits with typer.Exit(code=1) if any check fails.
  • Integrated run_preflight_checks() into cli.main() immediately after building the Config.
  • Extended the CLI prompt logic to detect when --prompt points to a file and load its contents.
  • Logged Node.js and Docker versions at INFO level using the existing logger, so they are written to ~/.oai_coding_agent/agent.log.

Assumptions

  • The Git binary is required to determine worktree membership; if Git is not installed, the check will fail with a clear error.
  • For simplicity, version commands use node --version and docker --version.

Testing

  • New unit tests in tests/test_preflight.py cover successful and failure scenarios for preflight checks (Git, Node.js, Docker) and validate the version logging via caplog.
  • The existing tests/test_cli.py was updated with an autouse fixture to stub out preflight during CLI tests, and the prompt-file behavior test was updated to reflect the new file-reading logic.
  • Ran uv run pytest -q to ensure all tests pass.

Considerations & Alternatives

  • Could have separately checked for the Git binary presence, but unified the worktree check to handle both missing Git and non-repo cases.
  • Chose to accumulate all preflight errors and display them together, rather than failing fast on the first error.
  • File-reading logic is local to the prompt-handling block; alternative designs could externalize prompt-loading to a helper.

@github-actions github-actions bot added the oai label May 27, 2025
@mattmorgis mattmorgis merged commit f3a4182 into main May 28, 2025
@mattmorgis mattmorgis deleted the oai/issue-8 branch May 28, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants