An intelligent programming assistant CLI tool built in Go, following the "Model as Agent" philosophy - where the LLM is the intelligent agent and code provides simple, focused tools.
┌─────────────────────────────────────────────────┐
│ User Input │
└──────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ Main Loop (Agent) │
│ ┌─────────────────────────────────────────┐ │
│ │ Message History Management │ │
│ └─────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────┐ │
│ │ System Prompt & Configuration │ │
│ └─────────────────────────────────────────┘ │
└──────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ LLM Client (OpenAI/Claude) │
└──────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ Tool Dispatcher │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Bash │ │ File │ │ Search │ │
│ │ Tool │ │ Tools │ │ Tool │ │
│ └──────────┘ └──────────┘ └──────────────┘ │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Edit │ │ Todo │ │ Security │ │
│ │ Tool │ │ Tool │ │ Validator │ │
│ └──────────┘ └──────────┘ └──────────────┘ │
└──────────────────────┬──────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ Output Formatting & Display │
└─────────────────────────────────────────────────┘
-
Agent System (
pkg/agent/)- Main loop orchestration
- Message history management
- LLM interaction coordination
- State management
-
Tool System (
pkg/tools/)- File Operations (
pkg/tools/file/): Read, write, list files with security validation - Bash Execution (
pkg/tools/bash/): Safe command execution with timeout and filtering - File Editing (
pkg/tools/edit/): Text replacement, insertion, deletion with backup - Code Search (
pkg/tools/search/): Grep-based code and symbol search with caching - Todo Management (
pkg/tools/todo/): Task tracking and progress monitoring - Security: Path validation, command filtering, permission system
- File Operations (
-
LLM Client (
pkg/llm/)- OpenAI Integration (
pkg/llm/openai/): Official OpenAI SDK integration - Anthropic Integration (
pkg/llm/anthropic/): Official Anthropic SDK integration - Mock Client (
pkg/llm/mock/): Testing and development support - Factory pattern for extensible provider support
- Streaming and non-streaming responses
- Tool calling (function calling) support
- Error handling and retry logic
- OpenAI Integration (
-
Message Management (
pkg/message/)- Message history with token limits
- Content formatting (Markdown, code highlighting)
- Message normalization
-
Configuration (
pkg/config/)- YAML-based configuration
- Environment variable support
- Validation and defaults
-
Todo System (
pkg/todo/)- Task management with status tracking
- Progress rendering with colors
- Constraints validation (max 20 items, 1 in-progress)
-
Reminder System (
pkg/reminder/)- Periodic reminders for Todo usage
- Non-intrusive message injection
- Go 1.24.6 or later
- API key for your chosen LLM provider:
- OpenAI API key (for GPT models)
- Anthropic API key (for Claude models)
git clone https://github.com/Zerofisher/goai.git
cd goai
go mod tidy
go build ./cmd/goai- Set up your API key (required for LLM features):
For OpenAI:
export OPENAI_API_KEY="your-api-key-here"For Anthropic:
export ANTHROPIC_API_KEY="your-api-key-here"- Build the project:
go build ./cmd/goai- Run GoAI Coder:
./goaiWhen you start GoAI Coder, you'll see an interactive prompt where you can ask the AI to help with programming tasks:
============================================================
GoAI Coder 0.1.0
============================================================
Welcome to GoAI Coder - Your intelligent programming assistant
Available commands:
/help - Show this help message
/clear - Clear the conversation
/stats - Show agent statistics
/reset - Reset the agent state
/exit - Exit the application
Type your query or command and press Enter.
------------------------------------------------------------
>
GoAI includes a full-screen TUI built with Bubble Tea. It shows assistant replies and real-time tool events side by side.
-
Run
- Default:
./goailaunches the TUI. - Fallback legacy prompt: set
GOAI_LEGACY_UI=1to use the old readline interface.
- Default:
-
Layout
- Left panel: conversation (assistant/user), with streaming updates.
- Right panel: tool events and outputs (started/succeeded/failed with truncated output).
- Bottom: input line; top/right: spinner status (e.g., “Running bash…”, “Thinking…”).
-
Keys
Enter: send the current inputEsc: cancel the current requestCtrl+C: quit
-
Tool Events
- Tools executed by the agent emit events in real time:
- started: tool name and sanitized arguments
- succeeded: duration + output (long output truncated)
- failed: error message
- Events do not alter conversation history; they are for visibility only.
- Tools executed by the agent emit events in real time:
-
Configuration (optional)
- Configure model/provider via
goai.yamlor env vars (see below). - Tool event output length is limited internally to keep the UI responsive.
- To force the legacy prompt temporarily:
GOAI_LEGACY_UI=1 ./goai.
- Configure model/provider via
> please create a simple Go program that prints "Hello, World!" to the console and save it as hello.go
[AI creates hello.go file]
File created: hello.go
created file: hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
> please create a Go program that calculates the Fibonacci sequence up to 10 numbers, save it as fib.go, and run it
[AI creates fib.go and runs it]
File created: fib.go
Running: go run fib.go
Output: [0 1 1 2 3 5 8 13 21 34]
> please search for all TODO comments in the codebase
[AI searches using grep-based search tool]
Found 5 TODO comments in the codebase...
> please help me implement the first TODO
[AI implements the TODO and updates the file]
GoAI Coder has access to the following tools to help with your development tasks:
- bash: Execute shell commands safely (with timeout and filtering)
- read_file: Read file contents
- write_file: Create or overwrite files
- list_files: List directory contents
- edit_file: Make precise edits to existing files
- search: Search code and symbols using grep
- todo: Manage task lists for complex operations
Inside the interactive prompt, you can use these commands:
/helpor/h- Show help message/clearor/c- Clear conversation history/statsor/s- Show agent statistics (messages, tokens, tool calls)/resetor/r- Reset the agent state/exitor/quit- Exit the application
You can customize GoAI Coder's behavior through environment variables:
# Required
export OPENAI_API_KEY="your-api-key"
# Optional
export OPENAI_MODEL="gpt-4" # Model to use (default: gpt-4)
export OPENAI_BASE_URL="https://api.openai.com/v1" # API endpoint (default: OpenAI)For advanced configuration, create a goai.yaml file in your project directory or ~/.config/goai/config.yaml:
OpenAI Configuration:
model:
provider: "openai"
name: "gpt-4.1-mini" # or "gpt-4", "gpt-3.5-turbo", etc.
max_tokens: 16000
timeout: 60
tools:
enabled:
- bash
- file
- edit
- search
- todo
bash:
timeout_ms: 30000
max_output_chars: 100000
forbidden_commands:
- "rm -rf /"
- "mkfs"
output:
format: "markdown"
colors: true
show_spinner: trueAnthropic Configuration:
model:
provider: "anthropic"
name: "claude-3-7-sonnet-latest" # or "claude-3-opus-latest", etc.
max_tokens: 16000
timeout: 60
tools:
enabled:
- bash
- file
- edit
- search
- todo
output:
format: "markdown"
colors: true
show_spinner: true- Be specific: Clearly describe what you want the AI to do
- Provide context: Mention file names, paths, and requirements
- Use /stats: Monitor token usage and conversation history
- Break down complex tasks: For large tasks, ask the AI to create a todo list first
- Review changes: Always review generated code before using it in production
# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Test specific packages
go test -v ./pkg/tools/search # Search tool tests
go test -v ./pkg/agent # Agent tests
go test -v ./pkg/tools/... # All tool tests
# Run with race detection
go test -race ./pkg/tools
# Run single test
go test -v ./pkg/tools/search -run TestSearchTool# Run comprehensive linter
golangci-lint run
# Auto-fix issues
golangci-lint run --fix
# Basic static analysis
go vet ./...goai/
├── cmd/goai/ # CLI entry point
│ ├── main.go # Application setup
│ ├── interactive.go # Interactive loop
│ └── spinner.go # Loading animations
├── pkg/
│ ├── agent/ # Agent core logic
│ ├── config/ # Configuration system
│ ├── dispatcher/ # Tool dispatcher
│ ├── llm/ # LLM client interface
│ ├── message/ # Message management
│ ├── reminder/ # System reminders
│ ├── todo/ # Todo management
│ ├── tools/ # Tool implementations
│ │ ├── bash/ # Command execution
│ │ ├── edit/ # File editing
│ │ ├── file/ # File operations
│ │ ├── search/ # Code search (grep-based)
│ │ └── todo/ # Todo tool
│ └── types/ # Core data structures
This project was inspired by and references the design of mini_kode, an excellent project that demonstrates the "Model as Agent" philosophy in AI-powered development tools.
This project is licensed under the MIT License - see the LICENSE file for details.