@replaystage/cli 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,7 +35,6 @@ async function uploadGameBundle(options) {
35
35
  formData.append("title", options.title);
36
36
  formData.append("tagline", options.tagline);
37
37
  if (options.description) formData.append("description", options.description);
38
- formData.append("ai_tool", options.aiTool);
39
38
  if (options.category) formData.append("category", options.category);
40
39
  formData.append("submission_type", options.submissionType || "maker");
41
40
  if (options.makerName) formData.append("maker_name", options.makerName);
@@ -44,6 +43,26 @@ async function uploadGameBundle(options) {
44
43
  if (options.fileHash) formData.append("file_hash", options.fileHash);
45
44
  if (options.changelog) formData.append("changelog", options.changelog);
46
45
  if (options.aspectRatio) formData.append("aspect_ratio", options.aspectRatio);
46
+ if (options.supportedPlatforms) {
47
+ formData.append("supportedPlatforms", options.supportedPlatforms);
48
+ formData.append("supported_platforms", options.supportedPlatforms);
49
+ }
50
+ if (options.aiModel) {
51
+ formData.append("ai_model", options.aiModel);
52
+ formData.append("aiModel", options.aiModel);
53
+ }
54
+ if (options.aiTool) {
55
+ formData.append("ai_tool", options.aiTool);
56
+ formData.append("aiTool", options.aiTool);
57
+ }
58
+ if (options.coverBuffer) {
59
+ const uint82 = new Uint8Array(options.coverBuffer);
60
+ const fileName = options.coverFileName || "cover.png";
61
+ const lower = fileName.toLowerCase();
62
+ const mimeType = lower.endsWith(".png") ? "image/png" : lower.endsWith(".webp") ? "image/webp" : lower.endsWith(".gif") ? "image/gif" : "image/jpeg";
63
+ const blob2 = new Blob([uint82], { type: mimeType });
64
+ formData.append("cover", blob2, fileName);
65
+ }
47
66
  const headers = {
48
67
  ...options.extraHeaders
49
68
  };
@@ -94,6 +113,26 @@ async function updateGameBundle(slug, options) {
94
113
  if (options.visibility) formData.append("visibility", options.visibility);
95
114
  if (options.changelog) formData.append("changelog", options.changelog);
96
115
  if (options.aspectRatio) formData.append("aspect_ratio", options.aspectRatio);
116
+ if (options.supportedPlatforms) {
117
+ formData.append("supportedPlatforms", options.supportedPlatforms);
118
+ formData.append("supported_platforms", options.supportedPlatforms);
119
+ }
120
+ if (options.aiModel) {
121
+ formData.append("ai_model", options.aiModel);
122
+ formData.append("aiModel", options.aiModel);
123
+ }
124
+ if (options.aiTool) {
125
+ formData.append("ai_tool", options.aiTool);
126
+ formData.append("aiTool", options.aiTool);
127
+ }
128
+ if (options.coverBuffer) {
129
+ const uint8 = new Uint8Array(options.coverBuffer);
130
+ const fileName = options.coverFileName || "cover.png";
131
+ const lower = fileName.toLowerCase();
132
+ const mimeType = lower.endsWith(".png") ? "image/png" : lower.endsWith(".webp") ? "image/webp" : lower.endsWith(".gif") ? "image/gif" : "image/jpeg";
133
+ const blob = new Blob([uint8], { type: mimeType });
134
+ formData.append("cover", blob, fileName);
135
+ }
97
136
  const headers = {
98
137
  ...options.extraHeaders
99
138
  };
@@ -150,22 +189,117 @@ async function fetchWhoami(apiUrl, token) {
150
189
  }
151
190
 
152
191
  // src/config.ts
153
- import fs from "fs";
154
- import os from "os";
155
- import path from "path";
192
+ import fs2 from "fs";
193
+ import os2 from "os";
194
+ import path2 from "path";
195
+
196
+ // src/project.ts
197
+ import * as fs from "fs";
198
+ import * as os from "os";
199
+ import * as path from "path";
200
+ function resolveProjectDirectory(targetPath) {
201
+ try {
202
+ const resolved = path.resolve(targetPath);
203
+ if (resolved.toLowerCase().endsWith(".zip")) {
204
+ return null;
205
+ }
206
+ if (resolved.includes("seed-games")) {
207
+ return null;
208
+ }
209
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {
210
+ if (resolved === path.resolve(os.tmpdir())) {
211
+ return null;
212
+ }
213
+ return resolved;
214
+ }
215
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
216
+ const parentDir = path.dirname(resolved);
217
+ if (parentDir === path.resolve(os.tmpdir())) {
218
+ return null;
219
+ }
220
+ return parentDir;
221
+ }
222
+ return resolved;
223
+ } catch {
224
+ return path.resolve(targetPath);
225
+ }
226
+ }
227
+ function getProjectConfigPath(targetDir) {
228
+ const dir = resolveProjectDirectory(targetDir);
229
+ return dir ? path.join(dir, ".replaystage.json") : null;
230
+ }
231
+ function readProjectConfig(targetDir) {
232
+ const configPath = getProjectConfigPath(targetDir);
233
+ if (!configPath || !fs.existsSync(configPath)) {
234
+ return null;
235
+ }
236
+ try {
237
+ const raw = fs.readFileSync(configPath, "utf-8");
238
+ const parsed = JSON.parse(raw);
239
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
240
+ return null;
241
+ }
242
+ if ("slug" in parsed) {
243
+ if (typeof parsed.slug !== "string" || !parsed.slug.trim()) {
244
+ return null;
245
+ }
246
+ }
247
+ const hasValidKey = typeof parsed.slug === "string" && parsed.slug.trim().length > 0 || typeof parsed.supportedPlatforms === "string" || typeof parsed.platforms === "string" || typeof parsed.aspectRatio === "string" || typeof parsed.aiModel === "string" || typeof parsed.aiTool === "string";
248
+ if (!hasValidKey) {
249
+ return null;
250
+ }
251
+ return parsed;
252
+ } catch {
253
+ return null;
254
+ }
255
+ }
256
+ function writeProjectConfig(targetDir, config) {
257
+ const configPath = getProjectConfigPath(targetDir);
258
+ if (!configPath) {
259
+ return;
260
+ }
261
+ const dir = path.dirname(configPath);
262
+ if (!fs.existsSync(dir)) {
263
+ fs.mkdirSync(dir, { recursive: true });
264
+ }
265
+ fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
266
+ `, "utf-8");
267
+ }
268
+ function incrementVersion(currentVersion) {
269
+ if (!currentVersion || typeof currentVersion !== "string") return "0.2.0";
270
+ const sanitized = currentVersion.trim().replace(/^v/i, "");
271
+ const parts = sanitized.split(".").map((n) => Number.parseInt(n, 10));
272
+ if (parts.length === 3 && !parts.some(Number.isNaN)) {
273
+ return `${parts[0]}.${parts[1] + 1}.0`;
274
+ }
275
+ if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
276
+ return `${parts[0]}.${parts[1] + 1}.0`;
277
+ }
278
+ return "0.2.0";
279
+ }
280
+ function promoteDraftVersion(currentVersion) {
281
+ if (!currentVersion || typeof currentVersion !== "string") return "1.0.0";
282
+ const sanitized = currentVersion.trim().replace(/^v/i, "");
283
+ if (sanitized.startsWith("0.")) {
284
+ return "1.0.0";
285
+ }
286
+ return incrementVersion(currentVersion);
287
+ }
288
+
289
+ // src/config.ts
156
290
  function getConfigDir() {
157
- return process.env.REPLAYSTAGE_CONFIG_DIR || path.join(os.homedir(), ".replaystage");
291
+ return process.env.REPLAYSTAGE_CONFIG_DIR || path2.join(os2.homedir(), ".replaystage");
158
292
  }
159
293
  function getConfigPath() {
160
- return path.join(getConfigDir(), "config.json");
294
+ return path2.join(getConfigDir(), "config.json");
161
295
  }
162
296
  function readConfig() {
163
297
  const dir = getConfigDir();
164
298
  for (const filename of ["config.json", "credentials.json"]) {
165
- const file = path.join(dir, filename);
166
- if (fs.existsSync(file)) {
299
+ const file = path2.join(dir, filename);
300
+ if (fs2.existsSync(file)) {
167
301
  try {
168
- const raw = fs.readFileSync(file, "utf-8");
302
+ const raw = fs2.readFileSync(file, "utf-8");
169
303
  return JSON.parse(raw);
170
304
  } catch {
171
305
  }
@@ -175,24 +309,24 @@ function readConfig() {
175
309
  }
176
310
  function writeConfig(config) {
177
311
  const dir = getConfigDir();
178
- fs.mkdirSync(dir, { recursive: true, mode: 448 });
312
+ fs2.mkdirSync(dir, { recursive: true, mode: 448 });
179
313
  const target = getConfigPath();
180
- fs.writeFileSync(target, JSON.stringify(config, null, 2), {
314
+ fs2.writeFileSync(target, JSON.stringify(config, null, 2), {
181
315
  encoding: "utf-8",
182
316
  mode: 384
183
317
  });
184
318
  try {
185
- fs.chmodSync(target, 384);
319
+ fs2.chmodSync(target, 384);
186
320
  } catch {
187
321
  }
188
322
  }
189
323
  function clearConfig() {
190
324
  const dir = getConfigDir();
191
325
  for (const filename of ["config.json", "credentials.json"]) {
192
- const file = path.join(dir, filename);
193
- if (fs.existsSync(file)) {
326
+ const file = path2.join(dir, filename);
327
+ if (fs2.existsSync(file)) {
194
328
  try {
195
- fs.unlinkSync(file);
329
+ fs2.unlinkSync(file);
196
330
  } catch {
197
331
  }
198
332
  }
@@ -287,6 +421,15 @@ ${pc.yellow(`\u2554${border}\u2557`)}`);
287
421
  `${pc.yellow("\u2551")} ${pc.dim("AI Tool:")} ${res.aiTool.padEnd(48)}${pc.yellow("\u2551")}`
288
422
  );
289
423
  }
424
+ if (res.aspectRatio) {
425
+ console.log(
426
+ `${pc.yellow("\u2551")} ${pc.dim("Ratio:")} ${res.aspectRatio.padEnd(48)}${pc.yellow("\u2551")}`
427
+ );
428
+ }
429
+ const plat = res.supportedPlatforms || res.platforms;
430
+ if (plat) {
431
+ console.log(`${pc.yellow("\u2551")} ${pc.dim("Platforms:")} ${plat.padEnd(48)}${pc.yellow("\u2551")}`);
432
+ }
290
433
  console.log(
291
434
  `${pc.yellow("\u2551")} ${pc.dim("Play URL:")} ${pc.cyan(res.url).padEnd(57)}${pc.yellow("\u2551")}`
292
435
  );
@@ -443,18 +586,158 @@ async function handleLogout(options = {}) {
443
586
  }
444
587
 
445
588
  // src/commands/publish.ts
589
+ import fs5 from "fs";
446
590
  import path5 from "path";
447
591
 
448
592
  // ../shared/src/constants.ts
449
593
  var AI_TOOL_KEYS = [
450
- "claude",
451
- "gemini",
594
+ "claude-code",
452
595
  "antigravity",
453
596
  "cursor",
597
+ "codex",
598
+ "claude",
599
+ "gemini",
454
600
  "chatgpt",
455
601
  "v0",
602
+ "windsurf",
603
+ "lovable",
604
+ "bolt",
456
605
  "other"
457
606
  ];
607
+ var AI_TOOLS = {
608
+ "claude-code": {
609
+ id: "claude-code",
610
+ name: "Claude Code",
611
+ fullName: "Anthropic Claude Code",
612
+ slug: "claude-code",
613
+ description: "Terminal-based agentic coding and game generation by Anthropic",
614
+ badgeColor: "#D97706",
615
+ badgeBg: "bg-amber-100 text-amber-900 border-amber-300 dark:bg-amber-950/60 dark:text-amber-200 dark:border-amber-700",
616
+ icon: "terminal",
617
+ website: "https://claude.ai/code"
618
+ },
619
+ antigravity: {
620
+ id: "antigravity",
621
+ name: "Antigravity",
622
+ fullName: "Antigravity Agent Platform",
623
+ slug: "antigravity",
624
+ description: "Autonomous multi-agent game productions orchestrated by Antigravity",
625
+ badgeColor: "#7C3AED",
626
+ badgeBg: "bg-purple-100 text-purple-900 border-purple-300 dark:bg-purple-950/60 dark:text-purple-200 dark:border-purple-700",
627
+ icon: "orbit",
628
+ website: "https://github.com/google-gemini/antigravity"
629
+ },
630
+ cursor: {
631
+ id: "cursor",
632
+ name: "Cursor",
633
+ fullName: "Cursor Composer & Agent",
634
+ slug: "cursor",
635
+ description: "Web games generated and iterated through Cursor AI Composer",
636
+ badgeColor: "#0F172A",
637
+ badgeBg: "bg-slate-100 text-slate-900 border-slate-300 dark:bg-slate-900 dark:text-slate-200 dark:border-slate-700",
638
+ icon: "mouse-pointer-click",
639
+ website: "https://cursor.com"
640
+ },
641
+ codex: {
642
+ id: "codex",
643
+ name: "Codex",
644
+ fullName: "OpenAI Codex",
645
+ slug: "codex",
646
+ description: "AI code generation and interactive canvas mechanics synthesized by Codex",
647
+ badgeColor: "#10A37F",
648
+ badgeBg: "bg-emerald-100 text-emerald-900 border-emerald-300 dark:bg-emerald-950/60 dark:text-emerald-200 dark:border-emerald-700",
649
+ icon: "code",
650
+ website: "https://openai.com"
651
+ },
652
+ claude: {
653
+ id: "claude",
654
+ name: "Claude",
655
+ fullName: "Anthropic Claude",
656
+ slug: "claude",
657
+ description: "Games designed and crafted with Anthropic Claude",
658
+ badgeColor: "#D97706",
659
+ badgeBg: "bg-amber-100 text-amber-900 border-amber-300 dark:bg-amber-950/60 dark:text-amber-200 dark:border-amber-700",
660
+ icon: "sparkles",
661
+ website: "https://anthropic.com/claude"
662
+ },
663
+ gemini: {
664
+ id: "gemini",
665
+ name: "Gemini",
666
+ fullName: "Google Gemini",
667
+ slug: "gemini",
668
+ description: "Ultra-fast web games generated with Google Gemini models",
669
+ badgeColor: "#2563EB",
670
+ badgeBg: "bg-blue-100 text-blue-900 border-blue-300 dark:bg-blue-950/60 dark:text-blue-200 dark:border-blue-700",
671
+ icon: "atom",
672
+ website: "https://gemini.google.com"
673
+ },
674
+ chatgpt: {
675
+ id: "chatgpt",
676
+ name: "ChatGPT",
677
+ fullName: "OpenAI ChatGPT & Canvas",
678
+ slug: "chatgpt",
679
+ description: "Games built in interactive canvas sessions with OpenAI ChatGPT",
680
+ badgeColor: "#10A37F",
681
+ badgeBg: "bg-emerald-100 text-emerald-900 border-emerald-300 dark:bg-emerald-950/60 dark:text-emerald-200 dark:border-emerald-700",
682
+ icon: "bot",
683
+ website: "https://chatgpt.com"
684
+ },
685
+ v0: {
686
+ id: "v0",
687
+ name: "v0",
688
+ fullName: "v0 by Vercel",
689
+ slug: "v0",
690
+ description: "Generative interactive UI and canvas components synthesized by v0",
691
+ badgeColor: "#18181B",
692
+ badgeBg: "bg-zinc-100 text-zinc-900 border-zinc-300 dark:bg-zinc-800 dark:text-zinc-200 dark:border-zinc-700",
693
+ icon: "layers",
694
+ website: "https://v0.dev"
695
+ },
696
+ windsurf: {
697
+ id: "windsurf",
698
+ name: "Windsurf",
699
+ fullName: "Codeium Windsurf",
700
+ slug: "windsurf",
701
+ description: "Agentic flow and web games developed with Codeium Windsurf",
702
+ badgeColor: "#0284C7",
703
+ badgeBg: "bg-sky-100 text-sky-900 border-sky-300 dark:bg-sky-950/60 dark:text-sky-200 dark:border-sky-700",
704
+ icon: "wind",
705
+ website: "https://codeium.com/windsurf"
706
+ },
707
+ lovable: {
708
+ id: "lovable",
709
+ name: "Lovable",
710
+ fullName: "Lovable AI",
711
+ slug: "lovable",
712
+ description: "Full-stack web applications and games engineered with Lovable",
713
+ badgeColor: "#EC4899",
714
+ badgeBg: "bg-pink-100 text-pink-900 border-pink-300 dark:bg-pink-950/60 dark:text-pink-200 dark:border-pink-700",
715
+ icon: "heart",
716
+ website: "https://lovable.dev"
717
+ },
718
+ bolt: {
719
+ id: "bolt",
720
+ name: "Bolt",
721
+ fullName: "Bolt.new by StackBlitz",
722
+ slug: "bolt",
723
+ description: "In-browser full-stack sandbox games generated with Bolt.new",
724
+ badgeColor: "#EAB308",
725
+ badgeBg: "bg-yellow-100 text-yellow-900 border-yellow-300 dark:bg-yellow-950/60 dark:text-yellow-200 dark:border-yellow-700",
726
+ icon: "zap",
727
+ website: "https://bolt.new"
728
+ },
729
+ other: {
730
+ id: "other",
731
+ name: "Other AI",
732
+ fullName: "Other / Custom AI Engine",
733
+ slug: "other",
734
+ description: "Games created with custom agents, local LLMs, or custom fine-tunes",
735
+ badgeColor: "#64748B",
736
+ badgeBg: "bg-neutral-100 text-neutral-800 border-neutral-300 dark:bg-neutral-800 dark:text-neutral-300 dark:border-neutral-700",
737
+ icon: "cpu",
738
+ website: "https://replaystage.com"
739
+ }
740
+ };
458
741
  var GAME_CATEGORY_KEYS = [
459
742
  "arcade",
460
743
  "action",
@@ -472,6 +755,8 @@ var MAX_GAME_DESCRIPTION_LENGTH = 2e3;
472
755
  var MAX_TAGS_COUNT = 6;
473
756
  var MAX_TAG_LENGTH = 20;
474
757
  var MAX_PROMPT_LENGTH = 4e3;
758
+ var MAX_AI_TOOL_LENGTH = 64;
759
+ var MAX_AI_MODEL_LENGTH = 80;
475
760
  var CLAIM_TOKEN_EXPIRY_DAYS = 7;
476
761
  var CLAIM_TOKEN_EXPIRY_MS = CLAIM_TOKEN_EXPIRY_DAYS * 24 * 60 * 60 * 1e3;
477
762
  var PROHIBITED_EXTENSIONS = [
@@ -517,6 +802,7 @@ var ASPECT_RATIO_PRESETS = [
517
802
  ];
518
803
  var MIN_ASPECT_RATIO = 0.25;
519
804
  var MAX_ASPECT_RATIO = 4;
805
+ var DEFAULT_SUPPORTED_PLATFORMS = "both";
520
806
 
521
807
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
522
808
  var external_exports = {};
@@ -4623,6 +4909,176 @@ function extractRawAspectRatioFromHtml(html) {
4623
4909
  return null;
4624
4910
  }
4625
4911
 
4912
+ // ../shared/src/platforms.ts
4913
+ var DESKTOP_TOKENS = /* @__PURE__ */ new Set(["desktop", "pc", "mac", "windows", "computer"]);
4914
+ var MOBILE_TOKENS = /* @__PURE__ */ new Set(["mobile", "touch", "phone", "tablet", "ios", "android"]);
4915
+ var UNIVERSAL_TOKENS = /* @__PURE__ */ new Set(["both", "all", "any"]);
4916
+ function normalizeSupportedPlatforms(input) {
4917
+ if (input === void 0 || input === null) {
4918
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4919
+ }
4920
+ const rawTokens = [];
4921
+ if (Array.isArray(input)) {
4922
+ for (const item of input) {
4923
+ if (typeof item === "string") {
4924
+ const split = item.trim().split(/[\s,+/|]+/);
4925
+ for (const s of split) {
4926
+ if (s) rawTokens.push(s.toLowerCase());
4927
+ }
4928
+ } else {
4929
+ return {
4930
+ valid: false,
4931
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4932
+ error: "Invalid platform specification. Expected string or array of strings"
4933
+ };
4934
+ }
4935
+ }
4936
+ } else if (typeof input === "string") {
4937
+ const trimmed = input.trim();
4938
+ if (trimmed === "") {
4939
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4940
+ }
4941
+ const split = trimmed.split(/[\s,+/|]+/);
4942
+ for (const s of split) {
4943
+ if (s) rawTokens.push(s.toLowerCase());
4944
+ }
4945
+ } else {
4946
+ return {
4947
+ valid: false,
4948
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4949
+ error: "Invalid platform specification. Expected string or array of strings"
4950
+ };
4951
+ }
4952
+ if (rawTokens.length === 0) {
4953
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4954
+ }
4955
+ let hasDesktop = false;
4956
+ let hasMobile = false;
4957
+ let hasBoth = false;
4958
+ for (const token of rawTokens) {
4959
+ if (UNIVERSAL_TOKENS.has(token)) {
4960
+ hasBoth = true;
4961
+ } else if (DESKTOP_TOKENS.has(token)) {
4962
+ hasDesktop = true;
4963
+ } else if (MOBILE_TOKENS.has(token)) {
4964
+ hasMobile = true;
4965
+ } else {
4966
+ return {
4967
+ valid: false,
4968
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4969
+ error: `Invalid platform: "${token}". Expected "both", "desktop", "mobile", or combinations like "desktop, mobile"`
4970
+ };
4971
+ }
4972
+ }
4973
+ if (hasBoth || hasDesktop && hasMobile) {
4974
+ return { valid: true, normalized: "both" };
4975
+ }
4976
+ if (hasDesktop) {
4977
+ return { valid: true, normalized: "desktop" };
4978
+ }
4979
+ if (hasMobile) {
4980
+ return { valid: true, normalized: "mobile" };
4981
+ }
4982
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4983
+ }
4984
+ function extractRawPlatformsFromHtml(html) {
4985
+ if (!html || typeof html !== "string") return null;
4986
+ const cleanHtml = html.replace(/<!--[\s\S]*?-->/g, "");
4987
+ const metaTagRegex = /<meta\s+([^>]*?)>/gi;
4988
+ for (const match of cleanHtml.matchAll(metaTagRegex)) {
4989
+ const attrs = match[1];
4990
+ const isPlatformMeta = /(?:^|\s)name\s*=\s*(["']?)replaystage:platforms?\1(?:\s|$|\/)/i.test(
4991
+ attrs
4992
+ );
4993
+ if (!isPlatformMeta) continue;
4994
+ const contentMatch = /(?:^|\s)content\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(attrs);
4995
+ if (contentMatch) {
4996
+ const content = contentMatch[1] ?? contentMatch[2] ?? contentMatch[3] ?? "";
4997
+ return content.trim();
4998
+ }
4999
+ }
5000
+ return null;
5001
+ }
5002
+ var extractRawSupportedPlatformsFromHtml = extractRawPlatformsFromHtml;
5003
+ function isCandidateScriptFile(filePath) {
5004
+ const normalized = filePath.replace(/\\/g, "/").toLowerCase();
5005
+ if (normalized.includes("/vendor/") || normalized.startsWith("vendor/") || normalized.includes("/node_modules/") || normalized.startsWith("node_modules/") || normalized.includes("__macosx") || normalized.includes("/.git/")) {
5006
+ return false;
5007
+ }
5008
+ if (normalized.endsWith(".min.js") || normalized.endsWith(".min.mjs")) {
5009
+ return false;
5010
+ }
5011
+ const baseName = normalized.split("/").pop() || "";
5012
+ if (/^(three|phaser|pixi|babylon|playcanvas|matter|howler|cannon|tone)[^/]*\.js$/i.test(baseName)) {
5013
+ return false;
5014
+ }
5015
+ return normalized.endsWith(".html") || normalized.endsWith(".htm") || normalized.endsWith(".js") || normalized.endsWith(".mjs");
5016
+ }
5017
+ function stripComments(code) {
5018
+ return code.replace(/<!--[\s\S]*?-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\r\n]*/g, "");
5019
+ }
5020
+ function detectBundlePlatforms(files, options) {
5021
+ const fileList = [];
5022
+ const decoder = new TextDecoder("utf-8");
5023
+ if (Array.isArray(files)) {
5024
+ for (const item of files) {
5025
+ const strContent = typeof item.content === "string" ? item.content : decoder.decode(item.content);
5026
+ fileList.push({ path: item.path, content: strContent });
5027
+ }
5028
+ } else if (typeof files === "object" && files !== null) {
5029
+ for (const [filePath, content] of Object.entries(files)) {
5030
+ const strContent = typeof content === "string" ? content : decoder.decode(content);
5031
+ fileList.push({ path: filePath, content: strContent });
5032
+ }
5033
+ }
5034
+ let hasPointerLock = false;
5035
+ let hasKeyboard = false;
5036
+ let hasMousemove = false;
5037
+ let hasDesktopMouse = false;
5038
+ let hasTouch = false;
5039
+ let hasMotion = false;
5040
+ let hasUniversalPointerOrClick = false;
5041
+ const POINTER_LOCK_REGEX = /\b(?:requestPointerLock|mozRequestPointerLock|webkitRequestPointerLock|pointerlockchange|pointerlockerror)\b/;
5042
+ const KEYBOARD_REGEX = /\b(?:keydown|keyup|keypress)\b/i;
5043
+ const MOUSEMOVE_REGEX = /\b(?:mousemove)\b/i;
5044
+ const DESKTOP_MOUSE_REGEX = /\b(?:mousedown|mouseup|contextmenu|dblclick|wheel)\b/i;
5045
+ const TOUCH_REGEX = /\b(?:touchstart|touchmove|touchend|touchcancel)\b/i;
5046
+ const MOTION_REGEX = /\b(?:DeviceOrientationEvent|DeviceMotionEvent|devicemotion|deviceorientation)\b/i;
5047
+ const UNIVERSAL_POINTER_REGEX = /\b(?:pointerdown|pointermove|pointerup|click)\b/i;
5048
+ for (const file of fileList) {
5049
+ if (!isCandidateScriptFile(file.path)) continue;
5050
+ const clean = stripComments(file.content);
5051
+ if (POINTER_LOCK_REGEX.test(clean)) hasPointerLock = true;
5052
+ if (KEYBOARD_REGEX.test(clean)) hasKeyboard = true;
5053
+ if (MOUSEMOVE_REGEX.test(clean)) hasMousemove = true;
5054
+ if (DESKTOP_MOUSE_REGEX.test(clean)) hasDesktopMouse = true;
5055
+ if (TOUCH_REGEX.test(clean)) hasTouch = true;
5056
+ if (MOTION_REGEX.test(clean)) hasMotion = true;
5057
+ if (UNIVERSAL_POINTER_REGEX.test(clean)) hasUniversalPointerOrClick = true;
5058
+ }
5059
+ const usesTouchOrMotion = hasTouch || hasMotion;
5060
+ const usesKeyboardOrMousemove = hasKeyboard || hasMousemove;
5061
+ const usesDesktop = hasPointerLock || hasKeyboard || hasMousemove || hasDesktopMouse;
5062
+ let detected = "both";
5063
+ if (hasPointerLock && !usesTouchOrMotion) {
5064
+ detected = "desktop";
5065
+ } else if (usesKeyboardOrMousemove && !usesTouchOrMotion && !hasUniversalPointerOrClick) {
5066
+ detected = "desktop";
5067
+ } else if (usesTouchOrMotion && !usesDesktop && !hasUniversalPointerOrClick) {
5068
+ detected = "mobile";
5069
+ } else {
5070
+ detected = "both";
5071
+ }
5072
+ const hasMobileControls = typeof options?.controls?.mobile === "string" && Boolean(options.controls.mobile.trim());
5073
+ const hasDesktopControls = typeof options?.controls?.desktop === "string" && Boolean(options.controls.desktop.trim());
5074
+ if (detected === "desktop" && hasMobileControls) {
5075
+ detected = "both";
5076
+ } else if (detected === "mobile" && hasDesktopControls) {
5077
+ detected = "both";
5078
+ }
5079
+ return detected;
5080
+ }
5081
+
4626
5082
  // ../shared/src/schemas.ts
4627
5083
  var SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
4628
5084
  var SHA256_REGEX = /^[a-f0-9]{64}$/;
@@ -4682,6 +5138,48 @@ var aspectRatioSchema = external_exports.preprocess((val) => {
4682
5138
  });
4683
5139
  }
4684
5140
  }).transform((val) => normalizeAspectRatio(val).normalized);
5141
+ var supportedPlatformsSchema = external_exports.preprocess((val) => {
5142
+ if (val === null || val === void 0 || val === "") {
5143
+ return DEFAULT_SUPPORTED_PLATFORMS;
5144
+ }
5145
+ return val;
5146
+ }, external_exports.unknown()).superRefine((val, ctx) => {
5147
+ if (typeof val !== "string" && !Array.isArray(val)) {
5148
+ ctx.addIssue({
5149
+ code: external_exports.ZodIssueCode.custom,
5150
+ message: "Invalid platform specification. Expected string or array of strings"
5151
+ });
5152
+ return;
5153
+ }
5154
+ const res = normalizeSupportedPlatforms(val);
5155
+ if (!res.valid) {
5156
+ ctx.addIssue({
5157
+ code: external_exports.ZodIssueCode.custom,
5158
+ message: res.error || "Invalid supported platform"
5159
+ });
5160
+ }
5161
+ }).transform((val) => normalizeSupportedPlatforms(val).normalized);
5162
+ var aiToolSchema = external_exports.preprocess(
5163
+ (val) => {
5164
+ if (val === null || val === void 0 || val === false || typeof val === "string" && val.trim() === "") {
5165
+ return "other";
5166
+ }
5167
+ if (typeof val === "string") {
5168
+ return val.trim();
5169
+ }
5170
+ return val;
5171
+ },
5172
+ external_exports.string({ errorMap: () => ({ message: "Invalid AI tool selection" }) }).min(1, "AI tool cannot be empty").max(MAX_AI_TOOL_LENGTH, `AI tool must be ${MAX_AI_TOOL_LENGTH} characters or less`)
5173
+ );
5174
+ var aiModelSchema = external_exports.preprocess((val) => {
5175
+ if (val === null || typeof val === "string" && val.trim() === "") {
5176
+ return null;
5177
+ }
5178
+ if (typeof val === "string") {
5179
+ return val.trim();
5180
+ }
5181
+ return val;
5182
+ }, external_exports.string().max(MAX_AI_MODEL_LENGTH, `AI model must be ${MAX_AI_MODEL_LENGTH} characters or less`).nullable().optional());
4685
5183
  var baseGameUploadObject = external_exports.object({
4686
5184
  title: external_exports.string().trim().min(2, "Title must be at least 2 characters").max(MAX_GAME_TITLE_LENGTH, `Title must be ${MAX_GAME_TITLE_LENGTH} characters or less`),
4687
5185
  tagline: external_exports.string({ required_error: "Tagline is required" }).trim().max(
@@ -4692,9 +5190,8 @@ var baseGameUploadObject = external_exports.object({
4692
5190
  MAX_GAME_DESCRIPTION_LENGTH,
4693
5191
  `Description must be ${MAX_GAME_DESCRIPTION_LENGTH} characters or less`
4694
5192
  ).default(""),
4695
- aiTool: external_exports.enum(AI_TOOL_KEYS, {
4696
- errorMap: () => ({ message: "Invalid AI tool selection" })
4697
- }),
5193
+ aiTool: aiToolSchema.default("other"),
5194
+ aiModel: aiModelSchema.optional().nullable(),
4698
5195
  primaryCategory: external_exports.enum(GAME_CATEGORY_KEYS, {
4699
5196
  errorMap: () => ({ message: "Invalid game category selection" })
4700
5197
  }),
@@ -4707,6 +5204,7 @@ var baseGameUploadObject = external_exports.object({
4707
5204
  visibility: external_exports.enum(UPLOAD_VISIBILITIES).optional(),
4708
5205
  bundleEntry: external_exports.string().trim().min(1).max(200).optional(),
4709
5206
  aspectRatio: aspectRatioSchema.default(DEFAULT_ASPECT_RATIO),
5207
+ supportedPlatforms: supportedPlatformsSchema.default(DEFAULT_SUPPORTED_PLATFORMS),
4710
5208
  changelog: external_exports.string().trim().max(500).optional(),
4711
5209
  slug: slugSchema.optional(),
4712
5210
  fileHash: external_exports.string().regex(SHA256_REGEX, "Invalid SHA-256 hash format").optional(),
@@ -4757,9 +5255,8 @@ var gameUpdateSchema = external_exports.object({
4757
5255
  MAX_GAME_DESCRIPTION_LENGTH,
4758
5256
  `Description must be ${MAX_GAME_DESCRIPTION_LENGTH} characters or less`
4759
5257
  ).optional(),
4760
- aiTool: external_exports.enum(AI_TOOL_KEYS, {
4761
- errorMap: () => ({ message: "Invalid AI tool selection" })
4762
- }).optional(),
5258
+ aiTool: aiToolSchema.optional(),
5259
+ aiModel: aiModelSchema.optional().nullable(),
4763
5260
  primaryCategory: external_exports.enum(GAME_CATEGORY_KEYS, {
4764
5261
  errorMap: () => ({ message: "Invalid game category selection" })
4765
5262
  }).optional(),
@@ -4772,6 +5269,7 @@ var gameUpdateSchema = external_exports.object({
4772
5269
  visibility: external_exports.enum(UPLOAD_VISIBILITIES).optional(),
4773
5270
  bundleEntry: external_exports.string().trim().min(1).max(200).optional(),
4774
5271
  aspectRatio: aspectRatioSchema.optional(),
5272
+ supportedPlatforms: supportedPlatformsSchema.optional(),
4775
5273
  changelog: external_exports.string().trim().max(500).optional(),
4776
5274
  fileHash: external_exports.string().regex(SHA256_REGEX, "Invalid SHA-256 hash format").optional(),
4777
5275
  sourceCode: external_exports.string().max(MAX_HTML_SIZE_BYTES, "Single-file HTML cannot exceed 5MB").optional().nullable(),
@@ -4873,6 +5371,33 @@ async function sha256(input) {
4873
5371
  return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
4874
5372
  }
4875
5373
 
5374
+ // ../shared/src/model.ts
5375
+ function extractRawAiModelFromHtml(html) {
5376
+ if (!html || typeof html !== "string") return null;
5377
+ const cleanHtml = html.replace(/<!--[\s\S]*?-->/g, "");
5378
+ const metaTagRegex = /<meta\b([^>]*)>/gi;
5379
+ for (const match of cleanHtml.matchAll(metaTagRegex)) {
5380
+ const attrs = match[1];
5381
+ const isModelMeta = /(?:^|\s)name\s*=\s*(["']?)replaystage:models?\1(?:\s|$|\/)/i.test(attrs);
5382
+ if (!isModelMeta) continue;
5383
+ const contentMatch = /(?:^|\s)content\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(attrs);
5384
+ if (contentMatch) {
5385
+ const content = contentMatch[1] ?? contentMatch[2] ?? contentMatch[3] ?? "";
5386
+ const trimmed = content.trim();
5387
+ return trimmed.length > 0 ? trimmed : null;
5388
+ }
5389
+ }
5390
+ return null;
5391
+ }
5392
+ function extractAiModelFromHtml(html) {
5393
+ const raw = extractRawAiModelFromHtml(html);
5394
+ if (!raw) return null;
5395
+ const truncated = raw.slice(0, MAX_AI_MODEL_LENGTH);
5396
+ const parsed = aiModelSchema.safeParse(truncated);
5397
+ if (!parsed.success || !parsed.data) return null;
5398
+ return parsed.data;
5399
+ }
5400
+
4876
5401
  // ../shared/src/sanitizer.ts
4877
5402
  var FORBIDDEN_SEGMENT_EXACT = /* @__PURE__ */ new Set([
4878
5403
  ".replaystage.json",
@@ -4953,6 +5478,30 @@ function isIgnoredZipEntry(entryPath) {
4953
5478
  return normalized.startsWith("__MACOSX/") || normalized.includes("/__MACOSX/") || normalized.endsWith(".DS_Store") || normalized.endsWith("Thumbs.db") || normalized.startsWith("._") || normalized.includes("/._");
4954
5479
  }
4955
5480
  var MAX_COVER_IMAGE_BYTES = 2 * 1024 * 1024;
5481
+ function validateCoverImageBytes(bytes) {
5482
+ if (!bytes || bytes.byteLength < 12) {
5483
+ return { valid: false, error: "Cover image is empty or truncated" };
5484
+ }
5485
+ if (bytes.byteLength > MAX_COVER_IMAGE_BYTES) {
5486
+ return { valid: false, error: "Cover image exceeds the 2 MB maximum limit" };
5487
+ }
5488
+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10) {
5489
+ return { valid: true, mimeType: "image/png", ext: "png" };
5490
+ }
5491
+ if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) {
5492
+ return { valid: true, mimeType: "image/jpeg", ext: "jpg" };
5493
+ }
5494
+ if (bytes[0] === 82 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 70 && bytes[8] === 87 && bytes[9] === 69 && bytes[10] === 66 && bytes[11] === 80) {
5495
+ return { valid: true, mimeType: "image/webp", ext: "webp" };
5496
+ }
5497
+ if (bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 56 && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
5498
+ return { valid: true, mimeType: "image/gif", ext: "gif" };
5499
+ }
5500
+ return {
5501
+ valid: false,
5502
+ error: "Unsupported cover image format (must be PNG, JPEG, WebP, or GIF)"
5503
+ };
5504
+ }
4956
5505
  function findEntryHtmlFile(paths) {
4957
5506
  const cleanPaths = paths.filter((p) => !isIgnoredZipEntry(p)).map((p) => p.replace(/\\/g, "/").replace(/^\.?\//, ""));
4958
5507
  if (cleanPaths.includes("index.html")) {
@@ -5013,9 +5562,94 @@ import pc3 from "picocolors";
5013
5562
 
5014
5563
  // src/packager.ts
5015
5564
  import crypto from "crypto";
5016
- import fs2 from "fs";
5017
- import path2 from "path";
5565
+ import fs3 from "fs";
5566
+ import path3 from "path";
5018
5567
  import * as fflate from "fflate";
5568
+ var COVER_PRECEDENCE_FILES = [
5569
+ "cover.png",
5570
+ "cover.jpg",
5571
+ "cover.jpeg",
5572
+ "cover.webp",
5573
+ "cover.gif"
5574
+ ];
5575
+ function detectSiblingCover(targetPath) {
5576
+ const resolved = path3.resolve(process.cwd(), targetPath || ".");
5577
+ if (!fs3.existsSync(resolved)) return null;
5578
+ const stat = fs3.statSync(resolved);
5579
+ if (stat.isFile()) {
5580
+ const ext = path3.extname(resolved).toLowerCase();
5581
+ if (ext === ".html" || ext === ".htm") {
5582
+ return scanDirectoryForCover(path3.dirname(resolved), "sibling");
5583
+ }
5584
+ if (ext === ".zip") {
5585
+ try {
5586
+ const zipContent = fs3.readFileSync(resolved);
5587
+ const unzipped = fflate.unzipSync(new Uint8Array(zipContent));
5588
+ const entryPaths = Object.keys(unzipped);
5589
+ const lookup = /* @__PURE__ */ new Map();
5590
+ for (const ep of entryPaths) {
5591
+ if (isIgnoredZipEntry(ep)) continue;
5592
+ const clean = ep.replace(/\\/g, "/").replace(/^\.?\//, "");
5593
+ lookup.set(clean.toLowerCase(), ep);
5594
+ }
5595
+ for (const candidate of COVER_PRECEDENCE_FILES) {
5596
+ const matchedKey = lookup.get(candidate);
5597
+ if (matchedKey) {
5598
+ const rawBytes = unzipped[matchedKey];
5599
+ const check = validateCoverImageBytes(rawBytes);
5600
+ if (check.valid && check.ext && check.mimeType) {
5601
+ return {
5602
+ source: "bundle",
5603
+ fileName: path3.basename(matchedKey),
5604
+ buffer: Buffer.from(rawBytes),
5605
+ ext: check.ext,
5606
+ mimeType: check.mimeType
5607
+ };
5608
+ }
5609
+ }
5610
+ }
5611
+ } catch {
5612
+ }
5613
+ return scanDirectoryForCover(path3.dirname(resolved), "sibling");
5614
+ }
5615
+ return null;
5616
+ }
5617
+ if (stat.isDirectory()) {
5618
+ return scanDirectoryForCover(resolved, "bundle");
5619
+ }
5620
+ return null;
5621
+ }
5622
+ function scanDirectoryForCover(dirPath, source) {
5623
+ try {
5624
+ const entries = fs3.readdirSync(dirPath, { withFileTypes: true });
5625
+ const entryMap = /* @__PURE__ */ new Map();
5626
+ for (const entry of entries) {
5627
+ if (entry.isFile()) {
5628
+ entryMap.set(entry.name.toLowerCase(), entry);
5629
+ }
5630
+ }
5631
+ for (const candidate of COVER_PRECEDENCE_FILES) {
5632
+ const match = entryMap.get(candidate);
5633
+ if (match) {
5634
+ const fullPath = path3.join(dirPath, match.name);
5635
+ const buf = fs3.readFileSync(fullPath);
5636
+ const check = validateCoverImageBytes(new Uint8Array(buf));
5637
+ if (check.valid && check.ext && check.mimeType) {
5638
+ return {
5639
+ source,
5640
+ fileName: match.name,
5641
+ filePath: fullPath,
5642
+ buffer: buf,
5643
+ ext: check.ext,
5644
+ mimeType: check.mimeType
5645
+ };
5646
+ }
5647
+ }
5648
+ }
5649
+ } catch {
5650
+ }
5651
+ return null;
5652
+ }
5019
5653
  function extractHtmlMetadata(html) {
5020
5654
  let title;
5021
5655
  let tagline;
@@ -5029,11 +5663,13 @@ function extractHtmlMetadata(html) {
5029
5663
  }
5030
5664
  const rawAspect = extractRawAspectRatioFromHtml(html);
5031
5665
  const aspectNorm = rawAspect ? normalizeAspectRatio(rawAspect) : null;
5666
+ const model = extractAiModelFromHtml(html);
5032
5667
  return {
5033
5668
  title,
5034
5669
  tagline,
5035
5670
  rawAspectRatio: rawAspect ?? void 0,
5036
- aspectRatio: aspectNorm?.valid ? aspectNorm.normalized : void 0
5671
+ aspectRatio: aspectNorm?.valid ? aspectNorm.normalized : void 0,
5672
+ model: model ?? null
5037
5673
  };
5038
5674
  }
5039
5675
  function computeSha256(buf) {
@@ -5049,40 +5685,46 @@ function createZipFromFiles(fileMap) {
5049
5685
  return Buffer.from(zipped);
5050
5686
  }
5051
5687
  async function packageGame(targetPath) {
5052
- const resolved = path2.resolve(process.cwd(), targetPath || ".");
5053
- if (!fs2.existsSync(resolved)) {
5688
+ const resolved = path3.resolve(process.cwd(), targetPath || ".");
5689
+ if (!fs3.existsSync(resolved)) {
5054
5690
  throw new Error(`Target path does not exist: ${resolved}`);
5055
5691
  }
5056
- const stat = fs2.statSync(resolved);
5692
+ const stat = fs3.statSync(resolved);
5057
5693
  if (stat.isFile()) {
5058
- const ext = path2.extname(resolved).toLowerCase();
5694
+ const ext = path3.extname(resolved).toLowerCase();
5059
5695
  if (ext === ".html" || ext === ".htm") {
5060
- const content = fs2.readFileSync(resolved);
5696
+ const content = fs3.readFileSync(resolved);
5061
5697
  if (content.length > MAX_HTML_SIZE_BYTES) {
5062
5698
  throw new Error(
5063
5699
  `Single HTML file exceeds maximum allowed size of 5MB (${(content.length / (1024 * 1024)).toFixed(2)} MB)`
5064
5700
  );
5065
5701
  }
5066
5702
  const meta = extractHtmlMetadata(content.toString("utf-8"));
5067
- const zipBuffer = createZipFromFiles({ "index.html": content });
5703
+ const files = { "index.html": content };
5704
+ const detectedCover = detectSiblingCover(resolved);
5705
+ if (detectedCover && detectedCover.buffer) {
5706
+ files[detectedCover.fileName] = detectedCover.buffer;
5707
+ }
5708
+ const zipBuffer = createZipFromFiles(files);
5068
5709
  const fileHash = computeSha256(zipBuffer);
5069
5710
  return {
5070
5711
  format: "single-html",
5071
5712
  entryPoint: "index.html",
5072
- fileCount: 1,
5713
+ fileCount: Object.keys(files).length,
5073
5714
  totalBytes: content.length,
5074
- totalSizeBytes: content.length,
5715
+ totalSizeBytes: Object.values(files).reduce((acc, b) => acc + b.length, 0),
5075
5716
  buffer: zipBuffer,
5076
5717
  bundleBuffer: zipBuffer,
5077
5718
  fileHash,
5078
- files: ["index.html"],
5719
+ files: Object.keys(files),
5079
5720
  extractedTitle: meta.title,
5080
5721
  extractedTagline: meta.tagline,
5081
- extractedAspectRatio: meta.aspectRatio
5722
+ extractedAspectRatio: meta.aspectRatio,
5723
+ extractedModel: meta.model ?? null
5082
5724
  };
5083
5725
  }
5084
5726
  if (ext === ".zip") {
5085
- const content = fs2.readFileSync(resolved);
5727
+ const content = fs3.readFileSync(resolved);
5086
5728
  if (content.length > MAX_BUNDLE_SIZE_BYTES) {
5087
5729
  throw new Error(
5088
5730
  `Zip archive exceeds maximum allowed size of 25MB (${(content.length / (1024 * 1024)).toFixed(2)} MB)`
@@ -5118,6 +5760,7 @@ async function packageGame(targetPath) {
5118
5760
  let extractedTitle;
5119
5761
  let extractedTagline;
5120
5762
  let extractedAspectRatio;
5763
+ let extractedModel;
5121
5764
  if (unzipped[entryRes.entryPath]) {
5122
5765
  const meta = extractHtmlMetadata(
5123
5766
  Buffer.from(unzipped[entryRes.entryPath]).toString("utf-8")
@@ -5125,6 +5768,7 @@ async function packageGame(targetPath) {
5125
5768
  extractedTitle = meta.title;
5126
5769
  extractedTagline = meta.tagline;
5127
5770
  extractedAspectRatio = meta.aspectRatio;
5771
+ extractedModel = meta.model;
5128
5772
  }
5129
5773
  return {
5130
5774
  format: "zip",
@@ -5138,7 +5782,8 @@ async function packageGame(targetPath) {
5138
5782
  files: filteredFiles,
5139
5783
  extractedTitle,
5140
5784
  extractedTagline,
5141
- extractedAspectRatio
5785
+ extractedAspectRatio,
5786
+ extractedModel: extractedModel ?? null
5142
5787
  };
5143
5788
  }
5144
5789
  throw new Error(
@@ -5147,13 +5792,13 @@ async function packageGame(targetPath) {
5147
5792
  }
5148
5793
  if (stat.isDirectory()) {
5149
5794
  let walk2 = function(currentDir, relDir) {
5150
- const dirEntries = fs2.readdirSync(currentDir, { withFileTypes: true });
5795
+ const dirEntries = fs3.readdirSync(currentDir, { withFileTypes: true });
5151
5796
  for (const entry of dirEntries) {
5152
5797
  const name = entry.name;
5153
5798
  if (name.startsWith(".") || name === ".replaystage.json" || name.startsWith(".replaystage") || name === "node_modules" || name === "__MACOSX" || name === "Thumbs.db" || isIgnoredZipEntry(name)) {
5154
5799
  continue;
5155
5800
  }
5156
- const fullPath = path2.join(currentDir, name);
5801
+ const fullPath = path3.join(currentDir, name);
5157
5802
  const relPath = relDir ? `${relDir}/${name}` : name;
5158
5803
  const normalizedRelPath = relPath.replace(/\\/g, "/");
5159
5804
  if (isIgnoredZipEntry(normalizedRelPath)) {
@@ -5171,14 +5816,14 @@ async function packageGame(targetPath) {
5171
5816
  if (!validation.valid) {
5172
5817
  throw new Error(`Invalid file path in directory: ${validation.error}`);
5173
5818
  }
5174
- const fileStat = fs2.statSync(fullPath);
5819
+ const fileStat = fs3.statSync(fullPath);
5175
5820
  totalSizeBytes += fileStat.size;
5176
5821
  if (totalSizeBytes > MAX_BUNDLE_SIZE_BYTES) {
5177
5822
  throw new Error(
5178
5823
  `Game bundle exceeds maximum allowed size of 25MB (${(totalSizeBytes / (1024 * 1024)).toFixed(2)} MB).`
5179
5824
  );
5180
5825
  }
5181
- const buf = fs2.readFileSync(fullPath);
5826
+ const buf = fs3.readFileSync(fullPath);
5182
5827
  fileEntries[normalizedRelPath] = buf;
5183
5828
  filesList.push(normalizedRelPath);
5184
5829
  }
@@ -5202,12 +5847,14 @@ async function packageGame(targetPath) {
5202
5847
  let extractedTitle;
5203
5848
  let extractedTagline;
5204
5849
  let extractedAspectRatio;
5850
+ let extractedModel;
5205
5851
  const entryBuf = fileEntries[entryResolution.entryPath];
5206
5852
  if (entryBuf) {
5207
5853
  const meta = extractHtmlMetadata(entryBuf.toString("utf-8"));
5208
5854
  extractedTitle = meta.title;
5209
5855
  extractedTagline = meta.tagline;
5210
5856
  extractedAspectRatio = meta.aspectRatio;
5857
+ extractedModel = meta.model;
5211
5858
  }
5212
5859
  const zipBuffer = createZipFromFiles(fileEntries);
5213
5860
  const fileHash = computeSha256(zipBuffer);
@@ -5223,96 +5870,13 @@ async function packageGame(targetPath) {
5223
5870
  files: filesList,
5224
5871
  extractedTitle,
5225
5872
  extractedTagline,
5226
- extractedAspectRatio
5873
+ extractedAspectRatio,
5874
+ extractedModel: extractedModel ?? null
5227
5875
  };
5228
5876
  }
5229
5877
  throw new Error(`Invalid target path: '${targetPath}' is neither a file nor a directory.`);
5230
5878
  }
5231
5879
 
5232
- // src/project.ts
5233
- import * as fs3 from "fs";
5234
- import * as os2 from "os";
5235
- import * as path3 from "path";
5236
- function resolveProjectDirectory(targetPath) {
5237
- try {
5238
- const resolved = path3.resolve(targetPath);
5239
- if (resolved.toLowerCase().endsWith(".zip")) {
5240
- return null;
5241
- }
5242
- if (resolved.includes("seed-games")) {
5243
- return null;
5244
- }
5245
- if (fs3.existsSync(resolved) && fs3.statSync(resolved).isDirectory()) {
5246
- if (resolved === path3.resolve(os2.tmpdir())) {
5247
- return null;
5248
- }
5249
- return resolved;
5250
- }
5251
- if (fs3.existsSync(resolved) && fs3.statSync(resolved).isFile()) {
5252
- const parentDir = path3.dirname(resolved);
5253
- if (parentDir === path3.resolve(os2.tmpdir())) {
5254
- return null;
5255
- }
5256
- return parentDir;
5257
- }
5258
- return resolved;
5259
- } catch {
5260
- return path3.resolve(targetPath);
5261
- }
5262
- }
5263
- function getProjectConfigPath(targetDir) {
5264
- const dir = resolveProjectDirectory(targetDir);
5265
- return dir ? path3.join(dir, ".replaystage.json") : null;
5266
- }
5267
- function readProjectConfig(targetDir) {
5268
- const configPath = getProjectConfigPath(targetDir);
5269
- if (!configPath || !fs3.existsSync(configPath)) {
5270
- return null;
5271
- }
5272
- try {
5273
- const raw = fs3.readFileSync(configPath, "utf-8");
5274
- const parsed = JSON.parse(raw);
5275
- if (!parsed || typeof parsed !== "object" || typeof parsed.slug !== "string") {
5276
- return null;
5277
- }
5278
- return parsed;
5279
- } catch {
5280
- return null;
5281
- }
5282
- }
5283
- function writeProjectConfig(targetDir, config) {
5284
- const configPath = getProjectConfigPath(targetDir);
5285
- if (!configPath) {
5286
- return;
5287
- }
5288
- const dir = path3.dirname(configPath);
5289
- if (!fs3.existsSync(dir)) {
5290
- fs3.mkdirSync(dir, { recursive: true });
5291
- }
5292
- fs3.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
5293
- `, "utf-8");
5294
- }
5295
- function incrementVersion(currentVersion) {
5296
- if (!currentVersion || typeof currentVersion !== "string") return "0.2.0";
5297
- const sanitized = currentVersion.trim().replace(/^v/i, "");
5298
- const parts = sanitized.split(".").map((n) => Number.parseInt(n, 10));
5299
- if (parts.length === 3 && !parts.some(Number.isNaN)) {
5300
- return `${parts[0]}.${parts[1] + 1}.0`;
5301
- }
5302
- if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
5303
- return `${parts[0]}.${parts[1] + 1}.0`;
5304
- }
5305
- return "0.2.0";
5306
- }
5307
- function promoteDraftVersion(currentVersion) {
5308
- if (!currentVersion || typeof currentVersion !== "string") return "1.0.0";
5309
- const sanitized = currentVersion.trim().replace(/^v/i, "");
5310
- if (sanitized.startsWith("0.")) {
5311
- return "1.0.0";
5312
- }
5313
- return incrementVersion(currentVersion);
5314
- }
5315
-
5316
5880
  // src/validation.ts
5317
5881
  import crypto2 from "crypto";
5318
5882
  import fs4 from "fs";
@@ -5351,11 +5915,18 @@ async function validateGamePackage(targetPath) {
5351
5915
  const errors = [];
5352
5916
  const warnings = [];
5353
5917
  let detectedAspectRatio = "auto";
5918
+ let detectedPlatforms = DEFAULT_SUPPORTED_PLATFORMS;
5919
+ let hasPlatformMeta = false;
5920
+ let detectedModel = null;
5354
5921
  if (!fs4.existsSync(resolved)) {
5355
5922
  return {
5356
5923
  valid: false,
5357
5924
  targetPath,
5358
5925
  aspectRatio: detectedAspectRatio,
5926
+ aiModel: detectedModel,
5927
+ supportedPlatforms: detectedPlatforms,
5928
+ platforms: detectedPlatforms,
5929
+ hasPlatformMeta,
5359
5930
  errors: [`Target path does not exist: ${resolved}`],
5360
5931
  warnings: []
5361
5932
  };
@@ -5375,6 +5946,7 @@ async function validateGamePackage(targetPath) {
5375
5946
  if (!depCheck.valid) {
5376
5947
  errors.push(...depCheck.errors);
5377
5948
  }
5949
+ detectedModel = extractAiModelFromHtml(htmlStr);
5378
5950
  const rawMeta = extractRawAspectRatioFromHtml(htmlStr);
5379
5951
  if (rawMeta) {
5380
5952
  const norm = normalizeAspectRatio(rawMeta);
@@ -5384,6 +5956,18 @@ async function validateGamePackage(targetPath) {
5384
5956
  detectedAspectRatio = norm.normalized;
5385
5957
  }
5386
5958
  }
5959
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlStr);
5960
+ if (rawPlatformMeta) {
5961
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
5962
+ if (!norm.valid) {
5963
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
5964
+ } else {
5965
+ detectedPlatforms = norm.normalized;
5966
+ hasPlatformMeta = true;
5967
+ }
5968
+ } else {
5969
+ detectedPlatforms = detectBundlePlatforms([{ path: "index.html", content: htmlStr }]);
5970
+ }
5387
5971
  } else if (ext === ".zip") {
5388
5972
  const content = fs4.readFileSync(resolved);
5389
5973
  if (content.length > MAX_BUNDLE_SIZE_BYTES) {
@@ -5401,6 +5985,7 @@ async function validateGamePackage(targetPath) {
5401
5985
  if (!depCheck.valid) {
5402
5986
  errors.push(...depCheck.errors);
5403
5987
  }
5988
+ detectedModel = extractAiModelFromHtml(htmlContent);
5404
5989
  const rawMeta = extractRawAspectRatioFromHtml(htmlContent);
5405
5990
  if (rawMeta) {
5406
5991
  const norm = normalizeAspectRatio(rawMeta);
@@ -5410,6 +5995,18 @@ async function validateGamePackage(targetPath) {
5410
5995
  detectedAspectRatio = norm.normalized;
5411
5996
  }
5412
5997
  }
5998
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlContent);
5999
+ if (rawPlatformMeta) {
6000
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
6001
+ if (!norm.valid) {
6002
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
6003
+ } else {
6004
+ detectedPlatforms = norm.normalized;
6005
+ hasPlatformMeta = true;
6006
+ }
6007
+ } else {
6008
+ detectedPlatforms = detectBundlePlatforms(unzipped);
6009
+ }
5413
6010
  }
5414
6011
  } catch {
5415
6012
  }
@@ -5490,6 +6087,7 @@ async function validateGamePackage(targetPath) {
5490
6087
  if (!depCheck.valid) {
5491
6088
  errors.push(...depCheck.errors);
5492
6089
  }
6090
+ detectedModel = extractAiModelFromHtml(htmlContent);
5493
6091
  const rawMeta = extractRawAspectRatioFromHtml(htmlContent);
5494
6092
  if (rawMeta) {
5495
6093
  const norm = normalizeAspectRatio(rawMeta);
@@ -5499,16 +6097,44 @@ async function validateGamePackage(targetPath) {
5499
6097
  detectedAspectRatio = norm.normalized;
5500
6098
  }
5501
6099
  }
6100
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlContent);
6101
+ if (rawPlatformMeta) {
6102
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
6103
+ if (!norm.valid) {
6104
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
6105
+ } else {
6106
+ detectedPlatforms = norm.normalized;
6107
+ hasPlatformMeta = true;
6108
+ }
6109
+ }
5502
6110
  } catch {
5503
6111
  }
5504
6112
  }
5505
6113
  }
6114
+ if (!hasPlatformMeta) {
6115
+ const candidateFiles = [];
6116
+ for (const relPath of collectedFiles) {
6117
+ const ext = path4.extname(relPath).toLowerCase();
6118
+ if (ext === ".html" || ext === ".htm" || ext === ".js" || ext === ".mjs") {
6119
+ try {
6120
+ const content = fs4.readFileSync(path4.join(resolved, relPath), "utf-8");
6121
+ candidateFiles.push({ path: relPath, content });
6122
+ } catch {
6123
+ }
6124
+ }
6125
+ }
6126
+ detectedPlatforms = detectBundlePlatforms(candidateFiles);
6127
+ }
5506
6128
  }
5507
6129
  if (errors.length > 0) {
5508
6130
  return {
5509
6131
  valid: false,
5510
6132
  targetPath,
5511
6133
  aspectRatio: detectedAspectRatio,
6134
+ aiModel: detectedModel,
6135
+ supportedPlatforms: detectedPlatforms,
6136
+ platforms: detectedPlatforms,
6137
+ hasPlatformMeta,
5512
6138
  errors,
5513
6139
  warnings
5514
6140
  };
@@ -5533,6 +6159,10 @@ async function validateGamePackage(targetPath) {
5533
6159
  fileHash: deterministicHash,
5534
6160
  files: pkg.files,
5535
6161
  aspectRatio: detectedAspectRatio !== "auto" ? detectedAspectRatio : pkg.extractedAspectRatio ?? detectedAspectRatio,
6162
+ aiModel: detectedModel || pkg.extractedModel || null,
6163
+ supportedPlatforms: detectedPlatforms,
6164
+ platforms: detectedPlatforms,
6165
+ hasPlatformMeta,
5536
6166
  errors: [],
5537
6167
  warnings
5538
6168
  };
@@ -5541,6 +6171,10 @@ async function validateGamePackage(targetPath) {
5541
6171
  valid: false,
5542
6172
  targetPath,
5543
6173
  aspectRatio: detectedAspectRatio,
6174
+ aiModel: detectedModel,
6175
+ supportedPlatforms: detectedPlatforms,
6176
+ platforms: detectedPlatforms,
6177
+ hasPlatformMeta,
5544
6178
  errors: [err.message || String(err)],
5545
6179
  warnings
5546
6180
  };
@@ -5611,10 +6245,6 @@ async function handlePublish(targetPath = ".", options = {}) {
5611
6245
  }
5612
6246
  if (tagline.length < 3) tagline = "An arcade game on ReplayStage";
5613
6247
  if (tagline.length > 120) tagline = tagline.slice(0, 120);
5614
- let aiTool = (options.tool || "other").toLowerCase().trim();
5615
- if (!AI_TOOL_KEYS.includes(aiTool)) {
5616
- aiTool = "other";
5617
- }
5618
6248
  let category = options.category?.toLowerCase().trim();
5619
6249
  if (category && !GAME_CATEGORY_KEYS.includes(category)) {
5620
6250
  category = void 0;
@@ -5622,6 +6252,110 @@ async function handlePublish(targetPath = ".", options = {}) {
5622
6252
  const token = options.anonymous ? null : resolveToken(options.token);
5623
6253
  const apiUrl = resolveApiUrl(options.apiUrl);
5624
6254
  const existingConfig = !options.fresh ? readProjectConfig(resolvedPath) : null;
6255
+ let aiTool = "other";
6256
+ if (options.tool !== void 0) {
6257
+ const parsedTool = aiToolSchema.safeParse(options.tool);
6258
+ if (!parsedTool.success) {
6259
+ const errorMsg = parsedTool.error.errors[0]?.message || `Invalid AI tool: ${options.tool}`;
6260
+ if (isJson) {
6261
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6262
+ } else {
6263
+ console.error(pc3.red(`
6264
+ \u2716 Invalid option: ${errorMsg}
6265
+ `));
6266
+ }
6267
+ process.exit(1);
6268
+ }
6269
+ const rawTool = parsedTool.data;
6270
+ const matchedPreset = AI_TOOL_KEYS.find(
6271
+ (key) => key.toLowerCase() === rawTool.toLowerCase() || AI_TOOLS[key] && AI_TOOLS[key].name.toLowerCase() === rawTool.toLowerCase()
6272
+ );
6273
+ aiTool = matchedPreset ? matchedPreset : rawTool;
6274
+ } else if (existingConfig?.aiTool) {
6275
+ aiTool = existingConfig.aiTool;
6276
+ }
6277
+ let resolvedModel = null;
6278
+ if (options.model !== void 0) {
6279
+ const parsedModel = aiModelSchema.safeParse(options.model);
6280
+ if (!parsedModel.success) {
6281
+ const errorMsg = parsedModel.error.errors[0]?.message || `Invalid AI model: ${options.model}`;
6282
+ if (isJson) {
6283
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6284
+ } else {
6285
+ console.error(pc3.red(`
6286
+ \u2716 Invalid option: ${errorMsg}
6287
+ `));
6288
+ }
6289
+ process.exit(1);
6290
+ }
6291
+ resolvedModel = parsedModel.data ?? null;
6292
+ } else if (bundle.extractedModel) {
6293
+ resolvedModel = bundle.extractedModel;
6294
+ } else if (existingConfig?.aiModel) {
6295
+ resolvedModel = existingConfig.aiModel;
6296
+ }
6297
+ let coverBuffer;
6298
+ let coverFileName;
6299
+ if (options.cover !== void 0 && options.cover !== "") {
6300
+ const resolvedCoverPath = path5.resolve(process.cwd(), options.cover);
6301
+ if (!fs5.existsSync(resolvedCoverPath)) {
6302
+ const errorMsg = `Cover image file does not exist: ${resolvedCoverPath}`;
6303
+ if (isJson) {
6304
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6305
+ } else {
6306
+ console.error(pc3.red(`
6307
+ \u2716 Invalid option: ${errorMsg}
6308
+ `));
6309
+ }
6310
+ process.exit(1);
6311
+ }
6312
+ const stat = fs5.statSync(resolvedCoverPath);
6313
+ if (!stat.isFile()) {
6314
+ const errorMsg = `Specified cover path is not a file: ${resolvedCoverPath}`;
6315
+ if (isJson) {
6316
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6317
+ } else {
6318
+ console.error(pc3.red(`
6319
+ \u2716 Invalid option: ${errorMsg}
6320
+ `));
6321
+ }
6322
+ process.exit(1);
6323
+ }
6324
+ const ext = path5.extname(resolvedCoverPath).toLowerCase().replace(".", "");
6325
+ const allowedExts = ["png", "jpg", "jpeg", "webp", "gif"];
6326
+ if (!allowedExts.includes(ext)) {
6327
+ const errorMsg = `Unsupported cover image format: '.${ext}'. Supported formats are PNG, JPG, JPEG, WebP, GIF.`;
6328
+ if (isJson) {
6329
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6330
+ } else {
6331
+ console.error(pc3.red(`
6332
+ \u2716 Invalid option: ${errorMsg}
6333
+ `));
6334
+ }
6335
+ process.exit(1);
6336
+ }
6337
+ const rawCoverBytes = fs5.readFileSync(resolvedCoverPath);
6338
+ const coverValidation = validateCoverImageBytes(new Uint8Array(rawCoverBytes));
6339
+ if (!coverValidation.valid) {
6340
+ const errorMsg = `Invalid cover image: ${coverValidation.error || "Corrupted image file"}`;
6341
+ if (isJson) {
6342
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6343
+ } else {
6344
+ console.error(pc3.red(`
6345
+ \u2716 Invalid option: ${errorMsg}
6346
+ `));
6347
+ }
6348
+ process.exit(1);
6349
+ }
6350
+ coverBuffer = rawCoverBytes;
6351
+ coverFileName = path5.basename(resolvedCoverPath);
6352
+ } else {
6353
+ const detected = detectSiblingCover(resolvedPath);
6354
+ if (detected) {
6355
+ coverBuffer = detected.buffer;
6356
+ coverFileName = detected.fileName;
6357
+ }
6358
+ }
5625
6359
  let resolvedAspectRatio = "auto";
5626
6360
  if (options.aspectRatio) {
5627
6361
  const norm = normalizeAspectRatio(options.aspectRatio);
@@ -5642,6 +6376,31 @@ async function handlePublish(targetPath = ".", options = {}) {
5642
6376
  } else if (existingConfig?.aspectRatio) {
5643
6377
  resolvedAspectRatio = existingConfig.aspectRatio;
5644
6378
  }
6379
+ let resolvedPlatforms = DEFAULT_SUPPORTED_PLATFORMS;
6380
+ if (options.platforms) {
6381
+ const norm = normalizeSupportedPlatforms(options.platforms);
6382
+ if (!norm.valid) {
6383
+ const errorMsg = norm.error || `Invalid platform: ${options.platforms}`;
6384
+ if (isJson) {
6385
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
6386
+ } else {
6387
+ console.error(pc3.red(`
6388
+ \u2716 Invalid option: ${errorMsg}
6389
+ `));
6390
+ }
6391
+ process.exit(1);
6392
+ }
6393
+ resolvedPlatforms = norm.normalized;
6394
+ } else if (validation.hasPlatformMeta && validation.supportedPlatforms) {
6395
+ resolvedPlatforms = validation.supportedPlatforms;
6396
+ } else if (existingConfig?.supportedPlatforms || existingConfig?.platforms) {
6397
+ const norm = normalizeSupportedPlatforms(
6398
+ existingConfig.supportedPlatforms || existingConfig.platforms
6399
+ );
6400
+ resolvedPlatforms = norm.valid ? norm.normalized : DEFAULT_SUPPORTED_PLATFORMS;
6401
+ } else if (validation.supportedPlatforms) {
6402
+ resolvedPlatforms = validation.supportedPlatforms;
6403
+ }
5645
6404
  if (existingConfig?.slug) {
5646
6405
  logInfo(
5647
6406
  `Updating existing stage '${existingConfig.slug}' (current version: ${existingConfig.version || "0.1.0"})...`,
@@ -5657,8 +6416,13 @@ async function handlePublish(targetPath = ".", options = {}) {
5657
6416
  visibility,
5658
6417
  changelog: options.changelog,
5659
6418
  aspectRatio: resolvedAspectRatio,
6419
+ supportedPlatforms: resolvedPlatforms,
5660
6420
  manageToken: existingConfig.manageToken,
5661
6421
  token,
6422
+ aiModel: resolvedModel,
6423
+ aiTool,
6424
+ coverBuffer,
6425
+ coverFileName,
5662
6426
  errorMsgFallback: "Failed to update stage"
5663
6427
  });
5664
6428
  const resolvedVis = updateResult.visibility || visibility || existingConfig.visibility;
@@ -5671,7 +6435,11 @@ async function handlePublish(targetPath = ".", options = {}) {
5671
6435
  title: title || existingConfig.title,
5672
6436
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5673
6437
  visibility: resolvedVis,
5674
- aspectRatio: resolvedAspectRatio
6438
+ aspectRatio: resolvedAspectRatio,
6439
+ supportedPlatforms: resolvedPlatforms,
6440
+ platforms: resolvedPlatforms,
6441
+ aiModel: resolvedModel !== void 0 ? resolvedModel : existingConfig.aiModel ?? null,
6442
+ aiTool: aiTool || existingConfig.aiTool
5675
6443
  };
5676
6444
  writeProjectConfig(resolvedPath, updatedConfig);
5677
6445
  if (isJson) {
@@ -5684,6 +6452,11 @@ async function handlePublish(targetPath = ".", options = {}) {
5684
6452
  semver: updatedConfig.version,
5685
6453
  versionNumber: updateResult.versionNumber,
5686
6454
  visibility: updatedConfig.visibility,
6455
+ aspectRatio: updatedConfig.aspectRatio,
6456
+ supportedPlatforms: resolvedPlatforms,
6457
+ platforms: resolvedPlatforms,
6458
+ aiModel: updatedConfig.aiModel,
6459
+ aiTool: updatedConfig.aiTool,
5687
6460
  promotedToPublic: updateResult.promotedToPublic,
5688
6461
  fileHash: updateResult.fileHash || bundle.fileHash,
5689
6462
  updated: true
@@ -5701,6 +6474,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5701
6474
  if (updatedConfig.visibility) {
5702
6475
  console.log(` Visibility: ${pc3.bold(updatedConfig.visibility)}`);
5703
6476
  }
6477
+ if (updatedConfig.supportedPlatforms) {
6478
+ console.log(` Platforms: ${pc3.bold(updatedConfig.supportedPlatforms)}`);
6479
+ }
5704
6480
  if (options.changelog) {
5705
6481
  console.log(` Changelog: "${options.changelog}"`);
5706
6482
  }
@@ -5738,6 +6514,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5738
6514
  tagline,
5739
6515
  description: options.description,
5740
6516
  aiTool,
6517
+ aiModel: resolvedModel,
6518
+ coverBuffer,
6519
+ coverFileName,
5741
6520
  category,
5742
6521
  token,
5743
6522
  fileHash: bundle.fileHash,
@@ -5746,7 +6525,8 @@ async function handlePublish(targetPath = ".", options = {}) {
5746
6525
  visibility,
5747
6526
  prompt: options.prompt,
5748
6527
  changelog: options.changelog,
5749
- aspectRatio: resolvedAspectRatio
6528
+ aspectRatio: resolvedAspectRatio,
6529
+ supportedPlatforms: resolvedPlatforms
5750
6530
  });
5751
6531
  const initialVersion = result.semver || (visibility === "draft" ? "0.1.0" : "1.0.0");
5752
6532
  const initialVisibility = result.visibility || visibility || (token ? "public" : "unlisted_claimable");
@@ -5758,7 +6538,11 @@ async function handlePublish(targetPath = ".", options = {}) {
5758
6538
  title,
5759
6539
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5760
6540
  visibility: initialVisibility,
5761
- aspectRatio: resolvedAspectRatio
6541
+ aspectRatio: resolvedAspectRatio,
6542
+ supportedPlatforms: resolvedPlatforms,
6543
+ platforms: resolvedPlatforms,
6544
+ aiModel: resolvedModel,
6545
+ aiTool
5762
6546
  });
5763
6547
  if (isJson) {
5764
6548
  printJson({
@@ -5774,7 +6558,12 @@ async function handlePublish(targetPath = ".", options = {}) {
5774
6558
  expiresAt: result.expiresAt,
5775
6559
  status: result.status,
5776
6560
  semver: initialVersion,
5777
- visibility: initialVisibility
6561
+ visibility: initialVisibility,
6562
+ aspectRatio: resolvedAspectRatio,
6563
+ supportedPlatforms: resolvedPlatforms,
6564
+ platforms: resolvedPlatforms,
6565
+ aiModel: resolvedModel,
6566
+ aiTool
5778
6567
  });
5779
6568
  } else {
5780
6569
  printPublishSuccess({
@@ -5785,7 +6574,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5785
6574
  claim_token: result.claim_token,
5786
6575
  claimUrl: result.claimUrl,
5787
6576
  aiTool,
5788
- fileHash: bundle.fileHash
6577
+ fileHash: bundle.fileHash,
6578
+ aspectRatio: resolvedAspectRatio,
6579
+ supportedPlatforms: resolvedPlatforms
5789
6580
  });
5790
6581
  console.log(pc3.dim(" \u2139 Project initialized and saved to .replaystage.json"));
5791
6582
  console.log(
@@ -5833,6 +6624,7 @@ async function handleValidate(targetPath = ".", options = {}) {
5833
6624
  console.log(` ${pc4.dim("Format:")} ${result.format || "directory"}`);
5834
6625
  console.log(` ${pc4.dim("Entry Point:")} ${pc4.cyan(result.entryPoint || "index.html")}`);
5835
6626
  console.log(` ${pc4.dim("Aspect Ratio:")} ${result.aspectRatio || "auto"}`);
6627
+ console.log(` ${pc4.dim("Platforms:")} ${result.supportedPlatforms || "both"}`);
5836
6628
  console.log(` ${pc4.dim("File Count:")} ${result.fileCount || 0}`);
5837
6629
  const sizeMb = ((result.totalSizeBytes || 0) / (1024 * 1024)).toFixed(2);
5838
6630
  console.log(` ${pc4.dim("Bundle Size:")} ${sizeMb} MB (limit: 25 MB)`);
@@ -5845,7 +6637,7 @@ async function handleValidate(targetPath = ".", options = {}) {
5845
6637
 
5846
6638
  // src/fingerprint.ts
5847
6639
  import crypto3 from "crypto";
5848
- import fs5 from "fs";
6640
+ import fs6 from "fs";
5849
6641
  async function computeFingerprint(input) {
5850
6642
  if (typeof input === "string") {
5851
6643
  return sha256(input);
@@ -5855,23 +6647,32 @@ async function computeFingerprint(input) {
5855
6647
  return hash.digest("hex").toLowerCase();
5856
6648
  }
5857
6649
  async function computeFileFingerprint(filePath) {
5858
- const content = fs5.readFileSync(filePath);
6650
+ const content = fs6.readFileSync(filePath);
5859
6651
  return computeFingerprint(content);
5860
6652
  }
5861
6653
 
5862
6654
  // src/index.ts
5863
6655
  function createProgram() {
5864
6656
  const program = new Command();
5865
- program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.1.0");
6657
+ program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.3.0");
5866
6658
  program.command("publish [path]").description("Package and deploy a web game to ReplayStage").option("-t, --title <title>", "Game title (2-60 characters)").option("-g, --tagline <tagline>", "Catchy one-line arcade tagline (3-120 characters)").option("-d, --description <desc>", "Gameplay instructions or description").option(
5867
6659
  "--tool <tool>",
5868
6660
  "AI tool used to generate the game (claude, gemini, antigravity, cursor, etc.)"
6661
+ ).option(
6662
+ "-m, --model <model>",
6663
+ "AI model used to synthesize the game (e.g., claude-3-7-sonnet, gpt-4o, gemini-2.5-pro)"
6664
+ ).option(
6665
+ "--cover <path>",
6666
+ "Path to custom cartridge cover image (PNG, JPG, WebP, GIF, max 2MB)"
5869
6667
  ).option(
5870
6668
  "--category <category>",
5871
6669
  "Game category (arcade, action, puzzle, racing, 3d, retro, chill)"
5872
6670
  ).option(
5873
6671
  "--aspect-ratio <ratio>",
5874
6672
  "Display aspect ratio (auto, 16:9, 9:16, 4:3, 3:4, 1:1, or custom W:H)"
6673
+ ).option(
6674
+ "--platforms <platforms>",
6675
+ "Supported gaming platforms (both, desktop, mobile, desktop,mobile, all)"
5875
6676
  ).option("--prompt <prompt>", "Creation prompt used to synthesize the game").option("--draft", "Publish as draft preview (WIP, excluded from leaderboards)").option("--unlisted", "Publish as unlisted private stage (direct link only)").option("--public", "Publish directly to public leaderboard (or promote draft to public)").option("--changelog <message>", "Changelog note describing updates in this version").option("--fresh", "Force fresh upload instead of updating existing stage in .replaystage.json").option("--anonymous", "Publish as anonymous instant preview without credentials").option("--hunter", "Submit as hunter / curator rather than original maker").option("--maker-name <name>", "Original maker name when submitting as hunter").option("--token <token>", "ReplayStage API token").option("--api-url <url>", "API endpoint URL (defaults to https://replaystage.com)").option("--json", "Output machine-readable JSON").action(async (targetPath, options) => {
5876
6677
  await handlePublish(targetPath, options);
5877
6678
  });
@@ -5915,6 +6716,7 @@ if (isDirectCliExecution) {
5915
6716
  void runCli(process.argv);
5916
6717
  }
5917
6718
  export {
6719
+ COVER_PRECEDENCE_FILES,
5918
6720
  checkHtmlDependencies,
5919
6721
  clearConfig,
5920
6722
  clearToken,
@@ -5923,6 +6725,7 @@ export {
5923
6725
  computeSha256,
5924
6726
  createProgram,
5925
6727
  createZipFromFiles,
6728
+ detectSiblingCover,
5926
6729
  extractHtmlMetadata,
5927
6730
  fetchWhoami,
5928
6731
  getConfigDir,
@@ -5945,6 +6748,7 @@ export {
5945
6748
  resolveProjectDirectory,
5946
6749
  resolveToken,
5947
6750
  runCli,
6751
+ writeProjectConfig as saveProjectConfig,
5948
6752
  setToken,
5949
6753
  updateGame,
5950
6754
  updateGameBundle,