Developer Guide
This guide provides information for developers who want to contribute to Terminal Agent.
Development Environment Setup
Prerequisites
Before you begin, ensure you have the following installed:
- Go - Terminal Agent is written in Go (1.20+ recommended)
- Official Go Installation Guide
-
Verify installation with:
go version
-
Taskfile - Used instead of Makefile for running tasks
- Taskfile Installation Guide
-
Verify installation with:
task --version
-
Docker - Required for running integration tests
- Docker Installation Guide
- Verify installation with:
docker --version
Setting Up the Repository
-
Clone the repository
-
Install dependencies
-
Build the project
-
Run tests
Development Workflow
Common Tasks
Terminal Agent uses Taskfile for managing development tasks. Here are some common commands:
# Build the project
task build
# Install to your PATH
task install
# Run unit tests
task test
# Run integration tests
task test:integ
# Run the agent with a question
task run:ask -- "What is a file descriptor?"
# Run the agent with a task
task run:task -- "List files in current directory"
# Set environment for different providers
task run:set:openai
task run:set:anthropic
task run:set:bedrock
task run:set:perplexity
task run:set:google
To see all available tasks:
Project Structure
terminal-agent/
├── cmd/ # Command-line applications
│ └── agent/ # Main agent application
├── internal/ # Private application and library code
│ ├── agent/ # Agent implementation
│ ├── commands/ # CLI command implementations
│ ├── config/ # Configuration handling
│ ├── connector/ # LLM provider connectors
│ ├── history/ # History logging and retrieval
│ ├── tools/ # Tool implementations
│ └── utils/ # Utility functions
├── docs/ # Documentation
├── tests/ # Test files
└── Taskfile.dist.yaml # Development tasks
Docker Environment
For integration testing and consistent development environments, Terminal Agent uses Docker:
# Build the test environment
task env:build
# Setup the test environment
task env:setup
# Access the test environment
task env:access
# Run tests in the environment
task env:test
Adding LLM Provider Support
To add support for a new LLM provider:
- Create a new connector file in
internal/connector/
- Implement the
LLMConnector
interface - Update the
NewConnector
factory function to include your provider - Add appropriate configuration options
Adding New Tools
To add a new tool:
- Create a new tool implementation in
internal/tools/
- Implement the
Tool
interface - Update the
ToolProvider
to return your new tool - Add documentation for your tool
Documentation
Documentation is written in Markdown and stored in the docs/
directory. To update the documentation:
- Edit the relevant Markdown files
- If adding new pages, update the navigation in
docs/Readme.md
Building for Release
To build for release:
This creates optimized binaries for multiple platforms in the release/
directory.
Code Style and Conventions
- Follow standard Go code style and conventions
- Use
go fmt
to format code - Use
golint
andgolangci-lint
for linting - Write tests for new functionality
- Document public functions and types
Pull Request Process
- Fork the repository
- Create a feature branch
- Make your changes
- Add/update tests as necessary
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request
Debugging
For debugging, use the --loglevel debug
flag:
Continuous Integration
The project uses GitHub Actions for continuous integration. When you submit a pull request, the CI system will automatically:
- Build the project
- Run unit tests
- Run integration tests
- Check code formatting
Ensure that all CI checks pass before your pull request can be merged.