AgentnessArenav2 / build-standalone.js
irregular6612's picture
llm: inline spectate into standalone build + README usage (batch + spectate)
0c1ac3e
Raw
History Blame Contribute Delete
1.26 kB
/* Regenerate standalone.html by inlining style.css + engine.js + app.js into
index.html (README: standalone.html must never be edited directly). */
'use strict';
const fs = require('fs');
const path = require('path');
const here = (f) => path.join(__dirname, f);
const read = (f) => fs.readFileSync(here(f), 'utf8');
let html = read('index.html');
const inline = (needle, replacement) => {
if (!html.includes(needle)) throw new Error('index.html missing: ' + needle);
html = html.replace(needle, () => replacement);
};
inline('<link rel="stylesheet" href="style.css">',
'<style>\n' + read('style.css') + '</style>');
inline('<script src="engine.js"></script>',
'<script>\n' + read('engine.js') + '</script>');
inline('<script src="app.js"></script>',
'<script>\n' + read('app.js') + '</script>');
inline('<script src="llm/observe.js"></script>',
'<script>\n' + read('llm/observe.js') + '</script>');
inline('<script src="llm/providers.js"></script>',
'<script>\n' + read('llm/providers.js') + '</script>');
inline('<script src="llm/spectate.js"></script>',
'<script>\n' + read('llm/spectate.js') + '</script>');
fs.writeFileSync(here('standalone.html'), html);
console.log('standalone.html regenerated (' + html.length + ' bytes)');