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
mod commands;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "arcane", version, about = "Arcane 2D game engine CLI")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Discover and run *.test.ts files in embedded V8
Test {
/// Optional directory or glob pattern (defaults to current directory)
path: Option<String>,
},
/// Open a window and run a game with hot-reload
Dev {
/// Path to the TypeScript entry file (defaults to src/visual.ts)
entry: Option<String>,
/// Enable HTTP inspector on the given port (e.g. --inspector 4321)
#[arg(long)]
inspector: Option<u16>,
/// MCP server port (default: 4322, use --no-mcp to disable)
#[arg(long, default_value = "4322")]
mcp_port: u16,
/// Disable the MCP server
#[arg(long)]
no_mcp: bool,
},
/// Stdio bridge for MCP (JSON-RPC over stdin/stdout)
Mcp {
/// Path to the TypeScript entry file (defaults to src/visual.ts)
entry: Option<String>,
/// MCP HTTP server port to connect to (default: auto-discover via .arcane/mcp-port)
#[arg(long)]
port: Option<u16>,
},
/// Print a text description of game state (headless)
Describe {
/// Path to the TypeScript entry file
entry: String,
/// Verbosity: minimal, normal, or detailed
#[arg(long)]
verbosity: Option<String>,
},
/// Inspect game state at a specific path (headless)
Inspect {
/// Path to the TypeScript entry file
entry: String,
/// Dot-separated state path (e.g. "player.hp")
path: String,
},
/// Add a recipe to the current project
Add {
/// Recipe name (e.g. "turn-based-combat")
name: Option<String>,
/// List all available recipes
#[arg(long)]
list: bool,
},
/// Discover and download free game assets
Assets {
#[command(subcommand)]
action: AssetsAction,
},
/// Create a new Arcane project from template
New {
/// Project name
name: String,
},
/// Initialize an Arcane project in the current directory
Init,
}
#[derive(Subcommand)]
enum AssetsAction {
/// List all available asset packs
List {
/// Filter by type (e.g. "audio", "2d-sprites", "ui", "tilesets", "fonts", "vfx")
#[arg(long = "type")]
type_filter: Option<String>,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Search asset packs by keyword
Search {
/// Search query (e.g. "dungeon", "platformer", "kitty")
query: String,
/// Filter by type (e.g. "audio", "2d-sprites", "ui", "tilesets", "fonts", "vfx")
#[arg(long = "type")]
type_filter: Option<String>,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Download an asset pack
Download {
/// Asset pack ID (e.g. "tiny-dungeon")
id: String,
/// Destination directory (defaults to "assets")
dest: Option<String>,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Inspect contents of an asset pack
Inspect {
/// Asset pack ID (e.g. "tiny-dungeon")
id: String,
/// Destination directory for cached downloads (defaults to system temp)
#[arg(long)]
cache: Option<String>,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Search OpenGameArt for CC0 assets
SearchOga {
/// Search query (e.g. "dungeon", "platformer")
query: String,
/// Filter by type: 2d, 3d, music, sound, texture, concept, document
#[arg(long = "type")]
asset_type: Option<String>,
/// Page number (0-indexed)
#[arg(long, default_value = "0")]
page: usize,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Get details about a CC0 asset from OpenGameArt
InfoOga {
/// Asset ID (e.g. "dungeon-tileset")
id: String,
/// Output as JSON
#[arg(long)]
json: bool,
},
/// Download a CC0 asset from OpenGameArt
DownloadOga {
/// Asset ID (e.g. "dungeon-tileset")
id: String,
/// Destination directory (defaults to "assets/oga")
dest: Option<String>,
/// Output as JSON
#[arg(long)]
json: bool,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Test { path } => commands::test::run(path),
Commands::Dev { entry, inspector, mcp_port, no_mcp } => {
let entry = entry.unwrap_or_else(|| "src/visual.ts".to_string());
let mcp = if no_mcp { None } else { Some(mcp_port) };
commands::dev::run(entry, inspector, mcp)
},
Commands::Mcp { entry, port } => {
let entry = entry.unwrap_or_else(|| "src/visual.ts".to_string());
commands::mcp_bridge::run(entry, port)
},
Commands::Describe { entry, verbosity } => commands::describe::run(entry, verbosity),
Commands::Inspect { entry, path } => commands::inspect::run(entry, path),
Commands::Add { name, list } => commands::add::run(name, list),
Commands::Assets { action } => match action {
AssetsAction::List { type_filter, json } => {
commands::assets::run_list(type_filter, json)
}
AssetsAction::Search {
query,
type_filter,
json,
} => commands::assets::run_search(query, type_filter, json),
AssetsAction::Download { id, dest, json } => {
commands::assets::run_download(id, dest, json)
}
AssetsAction::Inspect { id, cache, json } => {
commands::assets::run_inspect(id, cache, json)
}
AssetsAction::SearchOga {
query,
asset_type,
page,
json,
} => commands::assets_oga::run_search(query, asset_type, page, json),
AssetsAction::InfoOga { id, json } => commands::assets_oga::run_info(id, json),
AssetsAction::DownloadOga { id, dest, json } => {
commands::assets_oga::run_download(id, dest, json)
}
},
Commands::New { name } => commands::new::run(&name),
Commands::Init => commands::init::run(),
}
}