# czxieddan/rhoiscribe architecture

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

- Interactive diagram: https://gitdiagram.com/czxieddan/rhoiscribe
- Repository: https://github.com/czxieddan/rhoiscribe

## Overview

RHoiScribe is a local MCP server and bundled Skill for HOI4 modding agents. The main workflow is an MCP client discovering prompts, reference resources, and tools, then using project/environment inspection, CWT language support, and file-oriented generation, validation, and repair to produce mod-ready changes. Separate capabilities include preferences and RNMDB-backed state, audit logs, and Rchadow-assisted debug launch preparation. Relationships among unsampled tool implementations are limited to documented capabilities and the tool catalog’s indexed module references.

Main entry points: [`src/tools/mod.rs`](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/mod.rs) (Tool catalog), [`src/server.rs`](https://github.com/czxieddan/rhoiscribe/blob/master/src/server.rs) (MCP server), [`src/skill.rs`](https://github.com/czxieddan/rhoiscribe/blob/master/src/skill.rs) (Bundled Skill), [`src/tools/project_validation.rs`](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_validation.rs) (Validation and repair)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Agent interfaces"]
  node_server["MCP server<br/>[server.rs]"]
  node_catalog["Tool catalog<br/>[mod.rs]"]
  node_skill["Bundled Skill<br/>[skill.rs]"]
end

subgraph group_guidance["HOI4 guidance"]
  node_prompts["Prompt catalog<br/>[mod.rs]"]
  node_resources["Knowledge resources<br/>[mod.rs]"]
  node_knowledge["HOI4 knowledge<br/>[knowledge.rs]"]
  node_cwt_resources["CWT resources<br/>[cwt.rs]"]
end

subgraph group_language["CWT language"]
  node_cwt_config["HOI4 CWT config<br/>[hoi4_config.rs]"]
  node_cwt_rules["CWT rules<br/>[rules.rs]"]
  node_cwt_service["Workspace service<br/>[service.rs]"]
  node_cwt_workspace["Language workspace<br/>[workspace.rs]"]
  node_cwt_tools["CWT tools"]
end

subgraph group_project["Project tools"]
  node_environment["Environment discovery<br/>[environment.rs]"]
  node_project_files["Project file access<br/>[project_files.rs]"]
  node_effective_files["Effective file view"]
  node_project_index["Project indexing<br/>[project_index.rs]"]
  node_validation_repair["Validation and repair"]
  node_unique_scan["Identifier scan<br/>[unique_scan.rs]"]
  node_lexer["Paradox lexer<br/>[paradox_lexer.rs]"]
end

subgraph group_state["State and integrations"]
  node_preferences["Scoped preferences<br/>[preferences.rs]"]
  node_state_store[("RNMDB state store<br/>[sql.rs]")]
  node_tool_logs["Tool audit logs<br/>[tool_logs.rs]"]
  node_debug_launch["Debug launch prep<br/>[rchadow_debug.rs]"]
end

node_client(("MCP client"))
node_rchadow["Rchadow library"]

node_client -->|"uses stdio"| node_server
node_server -->|"dispatches tools"| node_catalog
node_server -->|"serves prompts"| node_prompts
node_server -->|"serves resources"| node_resources
node_client -.->|"uses Skill"| node_skill
node_skill -->|"uses catalog"| node_prompts
node_skill -->|"uses catalog"| node_resources
node_skill -->|"uses catalog"| node_catalog
node_resources -->|"serves topics"| node_knowledge
node_resources -->|"serves CWT"| node_cwt_resources
node_cwt_service -->|"manages workspaces"| node_cwt_workspace
node_cwt_workspace -->|"loads rules"| node_cwt_rules
node_cwt_workspace -->|"uses config"| node_cwt_config
node_catalog -->|"dispatches CWT"| node_cwt_tools
node_catalog -->|"dispatches discovery"| node_environment
node_catalog -->|"dispatches indexing"| node_project_index
node_catalog -->|"dispatches checks"| node_validation_repair
node_catalog -->|"dispatches scans"| node_unique_scan
node_project_index -->|"collects files"| node_project_files
node_project_index -->|"resolves effective files"| node_effective_files
node_effective_files -->|"uses collected files"| node_project_files
node_validation_repair -->|"reads project files"| node_project_files
node_validation_repair -->|"tokenizes scripts"| node_lexer
node_validation_repair -->|"uses project index"| node_project_index
node_unique_scan -->|"collects files"| node_project_files
node_unique_scan -->|"filters effective files"| node_effective_files
node_unique_scan -->|"parses scripts"| node_lexer
node_catalog -->|"dispatches preferences"| node_preferences
node_preferences -.->|"persists state"| node_state_store
node_tool_logs -.->|"stores log records"| node_state_store
node_catalog -.->|"dispatches log tools"| node_tool_logs
node_catalog -->|"dispatches debug prep"| node_debug_launch
node_debug_launch -.->|"prepares launch"| node_rchadow

click node_server "https://github.com/czxieddan/rhoiscribe/blob/master/src/server.rs"
click node_catalog "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/mod.rs"
click node_skill "https://github.com/czxieddan/rhoiscribe/blob/master/src/skill.rs"
click node_prompts "https://github.com/czxieddan/rhoiscribe/blob/master/src/prompts/mod.rs"
click node_resources "https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/mod.rs"
click node_knowledge "https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/knowledge.rs"
click node_cwt_resources "https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/cwt.rs"
click node_cwt_config "https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/hoi4_config.rs"
click node_cwt_rules "https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/rules.rs"
click node_cwt_service "https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/service.rs"
click node_cwt_workspace "https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/workspace.rs"
click node_cwt_tools "https://github.com/czxieddan/rhoiscribe/tree/master/src/tools"
click node_environment "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/environment.rs"
click node_project_files "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_files.rs"
click node_effective_files "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_effective_files.rs"
click node_project_index "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_index.rs"
click node_validation_repair "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_validation.rs"
click node_unique_scan "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/unique_scan.rs"
click node_lexer "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/paradox_lexer.rs"
click node_preferences "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/preferences.rs"
click node_state_store "https://github.com/czxieddan/rhoiscribe/blob/master/src/state/store/sql.rs"
click node_tool_logs "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/tool_logs.rs"
click node_debug_launch "https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/rchadow_debug.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_server,node_catalog,node_skill,node_client toneBlue
class node_prompts,node_resources,node_knowledge,node_cwt_resources toneAmber
class node_cwt_config,node_cwt_rules,node_cwt_service,node_cwt_workspace,node_cwt_tools toneMint
class node_environment,node_project_files,node_effective_files,node_project_index,node_validation_repair,node_unique_scan,node_lexer toneRose
class node_preferences,node_state_store,node_tool_logs,node_debug_launch,node_rchadow toneIndigo
```

## Components

### Agent interfaces

- [MCP server](https://github.com/czxieddan/rhoiscribe/blob/master/src/server.rs): `src/server.rs`
- [Tool catalog](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/mod.rs): `src/tools/mod.rs`
- [Bundled Skill](https://github.com/czxieddan/rhoiscribe/blob/master/src/skill.rs): `src/skill.rs`

### HOI4 guidance

- [Prompt catalog](https://github.com/czxieddan/rhoiscribe/blob/master/src/prompts/mod.rs): `src/prompts/mod.rs`
- [Knowledge resources](https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/mod.rs): `src/resources/mod.rs`
- [HOI4 knowledge](https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/knowledge.rs): `src/resources/knowledge.rs`
- [CWT resources](https://github.com/czxieddan/rhoiscribe/blob/master/src/resources/cwt.rs): `src/resources/cwt.rs`

### CWT language

- [HOI4 CWT config](https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/hoi4_config.rs): `src/cwt/hoi4_config.rs`
- [CWT rules](https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/rules.rs): `src/cwt/rules.rs`
- [Workspace service](https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/service.rs): `src/cwt/service.rs`
- [Language workspace](https://github.com/czxieddan/rhoiscribe/blob/master/src/cwt/workspace.rs): `src/cwt/workspace.rs`
- [CWT tools](https://github.com/czxieddan/rhoiscribe/tree/master/src/tools): `src/tools`

### Project tools

- [Environment discovery](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/environment.rs): `src/tools/environment.rs`
- [Project file access](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_files.rs): `src/tools/project_files.rs`
- [Effective file view](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_effective_files.rs): `src/tools/project_effective_files.rs`
- [Project indexing](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_index.rs): `src/tools/project_index.rs`
- [Validation and repair](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/project_validation.rs): `src/tools/project_validation.rs`
- [Identifier scan](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/unique_scan.rs): `src/tools/unique_scan.rs`
- [Paradox lexer](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/paradox_lexer.rs): `src/tools/paradox_lexer.rs`

### State and integrations

- [Scoped preferences](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/preferences.rs): `src/tools/preferences.rs`
- [RNMDB state store](https://github.com/czxieddan/rhoiscribe/blob/master/src/state/store/sql.rs): `src/state/store/sql.rs`
- [Tool audit logs](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/tool_logs.rs): `src/tools/tool_logs.rs`
- [Debug launch prep](https://github.com/czxieddan/rhoiscribe/blob/master/src/tools/rchadow_debug.rs): `src/tools/rchadow_debug.rs`

### Other components

- **MCP client**
- **Rchadow library**

## Connections

- MCP client → MCP server: uses stdio
- MCP server → Tool catalog: dispatches tools (evidence: `src/server.rs`)
- MCP server → Prompt catalog: serves prompts (evidence: `src/server.rs`)
- MCP server → Knowledge resources: serves resources (evidence: `src/server.rs`)
- MCP client → Bundled Skill: uses Skill
- Bundled Skill → Prompt catalog: uses catalog (evidence: `src/skill.rs`)
- Bundled Skill → Knowledge resources: uses catalog (evidence: `src/skill.rs`)
- Bundled Skill → Tool catalog: uses catalog (evidence: `src/skill.rs`)
- Knowledge resources → HOI4 knowledge: serves topics (evidence: `src/resources/mod.rs`)
- Knowledge resources → CWT resources: serves CWT (evidence: `src/resources/mod.rs`)
- Workspace service → Language workspace: manages workspaces (evidence: `src/cwt/service.rs`)
- Language workspace → CWT rules: loads rules (evidence: `src/cwt/workspace.rs`)
- Language workspace → HOI4 CWT config: uses config (evidence: `src/cwt/workspace.rs`)
- Tool catalog → CWT tools: dispatches CWT (evidence: `src/tools/mod.rs`)
- Tool catalog → Environment discovery: dispatches discovery (evidence: `src/tools/mod.rs`)
- Tool catalog → Project indexing: dispatches indexing (evidence: `src/tools/mod.rs`)
- Tool catalog → Validation and repair: dispatches checks (evidence: `src/tools/mod.rs`)
- Tool catalog → Identifier scan: dispatches scans (evidence: `src/tools/mod.rs`)
- Project indexing → Project file access: collects files (evidence: `src/tools/project_index.rs`)
- Project indexing → Effective file view: resolves effective files (evidence: `src/tools/project_index.rs`)
- Effective file view → Project file access: uses collected files (evidence: `src/tools/project_effective_files.rs`)
- Validation and repair → Project file access: reads project files (evidence: `src/tools/project_validation.rs`)
- Validation and repair → Paradox lexer: tokenizes scripts (evidence: `src/tools/project_validation.rs`)
- Validation and repair → Project indexing: uses project index (evidence: `src/tools/project_validation.rs`)
- Identifier scan → Project file access: collects files (evidence: `src/tools/unique_scan.rs`)
- Identifier scan → Effective file view: filters effective files (evidence: `src/tools/unique_scan.rs`)
- Identifier scan → Paradox lexer: parses scripts (evidence: `src/tools/unique_scan.rs`)
- Tool catalog → Scoped preferences: dispatches preferences (evidence: `src/tools/mod.rs`)
- Scoped preferences → RNMDB state store: persists state
- Tool audit logs → RNMDB state store: stores log records
- Tool catalog → Tool audit logs: dispatches log tools (evidence: `src/tools/mod.rs`)
- Tool catalog → Debug launch prep: dispatches debug prep (evidence: `src/tools/mod.rs`)
- Debug launch prep → Rchadow library: prepares launch
