akemon 0.1.30 → 0.1.31
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/server.js +42 -34
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -999,27 +999,31 @@ Requirements:
|
|
|
999
999
|
- Under 30KB total, no backdrop-filter or blur effects
|
|
1000
1000
|
- Include a game title in the <title> tag and as an <h1> or similar heading
|
|
1001
1001
|
- Write ONLY the file, nothing else.`;
|
|
1002
|
-
await runCommand(engineCmd.cmd, engineCmd.args, createPrompt, workdir, engineCmd.stdinMode);
|
|
1002
|
+
const engineOutput = await runCommand(engineCmd.cmd, engineCmd.args, createPrompt, workdir, engineCmd.stdinMode);
|
|
1003
|
+
// Try reading file first, fallback to stdout
|
|
1004
|
+
let raw = "";
|
|
1003
1005
|
try {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
newGameSlug = slug;
|
|
1012
|
-
newGameDesc = `Created by ${agentName}`;
|
|
1013
|
-
await saveGame(workdir, agentName, slug, newGameHTML);
|
|
1014
|
-
await appendGameEntry(workdir, agentName, slug, newGameTitle, newGameDesc, "created");
|
|
1015
|
-
console.log(`[self] New game created: ${newGameTitle} (${newGameHTML.length} bytes)`);
|
|
1016
|
-
}
|
|
1017
|
-
else {
|
|
1018
|
-
console.log("[self] Game file written but no valid HTML found");
|
|
1019
|
-
}
|
|
1006
|
+
raw = await readFile(gamePath, "utf-8");
|
|
1007
|
+
console.log(`[self] Game file found (${raw.length} bytes)`);
|
|
1008
|
+
}
|
|
1009
|
+
catch {
|
|
1010
|
+
// codex may have output HTML to stdout instead of writing file
|
|
1011
|
+
raw = engineOutput;
|
|
1012
|
+
console.log(`[self] Game file not written, trying stdout (${raw.length} bytes)`);
|
|
1020
1013
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1014
|
+
const htmlMatch = raw.match(/<!DOCTYPE html>[\s\S]*<\/html>/i);
|
|
1015
|
+
if (htmlMatch) {
|
|
1016
|
+
newGameHTML = htmlMatch[0];
|
|
1017
|
+
const titleMatch = newGameHTML.match(/<title>([^<]+)<\/title>/i);
|
|
1018
|
+
newGameTitle = titleMatch ? titleMatch[1].replace(/ — .*$/, "").trim() : "Untitled Game";
|
|
1019
|
+
newGameSlug = slug;
|
|
1020
|
+
newGameDesc = `Created by ${agentName}`;
|
|
1021
|
+
await saveGame(workdir, agentName, slug, newGameHTML);
|
|
1022
|
+
await appendGameEntry(workdir, agentName, slug, newGameTitle, newGameDesc, "created");
|
|
1023
|
+
console.log(`[self] New game created: ${newGameTitle} (${newGameHTML.length} bytes)`);
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
console.log(`[self] No valid HTML found in game output (${raw.length} bytes)`);
|
|
1023
1027
|
}
|
|
1024
1028
|
}
|
|
1025
1029
|
else if (decisionUpper.startsWith("B")) {
|
|
@@ -1038,23 +1042,27 @@ You are ${agentName}. This is your existing game "${target.title}":
|
|
|
1038
1042
|
${oldHTML}
|
|
1039
1043
|
|
|
1040
1044
|
Improve it — add features, fix bugs, make it more fun, or redesign the UI. Keep it self-contained HTML, dark theme, under 30KB. Write ONLY the file.`;
|
|
1041
|
-
await runCommand(engineCmd.cmd, engineCmd.args, improvePrompt, workdir, engineCmd.stdinMode);
|
|
1045
|
+
const improveOutput = await runCommand(engineCmd.cmd, engineCmd.args, improvePrompt, workdir, engineCmd.stdinMode);
|
|
1046
|
+
let improveRaw = "";
|
|
1042
1047
|
try {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1048
|
+
improveRaw = await readFile(gamePath, "utf-8");
|
|
1049
|
+
}
|
|
1050
|
+
catch {
|
|
1051
|
+
improveRaw = improveOutput;
|
|
1052
|
+
}
|
|
1053
|
+
const improveMatch = improveRaw.match(/<!DOCTYPE html>[\s\S]*<\/html>/i);
|
|
1054
|
+
if (improveMatch) {
|
|
1055
|
+
newGameHTML = improveMatch[0];
|
|
1056
|
+
const titleMatch = newGameHTML.match(/<title>([^<]+)<\/title>/i);
|
|
1057
|
+
newGameTitle = titleMatch ? titleMatch[1].replace(/ — .*$/, "").trim() : target.title;
|
|
1058
|
+
newGameSlug = target.slug;
|
|
1059
|
+
newGameDesc = target.description;
|
|
1060
|
+
await saveGame(workdir, agentName, target.slug, newGameHTML);
|
|
1061
|
+
await appendGameEntry(workdir, agentName, target.slug, newGameTitle, newGameDesc, "updated");
|
|
1062
|
+
console.log(`[self] Game improved: ${newGameTitle} (${newGameHTML.length} bytes)`);
|
|
1055
1063
|
}
|
|
1056
|
-
|
|
1057
|
-
console.log(`[self]
|
|
1064
|
+
else {
|
|
1065
|
+
console.log(`[self] No valid HTML in improved game output (${improveRaw.length} bytes)`);
|
|
1058
1066
|
}
|
|
1059
1067
|
}
|
|
1060
1068
|
}
|