Project Structure
Core Crates
goose
The heart of the framework. Contains:- agents/ - Agent implementations and lifecycle management
agent.rs- Main agent loopextension.rs- Extension configurationextension_manager.rs- Extension lifecycle
- providers/ - LLM provider integrations
base.rs- Provider trait definitionanthropic.rs,openai.rs, etc. - Specific providersdeclarative/- JSON-based provider configscanonical/- Model capability registry
- conversation/ - Message handling
message.rs- Message types- Conversation state management
- config/ - Configuration management
- Provider configs
- Extension configs
- Path management
goose-cli
Command-line interface. Entry point:crates/goose-cli/src/main.rs
Provides commands:
session- Start interactive sessionconfigure- Configure providersrun- Execute recipesversion- Version info
goose-server
HTTP/WebSocket server for the desktop UI. Entry point:crates/goose-server/src/main.rs
Features:
- REST API for agent management
- WebSocket for streaming responses
- Session management
- OpenAPI schema generation
goose-mcp
Builtin MCP (Model Context Protocol) extensions:- autovisualiser - Automatic visualization generation
- computercontroller - Desktop automation
- memory - Long-term memory storage
- tutorial - Interactive tutorials
rmcp::ServerHandler trait.
goose-acp
Agent Client Protocol - defines communication between agents and extensions.Key Architectural Patterns
Provider Trait
All LLM providers implement theProvider trait (crates/goose/src/providers/base.rs:456):
stream()- Primary method for streaming responsescomplete()- Non-streaming completiongenerate_session_name()- Create session titlesconfigure_oauth()- OAuth authentication
Extension System
Extensions are MCP servers that provide:- Tools - Functions the agent can call
- Resources - Data sources
- Prompts - Reusable prompt templates
tokio::io::DuplexStream.
Message Flow
Declarative Providers
Simple providers can be defined with JSON (crates/goose/src/providers/declarative/):
Entry Points
- CLI:
crates/goose-cli/src/main.rs - Server:
crates/goose-server/src/main.rs - UI:
ui/desktop/src/main.ts - Agent:
crates/goose/src/agents/agent.rs
Configuration Paths
Goose uses platform-specific directories:- Linux:
~/.config/goose/ - macOS:
~/Library/Application Support/goose/ - Windows:
%APPDATA%\goose\
GOOSE_PATH_ROOT environment variable.
Testing Architecture
Tests are organized:- Unit tests - Within crate files
- Integration tests -
crates/*/tests/directories - MCP tests -
crates/goose/tests/mcp_integration_test.rs - Test utilities -
goose-testandgoose-test-supportcrates
Build System
- Cargo - Rust build system and package manager
- Just - Task runner for common commands (see
Justfile) - npm - UI dependencies and scripts
- Hermit - Development environment manager
Design Principles
- Simplicity - Trust Rust’s type system, avoid defensive code
- Composability - Small, focused components
- Extensibility - MCP-based extension system
- Provider agnostic - Works with any LLM
- Local-first - Runs entirely on your machine
Common Code Patterns
Error Handling
Useanyhow::Result for error propagation:
Async Code
Heavy use oftokio and async_trait:
Streaming
Providers return streams of message chunks:Next Steps
- Learn about Testing
- Build Extensions
- Create Providers
- Understand Tool Creation