1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* Bevy Debugger MCP Server - Library
* Copyright (C) 2025 ladvien
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! # Bevy Debugger MCP
//!
//! AI-assisted debugging for Bevy games through Claude Code using Model Context Protocol.
//!
//! This crate provides a comprehensive debugging toolkit for Bevy games, enabling natural
//! language interaction with game state through Claude Code. It bridges the gap between
//! AI assistance and game development by offering intelligent observation, experimentation,
//! and analysis capabilities.
//!
//! ## Quick Start
//!
//! 1. **Add BRP to your Bevy game:**
//! ```toml
//! [dependencies]
//! bevy = { version = "0.12", features = ["bevy_remote_protocol"] }
//! ```
//!
//! 2. **Enable BRP in your game:**
//! ```rust,no_run
//! use bevy::prelude::*;
//! use bevy::remote::RemotePlugin;
//!
//! fn main() {
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugins(RemotePlugin::default())
//! .run();
//! }
//! ```
//!
//! 3. **Install and configure the MCP server:**
//! ```bash
//! cargo install bevy_debugger_mcp
//! bevy-debugger-mcp --help
//! ```
//!
//! 4. **Configure Claude Code:**
//! ```json
//! {
//! "mcpServers": {
//! "bevy-debugger-mcp": {
//! "command": "bevy-debugger-mcp",
//! "args": [],
//! "type": "stdio"
//! }
//! }
//! }
//! ```
//!
//! ## Features
//!
//! - **๐ Natural Language Queries**: Ask about your game state in plain English
//! - **๐งช Controlled Experiments**: Test hypotheses with systematic variations
//! - **๐ Performance Analysis**: Monitor and analyze game performance in real-time
//! - **โฑ๏ธ Time-Travel Debugging**: Record, replay, and branch timelines
//! - **๐จ Anomaly Detection**: Automatically detect unusual patterns in game behavior
//! - **๐ Stress Testing**: Systematically test your game under various loads
//! - **๐ง Tool Orchestration**: Chain debugging operations into complex workflows
//!
//! ## Core Modules
//!
//! ### Observation and Query
//! - [`query_parser`] - Natural language to game queries
//! - [`semantic_analyzer`] - Semantic understanding of game concepts
//! - [`brp_client`] - Bevy Remote Protocol communication
//!
//! ### Experimentation and Testing
//! - [`experiment_system`] - Controlled game state experiments
//! - [`hypothesis_system`] - Property-based testing for games
//! - [`stress_test_system`] - Systematic stress testing
//!
//! ### Time and State Management
//! - [`recording_system`] - Game state recording and persistence
//! - [`playback_system`] - Deterministic replay capabilities
//! - [`timeline_branching`] - Multi-timeline debugging with branching
//! - [`checkpoint`] - Save/restore debugging sessions
//!
//! ### Analysis and Monitoring
//! - [`anomaly_detector`] - Pattern recognition for unusual behavior
//! - [`state_diff`] - Intelligent state comparison and diffing
//! - [`diagnostics`] - System health monitoring and reporting
//!
//! ### Infrastructure
//! - [`mcp_server`] - Model Context Protocol server implementation
//! - [`tool_orchestration`] - Complex debugging workflow coordination
//! - [`error`] - Comprehensive error handling and recovery
//! - [`config`] - Configuration management
//!
//! ## Example Usage
//!
//! ```rust,no_run
//! use bevy_debugger_mcp::prelude::*;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to your Bevy game
//! let mut client = BrpClient::connect("ws://localhost:15702").await?;
//!
//! // Parse natural language queries
//! let parser = RegexQueryParser::new();
//! let request = parser.parse("find entities with Transform and Velocity")?;
//!
//! // Execute the query
//! let response = client.send_request(request).await?;
//! println!("Found entities: {:?}", response);
//! # Ok(())
//! # }
//! ```
//!
//! ## Architecture
//!
//! The system follows a modular architecture:
//!
//! ```text
//! Claude Code โโ MCP Protocol โโ MCP Server โโ BRP Protocol โโ Bevy Game
//! โ
//! Tool Modules
//! (observe, experiment,
//! stress, replay, etc.)
//! ```
//!
//! ## Error Handling
//!
//! All operations return [`Result<T, Error>`](error::Error) types. The system includes
//! comprehensive error recovery with automatic reconnection, dead letter queues for
//! failed operations, and checkpoint/restore capabilities.
// Re-export commonly used types
// Core functionality
// Communication
// Performance profiling and visual debugging
// Issue detection
// Performance budget monitoring
// Query and observation
// Experimentation and testing
// State management
// Analysis and monitoring
// Infrastructure
// Machine learning and pattern recognition (Epic BEVDBG-013)