Referenz: externe Läufe exportieren und importieren, Referenz ohne Rang mit Strich im Ranking, Reiter Referenz; Roadmap 0.1.1
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
269
src/lib/ReferencePanel.svelte
Normal file
269
src/lib/ReferencePanel.svelte
Normal file
@ -0,0 +1,269 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { revealItemInDir } from "@tauri-apps/plugin-opener";
|
||||
import { api, groupLabel, type BatchInfo, type ExportResult, type ImportSummary, type LoadReport, type TaskInfo } from "$lib/api";
|
||||
|
||||
let { tasks, onimported }: { tasks: LoadReport | null; onimported: (batchId: number) => void } = $props();
|
||||
|
||||
// 1. Exportieren
|
||||
let chosen = $state<string[]>([]);
|
||||
let repeats = $state(1);
|
||||
let exporting = $state(false);
|
||||
let exported = $state<ExportResult | null>(null);
|
||||
let exportError = $state("");
|
||||
|
||||
let byGroup = $derived.by(() => {
|
||||
const m = new Map<string, TaskInfo[]>();
|
||||
for (const t of tasks?.tasks ?? []) {
|
||||
if (!m.has(t.group)) m.set(t.group, []);
|
||||
m.get(t.group)!.push(t);
|
||||
}
|
||||
return [...m.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
||||
});
|
||||
|
||||
function toggle(id: string) {
|
||||
chosen = chosen.includes(id) ? chosen.filter((x) => x !== id) : [...chosen, id];
|
||||
}
|
||||
|
||||
async function doExport() {
|
||||
exporting = true;
|
||||
exportError = "";
|
||||
exported = null;
|
||||
try {
|
||||
exported = await api.exportExternal($state.snapshot(chosen), repeats);
|
||||
} catch (e) {
|
||||
exportError = String(e);
|
||||
} finally {
|
||||
exporting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function reveal(path: string) {
|
||||
try {
|
||||
await revealItemInDir(path);
|
||||
} catch {
|
||||
// Ohne Dateimanager bleibt der Pfad als Text sichtbar.
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Importieren
|
||||
let batches = $state<BatchInfo[]>([]);
|
||||
let dir = $state("");
|
||||
let model = $state("Claude Code (extern)");
|
||||
let batchId = $state<number | null>(null);
|
||||
let importing = $state(false);
|
||||
let summary = $state<ImportSummary | null>(null);
|
||||
let importError = $state("");
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
batches = await api.batches();
|
||||
if (batches.length > 0) batchId = batches[0].id;
|
||||
} catch {
|
||||
batches = [];
|
||||
}
|
||||
});
|
||||
|
||||
// Nach einem Export liegt der Pfad nahe, den wir nach dem Lösen wieder brauchen.
|
||||
$effect(() => {
|
||||
if (exported && !dir) dir = exported.dir;
|
||||
});
|
||||
|
||||
async function doImport() {
|
||||
if (batchId === null) return;
|
||||
importing = true;
|
||||
importError = "";
|
||||
summary = null;
|
||||
try {
|
||||
summary = await api.importExternal(dir.trim(), model, batchId);
|
||||
} catch (e) {
|
||||
importError = String(e);
|
||||
} finally {
|
||||
importing = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="card">
|
||||
<h2>Referenz von Hand erzeugen</h2>
|
||||
<p class="muted">
|
||||
Modelle, die du nicht anbinden kannst (z. B. Claude über ein Abo), löst du mit einem Werkzeug deiner Wahl, etwa Claude Code.
|
||||
coding-bench exportiert die Aufgaben als Ordner, prüft deine Ergebnisse mit derselben <code>check.sh</code> wie bei lokalen
|
||||
Modellen und zeigt das Ergebnis als Referenz im Ranking.
|
||||
</p>
|
||||
<p class="notice">
|
||||
<strong>Achtung, anderes Harness:</strong> Die Referenz misst „Modell plus dein Werkzeug“. Es gibt kein Schrittlimit, kein
|
||||
Zeitlimit, und das Werkzeug hat eigene Tools und Anweisungen. Der Strich im Ranking ist ein Orientierungswert, kein
|
||||
Gleichstand der Bedingungen.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>1. Aufgaben exportieren</h2>
|
||||
{#if !tasks || tasks.tasks.length === 0}
|
||||
<p class="muted">Keine Aufgaben geladen.</p>
|
||||
{/if}
|
||||
{#each byGroup as [group, list] (group)}
|
||||
<h3><span class="gbadge">{group}</span> {groupLabel(group)}</h3>
|
||||
<div class="list">
|
||||
{#each list as t (t.id)}
|
||||
<label class="choice">
|
||||
<input type="checkbox" checked={chosen.includes(t.id)} onchange={() => toggle(t.id)} />
|
||||
<span><strong>{t.title}</strong> <span class="muted small">{t.id}</span></span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
<div class="row">
|
||||
<label class="rep">
|
||||
Durchläufe je Aufgabe
|
||||
<input type="number" min="1" max="10" bind:value={repeats} />
|
||||
</label>
|
||||
<span class="muted small">
|
||||
{chosen.length * repeats} Sitzung(en) von Hand. Mit weniger als 3 Durchläufen ist die Referenz nur ein grober Hinweis.
|
||||
</span>
|
||||
<span class="spacer"></span>
|
||||
<button class="primary" onclick={doExport} disabled={chosen.length === 0 || repeats < 1 || exporting}>
|
||||
{exporting ? "exportiere …" : "Exportieren"}
|
||||
</button>
|
||||
</div>
|
||||
{#if exportError}<p class="error">{exportError}</p>{/if}
|
||||
{#if exported}
|
||||
<p class="ok">
|
||||
{exported.folders} Ordner angelegt:
|
||||
<code>{exported.dir}</code>
|
||||
<button class="link" onclick={() => reveal(exported!.dir)}>im Dateimanager zeigen</button>
|
||||
</p>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>2. Lösen lassen</h2>
|
||||
<ol class="muted steps">
|
||||
<li>Im Exportordner steht eine <code>ANLEITUNG.md</code>. Lies sie kurz.</li>
|
||||
<li>
|
||||
Pro Durchlauf eine frische Sitzung in <code><aufgabe>/run-<n>/arbeit/</code> starten und den Inhalt von
|
||||
<code>AUFGABE.md</code> als Auftrag einfügen.
|
||||
</li>
|
||||
<li>Kein Web, keine Hinweise, nur den Ordner <code>arbeit/</code> verändern lassen.</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>3. Ergebnis importieren</h2>
|
||||
<div class="grid">
|
||||
<label class="wide">
|
||||
Exportordner mit den Ergebnissen
|
||||
<input bind:value={dir} placeholder="/home/…/exports/referenz-…" />
|
||||
</label>
|
||||
<label>
|
||||
Name der Referenz
|
||||
<input bind:value={model} />
|
||||
</label>
|
||||
<label>
|
||||
In welchen Batch?
|
||||
<select bind:value={batchId} disabled={batches.length === 0}>
|
||||
{#each batches as b (b.id)}
|
||||
<option value={b.id}>Batch {b.id} · {b.created_at.slice(0, 16)} · {b.runs} Läufe</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{#if batches.length === 0}
|
||||
<p class="muted small">Es gibt noch keinen Batch. Starte zuerst einen Benchmark mit lokalen Modellen, damit die Referenz einen Vergleich hat.</p>
|
||||
{/if}
|
||||
<div class="row">
|
||||
<span class="muted small">Die App kopiert die Ergebnisse in einen Container und lässt dort <code>check.sh</code> laufen. Bereits importierte Läufe mit gleichem Namen werden ersetzt.</span>
|
||||
<span class="spacer"></span>
|
||||
<button class="primary" onclick={doImport} disabled={importing || !dir.trim() || !model.trim() || batchId === null}>
|
||||
{importing ? "prüfe …" : "Prüfen und speichern"}
|
||||
</button>
|
||||
</div>
|
||||
{#if importError}<p class="error">{importError}</p>{/if}
|
||||
{#if summary}
|
||||
<p class={summary.imported > 0 ? "ok" : "error"}>
|
||||
{summary.imported} Lauf/Läufe geprüft, {summary.passed} bestanden.
|
||||
{#if batchId !== null}<button class="link" onclick={() => onimported(batchId!)}>Ergebnisse ansehen</button>{/if}
|
||||
</p>
|
||||
{#if summary.skipped.length > 0}
|
||||
<details open>
|
||||
<summary class="error">{summary.skipped.length} Ordner nicht geprüft</summary>
|
||||
<ul>
|
||||
{#each summary.skipped as s (s)}<li>{s}</li>{/each}
|
||||
</ul>
|
||||
</details>
|
||||
{/if}
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.notice {
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
|
||||
background: var(--accent-soft);
|
||||
border-radius: 10px;
|
||||
padding: 0.6rem 0.9rem;
|
||||
margin: 0.8rem 0 0;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.gbadge {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
border-radius: 6px;
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 800;
|
||||
margin-right: 0.3rem;
|
||||
}
|
||||
.list {
|
||||
display: grid;
|
||||
gap: 0.25rem;
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
.choice {
|
||||
display: flex;
|
||||
gap: 0.6rem;
|
||||
align-items: baseline;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.7rem 1rem;
|
||||
margin-top: 0.9rem;
|
||||
}
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.rep,
|
||||
.grid label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
.rep input {
|
||||
width: 5rem;
|
||||
color: var(--text);
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.6rem 0.8rem;
|
||||
}
|
||||
.grid .wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.grid input,
|
||||
.grid select {
|
||||
color: var(--text);
|
||||
font-size: 1rem;
|
||||
}
|
||||
.steps {
|
||||
padding-left: 1.2rem;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user