GitHub Copilot

Integrate GitHub Copilot CLI with Ralph TUI for AI-assisted coding.

GitHub Copilot

The GitHub Copilot agent plugin integrates with GitHub's copilot CLI to execute AI coding tasks. It supports model selection and auto-approve mode for autonomous operation.

INFO

GitHub Copilot leverages your GitHub account and subscription for AI-powered code assistance directly from the command line.

Prerequisites

Bash
# Install Copilot CLI
brew install copilot-cli
# Or: npm install -g @github/copilot
# Or: winget install GitHub.Copilot (Windows)
# Or: curl -fsSL https://gh.io/copilot-install | bash
 
# (Optional) Install GitHub CLI for authentication
# See: https://github.com/cli/cli

Verify installation:

Bash
copilot --version

Ensure you have an active GitHub Copilot subscription (Individual, Business, or Enterprise).

Basic Usage

Run with GitHub Copilot

Use the --agent github-copilot flag:

Bash
ralph-tui run --prd ./prd.json --agent github-copilot

Select a Model

Override the model with --model:

Bash
ralph-tui run --prd ./prd.json --agent github-copilot --model gpt-4

Configure Auto-Approve

Enable auto-approve in config:

TOML
[agentOptions]
autoApprove = true

Configuration

Shorthand Config

The simplest configuration:

TOML
# .ralph-tui/config.toml
agent = "github-copilot"
 
[agentOptions]
model = "gpt-4"

Full Config

For advanced control:

TOML
[[agents]]
name = "my-copilot"
plugin = "github-copilot"
default = true
command = "copilot"
timeout = 300000
 
[agents.options]
model = "gpt-4"
autoApprove = true

Options Reference

OptionTypeDefaultDescription
modelstring-Model to use (e.g., gpt-4, gpt-3.5-turbo)
autoApprovebooleantrueAuto-approve operations for autonomous execution
timeoutnumber0Execution timeout in ms (0 = no timeout)
commandstring"copilot"Path to Copilot CLI executable

Auto-Approve Mode

When autoApprove is enabled (default), GitHub Copilot will execute operations without prompting for confirmation. This is required for Ralph TUI's autonomous operation.

TOML
[agentOptions]
autoApprove = true
INFO

With autoApprove enabled, Copilot will make changes without confirmation. Review your PRD carefully before running.

How It Works

When Ralph TUI executes a task with GitHub Copilot:

  1. Build command: Constructs copilot [options]
  2. Pass prompt via stdin: Avoids shell escaping issues with special characters
  3. Stream output: Captures stdout/stderr in real-time
  4. Handle exit: Reports success, failure, or timeout

CLI Arguments

Ralph TUI builds these arguments:

Bash
copilot \
  --yolo \                   # When autoApprove enabled (default)
  --model gpt-4 \            # If model specified
  < prompt.txt               # Prompt via stdin

Troubleshooting

"GitHub Copilot CLI not found"

Ensure Copilot is installed and in your PATH:

Bash
which copilot
# Should output: /path/to/copilot
 
# If not found, install Copilot CLI:
brew install copilot-cli
# Or: npm install -g `@github/copilot`
# Or: curl -fsSL https://gh.io/copilot-install | bash

"Execution timeout"

Increase the timeout for complex tasks:

TOML
[[agents]]
name = "github-copilot"
plugin = "github-copilot"
timeout = 600000  # 10 minutes

"Authentication failed"

Authenticate with GitHub Copilot using one of the following methods:

Method 1: Interactive Login

Run the copilot command and use the /login command at the prompt:

Bash
copilot
# In the prompt, type: /login

Method 2: Non-Interactive (Token)

Set GH_TOKEN or GITHUB_TOKEN to a fine-grained Personal Access Token (PAT) that includes the "Copilot Requests" permission:

Bash
export GH_TOKEN="your_fine_grained_pat"
# Or: export GITHUB_TOKEN="your_fine_grained_pat"

Next Steps