Rework as scripts-centric, upload-only, gated beta lifecycle

Scripts become first-class: named, versioned, uploaded via the UI, optionally
scoped to a game or map. Any change that would land on scope-matched servers
(marking-required or new version of a scoped script) must first pass a beta.
The beta runs a per-server state machine — deploy -beta.gsc → wait empty →
Komodo restart → wait healthy → optionally wait for a real match end
(games_sp.log 'ExitLevel: executed') — before it's eligible for promotion.
Rollback is always available and restores from .OLD.

The shared/scripts mirror and its betas/ staging folder are gone. Every
server now has a tracked script inventory (server_scripts table), populated
only by explicit upload flows.

New: /scripts, /scripts/[id], /betas/[id] UI; /api/scripts + /api/betas +
/api/servers/[name]/scripts endpoints; scripts.ts, inventory.ts, beta.ts
(rewritten), beta-runner.ts, match-log.ts, komodoInspectHealthy().
Removed: push.ts, /api/push, BetaPanel, legacy importer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-09-12 13:25:06 -04:00
co-authored by Claude Opus 4.7
parent 47051dc79a
commit 93d5a8e2e5
52 changed files with 2605 additions and 1689 deletions
+247
View File
@@ -0,0 +1,247 @@
<script lang="ts">
import { onMount } from 'svelte';
interface ScriptRow {
id: number;
name: string;
target_rel_path: string;
scope_type: 'game' | 'map' | null;
scope_value: string | null;
current_version_id: number | null;
latestVersion: {
id: number;
version: number;
sha256: string;
size: number;
uploaded_at: string;
} | null;
versionCount: number;
servers: string[];
runningBetaId: number | null;
}
let scripts = $state<ScriptRow[]>([]);
let loading = $state(true);
let flash = $state<string | null>(null);
let uploading = $state(false);
// Form state for creating a new script.
let newName = $state('');
let newTargetRelPath = $state('');
let newScopeType = $state<'none' | 'game' | 'map'>('none');
let newScopeValue = $state('');
let newFile = $state<File | null>(null);
let newNotes = $state('');
async function load(): Promise<void> {
const res = await fetch('/api/scripts');
const body = (await res.json()) as { scripts: ScriptRow[] };
scripts = body.scripts;
loading = false;
}
onMount(load);
function pickFile(e: Event): void {
const t = e.target as HTMLInputElement;
newFile = t.files?.[0] ?? null;
if (!newTargetRelPath && newFile) newTargetRelPath = newFile.name;
if (!newName && newFile) newName = newFile.name.replace(/\.[^.]+$/, '');
}
async function createScript(e: Event): Promise<void> {
e.preventDefault();
if (uploading || !newFile || !newName.trim() || !newTargetRelPath.trim()) return;
uploading = true;
flash = null;
const form = new FormData();
form.append('name', newName.trim());
form.append('targetRelPath', newTargetRelPath.trim());
form.append('scopeType', newScopeType);
if (newScopeValue.trim()) form.append('scopeValue', newScopeValue.trim());
if (newNotes.trim()) form.append('notes', newNotes.trim());
form.append('content', newFile);
try {
const res = await fetch('/api/scripts', { method: 'POST', body: form });
const body = (await res.json()) as { ok: boolean; error?: string };
if (!res.ok || !body.ok) {
flash = body.error ?? `HTTP ${res.status}`;
return;
}
newName = '';
newTargetRelPath = '';
newScopeType = 'none';
newScopeValue = '';
newNotes = '';
newFile = null;
await load();
} finally {
uploading = false;
}
}
function scopeLabel(s: ScriptRow): string {
if (!s.scope_type) return 'unscoped';
return `${s.scope_type}=${s.scope_value ?? '?'}`;
}
</script>
<h1>Scripts</h1>
<section class="panel">
<h2>Upload a script</h2>
<form onsubmit={createScript} class="upload-form">
<label>
<span class="k">name</span>
<input type="text" bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
</label>
<label>
<span class="k">target rel path</span>
<input type="text" bind:value={newTargetRelPath} placeholder="maps/mp_zom_theater/hud.gsc" disabled={uploading} />
</label>
<label>
<span class="k">scope</span>
<div class="scope-row">
<select bind:value={newScopeType} disabled={uploading}>
<option value="none">unscoped</option>
<option value="game">game</option>
<option value="map">map</option>
</select>
{#if newScopeType !== 'none'}
<input type="text" bind:value={newScopeValue} placeholder={newScopeType === 'game' ? 't5' : 'zombie_theater'} disabled={uploading} />
{/if}
</div>
</label>
<label>
<span class="k">notes (optional)</span>
<input type="text" bind:value={newNotes} placeholder="what changed" disabled={uploading} />
</label>
<label>
<span class="k">file</span>
<input type="file" onchange={pickFile} disabled={uploading} />
</label>
<button type="submit" class="primary" disabled={uploading || !newFile || !newName || !newTargetRelPath}>
{uploading ? 'uploading…' : 'upload script'}
</button>
</form>
{#if flash}<p class="flash">{flash}</p>{/if}
</section>
<section class="panel">
<h2>All scripts</h2>
{#if loading}
<p class="empty">loading…</p>
{:else if scripts.length === 0}
<p class="empty">no scripts yet — upload one above</p>
{:else}
<div class="scripts">
{#each scripts as s (s.id)}
<a class="script-row" href="/scripts/{s.id}">
<div class="row-top">
<span class="script-name">{s.name}</span>
<span class="scope tag scope-{s.scope_type ?? 'none'}">{scopeLabel(s)}</span>
{#if s.runningBetaId}
<span class="tag beta">beta {s.runningBetaId} running</span>
{/if}
</div>
<div class="row-meta mono">
<span>{s.target_rel_path}</span>
<span>v{s.latestVersion?.version ?? '—'} · {s.versionCount} version{s.versionCount === 1 ? '' : 's'}</span>
<span>{s.servers.length ? `${s.servers.length} matching server${s.servers.length === 1 ? '' : 's'}` : ''}</span>
</div>
</a>
{/each}
</div>
{/if}
</section>
<style>
h1 {
color: var(--cream);
font-family: var(--font-display);
font-size: var(--text-3xl);
letter-spacing: var(--tracking-display);
line-height: var(--leading-tight);
margin: 0 0 28px;
}
.panel {
background: var(--bg-nav);
border: 1px solid var(--border);
border-radius: var(--r-md);
padding: var(--pad-panel);
margin-bottom: 20px;
}
h2 {
margin: 0 0 14px;
font-family: var(--font-body);
font-size: var(--text-xs);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1.5px;
color: var(--ink-300);
}
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 0; }
.upload-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
.upload-form label .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
.upload-form input[type=text], .upload-form select, .upload-form input[type=file] {
background: var(--bg-page);
color: var(--ink-100);
border: 1px solid var(--border);
border-radius: var(--r-sm);
padding: 10px 12px;
font-family: var(--font-mono);
font-size: var(--text-mono);
}
.upload-form input[type=text]:focus, .upload-form select:focus {
outline: none;
border-color: var(--accent);
box-shadow: var(--accent-glow);
}
.scope-row { display: flex; gap: 8px; }
.scope-row select { flex: 0 0 120px; }
.scope-row input { flex: 1; }
.primary {
grid-column: 1 / -1;
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
border: 1px solid var(--blue-400);
border-radius: var(--r-sm);
padding: 12px 18px;
color: var(--cream);
font-family: var(--font-body);
font-weight: 600;
cursor: pointer;
}
.primary:disabled { opacity: 0.4; cursor: default; }
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
.scripts { display: flex; flex-direction: column; gap: 8px; }
.script-row {
display: flex;
flex-direction: column;
gap: 6px;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--r-sm);
padding: 14px 16px;
text-decoration: none;
color: var(--ink-100);
}
.script-row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
.row-top { display: flex; gap: 12px; align-items: center; }
.script-name { color: var(--cream); font-weight: 600; font-size: var(--text-md); }
.row-meta { display: flex; gap: 24px; color: var(--ink-500); font-size: var(--text-mono-sm); }
.mono { font-family: var(--font-mono); }
.tag {
font-family: var(--font-mono);
font-size: var(--text-xs);
padding: 3px 9px;
border-radius: var(--r-sm);
border: 1px solid transparent;
}
.scope-none { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
.scope-game { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
.scope-map { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.35); color: var(--amber-500); }
.beta { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
</style>