# opencoredev/grok-build2 architecture

> Architecture diagram of the GitHub repository opencoredev/grok-build2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/opencoredev/grok-build2
- Repository: https://github.com/opencoredev/grok-build2

## Overview

Grok Build is a terminal-based AI coding agent: users start it interactively, run it headlessly, or connect through ACP; the agent can inspect a codebase, edit files, run commands, search the web, and manage longer-running work. The graph preserves these product stages and major runtime capabilities, plus memory, voice, and workflow support. Several implementation links are based only on README descriptions or directory names, so uncertain wiring is omitted rather than inferred; the sampled excerpts do not show the top-level runtime orchestration.

Main entry points: [`crates/codegen/xai-grok-agent/src`](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-agent/src) (Agent runtime), [`crates/codegen/xai-grok-pager-bin/src/main.rs`](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-pager-bin/src/main.rs) (Grok CLI and TUI), [`crates/codegen/xai-grok-shell/src`](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-shell/src) (Shell and session), [`crates/codegen/xai-workflow/src/engine.rs`](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-workflow/src/engine.rs) (Long-running workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_cli["Grok CLI and TUI<br/>[main.rs]"]
end

subgraph group_agent["Agent runtime"]
  node_agent_runtime["Agent runtime"]
  node_shell["Shell and session"]
  node_workflow["Long-running workflows<br/>[engine.rs]"]
end

subgraph group_capabilities["Coding capabilities"]
  node_code_graph["Codebase indexing<br/>[index_manager.rs]"]
  node_tools["Agent tools"]
  node_web_search["Web search<br/>[web_search.rs]"]
  node_fast_worktree["Worktree operations<br/>[engine.rs]"]
  node_voice["Voice input<br/>[pipeline.rs]"]
end

subgraph group_state["Session state"]
  node_chat_state["Conversation state"]
  node_memory[("Agent memory<br/>[storage.rs]")]
end

subgraph group_interfaces["External interfaces"]
  node_acp["ACP integration"]
  node_auth[("Authentication<br/>[storage.rs]")]
  node_model_service(("OpenAI-compatible endpoint"))
  node_shell_environment(("Shell environment"))
end

node_user(("User or script"))

node_user -->|"starts session"| node_cli
node_user -->|"connects editor"| node_acp
node_cli -.->|"runs agent"| node_agent_runtime
node_agent_runtime -->|"understands codebase"| node_code_graph
node_agent_runtime -.->|"uses tools"| node_tools
node_agent_runtime -->|"searches web"| node_web_search
node_agent_runtime -.->|"manages sessions"| node_shell
node_agent_runtime -.->|"maintains conversation"| node_chat_state
node_agent_runtime -->|"manages tasks"| node_workflow
node_tools -->|"runs commands"| node_shell_environment
node_tools -.->|"edits files"| node_fast_worktree
node_agent_runtime -.->|"uses memory"| node_memory
node_user -.->|"speaks input"| node_voice
node_agent_runtime -->|"requests inference"| node_model_service
node_agent_runtime -.->|"authenticates"| node_auth

click node_cli "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-pager-bin/src/main.rs"
click node_acp "https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-acp-lib/src"
click node_agent_runtime "https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-agent/src"
click node_shell "https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-shell/src"
click node_chat_state "https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-chat-state/src"
click node_workflow "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-workflow/src/engine.rs"
click node_code_graph "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-codebase-graph/src/index_manager.rs"
click node_web_search "https://github.com/opencoredev/grok-build2/blob/main/crates/common/xai-tool-types/src/web_search.rs"
click node_fast_worktree "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-fast-worktree/src/copy/engine.rs"
click node_memory "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-memory/src/storage.rs"
click node_voice "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-voice/src/pipeline.rs"
click node_auth "https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-login/src/storage.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_user toneBlue
class node_agent_runtime,node_shell,node_workflow toneAmber
class node_code_graph,node_tools,node_web_search,node_fast_worktree,node_voice toneMint
class node_chat_state,node_memory toneRose
class node_acp,node_auth,node_model_service,node_shell_environment toneIndigo
```

## Components

### User entry

- [Grok CLI and TUI](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-pager-bin/src/main.rs): `crates/codegen/xai-grok-pager-bin/src/main.rs`

### Agent runtime

- [Agent runtime](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-agent/src): `crates/codegen/xai-grok-agent/src`
- [Shell and session](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-grok-shell/src): `crates/codegen/xai-grok-shell/src`
- [Long-running workflows](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-workflow/src/engine.rs): `crates/codegen/xai-workflow/src/engine.rs`

### Coding capabilities

- [Codebase indexing](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-codebase-graph/src/index_manager.rs): `crates/codegen/xai-codebase-graph/src/index_manager.rs`
- **Agent tools**
- [Web search](https://github.com/opencoredev/grok-build2/blob/main/crates/common/xai-tool-types/src/web_search.rs): `crates/common/xai-tool-types/src/web_search.rs`
- [Worktree operations](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-fast-worktree/src/copy/engine.rs): `crates/codegen/xai-fast-worktree/src/copy/engine.rs`
- [Voice input](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-voice/src/pipeline.rs): `crates/codegen/xai-grok-voice/src/pipeline.rs`

### Session state

- [Conversation state](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-chat-state/src): `crates/codegen/xai-chat-state/src`
- [Agent memory](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-memory/src/storage.rs): `crates/codegen/xai-grok-memory/src/storage.rs`

### External interfaces

- [ACP integration](https://github.com/opencoredev/grok-build2/tree/main/crates/codegen/xai-acp-lib/src): `crates/codegen/xai-acp-lib/src`
- [Authentication](https://github.com/opencoredev/grok-build2/blob/main/crates/codegen/xai-grok-login/src/storage.rs): `crates/codegen/xai-grok-login/src/storage.rs`
- **OpenAI-compatible endpoint**
- **Shell environment**

### Other components

- **User or script**

## Connections

- User or script → Grok CLI and TUI: starts session (evidence: `README.md`)
- User or script → ACP integration: connects editor (evidence: `README.md`)
- Grok CLI and TUI → Agent runtime: runs agent
- Agent runtime → Codebase indexing: understands codebase (evidence: `README.md`)
- Agent runtime → Agent tools: uses tools
- Agent runtime → Web search: searches web (evidence: `README.md`)
- Agent runtime → Shell and session: manages sessions
- Agent runtime → Conversation state: maintains conversation
- Agent runtime → Long-running workflows: manages tasks (evidence: `README.md`)
- Agent tools → Shell environment: runs commands (evidence: `README.md`)
- Agent tools → Worktree operations: edits files
- Agent runtime → Agent memory: uses memory
- User or script → Voice input: speaks input
- Agent runtime → OpenAI-compatible endpoint: requests inference (evidence: `README.md`)
- Agent runtime → Authentication: authenticates
