# sickwell/pentestgpt-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/sickwell/pentestgpt-v2
- Repository: https://github.com/sickwell/pentestgpt-v2

## Overview

Excalibur is a CLI-driven, CTF-focused penetration-testing agent. The documented workflow starts with a target and task, then uses an LLM agent and EGATS attack-tree planning to select work, invoke security tools, track findings and flags, and persist resumable sessions. Memory assembles attack context; events and the optional TUI expose run activity. The README documents model routing and lab use, but the sampled runtime sources do not establish every provider or deployment connection, so uncertain integrations are omitted or dashed.

Main entry points: [`excalibur/core/controller.py`](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/controller.py) (Run controller), [`excalibur/core/agent.py`](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/agent.py) (Pentest agent), [`excalibur/interface/main.py`](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/main.py) (CLI entry), [`excalibur/interface/tui.py`](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/tui.py) (Interactive TUI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and interaction"]
  node_cli["CLI entry<br/>[main.py]"]
  node_tui["Interactive TUI<br/>[tui.py]"]
  node_event_display["Activity display<br/>[activity_feed.py]"]
end

subgraph group_runtime["Agent runtime"]
  node_agent["Pentest agent<br/>[agent.py]"]
  node_controller["Run controller<br/>[controller.py]"]
  node_backend["LLM backend<br/>[backend.py]"]
  node_config["Run configuration<br/>[config.py]"]
  node_prompts["CTF prompts<br/>[pentesting.py]"]
  node_events["Run events<br/>[events.py]"]
  node_tracing["Tracing<br/>[tracer.py]"]
  node_telemetry["Langfuse telemetry<br/>[langfuse.py]"]
end

subgraph group_planning["Attack planning"]
  node_egats["EGATS planner<br/>[egats.py]"]
  node_attack_tree["Attack-tree models<br/>[models.py]"]
end

subgraph group_operations["Pentest operations"]
  node_tools["Tool registry<br/>[registry.py]"]
  node_tool_interface["Typed tool interface<br/>[base.py]"]
  node_tool_categories["Security tool categories"]
  node_skills["Tool skills"]
end

subgraph group_state["Memory and sessions"]
  node_state_store[("Pentest state store<br/>[state_store.py]")]
  node_context["Context assembler"]
  node_compression["Context compressor"]
  node_branch_summary["Branch summaries<br/>[branch_summary.py]"]
  node_sessions[("Session persistence<br/>[session.py]")]
end

node_operator(("Operator"))

node_operator -->|"starts run"| node_cli
node_cli -->|"invokes"| node_agent
node_cli -->|"starts"| node_tui
node_tui -->|"updates"| node_event_display
node_agent -->|"delegates run"| node_controller
node_agent -->|"uses"| node_config
node_agent -->|"tracks status"| node_tracing
node_agent -->|"uses prompt"| node_prompts
node_controller -->|"queries"| node_backend
node_controller -->|"drives planning"| node_egats
node_egats -->|"builds tree"| node_attack_tree
node_controller -->|"selects tools"| node_tools
node_tools -->|"registers"| node_tool_categories
node_tool_categories -->|"implements"| node_tool_interface
node_skills -->|"references registry"| node_tools
node_controller -->|"assembles context"| node_context
node_context -->|"reads state"| node_state_store
node_context -->|"summarizes branches"| node_branch_summary
node_controller -->|"compresses context"| node_compression
node_compression -->|"uses summaries"| node_branch_summary
node_controller -->|"persists run"| node_sessions
node_controller -->|"emits updates"| node_events
node_tui -->|"subscribes"| node_events
node_cli -->|"initializes"| node_telemetry
node_telemetry -->|"uses events"| node_events

click node_cli "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/main.py"
click node_tui "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/tui.py"
click node_event_display "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/components/activity_feed.py"
click node_agent "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/agent.py"
click node_controller "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/controller.py"
click node_backend "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/backend.py"
click node_config "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/config.py"
click node_prompts "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/prompts/pentesting.py"
click node_events "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/events.py"
click node_tracing "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/tracer.py"
click node_egats "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/planner/egats.py"
click node_attack_tree "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/planner/models.py"
click node_tools "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/tools/registry.py"
click node_tool_interface "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/tools/base.py"
click node_tool_categories "https://github.com/sickwell/pentestgpt-v2/tree/main/excalibur/tools/categories"
click node_skills "https://github.com/sickwell/pentestgpt-v2/tree/main/excalibur/tools/skills"
click node_state_store "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/state_store.py"
click node_context "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/context_assembler.py"
click node_compression "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/context_compressor.py"
click node_branch_summary "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/branch_summary.py"
click node_sessions "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/session.py"
click node_telemetry "https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/langfuse.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_tui,node_event_display toneBlue
class node_agent,node_controller,node_backend,node_config,node_prompts,node_events,node_tracing,node_telemetry toneAmber
class node_egats,node_attack_tree toneMint
class node_tools,node_tool_interface,node_tool_categories,node_skills toneRose
class node_state_store,node_context,node_compression,node_branch_summary,node_sessions,node_operator toneIndigo
```

## Components

### CLI and interaction

- [CLI entry](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/main.py): `excalibur/interface/main.py`
- [Interactive TUI](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/tui.py): `excalibur/interface/tui.py`
- [Activity display](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/interface/components/activity_feed.py): `excalibur/interface/components/activity_feed.py`

### Agent runtime

- [Pentest agent](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/agent.py): `excalibur/core/agent.py`
- [Run controller](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/controller.py): `excalibur/core/controller.py`
- [LLM backend](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/backend.py): `excalibur/core/backend.py`
- [Run configuration](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/config.py): `excalibur/core/config.py`
- [CTF prompts](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/prompts/pentesting.py): `excalibur/prompts/pentesting.py`
- [Run events](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/events.py): `excalibur/core/events.py`
- [Tracing](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/tracer.py): `excalibur/core/tracer.py`
- [Langfuse telemetry](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/langfuse.py): `excalibur/core/langfuse.py`

### Attack planning

- [EGATS planner](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/planner/egats.py): `excalibur/planner/egats.py`
- [Attack-tree models](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/planner/models.py): `excalibur/planner/models.py`

### Pentest operations

- [Tool registry](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/tools/registry.py): `excalibur/tools/registry.py`
- [Typed tool interface](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/tools/base.py): `excalibur/tools/base.py`
- [Security tool categories](https://github.com/sickwell/pentestgpt-v2/tree/main/excalibur/tools/categories): `excalibur/tools/categories`
- [Tool skills](https://github.com/sickwell/pentestgpt-v2/tree/main/excalibur/tools/skills): `excalibur/tools/skills`

### Memory and sessions

- [Pentest state store](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/state_store.py): `excalibur/memory/state_store.py`
- [Context assembler](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/context_assembler.py): `excalibur/memory/context_assembler.py`
- [Context compressor](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/context_compressor.py): `excalibur/memory/context_compressor.py`
- [Branch summaries](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/memory/branch_summary.py): `excalibur/memory/branch_summary.py`
- [Session persistence](https://github.com/sickwell/pentestgpt-v2/blob/main/excalibur/core/session.py): `excalibur/core/session.py`

### Other components

- **Operator**

## Connections

- Operator → CLI entry: starts run (evidence: `README.md`)
- CLI entry → Pentest agent: invokes (evidence: `excalibur/interface/main.py`)
- CLI entry → Interactive TUI: starts (evidence: `excalibur/interface/main.py`)
- Interactive TUI → Activity display: updates (evidence: `excalibur/interface/tui.py`)
- Pentest agent → Run controller: delegates run (evidence: `excalibur/core/agent.py`)
- Pentest agent → Run configuration: uses (evidence: `excalibur/core/agent.py`)
- Pentest agent → Tracing: tracks status (evidence: `excalibur/core/agent.py`)
- Pentest agent → CTF prompts: uses prompt (evidence: `excalibur/core/agent.py`)
- Run controller → LLM backend: queries (evidence: `excalibur/core/controller.py`)
- Run controller → EGATS planner: drives planning (evidence: `excalibur/core/controller.py`)
- EGATS planner → Attack-tree models: builds tree (evidence: `excalibur/planner/egats.py`)
- Run controller → Tool registry: selects tools (evidence: `excalibur/core/controller.py`)
- Tool registry → Security tool categories: registers (evidence: `excalibur/tools/registry.py`)
- Security tool categories → Typed tool interface: implements (evidence: `excalibur/tools/categories/active_directory.py`)
- Tool skills → Tool registry: references registry
- Run controller → Context assembler: assembles context (evidence: `excalibur/core/controller.py`)
- Context assembler → Pentest state store: reads state (evidence: `excalibur/memory/context_assembler.py`)
- Context assembler → Branch summaries: summarizes branches (evidence: `excalibur/memory/context_assembler.py`)
- Run controller → Context compressor: compresses context (evidence: `excalibur/core/controller.py`)
- Context compressor → Branch summaries: uses summaries (evidence: `excalibur/memory/context_compressor.py`)
- Run controller → Session persistence: persists run (evidence: `excalibur/core/controller.py`)
- Run controller → Run events: emits updates (evidence: `excalibur/core/controller.py`)
- Interactive TUI → Run events: subscribes (evidence: `excalibur/interface/tui.py`)
- CLI entry → Langfuse telemetry: initializes (evidence: `excalibur/interface/main.py`)
- Langfuse telemetry → Run events: uses events (evidence: `excalibur/core/langfuse.py`)
