# block/goose architecture

> Architecture diagram of the GitHub repository block/goose, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/block/goose
- Repository: https://github.com/block/goose

## Overview

##### Main Components

a) Core Components:
- CLI Interface (src/goose/cli)
- Command System (src/goose/command)
- Toolkit Framework (src/goose/toolkit)
- Exchange System (packages/exchange)
- Synopsis System (src/goose/synopsis)

b) Integration Components:
- LLM Providers (packages/exchange/src/exchange/providers)
- External Tools Integration (src/goose/tools)
- Plugin System
- Session Management

**┌─ User Interface Layer ─────────────────────┐**
- CLI Interface / IDE Extensions             │
- Core Processing Layer ────────────────────┤
- Command System   Synopsis System           │
- Toolkit System   Session Management        │
- Exchange Layer ───────────────────────────┤
- Message Handling                           │
- Provider Management                        │
- Tool Integration                           │
- External Integration Layer ───────────────┤
- LLM Providers (OpenAI, Anthropic, etc.)   │
- External Tools (GitHub, Jira, etc.)       │
- ┘

##### Key Relationships to Highlight

- Bidirectional flow between CLI and Core Processing Layer
- How the Exchange system mediates between core components and external providers
- Demonstrate toolkit extensibility with plugin architecture
- How session management persists across interactions

##### Specific Implementation Details

a) Core Flow:
**User Input → CLI → Command System → Exchange → LLM Provider → Response Processing → Action Execution**

b) Toolkit Integration:
**Toolkit Framework ─┬─ Developer Toolkit**
- GitHub Toolkit
- Lint Toolkit
- Custom Toolkits

##### Important Elements

- Session persistence mechanism
- Tool execution flow
- Provider abstraction layer
- Message handling system
- Moderator system for message processing
- Observer pattern for monitoring (Langfuse integration)

##### Technical Details to Highlight

- Python-based architecture
- Modular design with clear separation of concerns
- Plugin-based extensibility
- Multiple provider support
- Shell command integration

This system design should emphasize Goose's unique features: its autonomy in executing tasks, extensibility through toolkits, and integration with various external services while maintaining user control over the process.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef exchange fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef tools fill:#795548,stroke:#4E342E,color:white
    classDef session fill:#607D8B,stroke:#37474F,color:white
    classDef config fill:#00BCD4,stroke:#0097A7,color:white

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]:::ui
        IDE["IDE Extensions"]:::ui
    end

    %% Core Processing Layer
    subgraph Core
        CMD["Command System"]:::core
        SYN["Synopsis System"]:::core
        TK["Toolkit Framework"]:::core
        SESS["Session Management"]:::session
    end

    %% Exchange Layer
    subgraph Exchange
        EX["Exchange System"]:::exchange
        MSG["Message Handling"]:::exchange
        MOD["Moderator System"]:::exchange
        OBS["Observer System"]:::exchange
    end

    %% Tools Layer
    subgraph Tools
        REPO["Repository Context"]:::tools
        SUM["Summarization Tools"]:::tools
        SHELL["Shell Integration"]:::tools
    end

    %% Configuration
    subgraph Config
        CONF["Configuration Management"]:::config
    end

    %% External Integration Layer
    subgraph External
        LLM["LLM Providers"]:::external
        EXT["External Tools"]:::external
    end

    %% Relationships
    CLI --> CMD
    IDE --> CMD
    CMD --> EX
    CMD --> SYN
    CMD --> TK
    TK --> REPO
    TK --> SUM
    TK --> SHELL
    EX --> MSG
    EX --> MOD
    EX --> OBS
    EX --> LLM
    EX --> EXT
    SESS --> CMD
    CONF --> CMD

    %% Click Events
    click CLI "https://github.com/block/goose/tree/main/src/goose/cli/"
    click CMD "https://github.com/block/goose/tree/main/src/goose/command/"
    click TK "https://github.com/block/goose/tree/main/src/goose/toolkit/"
    click EX "https://github.com/block/goose/tree/main/packages/exchange/src/exchange/"
    click SYN "https://github.com/block/goose/tree/main/src/goose/synopsis/"
    click LLM "https://github.com/block/goose/tree/main/packages/exchange/src/exchange/providers/"
    click EXT "https://github.com/block/goose/tree/main/src/goose/tools/"
    click SESS "https://github.com/block/goose/blob/main/src/goose/cli/session.py"
    click MSG "https://github.com/block/goose/blob/main/packages/exchange/src/exchange/message.py"
    click MOD "https://github.com/block/goose/tree/main/packages/exchange/src/exchange/moderators/"
    click OBS "https://github.com/block/goose/tree/main/packages/exchange/src/exchange/observers/"
    click REPO "https://github.com/block/goose/tree/main/src/goose/toolkit/repo_context/"
    click SUM "https://github.com/block/goose/tree/main/src/goose/toolkit/summarization/"
    click SHELL "https://github.com/block/goose/blob/main/src/goose/utils/shell.py"
    click CONF "https://github.com/block/goose/blob/main/src/goose/cli/config.py"

    %% Legend
    classDef legend fill:#fff,stroke:#333,stroke-width:1px
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Core Components"]:::core
        L3["Exchange Components"]:::exchange
        L4["External Integration"]:::external
        L5["Tools"]:::tools
        L6["Session"]:::session
        L7["Configuration"]:::config
    end
```
