substrate: server, housekeeping job, spa - the mvp complete
- prompt split, GM's cut: system.md = opening + guards (glossary, purpose, input validation; repo-fed, per-project); invariants.md = substrate (syntax markers, tools, memory, records, the paper + its three-part gate; repo-fed, travels with the code); handbook.md = craft copy (shape of play, thoughts, purview, time skips, continuity, stance, hard limits; copied per run). One system message: system -> invariants -> the run's handbook. OOC is a single open paren, closing optional, match the GM's style; a lone paren is an empty OOC line, skipped by the parser. housekeeper.md aligned: the paper holds acute states, relational shifts are recorded as the facts behind them, and dates are story dates (follow the rings' calendar, never the wall clock - the seed is 2069 now, per canon) - server/ (phase 2, zero-dep node:http): REST spine per the sketch, per-run session machine with ask_gm pause/resume (the whole tool-call batch waits, pairing stays sound), view renderer (thinking-strip, tool-result elision with ask answers exempt, old status/conflict blocks stripped), boot-rebuild from the typed jsonl, lazy seed + turn-0 ingestion at window-open with the unhousekept refuse-and-override guard, usage tracking + context meter, tool-pairing validation, scripted mock model. The clerk gained --json (packages/runs/status); tool/bridge.mjs deleted at mock-parity per the retirement decision - housekeeping job (phase 3, server/housekeeping.mjs): trigger ends the window and runs the chain async - transcript with labeled thinking, run-state injection (records availability; the ring views stay pure memory), housekeeper on a fresh context, manifest saved (raw output too if unparseable), clerk apply (writes the window log, snapshots dumps/<window>.sql), state.json lastHousekeptSession, autorestart. Rejection holds the restart and surfaces why; the apply endpoint is the recovery path and the manual-relay close. Live-proven twice: both manifests sound (ring-B classification, first-person voice, precise touches, story-dated) - spa (phase 4, web/ - no build, vanilla es modules, served at /): three-register transcript per the ruled markers incl. multi-line narration blocks, bundle as a collapsed card with turn-0 as the opening GM turn, paper tags as chips, status pane with conflict surfacing, context meter hot past 85 percent, gm line input, ask modal re-presented from pendingAsk, housekeeping button with two-click arm + poll + inline log. No js alert/confirm (they block the embedded pane) - in-page banner instead. Driven end to end through the ui on a disposable live run - seed: date fixed to the 2069 story calendar (was a real-world date; real dates never surface to the player) - docs: README goal states the mvp is complete, layout covers server/ and web/, protocol and substrate sections rewritten for the server; ROADMAP phases 0-4 done, harness decisions current; QUESTIONS #4 #7 #10 #12 #16-mechanism #19a #20 #21 resolved; HANDOFF is the handoff map; AGENTS carries the working lessons (tokens are free, no screenshots - not multimodal, no js dialogs, external state survives rewinds)
This commit is contained in:
+482
@@ -0,0 +1,482 @@
|
||||
// web/app.mjs — the SPA: strictly a client of the REST API.
|
||||
//
|
||||
// The transcript renders three registers by the ruled markers: plain
|
||||
// text is speech, *italics* is narration, a line opening with `(` is
|
||||
// OOC (closing paren optional; a lone paren is an empty OOC line and
|
||||
// is skipped). The <status> blocks riding GM turns and the paper tags
|
||||
// on player turns are machinery, not prose — they render as chips and
|
||||
// pane state, mirroring the live-context policy.
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const state = { runId: null, runs: [], packages: [], poll: null };
|
||||
|
||||
async function api(path, opts = {}) {
|
||||
const res = await fetch(`/api${path}`, {
|
||||
method: opts.method ?? 'GET',
|
||||
headers: opts.body !== undefined ? { 'content-type': 'application/json' } : {},
|
||||
body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
const e = new Error(data.error ?? `${res.status}`);
|
||||
e.detail = data.detail;
|
||||
e.status = res.status;
|
||||
throw e;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// --- register rendering -------------------------------------------------------
|
||||
|
||||
// splits text into spans: *italics* = narration, **bold** = emphasis
|
||||
function renderSpans(el, text) {
|
||||
const parts = String(text).split(/(\*\*[^*]+\*\*|\*[^*\n]+\*)/g);
|
||||
for (const p of parts) {
|
||||
if (!p) continue;
|
||||
if (p.startsWith('**') && p.endsWith('**')) {
|
||||
const b = document.createElement('strong');
|
||||
b.textContent = p.slice(2, -2);
|
||||
el.appendChild(b);
|
||||
} else if (p.startsWith('*') && p.endsWith('*') && p.length > 2) {
|
||||
const i = document.createElement('em');
|
||||
i.className = 'narration';
|
||||
i.textContent = p.slice(1, -1);
|
||||
el.appendChild(i);
|
||||
} else {
|
||||
el.appendChild(document.createTextNode(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// one content block (a GM or player turn) -> DOM lines
|
||||
function renderContent(el, text, { extract }) {
|
||||
let body = String(text ?? '');
|
||||
let status = null;
|
||||
let conflict = null;
|
||||
if (extract) {
|
||||
const sm = body.match(/<status>([\s\S]*?)<\/status>/);
|
||||
if (sm) { status = sm[1]; body = body.replace(sm[0], ''); }
|
||||
const cm = body.match(/<conflict>([\s\S]*?)<\/conflict>/);
|
||||
if (cm) { conflict = cm[1]; body = body.replace(cm[0], ''); }
|
||||
}
|
||||
const tags = [];
|
||||
for (const m of body.matchAll(/<(lost|gained)>([\s\S]*?)<\/\1>/g)) {
|
||||
tags.push({ kind: m[1], items: m[2].split('\n').flatMap((l) => l.split(',')).map((x) => x.trim()).filter(Boolean) });
|
||||
}
|
||||
for (const t of tags) body = body.replace(new RegExp(`<${t.kind}>[\\s\\S]*?</${t.kind}>`), '');
|
||||
|
||||
let narr = false; // multi-line narration blocks: open on a leading *, close on a trailing *
|
||||
for (const line of body.split('\n')) {
|
||||
const t = line.trim();
|
||||
if (!t) { el.appendChild(document.createElement('br')); continue; }
|
||||
if (t.startsWith('(')) {
|
||||
if (t === '(') continue; // empty OOC — skip
|
||||
const d = document.createElement('div');
|
||||
d.className = 'line ooc';
|
||||
d.textContent = t;
|
||||
el.appendChild(d);
|
||||
continue;
|
||||
}
|
||||
let isNarr = narr;
|
||||
let content = line;
|
||||
if (!narr && t.startsWith('*') && !t.startsWith('**')) {
|
||||
isNarr = true;
|
||||
narr = true;
|
||||
content = line.replace(/^\s*\*/, '');
|
||||
if (content.trimEnd().endsWith('*')) {
|
||||
narr = false;
|
||||
content = content.trimEnd().slice(0, -1);
|
||||
}
|
||||
} else if (narr) {
|
||||
if (t.endsWith('*')) {
|
||||
narr = false;
|
||||
content = line.trimEnd().slice(0, -1);
|
||||
}
|
||||
}
|
||||
const d = document.createElement('div');
|
||||
d.className = `line ${isNarr ? 'narration' : 'speech'}`;
|
||||
renderSpans(d, content);
|
||||
el.appendChild(d);
|
||||
}
|
||||
if (tags.length) {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'tags';
|
||||
for (const t of tags) {
|
||||
for (const item of t.items) {
|
||||
const c = document.createElement('span');
|
||||
c.className = `chip ${t.kind}`;
|
||||
c.textContent = item;
|
||||
wrap.appendChild(c);
|
||||
}
|
||||
}
|
||||
el.appendChild(wrap);
|
||||
}
|
||||
return { status, conflict };
|
||||
}
|
||||
|
||||
// --- transcript ---------------------------------------------------------------
|
||||
|
||||
function el(tag, cls, text) {
|
||||
const e = document.createElement(tag);
|
||||
if (cls) e.className = cls;
|
||||
if (text !== undefined) e.textContent = text;
|
||||
return e;
|
||||
}
|
||||
|
||||
function renderTranscript(entries) {
|
||||
const t = $('transcript');
|
||||
t.textContent = '';
|
||||
const bundleParts = [];
|
||||
let flushBundle = () => {
|
||||
if (!bundleParts.length) return;
|
||||
const d = el('details', 'bundle');
|
||||
d.appendChild(el('summary', null, `window bundle — ${bundleParts.map((p) => p.part).join(', ')}`));
|
||||
for (const p of bundleParts) {
|
||||
const sec = el('details');
|
||||
sec.appendChild(el('summary', null, p.part));
|
||||
sec.appendChild(el('pre', null, p.m.content));
|
||||
d.appendChild(sec);
|
||||
}
|
||||
t.appendChild(d);
|
||||
bundleParts.length = 0;
|
||||
};
|
||||
|
||||
for (const e of entries) {
|
||||
if (e.t === 'bundle') {
|
||||
if (e.part === 'turn-0') {
|
||||
// the opening beat is fiction: it renders as the first GM turn
|
||||
gmTurn(e.m.content, 'turn-0');
|
||||
continue;
|
||||
}
|
||||
if (e.part !== 'system') bundleParts.push(e);
|
||||
continue;
|
||||
}
|
||||
flushBundle();
|
||||
if (e.t === 'msg') {
|
||||
if (e.m.role === 'user') gmTurn(e.m.content, 'GM');
|
||||
else if (e.m.role === 'assistant') playerTurn(e);
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'tool') {
|
||||
t.appendChild(el('div', 'machinery', `${e.ask ? '[ruling] ' : '[tool result] '}${String(e.m.content).split('\n')[0]}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'note') renderNote(e);
|
||||
}
|
||||
flushBundle();
|
||||
t.scrollTop = t.scrollHeight;
|
||||
|
||||
function gmTurn(content, who) {
|
||||
const d = el('div', 'turn gm');
|
||||
d.appendChild(el('div', 'who', who));
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
const { conflict } = renderContent(body, content, { extract: true });
|
||||
if (conflict) showConflict(conflict);
|
||||
t.appendChild(d);
|
||||
}
|
||||
function playerTurn(e) {
|
||||
const d = el('div', 'turn player');
|
||||
d.appendChild(el('div', 'who', 'player'));
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
if (e.m.reasoning_content) d.appendChild(el('div', 'machinery', '[thinking is logged for the housekeeper, not shown]'));
|
||||
renderContent(body, e.m.content, { extract: false });
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
}
|
||||
t.appendChild(d);
|
||||
}
|
||||
function renderNote(e) {
|
||||
let text = null;
|
||||
if (e.kind === 'window') text = `window opened ${e.at}${e.fresh ? ' — fresh' : ''}`;
|
||||
else if (e.kind === 'seed') text = `seed ${e.ok ? 'applied' : 'failed'}: ${e.detail}`;
|
||||
else if (e.kind === 'ingest') text = `turn-0 paper ingested`;
|
||||
else if (e.kind === 'ask') text = `ask_gm: ${e.question}`;
|
||||
else if (e.kind === 'paper') text = `paper: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
}
|
||||
}
|
||||
|
||||
// --- panes --------------------------------------------------------------------
|
||||
|
||||
function renderPaper(paper) {
|
||||
const ul = $('paper');
|
||||
ul.textContent = '';
|
||||
if (!paper?.length) {
|
||||
ul.appendChild(el('li', 'empty', 'a blank sheet'));
|
||||
return;
|
||||
}
|
||||
for (const p of paper) ul.appendChild(el('li', null, p));
|
||||
}
|
||||
|
||||
function showConflict(text) {
|
||||
const c = $('conflict');
|
||||
c.textContent = `conflict: ${text}`;
|
||||
c.hidden = false;
|
||||
}
|
||||
|
||||
function renderMeter(detail) {
|
||||
const fill = $('context-fill');
|
||||
const label = $('context-label');
|
||||
const c = detail?.context;
|
||||
if (!c || c.used == null) {
|
||||
fill.style.width = '0';
|
||||
label.textContent = '';
|
||||
return;
|
||||
}
|
||||
const pct = c.pct ?? 0;
|
||||
fill.style.width = `${Math.min(100, pct)}%`;
|
||||
fill.classList.toggle('hot', pct > 85);
|
||||
label.textContent = c.window ? `${pct}% — close & housekeep past 85%` : '';
|
||||
}
|
||||
|
||||
function setHk(stateText, cls) {
|
||||
const h = $('hk-state');
|
||||
h.textContent = stateText;
|
||||
h.className = cls ?? '';
|
||||
}
|
||||
|
||||
// --- data flow ----------------------------------------------------------------
|
||||
|
||||
async function loadRuns() {
|
||||
state.runs = await api('/runs');
|
||||
state.packages = await api('/packages');
|
||||
const sel = $('run-select');
|
||||
sel.textContent = '';
|
||||
if (!state.runs.length) {
|
||||
sel.appendChild(el('option', null, '(no runs — create one)'));
|
||||
return;
|
||||
}
|
||||
for (const r of state.runs) {
|
||||
const o = el('option', null, `${r.id} [${r.package}]`);
|
||||
o.value = r.id;
|
||||
sel.appendChild(o);
|
||||
}
|
||||
const saved = localStorage.getItem('run');
|
||||
if (state.runs.some((r) => r.id === saved)) sel.value = saved;
|
||||
state.runId = sel.value || null;
|
||||
}
|
||||
|
||||
async function selectRun(id) {
|
||||
state.runId = id;
|
||||
localStorage.setItem('run', id);
|
||||
stopPoll();
|
||||
await refresh();
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
if (!state.runId) {
|
||||
$('window-info').textContent = '';
|
||||
$('transcript').textContent = '';
|
||||
renderPaper([]);
|
||||
renderMeter(null);
|
||||
setInput(false);
|
||||
return;
|
||||
}
|
||||
const detail = await api(`/runs/${state.runId}`);
|
||||
$('window-info').textContent = detail.open
|
||||
? `window ${detail.window}${detail.fresh ? ' — fresh' : ''}${detail.pendingAsk ? ' — waiting for your answer' : ''}`
|
||||
: 'no open window';
|
||||
renderMeter(detail);
|
||||
renderPaper(detail.paper);
|
||||
$('conflict').hidden = true;
|
||||
if (detail.open) {
|
||||
const session = await api(`/runs/${state.runId}/session`);
|
||||
renderTranscript(session.entries);
|
||||
} else {
|
||||
$('transcript').textContent = '';
|
||||
}
|
||||
|
||||
// controls
|
||||
$('window-open').hidden = detail.open;
|
||||
$('hk-run').hidden = !detail.open;
|
||||
const inputOk = detail.open && !detail.pendingAsk;
|
||||
setInput(inputOk);
|
||||
|
||||
// pending ask: the modal re-presents after a refresh
|
||||
if (detail.pendingAsk) {
|
||||
$('ask-question').textContent = detail.pendingAsk;
|
||||
$('ask-modal').showModal();
|
||||
$('ask-answer').focus();
|
||||
} else {
|
||||
$('ask-modal').close();
|
||||
}
|
||||
|
||||
// housekeeping state
|
||||
const hk = await api(`/runs/${state.runId}/housekeeping`);
|
||||
renderHk(hk, detail);
|
||||
}
|
||||
|
||||
function renderHk(hk, detail) {
|
||||
if (hk.state === 'running') {
|
||||
setHk('housekeeping…', '');
|
||||
startPoll();
|
||||
return;
|
||||
}
|
||||
stopPoll();
|
||||
if (hk.state === 'applied') {
|
||||
setHk(`applied — window ${hk.window ?? ''}\nnext window open`, 'applied');
|
||||
} else if (hk.state === 'rejected') {
|
||||
setHk(`rejected — held, nothing applied:\n${hk.reason ?? ''}`, 'rejected');
|
||||
} else {
|
||||
setHk('idle', '');
|
||||
}
|
||||
}
|
||||
|
||||
function setInput(ok) {
|
||||
$('gm-input').disabled = !ok;
|
||||
$('gm-send').disabled = !ok;
|
||||
}
|
||||
|
||||
// in-page notices — no JS alert()/confirm(): they block the embedded pane
|
||||
let bannerTimer = null;
|
||||
function banner(text, kind = 'error') {
|
||||
const b = $('banner');
|
||||
b.textContent = text;
|
||||
b.className = kind;
|
||||
b.hidden = false;
|
||||
clearTimeout(bannerTimer);
|
||||
bannerTimer = setTimeout(() => { b.hidden = true; }, 10000);
|
||||
}
|
||||
function hideBanner() {
|
||||
$('banner').hidden = true;
|
||||
}
|
||||
|
||||
// --- actions ------------------------------------------------------------------
|
||||
|
||||
async function sendTurn() {
|
||||
const line = $('gm-input').value.trim();
|
||||
if (!line || !state.runId) return;
|
||||
$('gm-input').value = '';
|
||||
setInput(false);
|
||||
try {
|
||||
await api(`/runs/${state.runId}/turn`, { method: 'POST', body: { line } });
|
||||
} catch (e) {
|
||||
$('transcript').appendChild(el('div', 'error-line machinery', `error: ${e.message}`));
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
async function sendAnswer() {
|
||||
const answer = $('ask-answer').value.trim();
|
||||
if (!answer || !state.runId) return;
|
||||
$('ask-answer').value = '';
|
||||
try {
|
||||
await api(`/runs/${state.runId}/ask`, { method: 'POST', body: { answer } });
|
||||
} catch (e) {
|
||||
banner(e.message);
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
async function openWindow() {
|
||||
const override = $('hk-override').checked;
|
||||
hideBanner();
|
||||
try {
|
||||
await api(`/runs/${state.runId}/windows`, { method: 'POST', body: { override } });
|
||||
$('hk-override').checked = false;
|
||||
} catch (e) {
|
||||
if (e.status === 409 && e.detail?.hint) {
|
||||
banner(`${e.message}\n${e.detail.hint}`, 'info');
|
||||
} else {
|
||||
banner(e.message);
|
||||
}
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
// two-click confirm — the second click within 5s fires; anything else disarms
|
||||
let hkArmed = null;
|
||||
async function runHousekeeping() {
|
||||
const btn = $('hk-run');
|
||||
if (hkArmed === null) {
|
||||
btn.textContent = 'sure? click again to close & housekeep';
|
||||
hkArmed = setTimeout(() => {
|
||||
hkArmed = null;
|
||||
btn.textContent = 'close window & housekeep';
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
clearTimeout(hkArmed);
|
||||
hkArmed = null;
|
||||
btn.textContent = 'close window & housekeep';
|
||||
hideBanner();
|
||||
try {
|
||||
await api(`/runs/${state.runId}/housekeeping`, { method: 'POST', body: {} });
|
||||
setHk('housekeeping…', '');
|
||||
startPoll();
|
||||
} catch (e) {
|
||||
banner(e.message);
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
function startPoll() {
|
||||
stopPoll();
|
||||
state.poll = setInterval(async () => {
|
||||
if (!state.runId) return stopPoll();
|
||||
const hk = await api(`/runs/${state.runId}/housekeeping`).catch(() => null);
|
||||
if (!hk || hk.state !== 'running') {
|
||||
await refresh();
|
||||
if (hk?.state === 'applied') loadLog();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
function stopPoll() {
|
||||
if (state.poll) clearInterval(state.poll);
|
||||
state.poll = null;
|
||||
}
|
||||
|
||||
async function loadLog() {
|
||||
try {
|
||||
const log = await api(`/runs/${state.runId}/housekeeping/log`);
|
||||
$('hk-log-content').textContent = log.content;
|
||||
$('hk-log').hidden = false;
|
||||
$('hk-log').open = true;
|
||||
} catch {
|
||||
$('hk-log').hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
// --- wiring -------------------------------------------------------------------
|
||||
|
||||
$('run-select').addEventListener('change', (e) => selectRun(e.target.value));
|
||||
$('gm-send').addEventListener('click', sendTurn);
|
||||
$('gm-input').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendTurn(); }
|
||||
});
|
||||
$('ask-send').addEventListener('click', sendAnswer);
|
||||
$('ask-answer').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendAnswer(); }
|
||||
});
|
||||
$('window-open').addEventListener('click', openWindow);
|
||||
$('hk-run').addEventListener('click', runHousekeeping);
|
||||
$('new-run-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const name = $('new-run-name').value.trim();
|
||||
const pkg = $('new-run-package').value;
|
||||
if (!name || !pkg) return;
|
||||
try {
|
||||
await api('/runs', { method: 'POST', body: { package: pkg, name } });
|
||||
$('new-run-name').value = '';
|
||||
$('new-run').removeAttribute('open');
|
||||
await loadRuns();
|
||||
await selectRun(name);
|
||||
} catch (err) {
|
||||
banner(err.message);
|
||||
}
|
||||
});
|
||||
|
||||
(async function init() {
|
||||
await loadRuns();
|
||||
const pkgSel = $('new-run-package');
|
||||
for (const p of state.packages) {
|
||||
const o = el('option', null, p.name);
|
||||
o.value = p.name;
|
||||
pkgSel.appendChild(o);
|
||||
}
|
||||
if (state.runId) await selectRun(state.runId);
|
||||
else refresh();
|
||||
})();
|
||||
@@ -0,0 +1,62 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>rp-test</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<select id="run-select" title="run"></select>
|
||||
<details id="new-run">
|
||||
<summary>new run</summary>
|
||||
<form id="new-run-form">
|
||||
<select id="new-run-package"></select>
|
||||
<input id="new-run-name" placeholder="run id (slug)" autocomplete="off">
|
||||
<button type="submit">create</button>
|
||||
</form>
|
||||
</details>
|
||||
<div id="window-info"></div>
|
||||
<div id="context-meter" title="context usage of the last call">
|
||||
<div id="context-bar"><div id="context-fill"></div></div>
|
||||
<span id="context-label"></span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section id="transcript" aria-live="polite"></section>
|
||||
</main>
|
||||
|
||||
<aside>
|
||||
<section id="status-pane">
|
||||
<h2>her paper</h2>
|
||||
<ul id="paper"></ul>
|
||||
<div id="conflict" hidden></div>
|
||||
</section>
|
||||
<section id="housekeeping">
|
||||
<h2>housekeeping</h2>
|
||||
<div id="hk-state"></div>
|
||||
<button id="hk-run" hidden>close window & housekeep</button>
|
||||
<label id="hk-override-wrap"><input type="checkbox" id="hk-override"> override: skip the unhousekept check</label>
|
||||
<button id="window-open" hidden>open window</button>
|
||||
<details id="hk-log" hidden><summary>window log</summary><pre id="hk-log-content"></pre></details>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<footer>
|
||||
<div id="banner" hidden></div>
|
||||
<textarea id="gm-input" rows="2" placeholder="GM line — Enter sends, Shift+Enter newlines" disabled></textarea>
|
||||
<button id="gm-send" disabled>send</button>
|
||||
</footer>
|
||||
|
||||
<dialog id="ask-modal">
|
||||
<h2>the player asks</h2>
|
||||
<p id="ask-question"></p>
|
||||
<textarea id="ask-answer" rows="3" placeholder="your ruling — Enter sends"></textarea>
|
||||
<button id="ask-send">answer</button>
|
||||
</dialog>
|
||||
|
||||
<script type="module" src="/app.mjs"></script>
|
||||
</body>
|
||||
</html>
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
/* rp-test SPA — dark, quiet, fiction-first. Three registers: speech is
|
||||
plain, narration is italic (rendered dimmer), OOC is boxed. Machinery
|
||||
(tools, notes, deltas) stays small and muted. */
|
||||
|
||||
:root {
|
||||
--bg: #16161a;
|
||||
--panel: #1e1e24;
|
||||
--line: #2c2c34;
|
||||
--text: #d6d3cb;
|
||||
--dim: #8a877f;
|
||||
--accent: #c9a26d;
|
||||
--danger: #c96d6d;
|
||||
--ok: #7da87d;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: 15px/1.55 ui-sans-serif, system-ui, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
display: grid;
|
||||
grid-template:
|
||||
"header header" auto
|
||||
"main aside" 1fr
|
||||
"footer footer" auto / 1fr 300px;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* --- header --- */
|
||||
|
||||
header {
|
||||
grid-area: header;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 8px 14px;
|
||||
background: var(--panel);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
select, input, textarea, button {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
padding: 5px 8px;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
button { cursor: pointer; }
|
||||
button:hover { border-color: var(--accent); }
|
||||
button:disabled { opacity: 0.4; cursor: default; }
|
||||
|
||||
#new-run summary { cursor: pointer; color: var(--dim); }
|
||||
#new-run form { display: flex; gap: 6px; margin-top: 6px; }
|
||||
|
||||
#window-info { color: var(--dim); font-size: 13px; margin-left: auto; white-space: nowrap; }
|
||||
|
||||
#context-meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
|
||||
#context-bar { width: 90px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
|
||||
#context-fill { height: 100%; width: 0; background: var(--ok); transition: width 0.4s; }
|
||||
#context-fill.hot { background: var(--danger); }
|
||||
|
||||
/* --- transcript --- */
|
||||
|
||||
main { grid-area: main; overflow-y: auto; padding: 18px 22px; }
|
||||
|
||||
.turn { margin: 0 0 20px; max-width: 760px; }
|
||||
.turn .who { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
|
||||
.turn.gm .who { color: var(--accent); }
|
||||
.turn.player .who { color: var(--ok); }
|
||||
|
||||
.line { margin: 2px 0; white-space: pre-wrap; }
|
||||
.narration { color: var(--dim); font-style: italic; }
|
||||
.narration strong { color: var(--text); font-style: italic; }
|
||||
.ooc { color: var(--dim); border-left: 2px solid var(--line); padding-left: 8px; font-size: 13px; }
|
||||
|
||||
.tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
|
||||
.chip {
|
||||
font-size: 11px; padding: 1px 7px; border-radius: 9px;
|
||||
border: 1px solid var(--line); color: var(--dim);
|
||||
}
|
||||
.chip.lost { text-decoration: line-through; }
|
||||
.chip.gained { color: var(--ok); border-color: var(--ok); }
|
||||
.chip.machinery { font-size: 11px; }
|
||||
|
||||
.machinery {
|
||||
margin: 6px 0; font-size: 12px; color: var(--dim);
|
||||
border-left: 2px solid var(--line); padding-left: 8px;
|
||||
}
|
||||
.machinery .head { color: var(--text); }
|
||||
|
||||
/* the bundle: a collapsed card, per part */
|
||||
details.bundle {
|
||||
margin: 14px 0; border: 1px solid var(--line); border-radius: 6px;
|
||||
background: var(--panel); font-size: 13px; color: var(--dim);
|
||||
}
|
||||
details.bundle summary { cursor: pointer; padding: 6px 10px; letter-spacing: 0.06em; }
|
||||
details.bundle pre { margin: 0; padding: 0 12px 10px; white-space: pre-wrap; font: inherit; }
|
||||
|
||||
.error-line { color: var(--danger); }
|
||||
|
||||
/* --- aside --- */
|
||||
|
||||
aside {
|
||||
grid-area: aside;
|
||||
border-left: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
padding: 14px;
|
||||
overflow-y: auto;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
aside h2 {
|
||||
margin: 4px 0 8px; font-size: 11px; letter-spacing: 0.14em;
|
||||
text-transform: uppercase; color: var(--dim); font-weight: normal;
|
||||
}
|
||||
|
||||
#paper { list-style: none; margin: 0; padding: 0; }
|
||||
#paper li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
|
||||
#paper li::before { content: "— "; color: var(--dim); }
|
||||
#paper li.empty { color: var(--dim); font-style: italic; }
|
||||
|
||||
#conflict {
|
||||
margin-top: 10px; padding: 8px; border: 1px solid var(--danger);
|
||||
border-radius: 4px; color: var(--danger); font-size: 12px;
|
||||
}
|
||||
|
||||
#housekeeping { margin-top: 22px; }
|
||||
#hk-state { color: var(--dim); margin-bottom: 8px; white-space: pre-wrap; }
|
||||
#hk-state.rejected { color: var(--danger); }
|
||||
#hk-state.applied { color: var(--ok); }
|
||||
#hk-log pre { white-space: pre-wrap; font-size: 12px; max-height: 40vh; overflow-y: auto; }
|
||||
|
||||
#housekeeping button { width: 100%; margin-top: 6px; }
|
||||
#hk-override-wrap { display: block; margin-top: 6px; color: var(--dim); font-size: 12px; }
|
||||
|
||||
/* --- footer --- */
|
||||
|
||||
footer {
|
||||
grid-area: footer;
|
||||
display: flex; gap: 8px; padding: 10px 14px;
|
||||
background: var(--panel); border-top: 1px solid var(--line);
|
||||
position: relative;
|
||||
}
|
||||
#gm-input { flex: 1; resize: none; }
|
||||
#gm-send { padding: 5px 18px; }
|
||||
|
||||
/* in-page banner — replaces JS alert()/confirm() (they block the
|
||||
embedded pane); errors and notices land here instead */
|
||||
#banner {
|
||||
position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%);
|
||||
max-width: 70%; padding: 8px 14px; border-radius: 6px;
|
||||
background: var(--panel); border: 1px solid var(--danger);
|
||||
color: var(--danger); font-size: 13px; white-space: pre-wrap; z-index: 10;
|
||||
}
|
||||
#banner.info { border-color: var(--accent); color: var(--text); }
|
||||
|
||||
/* --- ask modal --- */
|
||||
|
||||
dialog {
|
||||
background: var(--panel); color: var(--text);
|
||||
border: 1px solid var(--accent); border-radius: 8px;
|
||||
min-width: 380px; max-width: 560px; padding: 18px 20px;
|
||||
}
|
||||
dialog::backdrop { background: rgba(0,0,0,0.6); }
|
||||
dialog h2 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
|
||||
dialog p { margin: 0 0 12px; }
|
||||
dialog textarea { width: 100%; }
|
||||
dialog button { margin-top: 10px; }
|
||||
Reference in New Issue
Block a user