@replaystage/cli 0.3.0 → 0.4.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.d.ts +9 -1
- package/dist/index.js +855 -700
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,6 +55,10 @@ async function uploadGameBundle(options) {
|
|
|
55
55
|
formData.append("ai_tool", options.aiTool);
|
|
56
56
|
formData.append("aiTool", options.aiTool);
|
|
57
57
|
}
|
|
58
|
+
if (options.tags !== void 0 && options.tags !== null) {
|
|
59
|
+
const tagsVal = Array.isArray(options.tags) ? JSON.stringify(options.tags) : String(options.tags);
|
|
60
|
+
formData.append("tags", tagsVal);
|
|
61
|
+
}
|
|
58
62
|
if (options.coverBuffer) {
|
|
59
63
|
const uint82 = new Uint8Array(options.coverBuffer);
|
|
60
64
|
const fileName = options.coverFileName || "cover.png";
|
|
@@ -125,6 +129,10 @@ async function updateGameBundle(slug, options) {
|
|
|
125
129
|
formData.append("ai_tool", options.aiTool);
|
|
126
130
|
formData.append("aiTool", options.aiTool);
|
|
127
131
|
}
|
|
132
|
+
if (options.tags !== void 0 && options.tags !== null) {
|
|
133
|
+
const tagsVal = Array.isArray(options.tags) ? JSON.stringify(options.tags) : String(options.tags);
|
|
134
|
+
formData.append("tags", tagsVal);
|
|
135
|
+
}
|
|
128
136
|
if (options.coverBuffer) {
|
|
129
137
|
const uint8 = new Uint8Array(options.coverBuffer);
|
|
130
138
|
const fileName = options.coverFileName || "cover.png";
|
|
@@ -197,555 +205,141 @@ import path2 from "path";
|
|
|
197
205
|
import * as fs from "fs";
|
|
198
206
|
import * as os from "os";
|
|
199
207
|
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
208
|
|
|
289
|
-
// src/
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
console.log(`${pc.yellow(`\u2560${border}\u2563`)}`);
|
|
413
|
-
console.log(
|
|
414
|
-
`${pc.yellow("\u2551")} ${pc.dim("Game:")} ${res.title.padEnd(48)}${pc.yellow("\u2551")}`
|
|
415
|
-
);
|
|
416
|
-
console.log(
|
|
417
|
-
`${pc.yellow("\u2551")} ${pc.dim("Slug:")} ${res.slug.padEnd(48)}${pc.yellow("\u2551")}`
|
|
418
|
-
);
|
|
419
|
-
if (res.aiTool) {
|
|
420
|
-
console.log(
|
|
421
|
-
`${pc.yellow("\u2551")} ${pc.dim("AI Tool:")} ${res.aiTool.padEnd(48)}${pc.yellow("\u2551")}`
|
|
422
|
-
);
|
|
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
|
-
}
|
|
433
|
-
console.log(
|
|
434
|
-
`${pc.yellow("\u2551")} ${pc.dim("Play URL:")} ${pc.cyan(res.url).padEnd(57)}${pc.yellow("\u2551")}`
|
|
435
|
-
);
|
|
436
|
-
if (res.shortUrl) {
|
|
437
|
-
console.log(
|
|
438
|
-
`${pc.yellow("\u2551")} ${pc.dim("Short Link:")} ${pc.magenta(res.shortUrl).padEnd(57)}${pc.yellow("\u2551")}`
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
if (res.claim_token) {
|
|
442
|
-
console.log(`${pc.yellow(`\u255F${border}\u2562`)}`);
|
|
443
|
-
console.log(
|
|
444
|
-
`${pc.yellow("\u2551")} \u{1F511} ${pc.bold(pc.yellow("SAFE HARBOR CLAIM TOKEN"))} (Keep private, 7-day TTL): ${pc.yellow("\u2551")}`
|
|
445
|
-
);
|
|
446
|
-
console.log(`${pc.yellow("\u2551")} ${pc.green(res.claim_token).padEnd(73)}${pc.yellow("\u2551")}`);
|
|
447
|
-
if (res.claimUrl) {
|
|
448
|
-
console.log(
|
|
449
|
-
`${pc.yellow("\u2551")} ${pc.dim("Claim URL:")} ${pc.cyan(res.claimUrl).padEnd(57)}${pc.yellow("\u2551")}`
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
console.log(`${pc.yellow(`\u255A${border}\u255D`)}
|
|
454
|
-
`);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// src/commands/auth.ts
|
|
458
|
-
async function handleLogin(options = {}) {
|
|
459
|
-
const isJson = Boolean(options.json);
|
|
460
|
-
let token = options.token?.trim();
|
|
461
|
-
const apiUrl = resolveApiUrl(options.apiUrl);
|
|
462
|
-
if (!token) {
|
|
463
|
-
if (isJson || !process.stdout.isTTY) {
|
|
464
|
-
if (isJson) {
|
|
465
|
-
printErrorJson("TOKEN_REQUIRED", "Authentication token is required via --token", 1);
|
|
466
|
-
} else {
|
|
467
|
-
console.error(pc2.red("Error: --token is required in non-interactive environment."));
|
|
468
|
-
console.error(`Generate your token at ${apiUrl}/settings#tokens`);
|
|
469
|
-
}
|
|
470
|
-
process.exit(1);
|
|
471
|
-
}
|
|
472
|
-
console.log(pc2.cyan("\n\u{1F579}\uFE0F ReplayStage Authentication"));
|
|
473
|
-
console.log(`To obtain a CLI token, visit: ${pc2.underline(`${apiUrl}/settings#tokens`)}
|
|
474
|
-
`);
|
|
475
|
-
const input = await text({
|
|
476
|
-
message: "Enter your ReplayStage API token:",
|
|
477
|
-
placeholder: "rps_...",
|
|
478
|
-
validate(val) {
|
|
479
|
-
if (!val || val.trim().length === 0) return "Token cannot be empty";
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
if (typeof input !== "string") {
|
|
483
|
-
console.log(pc2.yellow("Login cancelled."));
|
|
484
|
-
process.exit(1);
|
|
485
|
-
}
|
|
486
|
-
token = input.trim();
|
|
487
|
-
}
|
|
488
|
-
try {
|
|
489
|
-
let user = void 0;
|
|
490
|
-
try {
|
|
491
|
-
user = await fetchWhoami(apiUrl, token);
|
|
492
|
-
} catch (err) {
|
|
493
|
-
if (err?.status === 401 || err?.status === 403) {
|
|
494
|
-
throw err;
|
|
495
|
-
}
|
|
496
|
-
user = { id: "user_cli", handle: "cli_user" };
|
|
497
|
-
}
|
|
498
|
-
setToken(token, user, options.apiUrl ? apiUrl : void 0);
|
|
499
|
-
if (isJson) {
|
|
500
|
-
printJson({ success: true, apiUrl, user, token: `${token.slice(0, 8)}...` });
|
|
501
|
-
} else {
|
|
502
|
-
console.log(
|
|
503
|
-
pc2.green(`
|
|
504
|
-
\u2714 Logged in successfully as ${pc2.bold(`@${user?.handle || "user"}`)}!`)
|
|
505
|
-
);
|
|
506
|
-
console.log(` ${pc2.dim("API URL:")} ${apiUrl}
|
|
507
|
-
`);
|
|
508
|
-
}
|
|
509
|
-
} catch (err) {
|
|
510
|
-
if (isJson) {
|
|
511
|
-
printErrorJson("AUTH_FAILED", err.message, 1);
|
|
512
|
-
} else {
|
|
513
|
-
console.error(pc2.red(`
|
|
514
|
-
\u2716 Login failed: ${err.message}
|
|
515
|
-
`));
|
|
516
|
-
}
|
|
517
|
-
process.exit(1);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
async function handleWhoami(options = {}) {
|
|
521
|
-
const isJson = Boolean(options.json);
|
|
522
|
-
const config = readConfig();
|
|
523
|
-
const token = resolveToken();
|
|
524
|
-
const apiUrl = resolveApiUrl(options.apiUrl);
|
|
525
|
-
if (!token) {
|
|
526
|
-
if (isJson) {
|
|
527
|
-
printJson({ authenticated: false, message: "Not logged in (anonymous upload mode)" });
|
|
528
|
-
} else {
|
|
529
|
-
console.log(
|
|
530
|
-
pc2.yellow(
|
|
531
|
-
"\nNot logged in. CLI commands run in anonymous mode with Safe Harbor claim tokens."
|
|
532
|
-
)
|
|
533
|
-
);
|
|
534
|
-
console.log(`Run ${pc2.cyan("replaystage login --token <rps_token>")} to authenticate.
|
|
535
|
-
`);
|
|
536
|
-
}
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
try {
|
|
540
|
-
let user = config.user;
|
|
541
|
-
try {
|
|
542
|
-
user = await fetchWhoami(apiUrl, token);
|
|
543
|
-
if (config.token === token) {
|
|
544
|
-
writeConfig({ ...config, user });
|
|
545
|
-
}
|
|
546
|
-
} catch (err) {
|
|
547
|
-
if (err?.status === 401 || err?.status === 403) {
|
|
548
|
-
throw err;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
if (isJson) {
|
|
552
|
-
printJson({
|
|
553
|
-
authenticated: true,
|
|
554
|
-
apiUrl,
|
|
555
|
-
user: user || null,
|
|
556
|
-
token: `${token.slice(0, 8)}...`
|
|
557
|
-
});
|
|
558
|
-
} else {
|
|
559
|
-
console.log(pc2.green("\n\u2714 Authenticated to ReplayStage"));
|
|
560
|
-
console.log(` ${pc2.dim("API URL:")} ${apiUrl}`);
|
|
561
|
-
if (user?.handle) console.log(` ${pc2.dim("Handle:")} @${user.handle}`);
|
|
562
|
-
if (user?.name) console.log(` ${pc2.dim("Name:")} ${user.name}`);
|
|
563
|
-
if (user?.email) console.log(` ${pc2.dim("Email:")} ${user.email}`);
|
|
564
|
-
console.log(` ${pc2.dim("Token:")} ${token.slice(0, 8)}...${token.slice(-4)}
|
|
565
|
-
`);
|
|
566
|
-
}
|
|
567
|
-
} catch (err) {
|
|
568
|
-
if (isJson) {
|
|
569
|
-
printErrorJson("WHOAMI_FAILED", err.message, 1);
|
|
570
|
-
} else {
|
|
571
|
-
console.error(pc2.red(`
|
|
572
|
-
\u2716 Auth check failed: ${err.message}
|
|
573
|
-
`));
|
|
574
|
-
}
|
|
575
|
-
process.exit(1);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
async function handleLogout(options = {}) {
|
|
579
|
-
const isJson = Boolean(options.json);
|
|
580
|
-
clearConfig();
|
|
581
|
-
if (isJson) {
|
|
582
|
-
printJson({ success: true, message: "Logged out successfully" });
|
|
583
|
-
} else {
|
|
584
|
-
console.log(pc2.green("\n\u2714 Stored credentials cleared successfully.\n"));
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// src/commands/publish.ts
|
|
589
|
-
import fs5 from "fs";
|
|
590
|
-
import path5 from "path";
|
|
591
|
-
|
|
592
|
-
// ../shared/src/constants.ts
|
|
593
|
-
var AI_TOOL_KEYS = [
|
|
594
|
-
"claude-code",
|
|
595
|
-
"antigravity",
|
|
596
|
-
"cursor",
|
|
597
|
-
"codex",
|
|
598
|
-
"claude",
|
|
599
|
-
"gemini",
|
|
600
|
-
"chatgpt",
|
|
601
|
-
"v0",
|
|
602
|
-
"windsurf",
|
|
603
|
-
"lovable",
|
|
604
|
-
"bolt",
|
|
605
|
-
"other"
|
|
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"
|
|
209
|
+
// ../shared/src/constants.ts
|
|
210
|
+
var AI_TOOL_KEYS = [
|
|
211
|
+
"claude-code",
|
|
212
|
+
"antigravity",
|
|
213
|
+
"cursor",
|
|
214
|
+
"codex",
|
|
215
|
+
"windsurf",
|
|
216
|
+
"claude",
|
|
217
|
+
"gemini",
|
|
218
|
+
"v0",
|
|
219
|
+
"lovable",
|
|
220
|
+
"bolt"
|
|
221
|
+
];
|
|
222
|
+
var AI_TOOLS = {
|
|
223
|
+
"claude-code": {
|
|
224
|
+
id: "claude-code",
|
|
225
|
+
name: "Claude Code",
|
|
226
|
+
fullName: "Anthropic Claude Code",
|
|
227
|
+
slug: "claude-code",
|
|
228
|
+
description: "Terminal-based agentic coding and game generation by Anthropic",
|
|
229
|
+
badgeColor: "#D97706",
|
|
230
|
+
badgeBg: "bg-amber-100 text-amber-900 border-amber-300 dark:bg-amber-950/60 dark:text-amber-200 dark:border-amber-700",
|
|
231
|
+
icon: "terminal",
|
|
232
|
+
website: "https://claude.ai/code"
|
|
233
|
+
},
|
|
234
|
+
antigravity: {
|
|
235
|
+
id: "antigravity",
|
|
236
|
+
name: "Antigravity",
|
|
237
|
+
fullName: "Antigravity Agent Platform",
|
|
238
|
+
slug: "antigravity",
|
|
239
|
+
description: "Autonomous multi-agent game productions orchestrated by Antigravity",
|
|
240
|
+
badgeColor: "#7C3AED",
|
|
241
|
+
badgeBg: "bg-purple-100 text-purple-900 border-purple-300 dark:bg-purple-950/60 dark:text-purple-200 dark:border-purple-700",
|
|
242
|
+
icon: "orbit",
|
|
243
|
+
website: "https://github.com/google-gemini/antigravity"
|
|
244
|
+
},
|
|
245
|
+
cursor: {
|
|
246
|
+
id: "cursor",
|
|
247
|
+
name: "Cursor",
|
|
248
|
+
fullName: "Cursor Composer & Agent",
|
|
249
|
+
slug: "cursor",
|
|
250
|
+
description: "Web games generated and iterated through Cursor AI Composer",
|
|
251
|
+
badgeColor: "#0F172A",
|
|
252
|
+
badgeBg: "bg-slate-100 text-slate-900 border-slate-300 dark:bg-slate-900 dark:text-slate-200 dark:border-slate-700",
|
|
253
|
+
icon: "mouse-pointer-click",
|
|
254
|
+
website: "https://cursor.com"
|
|
255
|
+
},
|
|
256
|
+
codex: {
|
|
257
|
+
id: "codex",
|
|
258
|
+
name: "ChatGPT / Codex",
|
|
259
|
+
fullName: "OpenAI ChatGPT & Codex",
|
|
260
|
+
slug: "codex",
|
|
261
|
+
description: "Games synthesized with OpenAI ChatGPT and Codex canvas sessions",
|
|
262
|
+
badgeColor: "#10A37F",
|
|
263
|
+
badgeBg: "bg-emerald-100 text-emerald-900 border-emerald-300 dark:bg-emerald-950/60 dark:text-emerald-200 dark:border-emerald-700",
|
|
264
|
+
icon: "bot",
|
|
265
|
+
website: "https://chatgpt.com"
|
|
266
|
+
},
|
|
267
|
+
windsurf: {
|
|
268
|
+
id: "windsurf",
|
|
269
|
+
name: "Windsurf",
|
|
270
|
+
fullName: "Codeium Windsurf",
|
|
271
|
+
slug: "windsurf",
|
|
272
|
+
description: "Agentic flow and web games developed with Codeium Windsurf",
|
|
273
|
+
badgeColor: "#0284C7",
|
|
274
|
+
badgeBg: "bg-sky-100 text-sky-900 border-sky-300 dark:bg-sky-950/60 dark:text-sky-200 dark:border-sky-700",
|
|
275
|
+
icon: "wind",
|
|
276
|
+
website: "https://codeium.com/windsurf"
|
|
277
|
+
},
|
|
278
|
+
claude: {
|
|
279
|
+
id: "claude",
|
|
280
|
+
name: "Claude",
|
|
281
|
+
fullName: "Anthropic Claude",
|
|
282
|
+
slug: "claude",
|
|
283
|
+
description: "Games designed and crafted with Anthropic Claude",
|
|
284
|
+
badgeColor: "#D97706",
|
|
285
|
+
badgeBg: "bg-amber-100 text-amber-900 border-amber-300 dark:bg-amber-950/60 dark:text-amber-200 dark:border-amber-700",
|
|
286
|
+
icon: "sparkles",
|
|
287
|
+
website: "https://anthropic.com/claude"
|
|
288
|
+
},
|
|
289
|
+
gemini: {
|
|
290
|
+
id: "gemini",
|
|
291
|
+
name: "Gemini",
|
|
292
|
+
fullName: "Google Gemini",
|
|
293
|
+
slug: "gemini",
|
|
294
|
+
description: "Ultra-fast web games generated with Google Gemini models",
|
|
295
|
+
badgeColor: "#2563EB",
|
|
296
|
+
badgeBg: "bg-blue-100 text-blue-900 border-blue-300 dark:bg-blue-950/60 dark:text-blue-200 dark:border-blue-700",
|
|
297
|
+
icon: "atom",
|
|
298
|
+
website: "https://gemini.google.com"
|
|
299
|
+
},
|
|
300
|
+
v0: {
|
|
301
|
+
id: "v0",
|
|
302
|
+
name: "v0",
|
|
303
|
+
fullName: "v0 by Vercel",
|
|
304
|
+
slug: "v0",
|
|
305
|
+
description: "Generative interactive UI and canvas components synthesized by v0",
|
|
306
|
+
badgeColor: "#18181B",
|
|
307
|
+
badgeBg: "bg-zinc-100 text-zinc-900 border-zinc-300 dark:bg-zinc-800 dark:text-zinc-200 dark:border-zinc-700",
|
|
308
|
+
icon: "layers",
|
|
309
|
+
website: "https://v0.dev"
|
|
310
|
+
},
|
|
311
|
+
lovable: {
|
|
312
|
+
id: "lovable",
|
|
313
|
+
name: "Lovable",
|
|
314
|
+
fullName: "Lovable AI",
|
|
315
|
+
slug: "lovable",
|
|
316
|
+
description: "Full-stack web applications and games engineered with Lovable",
|
|
317
|
+
badgeColor: "#EC4899",
|
|
318
|
+
badgeBg: "bg-pink-100 text-pink-900 border-pink-300 dark:bg-pink-950/60 dark:text-pink-200 dark:border-pink-700",
|
|
319
|
+
icon: "heart",
|
|
320
|
+
website: "https://lovable.dev"
|
|
321
|
+
},
|
|
322
|
+
bolt: {
|
|
323
|
+
id: "bolt",
|
|
324
|
+
name: "Bolt",
|
|
325
|
+
fullName: "Bolt.new by StackBlitz",
|
|
326
|
+
slug: "bolt",
|
|
327
|
+
description: "In-browser full-stack sandbox games generated with Bolt.new",
|
|
328
|
+
badgeColor: "#EAB308",
|
|
329
|
+
badgeBg: "bg-yellow-100 text-yellow-900 border-yellow-300 dark:bg-yellow-950/60 dark:text-yellow-200 dark:border-yellow-700",
|
|
330
|
+
icon: "zap",
|
|
331
|
+
website: "https://bolt.new"
|
|
739
332
|
}
|
|
740
333
|
};
|
|
741
334
|
var GAME_CATEGORY_KEYS = [
|
|
742
335
|
"arcade",
|
|
743
336
|
"action",
|
|
744
337
|
"puzzle",
|
|
338
|
+
"strategy",
|
|
339
|
+
"simulation",
|
|
745
340
|
"racing",
|
|
746
|
-
"
|
|
747
|
-
"
|
|
748
|
-
"chill"
|
|
341
|
+
"rpg",
|
|
342
|
+
"casual"
|
|
749
343
|
];
|
|
750
344
|
var MAX_BUNDLE_SIZE_BYTES = 25 * 1024 * 1024;
|
|
751
345
|
var MAX_HTML_SIZE_BYTES = 5 * 1024 * 1024;
|
|
@@ -5159,17 +4753,36 @@ var supportedPlatformsSchema = external_exports.preprocess((val) => {
|
|
|
5159
4753
|
});
|
|
5160
4754
|
}
|
|
5161
4755
|
}).transform((val) => normalizeSupportedPlatforms(val).normalized);
|
|
4756
|
+
function normalizeToolSlug(input) {
|
|
4757
|
+
if (!input || typeof input !== "string") return "";
|
|
4758
|
+
let decoded = input;
|
|
4759
|
+
try {
|
|
4760
|
+
decoded = decodeURIComponent(input);
|
|
4761
|
+
} catch {
|
|
4762
|
+
decoded = input;
|
|
4763
|
+
}
|
|
4764
|
+
const slug = decoded.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4765
|
+
if (slug === "chatgpt" || slug === "chatgpt-codex" || slug === "chatgptcodex" || slug === "openai-codex" || slug === "openai-chatgpt") {
|
|
4766
|
+
return "codex";
|
|
4767
|
+
}
|
|
4768
|
+
return slug;
|
|
4769
|
+
}
|
|
5162
4770
|
var aiToolSchema = external_exports.preprocess(
|
|
5163
4771
|
(val) => {
|
|
5164
4772
|
if (val === null || val === void 0 || val === false || typeof val === "string" && val.trim() === "") {
|
|
5165
|
-
return
|
|
4773
|
+
return null;
|
|
5166
4774
|
}
|
|
5167
4775
|
if (typeof val === "string") {
|
|
5168
|
-
|
|
4776
|
+
const trimmed = val.trim();
|
|
4777
|
+
const lower = trimmed.toLowerCase();
|
|
4778
|
+
if (lower === "codex" || lower === "chatgpt" || lower === "chatgpt-codex" || lower === "chatgptcodex" || lower === "openai-codex" || lower === "openai-chatgpt" || lower === "chatgpt / codex" || lower === "chatgpt/codex" || normalizeToolSlug(trimmed) === "codex") {
|
|
4779
|
+
return "codex";
|
|
4780
|
+
}
|
|
4781
|
+
return trimmed;
|
|
5169
4782
|
}
|
|
5170
4783
|
return val;
|
|
5171
4784
|
},
|
|
5172
|
-
external_exports.string({ errorMap: () => ({ message: "Invalid AI tool selection" }) }).
|
|
4785
|
+
external_exports.string({ errorMap: () => ({ message: "Invalid AI tool selection" }) }).max(MAX_AI_TOOL_LENGTH, `AI tool must be ${MAX_AI_TOOL_LENGTH} characters or less`).nullable().optional()
|
|
5173
4786
|
);
|
|
5174
4787
|
var aiModelSchema = external_exports.preprocess((val) => {
|
|
5175
4788
|
if (val === null || typeof val === "string" && val.trim() === "") {
|
|
@@ -5190,7 +4803,7 @@ var baseGameUploadObject = external_exports.object({
|
|
|
5190
4803
|
MAX_GAME_DESCRIPTION_LENGTH,
|
|
5191
4804
|
`Description must be ${MAX_GAME_DESCRIPTION_LENGTH} characters or less`
|
|
5192
4805
|
).default(""),
|
|
5193
|
-
aiTool: aiToolSchema.default(
|
|
4806
|
+
aiTool: aiToolSchema.default(null),
|
|
5194
4807
|
aiModel: aiModelSchema.optional().nullable(),
|
|
5195
4808
|
primaryCategory: external_exports.enum(GAME_CATEGORY_KEYS, {
|
|
5196
4809
|
errorMap: () => ({ message: "Invalid game category selection" })
|
|
@@ -5387,177 +5000,651 @@ function extractRawAiModelFromHtml(html) {
|
|
|
5387
5000
|
return trimmed.length > 0 ? trimmed : null;
|
|
5388
5001
|
}
|
|
5389
5002
|
}
|
|
5390
|
-
return null;
|
|
5003
|
+
return null;
|
|
5004
|
+
}
|
|
5005
|
+
function extractAiModelFromHtml(html) {
|
|
5006
|
+
const raw = extractRawAiModelFromHtml(html);
|
|
5007
|
+
if (!raw) return null;
|
|
5008
|
+
const truncated = raw.slice(0, MAX_AI_MODEL_LENGTH);
|
|
5009
|
+
const parsed = aiModelSchema.safeParse(truncated);
|
|
5010
|
+
if (!parsed.success || !parsed.data) return null;
|
|
5011
|
+
return parsed.data;
|
|
5012
|
+
}
|
|
5013
|
+
|
|
5014
|
+
// ../shared/src/sanitizer.ts
|
|
5015
|
+
var FORBIDDEN_SEGMENT_EXACT = /* @__PURE__ */ new Set([
|
|
5016
|
+
".replaystage.json",
|
|
5017
|
+
".git",
|
|
5018
|
+
".github",
|
|
5019
|
+
"node_modules",
|
|
5020
|
+
".aws",
|
|
5021
|
+
".ssh",
|
|
5022
|
+
".bashrc",
|
|
5023
|
+
".bash_profile",
|
|
5024
|
+
".bash_history",
|
|
5025
|
+
".bash_logout",
|
|
5026
|
+
".zshrc",
|
|
5027
|
+
".zprofile",
|
|
5028
|
+
".zsh_history",
|
|
5029
|
+
".profile",
|
|
5030
|
+
".npmrc",
|
|
5031
|
+
".netrc"
|
|
5032
|
+
]);
|
|
5033
|
+
function validateZipEntryPath(rawPath) {
|
|
5034
|
+
if (typeof rawPath !== "string") {
|
|
5035
|
+
return { valid: false, error: "Zip entry path must be a string" };
|
|
5036
|
+
}
|
|
5037
|
+
const trimmed = rawPath.trim();
|
|
5038
|
+
if (trimmed === "") {
|
|
5039
|
+
return { valid: false, error: "Zip entry path cannot be empty" };
|
|
5040
|
+
}
|
|
5041
|
+
let normalized = trimmed.replace(/\\/g, "/");
|
|
5042
|
+
if (normalized.includes("\0")) {
|
|
5043
|
+
return { valid: false, error: "Null byte detected in zip entry path" };
|
|
5044
|
+
}
|
|
5045
|
+
if (normalized.startsWith("/") || /^[a-zA-Z]:/.test(normalized)) {
|
|
5046
|
+
return { valid: false, error: "Absolute paths are prohibited in zip archive entries" };
|
|
5047
|
+
}
|
|
5048
|
+
normalized = normalized.replace(/^\.?\//, "");
|
|
5049
|
+
const parts = normalized.split("/");
|
|
5050
|
+
const resolvedParts = [];
|
|
5051
|
+
for (const part of parts) {
|
|
5052
|
+
const trimmedPart = part.trim();
|
|
5053
|
+
if (trimmedPart === "" || trimmedPart === ".") {
|
|
5054
|
+
continue;
|
|
5055
|
+
}
|
|
5056
|
+
if (trimmedPart === ".." || /^\.{2,}$/.test(trimmedPart)) {
|
|
5057
|
+
return { valid: false, error: "Directory traversal ('..') is prohibited in zip entry path" };
|
|
5058
|
+
}
|
|
5059
|
+
const cleanSegment = trimmedPart.replace(/[\s.]+$/, "");
|
|
5060
|
+
if (cleanSegment === "") {
|
|
5061
|
+
continue;
|
|
5062
|
+
}
|
|
5063
|
+
resolvedParts.push(cleanSegment);
|
|
5064
|
+
}
|
|
5065
|
+
const cleanPath = resolvedParts.join("/");
|
|
5066
|
+
if (cleanPath === "") {
|
|
5067
|
+
return { valid: false, error: "Invalid zip entry path: resolves to empty path" };
|
|
5068
|
+
}
|
|
5069
|
+
if (isProhibitedExtension(cleanPath)) {
|
|
5070
|
+
return { valid: false, error: `Prohibited file extension detected: ${cleanPath}` };
|
|
5071
|
+
}
|
|
5072
|
+
for (const seg of resolvedParts) {
|
|
5073
|
+
const lower = seg.toLowerCase();
|
|
5074
|
+
if (lower === ".replaystage.json" || lower.startsWith(".replaystage")) {
|
|
5075
|
+
return {
|
|
5076
|
+
valid: false,
|
|
5077
|
+
error: `Prohibited ReplayStage state file in archive: ${cleanPath}`
|
|
5078
|
+
};
|
|
5079
|
+
}
|
|
5080
|
+
if (lower === ".env" || lower.startsWith(".env.") || lower.startsWith(".env-") || lower.startsWith(".env_") || FORBIDDEN_SEGMENT_EXACT.has(lower)) {
|
|
5081
|
+
return { valid: false, error: `Prohibited system or environment file: ${cleanPath}` };
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
return {
|
|
5085
|
+
valid: true,
|
|
5086
|
+
normalizedPath: cleanPath
|
|
5087
|
+
};
|
|
5088
|
+
}
|
|
5089
|
+
function isIgnoredZipEntry(entryPath) {
|
|
5090
|
+
const normalized = entryPath.replace(/\\/g, "/");
|
|
5091
|
+
return normalized.startsWith("__MACOSX/") || normalized.includes("/__MACOSX/") || normalized.endsWith(".DS_Store") || normalized.endsWith("Thumbs.db") || normalized.startsWith("._") || normalized.includes("/._");
|
|
5092
|
+
}
|
|
5093
|
+
var MAX_COVER_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
5094
|
+
function validateCoverImageBytes(bytes) {
|
|
5095
|
+
if (!bytes || bytes.byteLength < 12) {
|
|
5096
|
+
return { valid: false, error: "Cover image is empty or truncated" };
|
|
5097
|
+
}
|
|
5098
|
+
if (bytes.byteLength > MAX_COVER_IMAGE_BYTES) {
|
|
5099
|
+
return { valid: false, error: "Cover image exceeds the 2 MB maximum limit" };
|
|
5100
|
+
}
|
|
5101
|
+
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) {
|
|
5102
|
+
return { valid: true, mimeType: "image/png", ext: "png" };
|
|
5103
|
+
}
|
|
5104
|
+
if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) {
|
|
5105
|
+
return { valid: true, mimeType: "image/jpeg", ext: "jpg" };
|
|
5106
|
+
}
|
|
5107
|
+
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) {
|
|
5108
|
+
return { valid: true, mimeType: "image/webp", ext: "webp" };
|
|
5109
|
+
}
|
|
5110
|
+
if (bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 56 && (bytes[4] === 55 || bytes[4] === 57) && bytes[5] === 97) {
|
|
5111
|
+
return { valid: true, mimeType: "image/gif", ext: "gif" };
|
|
5112
|
+
}
|
|
5113
|
+
return {
|
|
5114
|
+
valid: false,
|
|
5115
|
+
error: "Unsupported cover image format (must be PNG, JPEG, WebP, or GIF)"
|
|
5116
|
+
};
|
|
5117
|
+
}
|
|
5118
|
+
function findEntryHtmlFile(paths) {
|
|
5119
|
+
const cleanPaths = paths.filter((p) => !isIgnoredZipEntry(p)).map((p) => p.replace(/\\/g, "/").replace(/^\.?\//, ""));
|
|
5120
|
+
if (cleanPaths.includes("index.html")) {
|
|
5121
|
+
return { entryPath: "index.html", prefix: "" };
|
|
5122
|
+
}
|
|
5123
|
+
if (cleanPaths.includes("index.htm")) {
|
|
5124
|
+
return { entryPath: "index.htm", prefix: "" };
|
|
5125
|
+
}
|
|
5126
|
+
const nestedIndices = cleanPaths.filter((p) => {
|
|
5127
|
+
const parts = p.split("/");
|
|
5128
|
+
return parts.length === 2 && (parts[1] === "index.html" || parts[1] === "index.htm");
|
|
5129
|
+
});
|
|
5130
|
+
if (nestedIndices.length === 1) {
|
|
5131
|
+
const entryPath = nestedIndices[0];
|
|
5132
|
+
const prefix = `${entryPath.split("/")[0]}/`;
|
|
5133
|
+
return { entryPath, prefix };
|
|
5134
|
+
}
|
|
5135
|
+
if (nestedIndices.length > 1) {
|
|
5136
|
+
const folders = new Set(nestedIndices.map((p) => p.split("/")[0]));
|
|
5137
|
+
if (folders.size === 1) {
|
|
5138
|
+
const htmlEntry = nestedIndices.find((p) => p.endsWith("/index.html"));
|
|
5139
|
+
if (htmlEntry) {
|
|
5140
|
+
return { entryPath: htmlEntry, prefix: `${htmlEntry.split("/")[0]}/` };
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
return { entryPath: null, prefix: "" };
|
|
5144
|
+
}
|
|
5145
|
+
const allIndices = cleanPaths.filter(
|
|
5146
|
+
(p) => p.endsWith("/index.html") || p === "index.html" || p.endsWith("/index.htm") || p === "index.htm"
|
|
5147
|
+
);
|
|
5148
|
+
if (allIndices.length === 1) {
|
|
5149
|
+
const entryPath = allIndices[0];
|
|
5150
|
+
const lastSlash = entryPath.lastIndexOf("/");
|
|
5151
|
+
const prefix = lastSlash >= 0 ? entryPath.slice(0, lastSlash + 1) : "";
|
|
5152
|
+
return { entryPath, prefix };
|
|
5153
|
+
}
|
|
5154
|
+
if (allIndices.length > 1) {
|
|
5155
|
+
const dirs = new Set(
|
|
5156
|
+
allIndices.map((p) => {
|
|
5157
|
+
const lastSlash = p.lastIndexOf("/");
|
|
5158
|
+
return lastSlash >= 0 ? p.slice(0, lastSlash + 1) : "";
|
|
5159
|
+
})
|
|
5160
|
+
);
|
|
5161
|
+
if (dirs.size === 1) {
|
|
5162
|
+
const htmlEntry = allIndices.find((p) => p.endsWith("/index.html") || p === "index.html");
|
|
5163
|
+
if (htmlEntry) {
|
|
5164
|
+
const lastSlash = htmlEntry.lastIndexOf("/");
|
|
5165
|
+
const prefix = lastSlash >= 0 ? htmlEntry.slice(0, lastSlash + 1) : "";
|
|
5166
|
+
return { entryPath: htmlEntry, prefix };
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
return { entryPath: null, prefix: "" };
|
|
5171
|
+
}
|
|
5172
|
+
|
|
5173
|
+
// ../shared/src/tags.ts
|
|
5174
|
+
function normalizeTags(input) {
|
|
5175
|
+
if (input === null || input === void 0) return [];
|
|
5176
|
+
let rawList = [];
|
|
5177
|
+
if (Array.isArray(input)) {
|
|
5178
|
+
rawList = input;
|
|
5179
|
+
} else if (typeof input === "string") {
|
|
5180
|
+
const trimmed = input.trim();
|
|
5181
|
+
if (trimmed === "" || trimmed === "null" || trimmed === "undefined") {
|
|
5182
|
+
return [];
|
|
5183
|
+
}
|
|
5184
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
5185
|
+
try {
|
|
5186
|
+
const parsed = JSON.parse(trimmed);
|
|
5187
|
+
if (Array.isArray(parsed)) {
|
|
5188
|
+
rawList = parsed;
|
|
5189
|
+
} else {
|
|
5190
|
+
rawList = trimmed.slice(1, -1).split(",");
|
|
5191
|
+
}
|
|
5192
|
+
} catch {
|
|
5193
|
+
rawList = trimmed.slice(1, -1).split(",");
|
|
5194
|
+
}
|
|
5195
|
+
} else {
|
|
5196
|
+
rawList = trimmed.split(",");
|
|
5197
|
+
}
|
|
5198
|
+
} else {
|
|
5199
|
+
return [];
|
|
5200
|
+
}
|
|
5201
|
+
const result = [];
|
|
5202
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5203
|
+
for (const item of rawList) {
|
|
5204
|
+
if (typeof item !== "string") continue;
|
|
5205
|
+
const formatted = item.trim().toLowerCase().replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
5206
|
+
if (!formatted) continue;
|
|
5207
|
+
const parseResult = tagSchema.safeParse(formatted);
|
|
5208
|
+
if (!parseResult.success) continue;
|
|
5209
|
+
const validTag = parseResult.data;
|
|
5210
|
+
if (!seen.has(validTag)) {
|
|
5211
|
+
seen.add(validTag);
|
|
5212
|
+
result.push(validTag);
|
|
5213
|
+
if (result.length >= MAX_TAGS_COUNT) {
|
|
5214
|
+
break;
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
}
|
|
5218
|
+
return result;
|
|
5219
|
+
}
|
|
5220
|
+
function extractRawTagsFromHtml(html) {
|
|
5221
|
+
if (!html || typeof html !== "string") return null;
|
|
5222
|
+
const cleanHtml = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
5223
|
+
const metaTagRegex = /<meta\b([^>]*)>/gi;
|
|
5224
|
+
for (const match of cleanHtml.matchAll(metaTagRegex)) {
|
|
5225
|
+
const attrs = match[1];
|
|
5226
|
+
const isTagsMeta = /(?:^|\s)name\s*=\s*(["']?)replaystage:tags?\1(?:\s|$|\/)/i.test(attrs);
|
|
5227
|
+
if (!isTagsMeta) continue;
|
|
5228
|
+
const contentMatch = /(?:^|\s)content\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(attrs);
|
|
5229
|
+
if (contentMatch) {
|
|
5230
|
+
const content = contentMatch[1] ?? contentMatch[2] ?? contentMatch[3] ?? "";
|
|
5231
|
+
const trimmed = content.trim();
|
|
5232
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
5233
|
+
}
|
|
5234
|
+
}
|
|
5235
|
+
return null;
|
|
5236
|
+
}
|
|
5237
|
+
function extractTagsFromHtml(html) {
|
|
5238
|
+
const raw = extractRawTagsFromHtml(html);
|
|
5239
|
+
if (!raw) return [];
|
|
5240
|
+
return normalizeTags(raw);
|
|
5241
|
+
}
|
|
5242
|
+
|
|
5243
|
+
// src/project.ts
|
|
5244
|
+
function resolveProjectDirectory(targetPath) {
|
|
5245
|
+
try {
|
|
5246
|
+
const resolved = path.resolve(targetPath);
|
|
5247
|
+
if (resolved.toLowerCase().endsWith(".zip")) {
|
|
5248
|
+
return null;
|
|
5249
|
+
}
|
|
5250
|
+
if (resolved.includes("seed-games")) {
|
|
5251
|
+
return null;
|
|
5252
|
+
}
|
|
5253
|
+
if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {
|
|
5254
|
+
if (resolved === path.resolve(os.tmpdir())) {
|
|
5255
|
+
return null;
|
|
5256
|
+
}
|
|
5257
|
+
return resolved;
|
|
5258
|
+
}
|
|
5259
|
+
if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
|
|
5260
|
+
const parentDir = path.dirname(resolved);
|
|
5261
|
+
if (parentDir === path.resolve(os.tmpdir())) {
|
|
5262
|
+
return null;
|
|
5263
|
+
}
|
|
5264
|
+
return parentDir;
|
|
5265
|
+
}
|
|
5266
|
+
return resolved;
|
|
5267
|
+
} catch {
|
|
5268
|
+
return path.resolve(targetPath);
|
|
5269
|
+
}
|
|
5391
5270
|
}
|
|
5392
|
-
function
|
|
5393
|
-
const
|
|
5394
|
-
|
|
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;
|
|
5271
|
+
function getProjectConfigPath(targetDir) {
|
|
5272
|
+
const dir = resolveProjectDirectory(targetDir);
|
|
5273
|
+
return dir ? path.join(dir, ".replaystage.json") : null;
|
|
5399
5274
|
}
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
".git",
|
|
5405
|
-
".github",
|
|
5406
|
-
"node_modules",
|
|
5407
|
-
".aws",
|
|
5408
|
-
".ssh",
|
|
5409
|
-
".bashrc",
|
|
5410
|
-
".bash_profile",
|
|
5411
|
-
".bash_history",
|
|
5412
|
-
".bash_logout",
|
|
5413
|
-
".zshrc",
|
|
5414
|
-
".zprofile",
|
|
5415
|
-
".zsh_history",
|
|
5416
|
-
".profile",
|
|
5417
|
-
".npmrc",
|
|
5418
|
-
".netrc"
|
|
5419
|
-
]);
|
|
5420
|
-
function validateZipEntryPath(rawPath) {
|
|
5421
|
-
if (typeof rawPath !== "string") {
|
|
5422
|
-
return { valid: false, error: "Zip entry path must be a string" };
|
|
5423
|
-
}
|
|
5424
|
-
const trimmed = rawPath.trim();
|
|
5425
|
-
if (trimmed === "") {
|
|
5426
|
-
return { valid: false, error: "Zip entry path cannot be empty" };
|
|
5427
|
-
}
|
|
5428
|
-
let normalized = trimmed.replace(/\\/g, "/");
|
|
5429
|
-
if (normalized.includes("\0")) {
|
|
5430
|
-
return { valid: false, error: "Null byte detected in zip entry path" };
|
|
5431
|
-
}
|
|
5432
|
-
if (normalized.startsWith("/") || /^[a-zA-Z]:/.test(normalized)) {
|
|
5433
|
-
return { valid: false, error: "Absolute paths are prohibited in zip archive entries" };
|
|
5275
|
+
function readProjectConfig(targetDir) {
|
|
5276
|
+
const configPath = getProjectConfigPath(targetDir);
|
|
5277
|
+
if (!configPath || !fs.existsSync(configPath)) {
|
|
5278
|
+
return null;
|
|
5434
5279
|
}
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
if (trimmedPart === "" || trimmedPart === ".") {
|
|
5441
|
-
continue;
|
|
5280
|
+
try {
|
|
5281
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
5282
|
+
const parsed = JSON.parse(raw);
|
|
5283
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5284
|
+
return null;
|
|
5442
5285
|
}
|
|
5443
|
-
if (
|
|
5444
|
-
|
|
5286
|
+
if ("slug" in parsed) {
|
|
5287
|
+
if (typeof parsed.slug !== "string" || !parsed.slug.trim()) {
|
|
5288
|
+
return null;
|
|
5289
|
+
}
|
|
5445
5290
|
}
|
|
5446
|
-
const
|
|
5447
|
-
if (
|
|
5448
|
-
|
|
5291
|
+
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" || Array.isArray(parsed.tags) || typeof parsed.tags === "string";
|
|
5292
|
+
if (!hasValidKey) {
|
|
5293
|
+
return null;
|
|
5449
5294
|
}
|
|
5450
|
-
|
|
5295
|
+
if (parsed.tags !== void 0) {
|
|
5296
|
+
parsed.tags = normalizeTags(parsed.tags);
|
|
5297
|
+
}
|
|
5298
|
+
return parsed;
|
|
5299
|
+
} catch {
|
|
5300
|
+
return null;
|
|
5451
5301
|
}
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5302
|
+
}
|
|
5303
|
+
function writeProjectConfig(targetDir, config) {
|
|
5304
|
+
const configPath = getProjectConfigPath(targetDir);
|
|
5305
|
+
if (!configPath) {
|
|
5306
|
+
return;
|
|
5455
5307
|
}
|
|
5456
|
-
|
|
5457
|
-
|
|
5308
|
+
const dir = path.dirname(configPath);
|
|
5309
|
+
if (!fs.existsSync(dir)) {
|
|
5310
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
5458
5311
|
}
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5312
|
+
const toWrite = { ...config };
|
|
5313
|
+
if (toWrite.tags !== void 0) {
|
|
5314
|
+
toWrite.tags = normalizeTags(toWrite.tags);
|
|
5315
|
+
}
|
|
5316
|
+
fs.writeFileSync(configPath, `${JSON.stringify(toWrite, null, 2)}
|
|
5317
|
+
`, "utf-8");
|
|
5318
|
+
}
|
|
5319
|
+
function incrementVersion(currentVersion) {
|
|
5320
|
+
if (!currentVersion || typeof currentVersion !== "string") return "0.2.0";
|
|
5321
|
+
const sanitized = currentVersion.trim().replace(/^v/i, "");
|
|
5322
|
+
const parts = sanitized.split(".").map((n) => Number.parseInt(n, 10));
|
|
5323
|
+
if (parts.length === 3 && !parts.some(Number.isNaN)) {
|
|
5324
|
+
return `${parts[0]}.${parts[1] + 1}.0`;
|
|
5325
|
+
}
|
|
5326
|
+
if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
|
|
5327
|
+
return `${parts[0]}.${parts[1] + 1}.0`;
|
|
5328
|
+
}
|
|
5329
|
+
return "0.2.0";
|
|
5330
|
+
}
|
|
5331
|
+
function promoteDraftVersion(currentVersion) {
|
|
5332
|
+
if (!currentVersion || typeof currentVersion !== "string") return "1.0.0";
|
|
5333
|
+
const sanitized = currentVersion.trim().replace(/^v/i, "");
|
|
5334
|
+
if (sanitized.startsWith("0.")) {
|
|
5335
|
+
return "1.0.0";
|
|
5336
|
+
}
|
|
5337
|
+
return incrementVersion(currentVersion);
|
|
5338
|
+
}
|
|
5339
|
+
|
|
5340
|
+
// src/config.ts
|
|
5341
|
+
function getConfigDir() {
|
|
5342
|
+
return process.env.REPLAYSTAGE_CONFIG_DIR || path2.join(os2.homedir(), ".replaystage");
|
|
5343
|
+
}
|
|
5344
|
+
function getConfigPath() {
|
|
5345
|
+
return path2.join(getConfigDir(), "config.json");
|
|
5346
|
+
}
|
|
5347
|
+
function readConfig() {
|
|
5348
|
+
const dir = getConfigDir();
|
|
5349
|
+
for (const filename of ["config.json", "credentials.json"]) {
|
|
5350
|
+
const file = path2.join(dir, filename);
|
|
5351
|
+
if (fs2.existsSync(file)) {
|
|
5352
|
+
try {
|
|
5353
|
+
const raw = fs2.readFileSync(file, "utf-8");
|
|
5354
|
+
return JSON.parse(raw);
|
|
5355
|
+
} catch {
|
|
5356
|
+
}
|
|
5466
5357
|
}
|
|
5467
|
-
|
|
5468
|
-
|
|
5358
|
+
}
|
|
5359
|
+
return {};
|
|
5360
|
+
}
|
|
5361
|
+
function writeConfig(config) {
|
|
5362
|
+
const dir = getConfigDir();
|
|
5363
|
+
fs2.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
5364
|
+
const target = getConfigPath();
|
|
5365
|
+
fs2.writeFileSync(target, JSON.stringify(config, null, 2), {
|
|
5366
|
+
encoding: "utf-8",
|
|
5367
|
+
mode: 384
|
|
5368
|
+
});
|
|
5369
|
+
try {
|
|
5370
|
+
fs2.chmodSync(target, 384);
|
|
5371
|
+
} catch {
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
function clearConfig() {
|
|
5375
|
+
const dir = getConfigDir();
|
|
5376
|
+
for (const filename of ["config.json", "credentials.json"]) {
|
|
5377
|
+
const file = path2.join(dir, filename);
|
|
5378
|
+
if (fs2.existsSync(file)) {
|
|
5379
|
+
try {
|
|
5380
|
+
fs2.unlinkSync(file);
|
|
5381
|
+
} catch {
|
|
5382
|
+
}
|
|
5469
5383
|
}
|
|
5470
5384
|
}
|
|
5471
|
-
return {
|
|
5472
|
-
valid: true,
|
|
5473
|
-
normalizedPath: cleanPath
|
|
5474
|
-
};
|
|
5475
5385
|
}
|
|
5476
|
-
function
|
|
5477
|
-
|
|
5478
|
-
|
|
5386
|
+
function getToken() {
|
|
5387
|
+
return resolveToken();
|
|
5388
|
+
}
|
|
5389
|
+
function setToken(token, user, apiUrl) {
|
|
5390
|
+
const current = readConfig();
|
|
5391
|
+
writeConfig({
|
|
5392
|
+
...current,
|
|
5393
|
+
...apiUrl ? { apiUrl: apiUrl.replace(/\/+$/, "") } : {},
|
|
5394
|
+
token,
|
|
5395
|
+
user: user || current.user
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
function clearToken() {
|
|
5399
|
+
const current = readConfig();
|
|
5400
|
+
current.token = void 0;
|
|
5401
|
+
current.user = void 0;
|
|
5402
|
+
writeConfig(current);
|
|
5403
|
+
}
|
|
5404
|
+
function resolveToken(cliToken) {
|
|
5405
|
+
if (cliToken?.trim()) return cliToken.trim();
|
|
5406
|
+
if (process.env.REPLAYSTAGE_TOKEN?.trim()) {
|
|
5407
|
+
return process.env.REPLAYSTAGE_TOKEN.trim();
|
|
5408
|
+
}
|
|
5409
|
+
if (process.env.REPLAYSTAGE_API_TOKEN?.trim()) {
|
|
5410
|
+
return process.env.REPLAYSTAGE_API_TOKEN.trim();
|
|
5411
|
+
}
|
|
5412
|
+
const config = readConfig();
|
|
5413
|
+
return config.token || null;
|
|
5414
|
+
}
|
|
5415
|
+
function resolveApiUrl(cliApiUrl) {
|
|
5416
|
+
if (cliApiUrl?.trim()) return cliApiUrl.trim().replace(/\/+$/, "");
|
|
5417
|
+
if (process.env.REPLAYSTAGE_API_URL?.trim()) {
|
|
5418
|
+
return process.env.REPLAYSTAGE_API_URL.trim().replace(/\/+$/, "");
|
|
5419
|
+
}
|
|
5420
|
+
const config = readConfig();
|
|
5421
|
+
return (config.apiUrl || "https://replaystage.com").replace(/\/+$/, "");
|
|
5422
|
+
}
|
|
5423
|
+
|
|
5424
|
+
// src/ui.ts
|
|
5425
|
+
import pc from "picocolors";
|
|
5426
|
+
function printJson(data) {
|
|
5427
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
5428
|
+
`);
|
|
5429
|
+
}
|
|
5430
|
+
function printErrorJson(error, message, code = 1, extra) {
|
|
5431
|
+
process.stdout.write(
|
|
5432
|
+
`${JSON.stringify({ success: false, code, error, message, ...extra }, null, 2)}
|
|
5433
|
+
`
|
|
5434
|
+
);
|
|
5435
|
+
}
|
|
5436
|
+
function logInfo(message, isJsonMode = false) {
|
|
5437
|
+
if (isJsonMode) return;
|
|
5438
|
+
process.stderr.write(`${pc.cyan("\u2139 ") + message}
|
|
5439
|
+
`);
|
|
5440
|
+
}
|
|
5441
|
+
function logSuccess(message, isJsonMode = false) {
|
|
5442
|
+
if (isJsonMode) return;
|
|
5443
|
+
process.stderr.write(`${pc.green("\u2714 ") + message}
|
|
5444
|
+
`);
|
|
5445
|
+
}
|
|
5446
|
+
function logWarn(message, isJsonMode = false) {
|
|
5447
|
+
if (isJsonMode) return;
|
|
5448
|
+
process.stderr.write(`${pc.yellow("\u26A0 ") + message}
|
|
5449
|
+
`);
|
|
5450
|
+
}
|
|
5451
|
+
function logError(message, isJsonMode = false) {
|
|
5452
|
+
if (isJsonMode) return;
|
|
5453
|
+
process.stderr.write(`${pc.red("\u2716 ") + message}
|
|
5454
|
+
`);
|
|
5479
5455
|
}
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5456
|
+
function printPublishSuccess(res) {
|
|
5457
|
+
const border = "\u2550".repeat(64);
|
|
5458
|
+
console.log(`
|
|
5459
|
+
${pc.yellow(`\u2554${border}\u2557`)}`);
|
|
5460
|
+
console.log(
|
|
5461
|
+
`${pc.yellow("\u2551")} \u{1F579}\uFE0F ${pc.bold(pc.white("REPLAYSTAGE PUBLISH SUCCESSFUL"))}${" ".repeat(30)}${pc.yellow("\u2551")}`
|
|
5462
|
+
);
|
|
5463
|
+
console.log(`${pc.yellow(`\u2560${border}\u2563`)}`);
|
|
5464
|
+
console.log(
|
|
5465
|
+
`${pc.yellow("\u2551")} ${pc.dim("Game:")} ${res.title.padEnd(48)}${pc.yellow("\u2551")}`
|
|
5466
|
+
);
|
|
5467
|
+
console.log(
|
|
5468
|
+
`${pc.yellow("\u2551")} ${pc.dim("Slug:")} ${res.slug.padEnd(48)}${pc.yellow("\u2551")}`
|
|
5469
|
+
);
|
|
5470
|
+
if (res.aiTool) {
|
|
5471
|
+
console.log(
|
|
5472
|
+
`${pc.yellow("\u2551")} ${pc.dim("AI Tool:")} ${res.aiTool.padEnd(48)}${pc.yellow("\u2551")}`
|
|
5473
|
+
);
|
|
5484
5474
|
}
|
|
5485
|
-
if (
|
|
5486
|
-
|
|
5475
|
+
if (res.tags && res.tags.length > 0) {
|
|
5476
|
+
const formattedTags = res.tags.map((t) => `#${t}`).join(" ");
|
|
5477
|
+
console.log(
|
|
5478
|
+
`${pc.yellow("\u2551")} ${pc.dim("Tags:")} ${formattedTags.padEnd(48)}${pc.yellow("\u2551")}`
|
|
5479
|
+
);
|
|
5487
5480
|
}
|
|
5488
|
-
if (
|
|
5489
|
-
|
|
5481
|
+
if (res.aspectRatio) {
|
|
5482
|
+
console.log(
|
|
5483
|
+
`${pc.yellow("\u2551")} ${pc.dim("Ratio:")} ${res.aspectRatio.padEnd(48)}${pc.yellow("\u2551")}`
|
|
5484
|
+
);
|
|
5490
5485
|
}
|
|
5491
|
-
|
|
5492
|
-
|
|
5486
|
+
const plat = res.supportedPlatforms || res.platforms;
|
|
5487
|
+
if (plat) {
|
|
5488
|
+
console.log(`${pc.yellow("\u2551")} ${pc.dim("Platforms:")} ${plat.padEnd(48)}${pc.yellow("\u2551")}`);
|
|
5493
5489
|
}
|
|
5494
|
-
|
|
5495
|
-
|
|
5490
|
+
console.log(
|
|
5491
|
+
`${pc.yellow("\u2551")} ${pc.dim("Play URL:")} ${pc.cyan(res.url).padEnd(57)}${pc.yellow("\u2551")}`
|
|
5492
|
+
);
|
|
5493
|
+
if (res.shortUrl) {
|
|
5494
|
+
console.log(
|
|
5495
|
+
`${pc.yellow("\u2551")} ${pc.dim("Short Link:")} ${pc.magenta(res.shortUrl).padEnd(57)}${pc.yellow("\u2551")}`
|
|
5496
|
+
);
|
|
5496
5497
|
}
|
|
5497
|
-
if (
|
|
5498
|
-
|
|
5498
|
+
if (res.claim_token) {
|
|
5499
|
+
console.log(`${pc.yellow(`\u255F${border}\u2562`)}`);
|
|
5500
|
+
console.log(
|
|
5501
|
+
`${pc.yellow("\u2551")} \u{1F511} ${pc.bold(pc.yellow("SAFE HARBOR CLAIM TOKEN"))} (Keep private, 7-day TTL): ${pc.yellow("\u2551")}`
|
|
5502
|
+
);
|
|
5503
|
+
console.log(`${pc.yellow("\u2551")} ${pc.green(res.claim_token).padEnd(73)}${pc.yellow("\u2551")}`);
|
|
5504
|
+
if (res.claimUrl) {
|
|
5505
|
+
console.log(
|
|
5506
|
+
`${pc.yellow("\u2551")} ${pc.dim("Claim URL:")} ${pc.cyan(res.claimUrl).padEnd(57)}${pc.yellow("\u2551")}`
|
|
5507
|
+
);
|
|
5508
|
+
}
|
|
5499
5509
|
}
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
error: "Unsupported cover image format (must be PNG, JPEG, WebP, or GIF)"
|
|
5503
|
-
};
|
|
5510
|
+
console.log(`${pc.yellow(`\u255A${border}\u255D`)}
|
|
5511
|
+
`);
|
|
5504
5512
|
}
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5513
|
+
|
|
5514
|
+
// src/commands/auth.ts
|
|
5515
|
+
async function handleLogin(options = {}) {
|
|
5516
|
+
const isJson = Boolean(options.json);
|
|
5517
|
+
let token = options.token?.trim();
|
|
5518
|
+
const apiUrl = resolveApiUrl(options.apiUrl);
|
|
5519
|
+
if (!token) {
|
|
5520
|
+
if (isJson || !process.stdout.isTTY) {
|
|
5521
|
+
if (isJson) {
|
|
5522
|
+
printErrorJson("TOKEN_REQUIRED", "Authentication token is required via --token", 1);
|
|
5523
|
+
} else {
|
|
5524
|
+
console.error(pc2.red("Error: --token is required in non-interactive environment."));
|
|
5525
|
+
console.error(`Generate your token at ${apiUrl}/settings#tokens`);
|
|
5526
|
+
}
|
|
5527
|
+
process.exit(1);
|
|
5528
|
+
}
|
|
5529
|
+
console.log(pc2.cyan("\n\u{1F579}\uFE0F ReplayStage Authentication"));
|
|
5530
|
+
console.log(`To obtain a CLI token, visit: ${pc2.underline(`${apiUrl}/settings#tokens`)}
|
|
5531
|
+
`);
|
|
5532
|
+
const input = await text({
|
|
5533
|
+
message: "Enter your ReplayStage API token:",
|
|
5534
|
+
placeholder: "rps_...",
|
|
5535
|
+
validate(val) {
|
|
5536
|
+
if (!val || val.trim().length === 0) return "Token cannot be empty";
|
|
5537
|
+
}
|
|
5538
|
+
});
|
|
5539
|
+
if (typeof input !== "string") {
|
|
5540
|
+
console.log(pc2.yellow("Login cancelled."));
|
|
5541
|
+
process.exit(1);
|
|
5542
|
+
}
|
|
5543
|
+
token = input.trim();
|
|
5521
5544
|
}
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5545
|
+
try {
|
|
5546
|
+
let user = void 0;
|
|
5547
|
+
try {
|
|
5548
|
+
user = await fetchWhoami(apiUrl, token);
|
|
5549
|
+
} catch (err) {
|
|
5550
|
+
if (err?.status === 401 || err?.status === 403) {
|
|
5551
|
+
throw err;
|
|
5528
5552
|
}
|
|
5553
|
+
user = { id: "user_cli", handle: "cli_user" };
|
|
5529
5554
|
}
|
|
5530
|
-
|
|
5555
|
+
setToken(token, user, options.apiUrl ? apiUrl : void 0);
|
|
5556
|
+
if (isJson) {
|
|
5557
|
+
printJson({ success: true, apiUrl, user, token: `${token.slice(0, 8)}...` });
|
|
5558
|
+
} else {
|
|
5559
|
+
console.log(
|
|
5560
|
+
pc2.green(`
|
|
5561
|
+
\u2714 Logged in successfully as ${pc2.bold(`@${user?.handle || "user"}`)}!`)
|
|
5562
|
+
);
|
|
5563
|
+
console.log(` ${pc2.dim("API URL:")} ${apiUrl}
|
|
5564
|
+
`);
|
|
5565
|
+
}
|
|
5566
|
+
} catch (err) {
|
|
5567
|
+
if (isJson) {
|
|
5568
|
+
printErrorJson("AUTH_FAILED", err.message, 1);
|
|
5569
|
+
} else {
|
|
5570
|
+
console.error(pc2.red(`
|
|
5571
|
+
\u2716 Login failed: ${err.message}
|
|
5572
|
+
`));
|
|
5573
|
+
}
|
|
5574
|
+
process.exit(1);
|
|
5531
5575
|
}
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
);
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5576
|
+
}
|
|
5577
|
+
async function handleWhoami(options = {}) {
|
|
5578
|
+
const isJson = Boolean(options.json);
|
|
5579
|
+
const config = readConfig();
|
|
5580
|
+
const token = resolveToken();
|
|
5581
|
+
const apiUrl = resolveApiUrl(options.apiUrl);
|
|
5582
|
+
if (!token) {
|
|
5583
|
+
if (isJson) {
|
|
5584
|
+
printJson({ authenticated: false, message: "Not logged in (anonymous upload mode)" });
|
|
5585
|
+
} else {
|
|
5586
|
+
console.log(
|
|
5587
|
+
pc2.yellow(
|
|
5588
|
+
"\nNot logged in. CLI commands run in anonymous mode with Safe Harbor claim tokens."
|
|
5589
|
+
)
|
|
5590
|
+
);
|
|
5591
|
+
console.log(`Run ${pc2.cyan("replaystage login --token <rps_token>")} to authenticate.
|
|
5592
|
+
`);
|
|
5593
|
+
}
|
|
5594
|
+
return;
|
|
5540
5595
|
}
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
const lastSlash = htmlEntry.lastIndexOf("/");
|
|
5552
|
-
const prefix = lastSlash >= 0 ? htmlEntry.slice(0, lastSlash + 1) : "";
|
|
5553
|
-
return { entryPath: htmlEntry, prefix };
|
|
5596
|
+
try {
|
|
5597
|
+
let user = config.user;
|
|
5598
|
+
try {
|
|
5599
|
+
user = await fetchWhoami(apiUrl, token);
|
|
5600
|
+
if (config.token === token) {
|
|
5601
|
+
writeConfig({ ...config, user });
|
|
5602
|
+
}
|
|
5603
|
+
} catch (err) {
|
|
5604
|
+
if (err?.status === 401 || err?.status === 403) {
|
|
5605
|
+
throw err;
|
|
5554
5606
|
}
|
|
5555
5607
|
}
|
|
5608
|
+
if (isJson) {
|
|
5609
|
+
printJson({
|
|
5610
|
+
authenticated: true,
|
|
5611
|
+
apiUrl,
|
|
5612
|
+
user: user || null,
|
|
5613
|
+
token: `${token.slice(0, 8)}...`
|
|
5614
|
+
});
|
|
5615
|
+
} else {
|
|
5616
|
+
console.log(pc2.green("\n\u2714 Authenticated to ReplayStage"));
|
|
5617
|
+
console.log(` ${pc2.dim("API URL:")} ${apiUrl}`);
|
|
5618
|
+
if (user?.handle) console.log(` ${pc2.dim("Handle:")} @${user.handle}`);
|
|
5619
|
+
if (user?.name) console.log(` ${pc2.dim("Name:")} ${user.name}`);
|
|
5620
|
+
if (user?.email) console.log(` ${pc2.dim("Email:")} ${user.email}`);
|
|
5621
|
+
console.log(` ${pc2.dim("Token:")} ${token.slice(0, 8)}...${token.slice(-4)}
|
|
5622
|
+
`);
|
|
5623
|
+
}
|
|
5624
|
+
} catch (err) {
|
|
5625
|
+
if (isJson) {
|
|
5626
|
+
printErrorJson("WHOAMI_FAILED", err.message, 1);
|
|
5627
|
+
} else {
|
|
5628
|
+
console.error(pc2.red(`
|
|
5629
|
+
\u2716 Auth check failed: ${err.message}
|
|
5630
|
+
`));
|
|
5631
|
+
}
|
|
5632
|
+
process.exit(1);
|
|
5633
|
+
}
|
|
5634
|
+
}
|
|
5635
|
+
async function handleLogout(options = {}) {
|
|
5636
|
+
const isJson = Boolean(options.json);
|
|
5637
|
+
clearConfig();
|
|
5638
|
+
if (isJson) {
|
|
5639
|
+
printJson({ success: true, message: "Logged out successfully" });
|
|
5640
|
+
} else {
|
|
5641
|
+
console.log(pc2.green("\n\u2714 Stored credentials cleared successfully.\n"));
|
|
5556
5642
|
}
|
|
5557
|
-
return { entryPath: null, prefix: "" };
|
|
5558
5643
|
}
|
|
5559
5644
|
|
|
5560
5645
|
// src/commands/publish.ts
|
|
5646
|
+
import fs5 from "fs";
|
|
5647
|
+
import path5 from "path";
|
|
5561
5648
|
import pc3 from "picocolors";
|
|
5562
5649
|
|
|
5563
5650
|
// src/packager.ts
|
|
@@ -5664,12 +5751,14 @@ function extractHtmlMetadata(html) {
|
|
|
5664
5751
|
const rawAspect = extractRawAspectRatioFromHtml(html);
|
|
5665
5752
|
const aspectNorm = rawAspect ? normalizeAspectRatio(rawAspect) : null;
|
|
5666
5753
|
const model = extractAiModelFromHtml(html);
|
|
5754
|
+
const tags = extractTagsFromHtml(html);
|
|
5667
5755
|
return {
|
|
5668
5756
|
title,
|
|
5669
5757
|
tagline,
|
|
5670
5758
|
rawAspectRatio: rawAspect ?? void 0,
|
|
5671
5759
|
aspectRatio: aspectNorm?.valid ? aspectNorm.normalized : void 0,
|
|
5672
|
-
model: model ?? null
|
|
5760
|
+
model: model ?? null,
|
|
5761
|
+
tags: tags.length > 0 ? tags : void 0
|
|
5673
5762
|
};
|
|
5674
5763
|
}
|
|
5675
5764
|
function computeSha256(buf) {
|
|
@@ -5720,7 +5809,8 @@ async function packageGame(targetPath) {
|
|
|
5720
5809
|
extractedTitle: meta.title,
|
|
5721
5810
|
extractedTagline: meta.tagline,
|
|
5722
5811
|
extractedAspectRatio: meta.aspectRatio,
|
|
5723
|
-
extractedModel: meta.model ?? null
|
|
5812
|
+
extractedModel: meta.model ?? null,
|
|
5813
|
+
extractedTags: meta.tags
|
|
5724
5814
|
};
|
|
5725
5815
|
}
|
|
5726
5816
|
if (ext === ".zip") {
|
|
@@ -5761,6 +5851,7 @@ async function packageGame(targetPath) {
|
|
|
5761
5851
|
let extractedTagline;
|
|
5762
5852
|
let extractedAspectRatio;
|
|
5763
5853
|
let extractedModel;
|
|
5854
|
+
let extractedTags;
|
|
5764
5855
|
if (unzipped[entryRes.entryPath]) {
|
|
5765
5856
|
const meta = extractHtmlMetadata(
|
|
5766
5857
|
Buffer.from(unzipped[entryRes.entryPath]).toString("utf-8")
|
|
@@ -5769,6 +5860,7 @@ async function packageGame(targetPath) {
|
|
|
5769
5860
|
extractedTagline = meta.tagline;
|
|
5770
5861
|
extractedAspectRatio = meta.aspectRatio;
|
|
5771
5862
|
extractedModel = meta.model;
|
|
5863
|
+
extractedTags = meta.tags;
|
|
5772
5864
|
}
|
|
5773
5865
|
return {
|
|
5774
5866
|
format: "zip",
|
|
@@ -5783,7 +5875,8 @@ async function packageGame(targetPath) {
|
|
|
5783
5875
|
extractedTitle,
|
|
5784
5876
|
extractedTagline,
|
|
5785
5877
|
extractedAspectRatio,
|
|
5786
|
-
extractedModel: extractedModel ?? null
|
|
5878
|
+
extractedModel: extractedModel ?? null,
|
|
5879
|
+
extractedTags
|
|
5787
5880
|
};
|
|
5788
5881
|
}
|
|
5789
5882
|
throw new Error(
|
|
@@ -5848,6 +5941,7 @@ async function packageGame(targetPath) {
|
|
|
5848
5941
|
let extractedTagline;
|
|
5849
5942
|
let extractedAspectRatio;
|
|
5850
5943
|
let extractedModel;
|
|
5944
|
+
let extractedTags;
|
|
5851
5945
|
const entryBuf = fileEntries[entryResolution.entryPath];
|
|
5852
5946
|
if (entryBuf) {
|
|
5853
5947
|
const meta = extractHtmlMetadata(entryBuf.toString("utf-8"));
|
|
@@ -5855,6 +5949,7 @@ async function packageGame(targetPath) {
|
|
|
5855
5949
|
extractedTagline = meta.tagline;
|
|
5856
5950
|
extractedAspectRatio = meta.aspectRatio;
|
|
5857
5951
|
extractedModel = meta.model;
|
|
5952
|
+
extractedTags = meta.tags;
|
|
5858
5953
|
}
|
|
5859
5954
|
const zipBuffer = createZipFromFiles(fileEntries);
|
|
5860
5955
|
const fileHash = computeSha256(zipBuffer);
|
|
@@ -5871,7 +5966,8 @@ async function packageGame(targetPath) {
|
|
|
5871
5966
|
extractedTitle,
|
|
5872
5967
|
extractedTagline,
|
|
5873
5968
|
extractedAspectRatio,
|
|
5874
|
-
extractedModel: extractedModel ?? null
|
|
5969
|
+
extractedModel: extractedModel ?? null,
|
|
5970
|
+
extractedTags
|
|
5875
5971
|
};
|
|
5876
5972
|
}
|
|
5877
5973
|
throw new Error(`Invalid target path: '${targetPath}' is neither a file nor a directory.`);
|
|
@@ -6163,6 +6259,7 @@ async function validateGamePackage(targetPath) {
|
|
|
6163
6259
|
supportedPlatforms: detectedPlatforms,
|
|
6164
6260
|
platforms: detectedPlatforms,
|
|
6165
6261
|
hasPlatformMeta,
|
|
6262
|
+
tags: pkg.extractedTags ?? [],
|
|
6166
6263
|
errors: [],
|
|
6167
6264
|
warnings
|
|
6168
6265
|
};
|
|
@@ -6252,7 +6349,7 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6252
6349
|
const token = options.anonymous ? null : resolveToken(options.token);
|
|
6253
6350
|
const apiUrl = resolveApiUrl(options.apiUrl);
|
|
6254
6351
|
const existingConfig = !options.fresh ? readProjectConfig(resolvedPath) : null;
|
|
6255
|
-
let aiTool = "
|
|
6352
|
+
let aiTool = "";
|
|
6256
6353
|
if (options.tool !== void 0) {
|
|
6257
6354
|
const parsedTool = aiToolSchema.safeParse(options.tool);
|
|
6258
6355
|
if (!parsedTool.success) {
|
|
@@ -6267,11 +6364,15 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6267
6364
|
process.exit(1);
|
|
6268
6365
|
}
|
|
6269
6366
|
const rawTool = parsedTool.data;
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6367
|
+
if (rawTool) {
|
|
6368
|
+
const matchedPreset = AI_TOOL_KEYS.find(
|
|
6369
|
+
(key) => key.toLowerCase() === rawTool.toLowerCase() || AI_TOOLS[key] && AI_TOOLS[key].name.toLowerCase() === rawTool.toLowerCase()
|
|
6370
|
+
);
|
|
6371
|
+
aiTool = matchedPreset ? matchedPreset : rawTool;
|
|
6372
|
+
} else {
|
|
6373
|
+
aiTool = "";
|
|
6374
|
+
}
|
|
6375
|
+
} else if (existingConfig?.aiTool && existingConfig.aiTool !== "other") {
|
|
6275
6376
|
aiTool = existingConfig.aiTool;
|
|
6276
6377
|
}
|
|
6277
6378
|
let resolvedModel = null;
|
|
@@ -6401,6 +6502,47 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6401
6502
|
} else if (validation.supportedPlatforms) {
|
|
6402
6503
|
resolvedPlatforms = validation.supportedPlatforms;
|
|
6403
6504
|
}
|
|
6505
|
+
let resolvedTags = [];
|
|
6506
|
+
if (options.tags !== void 0) {
|
|
6507
|
+
const rawTags = options.tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
6508
|
+
if (rawTags.length > 0) {
|
|
6509
|
+
if (rawTags.length > MAX_TAGS_COUNT) {
|
|
6510
|
+
const errorMsg = `Too many tags: maximum ${MAX_TAGS_COUNT} tags allowed, but received ${rawTags.length}`;
|
|
6511
|
+
if (isJson) {
|
|
6512
|
+
printErrorJson("INVALID_OPTIONS", errorMsg, 1);
|
|
6513
|
+
} else {
|
|
6514
|
+
console.error(pc3.red(`
|
|
6515
|
+
\u2716 Invalid option: ${errorMsg}
|
|
6516
|
+
`));
|
|
6517
|
+
}
|
|
6518
|
+
process.exit(1);
|
|
6519
|
+
}
|
|
6520
|
+
for (const rawTag of rawTags) {
|
|
6521
|
+
const formatted = rawTag.toLowerCase().replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
6522
|
+
const parsedTag = tagSchema.safeParse(formatted);
|
|
6523
|
+
if (!parsedTag.success) {
|
|
6524
|
+
const errorMsg = `Invalid tag '${rawTag}': ${parsedTag.error.errors[0]?.message || "invalid tag format"}`;
|
|
6525
|
+
if (isJson) {
|
|
6526
|
+
printErrorJson("INVALID_OPTIONS", errorMsg, 1);
|
|
6527
|
+
} else {
|
|
6528
|
+
console.error(pc3.red(`
|
|
6529
|
+
\u2716 Invalid option: ${errorMsg}
|
|
6530
|
+
`));
|
|
6531
|
+
}
|
|
6532
|
+
process.exit(1);
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
resolvedTags = normalizeTags(rawTags);
|
|
6536
|
+
} else {
|
|
6537
|
+
resolvedTags = [];
|
|
6538
|
+
}
|
|
6539
|
+
} else if (bundle.extractedTags && bundle.extractedTags.length > 0) {
|
|
6540
|
+
resolvedTags = bundle.extractedTags;
|
|
6541
|
+
} else if (existingConfig?.tags && Array.isArray(existingConfig.tags) && existingConfig.tags.length > 0) {
|
|
6542
|
+
resolvedTags = normalizeTags(existingConfig.tags);
|
|
6543
|
+
} else {
|
|
6544
|
+
resolvedTags = [];
|
|
6545
|
+
}
|
|
6404
6546
|
if (existingConfig?.slug) {
|
|
6405
6547
|
logInfo(
|
|
6406
6548
|
`Updating existing stage '${existingConfig.slug}' (current version: ${existingConfig.version || "0.1.0"})...`,
|
|
@@ -6421,6 +6563,7 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6421
6563
|
token,
|
|
6422
6564
|
aiModel: resolvedModel,
|
|
6423
6565
|
aiTool,
|
|
6566
|
+
tags: resolvedTags,
|
|
6424
6567
|
coverBuffer,
|
|
6425
6568
|
coverFileName,
|
|
6426
6569
|
errorMsgFallback: "Failed to update stage"
|
|
@@ -6439,7 +6582,8 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6439
6582
|
supportedPlatforms: resolvedPlatforms,
|
|
6440
6583
|
platforms: resolvedPlatforms,
|
|
6441
6584
|
aiModel: resolvedModel !== void 0 ? resolvedModel : existingConfig.aiModel ?? null,
|
|
6442
|
-
aiTool: aiTool ||
|
|
6585
|
+
aiTool: aiTool || void 0,
|
|
6586
|
+
tags: resolvedTags
|
|
6443
6587
|
};
|
|
6444
6588
|
writeProjectConfig(resolvedPath, updatedConfig);
|
|
6445
6589
|
if (isJson) {
|
|
@@ -6457,6 +6601,7 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6457
6601
|
platforms: resolvedPlatforms,
|
|
6458
6602
|
aiModel: updatedConfig.aiModel,
|
|
6459
6603
|
aiTool: updatedConfig.aiTool,
|
|
6604
|
+
tags: resolvedTags,
|
|
6460
6605
|
promotedToPublic: updateResult.promotedToPublic,
|
|
6461
6606
|
fileHash: updateResult.fileHash || bundle.fileHash,
|
|
6462
6607
|
updated: true
|
|
@@ -6477,6 +6622,9 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6477
6622
|
if (updatedConfig.supportedPlatforms) {
|
|
6478
6623
|
console.log(` Platforms: ${pc3.bold(updatedConfig.supportedPlatforms)}`);
|
|
6479
6624
|
}
|
|
6625
|
+
if (resolvedTags.length > 0) {
|
|
6626
|
+
console.log(` Tags: ${resolvedTags.map((t) => pc3.cyan(`#${t}`)).join(" ")}`);
|
|
6627
|
+
}
|
|
6480
6628
|
if (options.changelog) {
|
|
6481
6629
|
console.log(` Changelog: "${options.changelog}"`);
|
|
6482
6630
|
}
|
|
@@ -6515,6 +6663,7 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6515
6663
|
description: options.description,
|
|
6516
6664
|
aiTool,
|
|
6517
6665
|
aiModel: resolvedModel,
|
|
6666
|
+
tags: resolvedTags,
|
|
6518
6667
|
coverBuffer,
|
|
6519
6668
|
coverFileName,
|
|
6520
6669
|
category,
|
|
@@ -6542,7 +6691,8 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6542
6691
|
supportedPlatforms: resolvedPlatforms,
|
|
6543
6692
|
platforms: resolvedPlatforms,
|
|
6544
6693
|
aiModel: resolvedModel,
|
|
6545
|
-
aiTool
|
|
6694
|
+
aiTool: aiTool || void 0,
|
|
6695
|
+
tags: resolvedTags
|
|
6546
6696
|
});
|
|
6547
6697
|
if (isJson) {
|
|
6548
6698
|
printJson({
|
|
@@ -6563,7 +6713,8 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6563
6713
|
supportedPlatforms: resolvedPlatforms,
|
|
6564
6714
|
platforms: resolvedPlatforms,
|
|
6565
6715
|
aiModel: resolvedModel,
|
|
6566
|
-
aiTool
|
|
6716
|
+
aiTool: aiTool || void 0,
|
|
6717
|
+
tags: resolvedTags
|
|
6567
6718
|
});
|
|
6568
6719
|
} else {
|
|
6569
6720
|
printPublishSuccess({
|
|
@@ -6574,6 +6725,7 @@ async function handlePublish(targetPath = ".", options = {}) {
|
|
|
6574
6725
|
claim_token: result.claim_token,
|
|
6575
6726
|
claimUrl: result.claimUrl,
|
|
6576
6727
|
aiTool,
|
|
6728
|
+
tags: resolvedTags,
|
|
6577
6729
|
fileHash: bundle.fileHash,
|
|
6578
6730
|
aspectRatio: resolvedAspectRatio,
|
|
6579
6731
|
supportedPlatforms: resolvedPlatforms
|
|
@@ -6654,19 +6806,22 @@ async function computeFileFingerprint(filePath) {
|
|
|
6654
6806
|
// src/index.ts
|
|
6655
6807
|
function createProgram() {
|
|
6656
6808
|
const program = new Command();
|
|
6657
|
-
program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.
|
|
6809
|
+
program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.4.0");
|
|
6658
6810
|
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(
|
|
6659
6811
|
"--tool <tool>",
|
|
6660
6812
|
"AI tool used to generate the game (claude, gemini, antigravity, cursor, etc.)"
|
|
6661
6813
|
).option(
|
|
6662
6814
|
"-m, --model <model>",
|
|
6663
|
-
"AI model used to synthesize the game (e.g.,
|
|
6815
|
+
"AI model used to synthesize the game (e.g., Claude Sonnet 5.5, GPT-6 Astra, Gemini 4 Carbon)"
|
|
6664
6816
|
).option(
|
|
6665
6817
|
"--cover <path>",
|
|
6666
6818
|
"Path to custom cartridge cover image (PNG, JPG, WebP, GIF, max 2MB)"
|
|
6667
6819
|
).option(
|
|
6668
6820
|
"--category <category>",
|
|
6669
|
-
"Game category (arcade, action, puzzle,
|
|
6821
|
+
"Game category (arcade, action, puzzle, strategy, simulation, racing, rpg, casual)"
|
|
6822
|
+
).option(
|
|
6823
|
+
"--tags <tags>",
|
|
6824
|
+
"Comma-separated feature tags (e.g., 3d, retro, physics, roguelike, cozy; max 6 tags)"
|
|
6670
6825
|
).option(
|
|
6671
6826
|
"--aspect-ratio <ratio>",
|
|
6672
6827
|
"Display aspect ratio (auto, 16:9, 9:16, 4:3, 3:4, 1:1, or custom W:H)"
|