Gopilot-CLI is a terminal-based, multi-turn AI coding agent written in Go.
It talks to an OpenAI-compatible API and can run shell commands, read/write files in your workspace, and auto-summarize long sessions.
- Go
1.21+ - An OpenAI-compatible chat completion API (e.g. OpenAI, local gateway, or OSS service)
- A valid API key for that service
# Clone and build
git clone <repository-url>
cd gopilot-cli
go build -o gopilot ./cmd/gopilotGopilot-CLI reads its main configuration from configs/config.yaml.
You can set your API key either in this file or via environment variable:
export OPENAI_API_KEY="your-api-key-here"In configs/config.yaml:
llm:
api_key: "sk-xxx" # optional if you use OPENAI_API_KEY
api_base: "https://api.openai.com/v1" # or your own compatible endpoint
model: "gpt-4.1" # or any compatible model
agent:
workspace_dir: "./workspace" # default workspace folder
max_steps: 50
token_limit: 80000 # triggers history summarizationWhen both are set, the value in configs/config.yaml (llm.api_key) takes precedence over OPENAI_API_KEY.
# Run with current directory as workspace
./gopilot
# Or specify workspace directory
./gopilot -w /path/to/workspaceTypical workflow:
- Run
gopilotinside a project directory - Describe the task you want it to perform (e.g. “add a REST handler”, “fix failing tests”)
- Let it use tools to edit files and run
gocommands for you
- 🔄 Multi-turn Conversations with context preservation
- 🛠️ Tool Calling for commands and file operations
- 📝 Auto-summarization when token limits exceeded
- 🎨 Interactive Terminal with command completion
- 🔁 Retry Mechanism with exponential backoff
Bash- Execute shell commandsBashOutput- Monitor background processesBashKill- Terminate processes
Read- Read files within workspaceWrite- Create/overwrite filesEdit- Modify file contents
| Command | Description |
|---|---|
/help |
Show available commands |
/clear |
Clear session history |
/history |
Display message count |
/stats |
Show session statistics |
/exit |
Exit program |
Also supports: exit, quit, or q
# Build the binary
go build -o gopilot ./cmd/gopilot
# Run tests
go test ./tests/...
# Format code
go fmt ./...openai/openai-go/v3- OpenAI API SDKc-bata/go-prompt- Interactive terminalpkoukk/tiktoken-go- Token countingstretchr/testify- Testing assertions
