agenda: the player's second paper (add/drop deltas, cap-5 recency queue); conflicts self-heal as their own turn; same-verb blocks combine; per-run model selection; substrate-tag syntax rule

This commit is contained in:
2026-11-14 21:15:32 +00:00
parent 711634cc38
commit 5956e44f7a
15 changed files with 627 additions and 71 deletions
+127 -5
View File
@@ -113,14 +113,17 @@ function renderContent(el, text, { extract }) {
let body = String(text ?? '');
let status = null;
let conflict = null;
let agenda = 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 am = body.match(/<agenda>([\s\S]*?)<\/agenda>/);
if (am) { agenda = am[1]; body = body.replace(am[0], ''); }
}
const tags = [];
for (const m of body.matchAll(/<(lost|gained)>([\s\S]*?)<\/\1>/g)) {
for (const m of body.matchAll(/<(lost|gained|add|drop)>([\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}>`), '');
@@ -137,6 +140,16 @@ function renderContent(el, text, { extract }) {
el.appendChild(d);
continue;
}
if (t.startsWith('<')) {
// substrate lines: an opening <tag> is always OOC (invariants.md).
// Known blocks were extracted above; whatever remains is an
// unknown or unbalanced tag — keep it visible, styled as OOC
const d = document.createElement('div');
d.className = 'line ooc';
d.textContent = t;
el.appendChild(d);
continue;
}
const stars = (line.match(/\*/g) ?? []).length;
if (!narr && stars % 2 === 0) {
// balanced: spans carry the registers — mixed lines
@@ -183,7 +196,7 @@ function renderContent(el, text, { extract }) {
}
el.appendChild(wrap);
}
return { status, conflict };
return { status, conflict, agenda };
}
// --- transcript ---------------------------------------------------------------
@@ -222,6 +235,11 @@ function renderTranscript(entries) {
}
flushBundle();
if (e.t === 'msg') {
if (e.m.role === 'user' && e.conflictOnly) {
// the self-heal message: error traffic on its own, never GM prose
t.appendChild(el('div', 'machinery', `[conflict] ${String(e.m.content).replace(/<\/?conflict>/g, '').trim()}`));
continue;
}
if (e.m.role === 'user') gmTurn(e.m.content, 'GM');
else if (e.m.role === 'assistant') playerTurn(e);
continue;
@@ -281,6 +299,47 @@ function renderPaper(paper) {
p.textContent = state.paper.join(', '); // compact, mirroring the <status> wire format
}
// the agenda pane mirrors the wire: the queue numbered from the top,
// exactly as the model cites it
function renderAgenda(agenda) {
state.agenda = agenda ?? [];
const a = $('agenda');
if (!state.agenda.length) {
a.textContent = 'a clear head';
a.classList.add('empty');
return;
}
a.classList.remove('empty');
a.textContent = state.agenda.map((d, i) => `${i}. ${d}`).join('; ');
}
// the GM's out-of-band agenda override: whole-queue replace via agenda-set
function editAgenda() {
$('agenda-edit-area').value = state.agenda.join('\n');
$('agenda').hidden = true;
$('agenda-edit').hidden = true;
$('agenda-editor').hidden = false;
$('agenda-edit-area').focus();
}
function cancelAgendaEdit() {
$('agenda-editor').hidden = true;
$('agenda').hidden = false;
$('agenda-edit').hidden = false;
}
async function saveAgenda() {
const items = $('agenda-edit-area').value
.split('\n').flatMap((l) => l.replace(/^\s*[-*]\s+\d*[.:)]?\s*/, '').split(','))
.map((x) => x.trim()).filter(Boolean);
try {
await api(`/runs/${state.runId}/agenda`, { method: 'POST', body: { items } });
} catch (e) {
banner(e.message);
return; // stay in the editor — nothing was changed
}
cancelAgendaEdit();
render();
}
// the GM's out-of-band override: whole-paper replace via paper-set
function editPaper() {
$('paper-edit-area').value = state.paper.join('\n');
@@ -386,6 +445,7 @@ function show(view) {
$('conflict').hidden = true;
renderMeter(null);
cancelPaperEdit(); // a stale open editor must never leave the pane hidden
cancelAgendaEdit();
if (view !== 'play') $('ask-modal').close();
}
@@ -421,7 +481,7 @@ async function viewHome(seq) {
// the name carries the content facts plus the ownership garnish;
// started-or-forked rides the meta — chrome, never model-facing
card.appendChild(el('span', 'card-name', `${r.display ?? r.id}${ownershipTag(r, mine)}`));
card.appendChild(el('span', 'card-meta', `${r.package} · ${r.forked ? `forked ${fmtUnix(r.forked)}` : `started ${r.created ?? '?'}`} · ring A ${r.fill?.a ?? 0} / B ${r.fill?.b ?? 0} · ${r.id}${r.model ? ` · ${r.model}` : ''}`));
card.appendChild(el('span', 'card-meta', `${r.package} · ${r.forked ? `forked ${fmtUnix(r.forked)}` : `started ${r.created ?? '?'}`} · ring A ${r.fill?.a ?? 0} / B ${r.fill?.b ?? 0} · ${r.id}${r.models?.player ? ` · ${r.models.player}` : ''}`));
card.appendChild(el('span', `card-state ${runStateClass(r)}`, runStateText(r)));
// another user's draft is read-only: the play view says so; your own opens the editor
card.addEventListener('click', () => navigate(r.lastSession || !mine ? `/runs/${r.id}` : `/runs/${r.id}/setup`));
@@ -543,6 +603,46 @@ async function pickPackage(p) {
if ($('create-pc').value === '' && roll?.name) $('create-pc').value = roll.name;
}
// --- models: per-run overrides of the deployment defaults --------------------
//
// The upstream listing is fetched once per session (a live /models
// call every render would hammer the endpoint for a list that rarely
// changes). A select's "" value means "deployment default"; a current
// override missing from the listing stays selectable, so a stale pick
// never silently rewrites itself.
async function modelList() {
if (!state.modelList) state.modelList = await api('/models').catch(() => []);
return state.modelList;
}
function fillModelSelect(sel, current, list, def) {
sel.textContent = '';
const mk = (v, label) => {
const o = el('option', null, label);
o.value = v;
sel.appendChild(o);
};
mk('', `deployment default${def ? ` — ${def}` : ' (unset)'}`);
const opts = [...list];
if (current && !opts.includes(current)) opts.push(current);
for (const m of opts) mk(m, m);
sel.value = current ?? '';
}
async function saveModels(playerSel, housekeeperSel, stateEl) {
try {
await api(`/runs/${state.runId}/model`, {
method: 'POST',
body: { player: playerSel.value || null, housekeeper: housekeeperSel.value || null },
});
stateEl.textContent = 'saved';
} catch (e) {
banner(e.message);
stateEl.textContent = 'not saved';
}
}
// --- setup: the editor + start -----------------------------------------------------
// one list, in bundle-assembly order: the repo-fed system message
@@ -603,8 +703,7 @@ async function viewSetup(id, seq) {
api(`/runs/${id}/files`),
api('/prompts'),
]);
} catch (e) {
if (e.status === 404) {
} catch (e) { if (e.status === 404) {
const from = location.pathname;
navigate('/'); // render() clears the banner first — set it after
banner(`run ${id} is gone — deleted?`);
@@ -641,6 +740,13 @@ async function viewSetup(id, seq) {
varsList.appendChild(row);
}
// models: per-run overrides, selected from the upstream listing
const mlist = await modelList();
if (seq !== state.seq) return;
fillModelSelect($('model-player'), detail.run.models?.player ?? null, mlist, detail.run.modelDefaults?.player);
fillModelSelect($('model-housekeeper'), detail.run.models?.housekeeper ?? null, mlist, detail.run.modelDefaults?.housekeeper);
$('models-state').textContent = '';
const nav = $('setup-files');
nav.textContent = '';
state.fileSpecs = {};
@@ -871,11 +977,13 @@ async function refreshPlay(id, seq) {
+ (mine ? '' : detail.run.owner == null ? ' — ownerless' : ' — spectating');
renderMeter(detail);
renderPaper(detail.paper);
renderAgenda(detail.agenda);
$('conflict').hidden = true;
// spectator mode: read everything, mutate nothing — the fork is the
// way in. Ownerless runs are spectators for everyone alike.
$('paper-edit').hidden = !mine;
$('agenda-edit').hidden = !mine;
$('gm-notes').readOnly = !mine;
let beatNeeded = false;
@@ -900,6 +1008,15 @@ async function refreshPlay(id, seq) {
? 'GM line — Enter sends, Shift+Enter newlines'
: 'spectating — fork this run to continue it as yours';
// models: the owner's per-run overrides
$('models-pane').hidden = !mine;
if (mine) {
const mlist = await modelList();
if (seq !== state.seq) return;
fillModelSelect($('pm-player'), detail.run.models?.player ?? null, mlist, detail.run.modelDefaults?.player);
fillModelSelect($('pm-housekeeper'), detail.run.models?.housekeeper ?? null, mlist, detail.run.modelDefaults?.housekeeper);
}
// pending ask: the modal re-presents after a refresh — the owner's
// to answer; a spectator follows the thread in the transcript
if (detail.pendingAsk && mine) {
@@ -1188,6 +1305,8 @@ $('setup-vars-save').addEventListener('click', async () => {
}
});
$('setup-save').addEventListener('click', saveFile);
$('models-save').addEventListener('click', () => saveModels($('model-player'), $('model-housekeeper'), $('models-state')));
$('pm-save').addEventListener('click', () => saveModels($('pm-player'), $('pm-housekeeper'), $('pm-state')));
$('setup-delete').addEventListener('click', deleteDraft);
$('setup-edit').addEventListener('input', () => {
if (state.currentFile) stashDraft(state.currentFile);
@@ -1215,6 +1334,9 @@ $('hk-replay').addEventListener('click', replayWrap);
$('paper-edit').addEventListener('click', editPaper);
$('paper-cancel').addEventListener('click', cancelPaperEdit);
$('paper-save').addEventListener('click', savePaper);
$('agenda-edit').addEventListener('click', editAgenda);
$('agenda-cancel').addEventListener('click', cancelAgendaEdit);
$('agenda-save').addEventListener('click', saveAgenda);
$('gm-notes').addEventListener('input', notesInput);
$('gm-notes').addEventListener('blur', saveNotes);
window.addEventListener('pagehide', saveNotes); // tab close / reload mid-debounce
+30
View File
@@ -78,6 +78,15 @@
<span id="setup-vars-state"></span>
</div>
</div>
<div id="setup-models">
<h2>models — per-run, over the deployment defaults</h2>
<label class="field">player <select id="model-player"></select></label>
<label class="field">housekeeper <select id="model-housekeeper"></select></label>
<div class="form-actions">
<button id="models-save">save models</button>
<span id="models-state"></span>
</div>
</div>
<div id="setup-savepkg">
<input id="savepkg-name" placeholder="new package display name" autocomplete="off">
<button id="savepkg-btn">save as package</button>
@@ -119,6 +128,20 @@
</div>
<div id="conflict" hidden></div>
</section>
<section id="agenda-pane">
<div class="pane-head">
<h2>her agenda</h2>
<button id="agenda-edit">edit</button>
</div>
<div id="agenda"></div>
<div id="agenda-editor" hidden>
<textarea id="agenda-edit-area" rows="4" placeholder="one item per line, top first — empty clears the agenda"></textarea>
<div class="pane-editor-actions">
<button id="agenda-save">save</button>
<button id="agenda-cancel">cancel</button>
</div>
</div>
</section>
<section id="notes-pane">
<div class="pane-head">
<h2>gm notes</h2>
@@ -141,6 +164,13 @@
<p class="hint">a copy of this run — yours to continue</p>
<button id="fork-btn">fork this run</button>
</section>
<section id="models-pane" hidden>
<h2>models</h2>
<label class="field">player <select id="pm-player"></select></label>
<label class="field">housekeeper <select id="pm-housekeeper"></select></label>
<button id="pm-save">save models</button>
<span id="pm-state"></span>
</section>
</aside>
<footer>
+18 -4
View File
@@ -152,12 +152,18 @@ h1 { font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: v
#setup-savepkg input { flex: 1; }
#savepkg-state { color: var(--dim); font-size: 12px; }
/* --- aside: fork --- */
/* --- aside: fork, models --- */
#fork-pane { margin-top: 22px; }
#fork-pane .hint { margin: 0 0 8px; }
#fork-pane button { width: 100%; }
#models-pane { margin-top: 22px; }
#models-pane .field { margin-bottom: 6px; }
#models-pane .field select { flex: 1; }
#models-pane button { width: 100%; margin-top: 4px; }
#pm-state { color: var(--dim); font-size: 11px; }
/* the naming form (new run) and the vars box (setup) */
#create-form { max-width: 560px; }
#create-form h2 { font-size: 15px; margin: 0 0 14px; color: var(--text); font-weight: 600; }
@@ -165,7 +171,7 @@ h1 { font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: v
.field input { flex: 1; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#setup-vars {
#setup-vars, #setup-models {
max-width: 560px;
border: 1px solid var(--line);
border-radius: 6px;
@@ -173,11 +179,12 @@ h1 { font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: v
padding: 10px 14px;
margin-bottom: 14px;
}
#setup-vars h2 {
#setup-vars h2, #setup-models h2 {
margin: 0 0 10px; font-size: 11px; letter-spacing: 0.14em;
text-transform: uppercase; color: var(--dim); font-weight: normal;
}
#setup-vars-state { color: var(--dim); font-size: 12px; }
#setup-vars-state, #models-state { color: var(--dim); font-size: 12px; }
#setup-models .field select { flex: 1; }
/* --- setup: the editor --- */
@@ -265,6 +272,8 @@ h1 { font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: v
}
.chip.lost { text-decoration: line-through; }
.chip.gained { color: var(--ok); border-color: var(--ok); }
.chip.drop { text-decoration: line-through; }
.chip.add { color: var(--ok); border-color: var(--ok); }
.machinery {
margin: 6px 0; font-size: 12px; color: var(--dim);
@@ -317,6 +326,11 @@ body.play #play-aside { display: block; }
#paper { margin: 0; line-height: 1.5; }
#paper.empty { color: var(--dim); font-style: italic; }
#agenda-pane { margin-top: 16px; }
#agenda { margin: 0; line-height: 1.5; }
#agenda.empty { color: var(--dim); font-style: italic; }
#agenda-editor textarea { width: 100%; resize: vertical; font: 13px/1.5 inherit; }
#paper-editor textarea { width: 100%; resize: vertical; font: 13px/1.5 inherit; }
.pane-editor-actions { display: flex; gap: 6px; margin-top: 6px; }
.pane-editor-actions button { font-size: 12px; padding: 2px 12px; }