Skip to content

argobell/gopilot-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gopilot-CLI

Go Version License

中文 English
Gopilot-CLI

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.

Requirements

  • Go 1.21+
  • An OpenAI-compatible chat completion API (e.g. OpenAI, local gateway, or OSS service)
  • A valid API key for that service

Quick Start

Installation

# Clone and build
git clone <repository-url>
cd gopilot-cli
go build -o gopilot ./cmd/gopilot

Configuration

Gopilot-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 summarization

When both are set, the value in configs/config.yaml (llm.api_key) takes precedence over OPENAI_API_KEY.

Usage

# Run with current directory as workspace
./gopilot

# Or specify workspace directory
./gopilot -w /path/to/workspace

Typical workflow:

  • Run gopilot inside 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 go commands for you

Features

  • 🔄 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

Tools

Bash Tools

  • Bash - Execute shell commands
  • BashOutput - Monitor background processes
  • BashKill - Terminate processes

File Tools

  • Read - Read files within workspace
  • Write - Create/overwrite files
  • Edit - Modify file contents

Commands

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

Development

# Build the binary
go build -o gopilot ./cmd/gopilot

# Run tests
go test ./tests/...

# Format code
go fmt ./...

Dependencies

About

Gopilot-CLI is a terminal-based, multi-turn AI coding agent written in Go.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages