# bytewife/agentcraft architecture

> Architecture diagram of the GitHub repository bytewife/agentcraft, 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/bytewife/agentcraft
- Repository: https://github.com/bytewife/agentcraft

## Overview

AgentCraft turns a selected Minecraft build area into an adaptive settlement: it reads terrain, initializes a social-agent simulation, develops roads and buildings through agent actions and world-state updates, then renders changes and records settlement history. The graph shows the documented generation and rendering workflow plus schematic construction and chronicle output. Several source files are only partially excerpted; edges are limited to relationships visible in excerpts or explicitly documented in the README/index.

Main entry points: [`src/states.py`](https://github.com/bytewife/agentcraft/blob/main/src/states.py) (Settlement state), [`src/simulation.py`](https://github.com/bytewife/agentcraft/blob/main/src/simulation.py) (Simulation controller), [`src/agent.py`](https://github.com/bytewife/agentcraft/blob/main/src/agent.py) (Social agents), [`http_framework/interfaceUtils.py`](https://github.com/bytewife/agentcraft/blob/main/http_framework/interfaceUtils.py) (Minecraft HTTP interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run control"]
  node_launcher["CLI launcher<br/>[run.py]"]
end

subgraph group_world["Minecraft interface"]
  node_http["Minecraft HTTP interface<br/>[interfaceUtils.py]"]
  node_loader["World slice loader<br/>[worldLoader.py]"]
  node_bits["Packed block data<br/>[bitarray.py]"]
  node_palette["Block color palette<br/>[blockColors.py]"]
end

subgraph group_generation["Settlement simulation"]
  node_sim["Simulation controller<br/>[simulation.py]"]
  node_state["Settlement state<br/>[states.py]"]
  node_agents["Social agents<br/>[agent.py]"]
  node_path["Pathfinding<br/>[pathfinding.py]"]
  node_manip["Block manipulation<br/>[manipulation.py]"]
  node_schemes["Building schemes<br/>[scheme_utils.py]"]
  node_nodes["Settlement nodes<br/>[node.py]"]
  node_roads["Road segments<br/>[road_segment.py]"]
  node_draw["Line drawing<br/>[line_drawing.py]"]
  node_utils["World rules<br/>[utils.py]"]
end

subgraph group_records["Output records"]
  node_chronicle["Settlement chronicle<br/>[chronicle.py]"]
end

node_user(("Generator user"))
node_minecraft(("Running Minecraft"))
node_schematic["Schematic assets"]

node_user -->|"sets area and limits"| node_launcher
node_launcher -->|"starts simulation"| node_sim
node_launcher -->|"cleans world entities"| node_http
node_sim -->|"updates state"| node_state
node_sim -.->|"loads terrain"| node_loader
node_sim -.->|"renders commands"| node_http
node_sim -->|"writes sign coordinates"| node_chronicle
node_state -->|"creates agents"| node_agents
node_state -.->|"creates road segments"| node_roads
node_state -.->|"tracks nodes"| node_nodes
node_agents -->|"searches routes"| node_path
node_agents -->|"performs block actions"| node_manip
node_agents -->|"updates occupancy"| node_state
node_state -.->|"maintains connectivity"| node_path
node_state -.->|"uses building schemes"| node_schemes
node_schemes -.->|"loads designs"| node_schematic
node_schemes -.->|"places blocks"| node_http
node_loader -->|"decodes block data"| node_bits
node_loader -->|"requests chunk data"| node_minecraft
node_http -->|"reads and modifies world"| node_minecraft
node_chronicle -->|"writes books and signs"| node_http
node_chronicle -->|"reads output settings"| node_launcher
node_utils -.->|"defines agent rules"| node_agents
node_utils -.->|"defines block types"| node_state

click node_launcher "https://github.com/bytewife/agentcraft/blob/main/run.py"
click node_sim "https://github.com/bytewife/agentcraft/blob/main/src/simulation.py"
click node_state "https://github.com/bytewife/agentcraft/blob/main/src/states.py"
click node_agents "https://github.com/bytewife/agentcraft/blob/main/src/agent.py"
click node_path "https://github.com/bytewife/agentcraft/blob/main/src/pathfinding.py"
click node_manip "https://github.com/bytewife/agentcraft/blob/main/src/manipulation.py"
click node_schemes "https://github.com/bytewife/agentcraft/blob/main/src/scheme_utils.py"
click node_nodes "https://github.com/bytewife/agentcraft/blob/main/src/node.py"
click node_roads "https://github.com/bytewife/agentcraft/blob/main/src/road_segment.py"
click node_draw "https://github.com/bytewife/agentcraft/blob/main/src/line_drawing.py"
click node_utils "https://github.com/bytewife/agentcraft/blob/main/src/utils.py"
click node_http "https://github.com/bytewife/agentcraft/blob/main/http_framework/interfaceUtils.py"
click node_loader "https://github.com/bytewife/agentcraft/blob/main/http_framework/worldLoader.py"
click node_bits "https://github.com/bytewife/agentcraft/blob/main/http_framework/bitarray.py"
click node_palette "https://github.com/bytewife/agentcraft/blob/main/http_framework/blockColors.py"
click node_chronicle "https://github.com/bytewife/agentcraft/blob/main/src/chronicle.py"
click node_schematic "https://github.com/bytewife/agentcraft/tree/main/schemes"

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_launcher,node_user toneBlue
class node_http,node_loader,node_bits,node_palette toneAmber
class node_sim,node_state,node_agents,node_path,node_manip,node_schemes,node_nodes,node_roads,node_draw,node_utils toneMint
class node_chronicle toneRose
class node_minecraft toneIndigo
class node_schematic toneTeal
```

## Components

### Run control

- [CLI launcher](https://github.com/bytewife/agentcraft/blob/main/run.py): `run.py`

### Minecraft interface

- [Minecraft HTTP interface](https://github.com/bytewife/agentcraft/blob/main/http_framework/interfaceUtils.py): `http_framework/interfaceUtils.py`
- [World slice loader](https://github.com/bytewife/agentcraft/blob/main/http_framework/worldLoader.py): `http_framework/worldLoader.py`
- [Packed block data](https://github.com/bytewife/agentcraft/blob/main/http_framework/bitarray.py): `http_framework/bitarray.py`
- [Block color palette](https://github.com/bytewife/agentcraft/blob/main/http_framework/blockColors.py): `http_framework/blockColors.py`

### Settlement simulation

- [Simulation controller](https://github.com/bytewife/agentcraft/blob/main/src/simulation.py): `src/simulation.py`
- [Settlement state](https://github.com/bytewife/agentcraft/blob/main/src/states.py): `src/states.py`
- [Social agents](https://github.com/bytewife/agentcraft/blob/main/src/agent.py): `src/agent.py`
- [Pathfinding](https://github.com/bytewife/agentcraft/blob/main/src/pathfinding.py): `src/pathfinding.py`
- [Block manipulation](https://github.com/bytewife/agentcraft/blob/main/src/manipulation.py): `src/manipulation.py`
- [Building schemes](https://github.com/bytewife/agentcraft/blob/main/src/scheme_utils.py): `src/scheme_utils.py`
- [Settlement nodes](https://github.com/bytewife/agentcraft/blob/main/src/node.py): `src/node.py`
- [Road segments](https://github.com/bytewife/agentcraft/blob/main/src/road_segment.py): `src/road_segment.py`
- [Line drawing](https://github.com/bytewife/agentcraft/blob/main/src/line_drawing.py): `src/line_drawing.py`
- [World rules](https://github.com/bytewife/agentcraft/blob/main/src/utils.py): `src/utils.py`

### Output records

- [Settlement chronicle](https://github.com/bytewife/agentcraft/blob/main/src/chronicle.py): `src/chronicle.py`

### Other components

- **Generator user**
- **Running Minecraft**
- [Schematic assets](https://github.com/bytewife/agentcraft/tree/main/schemes): `schemes`

## Connections

- Generator user → CLI launcher: sets area and limits (evidence: `README.md`)
- CLI launcher → Simulation controller: starts simulation (evidence: `run.py`)
- CLI launcher → Minecraft HTTP interface: cleans world entities (evidence: `run.py`)
- Simulation controller → Settlement state: updates state (evidence: `src/simulation.py`)
- Simulation controller → World slice loader: loads terrain (evidence: `src/simulation.py`)
- Simulation controller → Minecraft HTTP interface: renders commands (evidence: `src/simulation.py`)
- Simulation controller → Settlement chronicle: writes sign coordinates (evidence: `src/simulation.py`)
- Settlement state → Social agents: creates agents (evidence: `src/states.py`)
- Settlement state → Road segments: creates road segments (evidence: `src/states.py`)
- Settlement state → Settlement nodes: tracks nodes (evidence: `src/states.py`)
- Social agents → Pathfinding: searches routes (evidence: `src/agent.py`)
- Social agents → Block manipulation: performs block actions (evidence: `src/agent.py`)
- Social agents → Settlement state: updates occupancy (evidence: `src/agent.py`)
- Settlement state → Pathfinding: maintains connectivity (evidence: `src/states.py`)
- Settlement state → Building schemes: uses building schemes (evidence: `src/states.py`)
- Building schemes → Schematic assets: loads designs
- Building schemes → Minecraft HTTP interface: places blocks (evidence: `src/scheme_utils.py`)
- World slice loader → Packed block data: decodes block data (evidence: `http_framework/worldLoader.py`)
- World slice loader → Running Minecraft: requests chunk data (evidence: `http_framework/worldLoader.py`)
- Minecraft HTTP interface → Running Minecraft: reads and modifies world (evidence: `http_framework/interfaceUtils.py`)
- Settlement chronicle → Minecraft HTTP interface: writes books and signs (evidence: `src/chronicle.py`)
- Settlement chronicle → CLI launcher: reads output settings (evidence: `src/chronicle.py`)
- World rules → Social agents: defines agent rules (evidence: `src/utils.py`)
- World rules → Settlement state: defines block types (evidence: `src/states.py`)
