Add /newroaster and a configurable default board

- /newroaster builds a new advisor the way the original seven were built:
  finds and fetches public sources, extracts frameworks, rules, positions,
  stories, and voice with parallel sub-agents, writes the brain, checks every
  quote is verbatim, writes the council agent, and registers the seat.
- roster.json lists every seat, the default board, and how each council
  picks its seats (default, ask, or auto). /roast-room board changes it;
  --seats and --all override it per run.
- The room reads the roster: it seats up to nine, picks up new seats without
  a restart, and draws a talking bust for seats without portraits.
- README and CLAUDE.md explain choosing the board and adding an advisor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nate HerkandClaude Opus 5.5 committed 2026-10-21 08:05:29 -05:00
1 parent f5e7b631a1
commit bc9f45ba0d
21 files changed
+965 -75

No files matched your search

+22 -18
View File
@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { SEATS, byKey, systemFor, parseCard, checkQuotes } from "./seats.mjs";
import { byKey, systemFor, parseCard, checkQuotes, defaultBoard } from "./seats.mjs";
import * as ai from "./anthropic.mjs";
import { S } from "./anthropic.mjs";
import { SESSIONS_DIR } from "./env.mjs";
@@ -10,8 +10,12 @@ export const MODELS = {
chair: process.env.CHAIR_MODEL || "claude-opus-5-5",
};
const CHAIR_SYSTEM = `You are the Chair of a Roast Room council: seven simulated advisors built from the public work of Jeff Bezos (strategy and decisions), Paul Graham (product and startups), Alex Hormozi (offers, pricing, and sales), Gary Vaynerchuk (marketing and attention), Dan Martell (people, hiring, and founder time), Gino Wickman (operations and scaling), and Warren Buffett (money and capital).
You never argue a side and never add your own pillar. You run the room, keep score, and write in plain English: short sentences, no em dashes, no hype, no tee-ups like "here's the thing", no filler. Seat keys (for key fields only): bezos, graham, hormozi, garyvee, martell, wickman, buffett. Whenever you write a seat's name in prose or in a seat field, use its display name: Bezos, Graham, Hormozi, Gary V, Martell, Wickman, Buffett.`;
// The board comes from the roster: the saved default board, or every seat it lists.
const chairSystem = (st) => {
const seats = st.board.map((k) => byKey[k]);
return `You are the Chair of a Roast Room council: ${seats.length} simulated advisors built from the public work of ${seats.map((x) => `${x.name} (${x.pillar.toLowerCase()})`).join(", ")}.
You never argue a side and never add your own pillar. You run the room, keep score, and write in plain English: short sentences, no em dashes, no hype, no tee-ups like "here's the thing", no filler. Seat keys (for key fields only): ${seats.map((x) => x.key).join(", ")}. Whenever you write a seat's name in prose or in a seat field, use its display name: ${seats.map((x) => x.short).join(", ")}.`;
};
export const DISCLAIMER = "Simulated advisors built from each person's public work. They are not the people and do not speak for them.";
@@ -187,11 +191,11 @@ async function chairSetup(st) {
brief: S.str,
options: S.arr(S.obj({ id: S.enum("A", "B", "C", "D"), label: S.str })),
assumptions: S.arr(S.str),
weights: S.arr(S.obj({ seat: S.enum(...SEATS.map((s) => s.key)), weight: S.int, reason: S.str })),
quick_seats: S.arr(S.enum(...SEATS.map((s) => s.key))),
weights: S.arr(S.obj({ seat: S.enum(...st.board), weight: S.int, reason: S.str })),
quick_seats: S.arr(S.enum(...st.board)),
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
model: MODELS.chair, system: chairSystem(st), schema, maxTokens: 3000,
prompt: `A founder brought this to the council:
"""${st.prompt}"""
@@ -203,19 +207,19 @@ Set up the room.
- brief: under 200 words covering the business, resources, what success looks like, and the founder's lean, using only what the founder said. Do not invent facts.
- assumptions: any number or fact you had to assume to make the brief usable, each one line. Keep it to what matters.
- weights: one entry for every seat, weight 1 to 3 (3 = the decision lives in this pillar, 2 = materially affected, 1 = touched at the edges). Exactly one or two seats at 3. Reason in one line.
- quick_seats: the four seats for a quick council: the two highest-weight seats, Buffett or Bezos as the downside check (whichever is not already in), and the seat most likely to disagree with the others.`,
- quick_seats: the four seats for a quick council: the two highest-weight seats, the seat that guards the downside (money, capital, or risk) if it is not already in, and the seat most likely to disagree with the others.`,
});
}
async function chairCruxes(st) {
const schema = S.obj({
cruxes: S.arr(S.obj({ question: S.str, sides: S.arr(S.obj({ position: S.str, seats: S.arr(S.enum(...SEATS.map((s) => s.key))) })) })),
cruxes: S.arr(S.obj({ question: S.str, sides: S.arr(S.obj({ position: S.str, seats: S.arr(S.enum(...st.board)) })) })),
unanimous: S.bool,
note: S.str,
pressure: S.arr(S.obj({ seat: S.enum(...SEATS.map((s) => s.key)), ask: S.str })),
pressure: S.arr(S.obj({ seat: S.enum(...st.board), ask: S.str })),
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
model: MODELS.chair, system: chairSystem(st), schema, maxTokens: 3000,
prompt: `${briefBlock(st)}
ROUND 1 CARDS
@@ -239,7 +243,7 @@ async function chairDraft(st, interim) {
kill_criteria: S.str,
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
model: MODELS.chair, system: chairSystem(st), schema, maxTokens: 3000,
prompt: `${briefBlock(st)}
ROUND 2 CARDS (the debate)
@@ -269,7 +273,7 @@ async function chairVerdict(st, finalScores, recommended) {
revisit: S.str,
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 5000,
model: MODELS.chair, system: chairSystem(st), schema, maxTokens: 5000,
prompt: `${briefBlock(st)}
CRUXES: ${JSON.stringify(st.cruxes)}
@@ -336,18 +340,18 @@ export function startCouncil(prompt, mode = "full") {
}
async function run(s) {
const st = (s.state = { prompt: s.prompt, mode: s.mode, cards: { 1: {}, 2: {}, 3: {} }, scores: {}, rounds: [] });
const st = (s.state = { prompt: s.prompt, mode: s.mode, board: defaultBoard(), cards: { 1: {}, 2: {}, 3: {} }, scores: {}, rounds: [] });
emit(s, "phase", { phase: "setup", label: "The Chair is reading your question" });
const setup = await chairSetup(st);
Object.assign(st, {
title: setup.title, decision: setup.decision, brief: setup.brief,
options: setup.options, assumptions: setup.assumptions,
weights: Object.fromEntries(SEATS.map((x) => [x.key, { weight: 1, reason: "" }])),
weights: Object.fromEntries(st.board.map((k) => [k, { weight: 1, reason: "" }])),
});
for (const w of setup.weights) st.weights[w.seat] = { weight: Math.max(1, Math.min(3, w.weight)), reason: w.reason };
st.seats = s.mode === "quick" ? [...new Set(setup.quick_seats)].slice(0, 4) : SEATS.map((x) => x.key);
for (const w of setup.weights) if (st.weights[w.seat]) st.weights[w.seat] = { weight: Math.max(1, Math.min(3, w.weight)), reason: w.reason };
st.seats = s.mode === "quick" ? [...new Set(setup.quick_seats)].filter((k) => st.board.includes(k)).slice(0, 4) : st.board.slice();
if (s.mode === "quick" && st.seats.length < 4) {
for (const x of SEATS) if (st.seats.length < 4 && !st.seats.includes(x.key)) st.seats.push(x.key);
for (const k of st.board) if (st.seats.length < 4 && !st.seats.includes(k)) st.seats.push(k);
}
emit(s, "setup", { title: st.title, decision: st.decision, brief: st.brief, options: st.options, assumptions: st.assumptions, weights: st.weights, seats: st.seats, mode: s.mode });
@@ -432,7 +436,7 @@ export function save(s) {
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, "events.json"), JSON.stringify({ id: s.id, prompt: s.prompt, mode: s.mode, status: s.status, title: st.title, events: s.events }, null, 1));
if (st.options) {
const lines = [`# ${st.title}`, "", `Asked: ${s.prompt}`, "", st.brief, "", "Options:", ...st.options.map((o) => `- ${o.id}: ${o.label}`), "", "Assumptions:", ...(st.assumptions || []).map((a) => `- ${a}`), "", "| Seat | Weight | Reason |", "|---|---|---|", ...SEATS.map((x) => `| ${x.short} | ${st.weights[x.key].weight} | ${st.weights[x.key].reason} |`)];
const lines = [`# ${st.title}`, "", `Asked: ${s.prompt}`, "", st.brief, "", "Options:", ...st.options.map((o) => `- ${o.id}: ${o.label}`), "", "Assumptions:", ...(st.assumptions || []).map((a) => `- ${a}`), "", "| Seat | Weight | Reason |", "|---|---|---|", ...st.seats.map((k) => `| ${byKey[k].short} | ${st.weights[k].weight} | ${st.weights[k].reason} |`)];
fs.writeFileSync(path.join(dir, "brief.md"), lines.join("\n") + "\n");
}
for (const r of st.rounds || []) {
+1
View File
@@ -8,6 +8,7 @@ export const APP_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)
const KIT = fs.existsSync(path.join(APP_ROOT, "..", ".claude", "skills", "roast-room"));
export const REPO_ROOT = KIT ? path.resolve(APP_ROOT, "..") : path.resolve(APP_ROOT, "..", "..");
export const BRAINS_DIR = path.join(REPO_ROOT, ".claude", "skills", "roast-room", "brains");
export const ROSTER = path.join(REPO_ROOT, ".claude", "skills", "roast-room", "roster.json");
export const AGENTS_DIR = path.join(REPO_ROOT, ".claude", "agents");
export const SESSIONS_DIR = KIT ? path.join(REPO_ROOT, "sessions") : path.join(REPO_ROOT, "projects", "founder-council", "sessions");
+29 -11
View File
@@ -1,17 +1,33 @@
import fs from "node:fs";
import path from "node:path";
import { AGENTS_DIR, BRAINS_DIR } from "./env.mjs";
import { AGENTS_DIR, BRAINS_DIR, ROSTER } from "./env.mjs";
export const SEATS = [
{ key: "bezos", name: "Jeff Bezos", short: "Bezos", initials: "JB", slug: "jeff-bezos", pillar: "Strategy and decisions", question: "Is this the right bet, and how reversible is it?", dimension: "Strategic fit and reversibility", color: "#e8a33d" },
{ key: "graham", name: "Paul Graham", short: "Graham", initials: "PG", slug: "paul-graham", pillar: "Product and startups", question: "Is this something people actually want, and is it growing?", dimension: "Real demand and growth", color: "#f06b3f" },
{ key: "hormozi", name: "Alex Hormozi", short: "Hormozi", initials: "AH", slug: "alex-hormozi", pillar: "Offers, pricing, and sales", question: "Will people pay, how much, and how do we close?", dimension: "Offer strength and unit economics", color: "#d94a6a" },
{ key: "garyvee", name: "Gary Vaynerchuk", short: "Gary V", initials: "GV", slug: "gary-vaynerchuk", pillar: "Marketing and attention", question: "Where does the attention come from, and is it underpriced?", dimension: "Attention and distribution", color: "#9b5de5" },
{ key: "martell", name: "Dan Martell", short: "Martell", initials: "DM", slug: "dan-martell", pillar: "People, hiring, and founder time", question: "Who does this, and what does it cost the founder's calendar?", dimension: "Team capacity and founder time", color: "#3d8bfd" },
{ key: "wickman", name: "Gino Wickman", short: "Wickman", initials: "GW", slug: "gino-wickman", pillar: "Operations and scaling", question: "Can the business run this without the founder holding it together?", dimension: "Operational readiness", color: "#1fa67a" },
{ key: "buffett", name: "Warren Buffett", short: "Buffett", initials: "WB", slug: "warren-buffett", pillar: "Money and capital", question: "What does it do to cash, risk, and long-term value?", dimension: "Downside and capital efficiency", color: "#4c6a92" },
];
export const byKey = Object.fromEntries(SEATS.map((s) => [s.key, s]));
// Every seat lives in the skill's roster.json (the /newroaster skill adds to it). SEATS and
// byKey are filled in place, so a seat added while the room is running shows up on the next
// read without a restart.
export const SEATS = [];
export const byKey = {};
export const BOARD = { mode: "default", default: [] };
let rosterStamp = 0;
export function loadRoster() {
let stat;
try { stat = fs.statSync(ROSTER); } catch { throw new Error(`roster not found at ${ROSTER}`); }
if (stat.mtimeMs === rosterStamp && SEATS.length) return SEATS;
const r = JSON.parse(fs.readFileSync(ROSTER, "utf8"));
const seats = (r.seats || []).filter((s) => s.key && s.slug && fs.existsSync(path.join(AGENTS_DIR, `council-${s.key}.md`)));
SEATS.splice(0, SEATS.length, ...seats);
for (const k of Object.keys(byKey)) delete byKey[k];
for (const s of SEATS) byKey[s.key] = s;
BOARD.mode = ["default", "ask", "auto"].includes(r.board) ? r.board : "default";
const def = (r.default || []).filter((k) => byKey[k]);
BOARD.default = def.length ? def : SEATS.slice(0, 7).map((s) => s.key);
rosterStamp = stat.mtimeMs;
for (const k of [...systemCache.keys()]) if (!byKey[k]) systemCache.delete(k);
brainText.clear();
return SEATS;
}
/** The seats at the table when no one picked: the saved default board. */
export const defaultBoard = () => (loadRoster(), BOARD.default.slice());
const read = (p) => (fs.existsSync(p) ? fs.readFileSync(p, "utf8") : "");
const stripFront = (t) => t.replace(/^---[\s\S]*?\n---\n/, "");
@@ -109,3 +125,5 @@ export function parseCard(text, optionIds) {
thisWeek: field(text, "WHAT I'D DO THIS WEEK"),
};
}
loadRoster();
+3 -2
View File
@@ -8,7 +8,7 @@
// verdict.json -> the verdict
import fs from "node:fs";
import path from "node:path";
import { SEATS, byKey, parseCard, checkQuotes } from "./seats.mjs";
import { SEATS, byKey, parseCard, checkQuotes, loadRoster, defaultBoard } from "./seats.mjs";
import { SESSIONS_DIR } from "./env.mjs";
import { optionScores, finalNumbers, verdictSeats, DISCLAIMER } from "./council.mjs";
@@ -62,6 +62,7 @@ function finish(x, status) {
function normalizeSetup(c) {
const options = (c.options || []).map((o, i) => (typeof o === "string" ? { id: "ABCD"[i], label: o } : { id: String(o.id || "ABCD"[i]).toUpperCase(), label: o.label || o.text || "" }));
loadRoster(); // pick up a seat added since the room started
const weights = Object.fromEntries(SEATS.map((s) => [s.key, { weight: 1, reason: "" }]));
const wl = Array.isArray(c.weights) ? c.weights : Object.entries(c.weights || {}).map(([seat, w]) => (typeof w === "number" ? { seat, weight: w } : { seat, ...w }));
for (const w of wl) { const k = seatKey(w.seat); if (k) weights[k] = { weight: Math.max(1, Math.min(3, Number(w.weight) || 1)), reason: w.reason || "" }; }
@@ -70,7 +71,7 @@ function normalizeSetup(c) {
return {
title: c.title || "Roast Room", decision: c.decision || "", brief: c.brief || "", mode,
options, assumptions: c.assumptions || [], weights,
seats: seats.length ? [...new Set(seats)] : SEATS.map((s) => s.key),
seats: seats.length ? [...new Set(seats)] : defaultBoard(),
};
}
+81 -19
View File
@@ -47,30 +47,61 @@ const GUIDE = `
<div class="guide-sec">
<h4>Good to know</h4>
<ul>
<li><span><b>Full council:</b> 7 advisors, 3 rounds. For big calls that are hard to undo.</span></li>
<li><span><b>Full council:</b> your default board (the 7 advisors out of the box), 3 rounds. For big calls that are hard to undo.</span></li>
<li><span><b>Quick:</b> add <code>--quick</code> for 4 advisors and 2 rounds. Uses far less of your plan.</span></li>
<li><span><b>Every council is saved.</b> Open Past sessions to replay one or download its PDF.</span></li>
<li><span><b>Add an advisor:</b> type <code>/newroaster</code> and a name. Change who sits at the table with <code>/roast-room board</code>.</span></li>
</ul>
</div>
</div>`;
const SHAPES = ["base", "open", "mid", "blink"];
const portrait = (key, shape = "base") => `/portraits/${key}-${shape}.webp`;
// A seat's cartoon frames live in /portraits/<key>-<shape>.webp (or .png, .jpg). A seat added with /newroaster
// may have only a base frame, or none: missing frames fall back to the base frame, then to a
// drawn bust in the seat's color whose mouth and eyes still move.
const portrait = (key, shape = "base") => {
const have = state.byKey[key]?.portraits || {};
return have[shape] || have.base || drawnBust(key, shape);
};
const bustCache = new Map();
function drawnBust(key, shape) {
const id = `${key}-${shape}`;
if (bustCache.has(id)) return bustCache.get(id);
const s = state.byKey[key] || {};
const c = /^#[0-9a-f]{6}$/i.test(s.color || "") ? s.color : "#37bdf8";
const initials = esc((s.initials || s.short || key).slice(0, 3).toUpperCase());
const eyes = shape === "blink"
? `<path d="M226 250h30M304 250h30" stroke="#1d2733" stroke-width="7" stroke-linecap="round"/>`
: `<circle cx="241" cy="250" r="11" fill="#1d2733"/><circle cx="319" cy="250" r="11" fill="#1d2733"/><circle cx="245" cy="246" r="3.5" fill="#fff"/><circle cx="323" cy="246" r="3.5" fill="#fff"/>`;
const mouth = shape === "open" ? `<ellipse cx="280" cy="318" rx="24" ry="17" fill="#5a2430"/>`
: shape === "mid" ? `<ellipse cx="280" cy="316" rx="20" ry="8" fill="#5a2430"/>`
: `<path d="M256 312q24 16 48 0" fill="none" stroke="#5a2430" stroke-width="7" stroke-linecap="round"/>`;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 560 560"><g transform="translate(-14 -64) scale(1.05)">
<path d="M70 640c0-160 86-250 210-250s210 90 210 250z" fill="${c}"/>
<path d="M232 384h96l-48 58z" fill="#e9eef3"/>
<rect x="248" y="330" width="64" height="70" rx="22" fill="#d9b49a"/>
<ellipse cx="280" cy="250" rx="112" ry="128" fill="#e8c4a8"/>
<path d="M168 236c0-90 50-122 112-122s112 32 112 122c-20-46-60-64-112-64s-92 18-112 64z" fill="#3a4654"/>
${eyes}${mouth}
<text x="280" y="540" text-anchor="middle" font-family="Montserrat, Arial, sans-serif" font-weight="800" font-size="54" fill="rgba(255,255,255,.92)">${initials}</text>
</g></svg>`;
const url = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg);
bustCache.set(id, url);
return url;
}
const ROUND_NAME = ["", "Opening", "Debate", "Vote"];
const state = {
seats: [], byKey: {}, session: null, options: [], weights: {}, active: [], round: 0,
seats: [], byKey: {}, board: [], table: [], session: null, options: [], weights: {}, active: [], round: 0,
cards: { 1: {}, 2: {}, 3: {} }, replaying: false, verdict: null, links: [], geo: {}, setup: null, wait: null,
};
// ------------------------------------------------------------- boot
async function boot() {
const r = await fetch("/api/seats").then((x) => x.json());
state.seats = r.seats;
state.byKey = Object.fromEntries(r.seats.map((s) => [s.key, s]));
const r = await refreshSeats();
state.runner = r.runner;
if (r.runner === "api" && !r.hasKey) toast("No ANTHROPIC_API_KEY found in .env. Add it and restart the server.");
renderSeats();
renderSeats(state.board);
renderSamples();
bindUI();
new ResizeObserver(() => { layoutStage(); drawLinks(); }).observe($("#stage"));
@@ -86,6 +117,17 @@ async function boot() {
setInterval(tickWait, 1000);
}
// The roster (every seat, plus the default board) comes from the skill's roster.json.
async function refreshSeats() {
const r = await fetch("/api/seats").then((x) => x.json());
state.seats = r.seats;
state.byKey = Object.fromEntries(r.seats.map((s) => [s.key, s]));
state.board = (r.board?.default || []).filter((k) => state.byKey[k]);
if (!state.board.length) state.board = r.seats.slice(0, 7).map((s) => s.key);
bustCache.clear();
return r;
}
// a council started in Claude Code shows up here on its own
const seenLive = new Set();
async function watchForLive() {
@@ -116,19 +158,28 @@ function renderSamples() {
});
}
function renderSeats() {
$("#seats").innerHTML = state.seats.map((s, i) => `
const MAX_TABLE = 9; // the most busts the table can seat and still read
/** Seat these keys at the table (roster order). Does nothing when they are already seated. */
function renderSeats(keys) {
const order = state.seats.map((s) => s.key);
const want = order.filter((k) => keys.includes(k)).slice(0, MAX_TABLE);
if (want.join() === state.table.join() && $("#seats").children.length) return;
state.table = want;
const seats = want.map((k) => state.byKey[k]);
$("#seats").innerHTML = seats.map((s, i) => `
<div class="seat" id="seat-${s.key}" data-seat="${s.key}" style="--d:-${(i * 1.7) % 6}s" tabindex="0" role="button" aria-label="${esc(s.name)}, ${esc(s.pillar)}. Open card.">
<div class="think" aria-hidden="true"><i></i><i></i><i></i></div>
<div class="bust" data-shape="base">${SHAPES.map((sh) => `<img class="${sh}" src="${portrait(s.key, sh)}" alt="" draggable="false">`).join("")}</div>
</div>`).join("");
$("#plates").innerHTML = state.seats.map((s) => `
$("#plates").innerHTML = seats.map((s) => `
<div class="nameplate" id="plate-${s.key}" data-seat="${s.key}">
<b>${esc(s.short === "Gary V" ? "Gary V" : s.name)}</b>
<small>${esc(s.pillar)}</small>
<div class="meta"><span class="pips" title="Weight on this decision"></span><span class="chip" hidden></span><span class="score" hidden></span></div>
</div>`).join("");
layoutStage();
startBlinking();
}
// The table is an ellipse seen from the front. Seats sit along its far edge: the
@@ -142,11 +193,16 @@ function layoutStage() {
const t = $("#table");
Object.assign(t.style, { left: `${cx - rx}px`, top: `${cy - ry}px`, width: `${rx * 2}px`, height: `${ry * 2}px` });
const edge = (x) => cy - ry * Math.sqrt(Math.max(0, 1 - ((x - cx) / rx) ** 2));
const xs = [0.085, 0.222, 0.361, 0.5, 0.639, 0.778, 0.915];
state.seats.forEach((s, i) => {
// seats spread evenly along the far edge; past seven they shrink to fit
const n = state.table.length;
const xs = n === 1 ? [0.5] : state.table.map((_, i) => 0.085 + (0.83 * i) / (n - 1));
const fit = Math.min(1, 6 / Math.max(1, n - 1));
state.geo = {};
state.table.forEach((k, i) => {
const s = state.byKey[k];
const x = W * xs[i];
const d = ((x - cx) / rx) ** 2;
const size = H * (narrow ? 0.5 + 0.08 * d : 0.37 + 0.07 * d);
const size = H * (narrow ? 0.5 + 0.08 * d : 0.37 + 0.07 * d) * fit;
const bottom = edge(x) + size * 0.2;
const el = $(`#seat-${s.key}`);
Object.assign(el.style, { left: `${x - size / 2}px`, top: `${bottom - size}px`, width: `${size}px`, height: `${size}px`, zIndex: 10 + Math.round(d * 10) });
@@ -161,7 +217,7 @@ function layoutStage() {
} else {
stage.style.paddingTop = "";
// the captions start below the lowest nameplate they could collide with
const inner = [1, 2, 3, 4, 5].map((i) => $(`#plate-${state.seats[i].key}`));
const inner = (n > 2 ? state.table.slice(1, -1) : state.table).map((k) => $(`#plate-${k}`));
const top = Math.max(...inner.map((p) => p.offsetTop + p.offsetHeight / 2)) + H * 0.035;
Object.assign(c.style, { left: `${W * 0.2}px`, width: `${W * 0.6}px`, top: `${top}px`, height: `${H - top - H * 0.09}px` });
}
@@ -268,6 +324,7 @@ function reset() {
$("#panelHead").textContent = "Getting started";
$("#feed").innerHTML = GUIDE;
$$(".vote").forEach((b) => b.remove());
renderSeats(state.board);
$$(".seat").forEach((el) => { el.classList.remove("absent", "speaking", "thinking", "addressed"); $(".bust", el).dataset.shape = "base"; });
$$(".nameplate").forEach((el) => { el.classList.remove("absent", "speaking"); $(".chip", el).hidden = true; $(".score", el).hidden = true; $(".pips", el).innerHTML = ""; });
$("#spot").classList.remove("on");
@@ -329,7 +386,7 @@ async function handle(ev) {
}
break;
}
case "setup": state.setup = ev; onSetup(ev); await player.sleep(1800); break;
case "setup": state.setup = ev; await onSetup(ev); await player.sleep(1800); break;
case "round_start": onRoundStart(ev.round); break;
case "seat_start": $(`#seat-${ev.seat}`)?.classList.add("thinking"); break;
case "seat_done": await onSeatDone(ev); break;
@@ -341,7 +398,11 @@ async function handle(ev) {
}
}
function onSetup(ev) {
async function onSetup(ev) {
if (ev.seats.some((k) => !state.byKey[k])) await refreshSeats(); // a seat added since the page loaded
// seat the default board plus anyone this council called in; past the table's limit, only this council
const both = [...new Set([...state.board, ...ev.seats])];
renderSeats(both.length <= MAX_TABLE ? both : ev.seats);
state.options = ev.options;
state.weights = ev.weights;
state.active = ev.seats;
@@ -350,7 +411,7 @@ function onSetup(ev) {
typeIn($("#topicTitle"));
$("#options").innerHTML = ev.options.map((o) => `
<div class="opt" data-opt="${o.id}"><span class="id">${o.id}</span><span class="label">${esc(o.label)}</span><span class="val">-</span><span class="bar"><i></i></span></div>`).join("");
for (const s of state.seats) {
for (const s of state.table.map((k) => state.byKey[k])) {
const absent = !ev.seats.includes(s.key);
$(`#seat-${s.key}`).classList.toggle("absent", absent);
const pl = $(`#plate-${s.key}`);
@@ -478,6 +539,7 @@ async function speak(key, text, { tag = "", target = null, sub = "" } = {}) {
}
// idle blinking for everyone, so the room feels alive between lines
const blinking = new Set();
function startBlinking() {
const blink = (key) => {
const b = $(`#seat-${key} .bust`);
@@ -487,7 +549,7 @@ function startBlinking() {
}
setTimeout(() => blink(key), 2400 + Math.random() * 4200);
};
state.seats.forEach((s, i) => setTimeout(() => blink(s.key), 600 + i * 530));
state.table.filter((k) => !blinking.has(k)).forEach((k, i) => { blinking.add(k); setTimeout(() => blink(k), 600 + i * 530); });
}
async function onSeatDone(ev) {
@@ -773,7 +835,7 @@ function tickWait() {
const bar = $("#wcBar").parentElement;
const muse = $("#wcMuse");
if (round) {
const seats = state.active.length ? state.active : state.seats.map((s) => s.key);
const seats = state.active.length ? state.active : state.table;
const done = seats.filter((k) => state.cards[round][k]).length;
bar.classList.toggle("indeterminate", done === 0);
$("#wcBar").style.width = done ? Math.round((done / seats.length) * 100) + "%" : "";
+8 -3
View File
@@ -2,14 +2,14 @@ import http from "node:http";
import fs from "node:fs";
import path from "node:path";
import { APP_ROOT, env } from "./lib/env.mjs";
import { SEATS } from "./lib/seats.mjs";
import { loadRoster, BOARD } from "./lib/seats.mjs";
import { startCouncil, getSession, subscribe, listSaved, loadSaved, MODELS } from "./lib/council.mjs";
import { usage } from "./lib/anthropic.mjs";
import * as watch from "./lib/watch.mjs";
const PORT = Number(process.env.PORT) || 4730;
const PUBLIC = path.join(APP_ROOT, "public");
const TYPES = { ".html": "text/html; charset=utf-8", ".js": "text/javascript; charset=utf-8", ".css": "text/css; charset=utf-8", ".svg": "image/svg+xml", ".png": "image/png", ".webp": "image/webp", ".ico": "image/x-icon", ".json": "application/json", ".ttf": "font/ttf", ".txt": "text/plain; charset=utf-8" };
const TYPES = { ".html": "text/html; charset=utf-8", ".js": "text/javascript; charset=utf-8", ".css": "text/css; charset=utf-8", ".svg": "image/svg+xml", ".png": "image/png", ".webp": "image/webp", ".jpg": "image/jpeg", ".ico": "image/x-icon", ".json": "application/json", ".ttf": "font/ttf", ".txt": "text/plain; charset=utf-8" };
let running = null; // one council at a time (API runner)
@@ -33,7 +33,12 @@ const server = http.createServer(async (req, res) => {
const url = new URL(req.url, `http://${req.headers.host}`);
const p = url.pathname;
try {
if (p === "/api/seats") return send(res, 200, { seats: SEATS, models: MODELS, runner: RUNNER, hasKey: Boolean(env("ANTHROPIC_API_KEY")) });
if (p === "/api/seats") {
// portraits: which of the four mouth shapes exist for each seat (a seat with none gets a drawn bust)
const frame = (key, sh) => ["webp", "png", "jpg"].map((x) => `${key}-${sh}.${x}`).find((f) => fs.existsSync(path.join(PUBLIC, "portraits", f)));
const seats = loadRoster().map((s) => ({ ...s, portraits: Object.fromEntries(["base", "open", "mid", "blink"].map((sh) => [sh, frame(s.key, sh)]).filter(([, f]) => f).map(([sh, f]) => [sh, `/portraits/${f}`])) }));
return send(res, 200, { seats, board: BOARD, models: MODELS, runner: RUNNER, hasKey: Boolean(env("ANTHROPIC_API_KEY")) });
}
if (p === "/api/usage") return send(res, 200, usage);
if (p === "/api/council" && req.method === "POST") {
if (RUNNER !== "api") return send(res, 403, { error: "This room is a viewer. Run /roast-room in Claude Code, or set COUNCIL_RUNNER=api in .env." });