# shobrook/wut architecture

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

- Interactive diagram: https://gitdiagram.com/shobrook/wut
- Repository: https://github.com/shobrook/wut

## Overview

wut is a terminal-output explanation CLI: a user runs it after a command, the CLI validates the tmux/screen and model configuration, gathers shell history, and requests an explanation or answer from a configured LLM before displaying Markdown. The sampled code shows shell/context/explanation calls and provider dispatch; several context-building internals are omitted, so those relationships are not expanded. README-documented provider options are retained as separate integrations.

Main entry points: [`wut/utils.py`](https://github.com/shobrook/wut/blob/master/wut/utils.py) (Explain and dispatch), [`wut/wut.py`](https://github.com/shobrook/wut/blob/master/wut/wut.py) (wut CLI), [`wut/prompts.py`](https://github.com/shobrook/wut/blob/master/wut/prompts.py) (Prompt templates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["wut CLI<br/>[wut.py]"]
end

subgraph group_context["Terminal context"]
  node_shell["Shell detection<br/>[utils.py]"]
  node_capture["Pane capture<br/>[utils.py]"]
  node_history["Command history<br/>[utils.py]"]
  node_context_bundle["Context assembly<br/>[utils.py]"]
end

subgraph group_reasoning["Prompt and inference"]
  node_prompt_templates["Prompt templates<br/>[prompts.py]"]
  node_inference["Explain and dispatch<br/>[utils.py]"]
  node_markdown["Markdown formatting<br/>[utils.py]"]
end

subgraph group_providers["LLM providers"]
  node_openai["OpenAI client<br/>[utils.py]"]
  node_anthropic["Anthropic client<br/>[utils.py]"]
  node_ollama["Ollama client<br/>[utils.py]"]
end

node_user(("Terminal user"))
node_openai_service["OpenAI service"]
node_anthropic_service["Anthropic service"]
node_ollama_service["Ollama model"]

node_user -->|"runs"| node_cli
node_cli -->|"detects shell"| node_shell
node_cli -->|"gathers context"| node_context_bundle
node_cli -->|"requests explanation"| node_inference
node_shell -.-> node_capture
node_capture -.-> node_history
node_history -.-> node_context_bundle
node_prompt_templates -->|"supplies templates"| node_inference
node_inference -->|"dispatches"| node_openai
node_inference -->|"dispatches"| node_anthropic
node_inference -->|"dispatches"| node_ollama
node_openai -->|"requests completion"| node_openai_service
node_anthropic -->|"requests message"| node_anthropic_service
node_ollama -->|"requests chat"| node_ollama_service
node_inference -->|"formats response"| node_markdown
node_markdown -->|"returns for display"| node_cli

click node_cli "https://github.com/shobrook/wut/blob/master/wut/wut.py"
click node_shell "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_capture "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_history "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_context_bundle "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_prompt_templates "https://github.com/shobrook/wut/blob/master/wut/prompts.py"
click node_inference "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_markdown "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_openai "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_anthropic "https://github.com/shobrook/wut/blob/master/wut/utils.py"
click node_ollama "https://github.com/shobrook/wut/blob/master/wut/utils.py"

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_shell,node_capture,node_history,node_context_bundle toneAmber
class node_prompt_templates,node_inference,node_markdown toneMint
class node_openai,node_anthropic,node_ollama toneRose
class node_openai_service,node_anthropic_service,node_ollama_service toneIndigo
```

## Components

### CLI entry

- [wut CLI](https://github.com/shobrook/wut/blob/master/wut/wut.py): `wut/wut.py`

### Terminal context

- [Shell detection](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Pane capture](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Command history](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Context assembly](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`

### Prompt and inference

- [Prompt templates](https://github.com/shobrook/wut/blob/master/wut/prompts.py): `wut/prompts.py`
- [Explain and dispatch](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Markdown formatting](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`

### LLM providers

- [OpenAI client](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Anthropic client](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`
- [Ollama client](https://github.com/shobrook/wut/blob/master/wut/utils.py): `wut/utils.py`

### Other components

- **Terminal user**
- **OpenAI service**
- **Anthropic service**
- **Ollama model**

## Connections

- Terminal user → wut CLI: runs (evidence: `README.md`)
- wut CLI → Shell detection: detects shell (evidence: `wut/wut.py`)
- wut CLI → Context assembly: gathers context (evidence: `wut/wut.py`)
- wut CLI → Explain and dispatch: requests explanation (evidence: `wut/wut.py`)
- Shell detection → Pane capture (evidence: `wut/utils.py`)
- Pane capture → Command history (evidence: `wut/utils.py`)
- Command history → Context assembly (evidence: `wut/utils.py`)
- Prompt templates → Explain and dispatch: supplies templates (evidence: `wut/utils.py`)
- Explain and dispatch → OpenAI client: dispatches (evidence: `wut/utils.py`)
- Explain and dispatch → Anthropic client: dispatches (evidence: `wut/utils.py`)
- Explain and dispatch → Ollama client: dispatches (evidence: `wut/utils.py`)
- OpenAI client → OpenAI service: requests completion (evidence: `wut/utils.py`)
- Anthropic client → Anthropic service: requests message (evidence: `wut/utils.py`)
- Ollama client → Ollama model: requests chat (evidence: `wut/utils.py`)
- Explain and dispatch → Markdown formatting: formats response (evidence: `wut/utils.py`)
- Markdown formatting → wut CLI: returns for display (evidence: `wut/wut.py`)
