Founder Council: seven AI advisors debate your decision in Claude Code

- /founder-council skill: three-round protocol, scoring, and verdict
- Seven seat agents with brains built from each expert's public work
- The room: a zero-dependency local app that plays councils live from sessions/
- Three example councils to watch before running your own

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nate HerkandClaude Opus 5.5 committed 2026-10-10 15:38:54 -05:00
commit 8a6b473934
143 files changed
+12244

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
import { env } from "./env.mjs";
const URL = "https://api.anthropic.com/v1/messages";
const RETRY = new Set([429, 500, 502, 503, 529]);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
function headers() {
return {
"x-api-key": env("ANTHROPIC_API_KEY"),
"anthropic-version": "2023-06-01",
"content-type": "application/json",
};
}
// Running token tally for the whole app, shown in the UI.
export const usage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, calls: 0 };
function addUsage(u = {}) {
usage.input += u.input_tokens || 0;
usage.output += u.output_tokens || 0;
usage.cacheRead += u.cache_read_input_tokens || 0;
usage.cacheWrite += u.cache_creation_input_tokens || 0;
usage.calls += 1;
}
/** Stream a message; calls onText(delta) as text arrives. Returns the full text. */
export async function stream({ model, system, messages, maxTokens = 2000, onText = () => {} }) {
for (let attempt = 0; attempt < 6; attempt++) {
const res = await fetch(URL, {
method: "POST",
headers: headers(),
body: JSON.stringify({ model, system, messages, max_tokens: maxTokens, stream: true }),
});
if (RETRY.has(res.status)) { await sleep(Math.min(30000, 2000 * 2 ** attempt)); continue; }
if (!res.ok) throw new Error(`Anthropic ${res.status}: ${(await res.text()).slice(0, 300)}`);
let text = "";
let buf = "";
const dec = new TextDecoder();
const finalUsage = {};
for await (const chunk of res.body) {
buf += dec.decode(chunk, { stream: true });
let i;
while ((i = buf.indexOf("\n")) >= 0) {
const line = buf.slice(0, i).trim();
buf = buf.slice(i + 1);
if (!line.startsWith("data:")) continue;
let ev;
try { ev = JSON.parse(line.slice(5)); } catch { continue; }
if (ev.type === "content_block_delta" && ev.delta?.type === "text_delta") {
text += ev.delta.text;
onText(ev.delta.text);
} else if (ev.type === "message_start") {
Object.assign(finalUsage, ev.message?.usage || {});
} else if (ev.type === "message_delta") {
Object.assign(finalUsage, ev.usage || {});
} else if (ev.type === "error") {
throw new Error(`Anthropic stream error: ${JSON.stringify(ev.error).slice(0, 300)}`);
}
}
}
addUsage(finalUsage);
return text;
}
throw new Error("Anthropic API kept refusing after retries");
}
/** One call with structured JSON output matching `schema`. */
export async function json({ model, system, prompt, schema, maxTokens = 4000 }) {
for (let attempt = 0; attempt < 6; attempt++) {
const res = await fetch(URL, {
method: "POST",
headers: headers(),
body: JSON.stringify({
model, system, max_tokens: maxTokens,
output_config: { format: { type: "json_schema", schema } },
messages: [{ role: "user", content: prompt }],
}),
});
if (RETRY.has(res.status)) { await sleep(Math.min(30000, 2000 * 2 ** attempt)); continue; }
if (!res.ok) throw new Error(`Anthropic ${res.status}: ${(await res.text()).slice(0, 300)}`);
const j = await res.json();
addUsage(j.usage);
if (j.stop_reason === "max_tokens") throw new Error("Chair output hit max_tokens");
return JSON.parse(j.content.map((b) => b.text || "").join(""));
}
throw new Error("Anthropic API kept refusing after retries");
}
// JSON schema helpers
export const S = {
str: { type: "string" },
num: { type: "number" },
int: { type: "integer" },
bool: { type: "boolean" },
arr: (items) => ({ type: "array", items }),
obj: (props) => ({ type: "object", properties: props, required: Object.keys(props), additionalProperties: false }),
enum: (...v) => ({ type: "string", enum: v }),
};
+480
View File
@@ -0,0 +1,480 @@
import fs from "node:fs";
import path from "node:path";
import { SEATS, byKey, systemFor, parseCard, checkQuotes } from "./seats.mjs";
import * as ai from "./anthropic.mjs";
import { S } from "./anthropic.mjs";
import { SESSIONS_DIR } from "./env.mjs";
export const MODELS = {
seat: process.env.SEAT_MODEL || "claude-sonnet-5-5",
chair: process.env.CHAIR_MODEL || "claude-opus-5-5",
};
const CHAIR_SYSTEM = `You are the Chair of the Founder 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.`;
export const DISCLAIMER = "Simulated advisors built from each person's public work. They are not the people and do not speak for them.";
// ---------------------------------------------------------------- sessions
const sessions = new Map();
export const getSession = (id) => sessions.get(id);
function slugify(t) {
return (t || "council").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 50) || "council";
}
function newSession(prompt, mode) {
const id = `${new Date().toISOString().slice(0, 10)}-${Date.now().toString(36)}`;
const s = { id, prompt, mode, status: "running", events: [], subs: new Set(), started: Date.now(), state: {} };
sessions.set(id, s);
return s;
}
function emit(s, type, data = {}) {
const ev = { type, t: Date.now() - s.started, ...data };
// text deltas are streamed live but not stored one by one; the final card is stored
if (type !== "delta") s.events.push(ev);
const line = `data: ${JSON.stringify(ev)}\n\n`;
for (const res of s.subs) res.write(line);
}
export function subscribe(s, res) {
for (const ev of s.events) res.write(`data: ${JSON.stringify(ev)}\n\n`);
if (s.status !== "running") { res.write(`data: ${JSON.stringify({ type: "end" })}\n\n`); return; }
s.subs.add(res);
res.on("close", () => s.subs.delete(res));
}
// ---------------------------------------------------------------- prompts
function briefBlock(st) {
const opts = st.options.map((o) => `(${o.id}) ${o.label}`).join("\n");
return `THE DECISION: ${st.decision}\n\nOPTIONS:\n${opts}\n\n${st.brief}\n\nAssumptions the Chair made (marked as assumed; challenge them if they matter):\n${st.assumptions.map((a) => `- ${a}`).join("\n")}`;
}
const optLine = (st) => st.options.map((o) => `${o.id} n/10`).join(" · ");
function round1Prompt(st, seat) {
const w = st.weights[seat.key];
return `FOUNDER COUNCIL, ROUND 1 OF 3: OPENING POSITION
You hold the ${seat.short.toUpperCase()} seat (${seat.pillar}).
THE BRIEF
${briefBlock(st)}
Your weight on this decision: ${w.weight}/3 (${w.reason}).
Answer in your seat's voice, first person, plain text, under 300 words, in exactly this shape:
SEAT: ${seat.short.toUpperCase()} (${seat.pillar})
STANCE: Strong yes | Yes | Conditional yes | No | Strong no (on the option you recommend)
OPTION SCORES: ${optLine(st)}
PILLAR SCORE: n/10 (${seat.dimension}: the option you recommend, judged on your pillar alone)
CONFIDENCE: n/5
RUIN RISK: none | possible | likely
DOOR: one-way | two-way
THE CALL: one sentence, naming the option or a variant.
WHY:
1. argument, naming the framework or principle you used and its source id, e.g. (Value Equation, S014)
2. ...
3. ...
THE RISK I SEE: the single biggest thing that goes wrong.
WHAT WOULD CHANGE MY MIND: a concrete fact or number.
WHAT I'D DO THIS WEEK: one action.
QUESTION FOR THE FOUNDER: the one question you would ask before signing off.
Rules: argue from your pillar first. Use real numbers when the brief has them, and say which numbers you are assuming. Quote only verbatim lines from your brain, with the source id. Do not hedge to sound balanced; the Chair balances the council.`;
}
function cardsBlock(st, round) {
return st.seats.map((k) => `### ${byKey[k].short} (weight ${st.weights[k].weight})\n${st.cards[round][k]?.text || "(no card)"}`).join("\n\n");
}
function round2Prompt(st, seat) {
const cr = st.cruxes.map((c, i) => `${i + 1}. ${c.question} (${c.sides.map((x) => `${x.position}: ${x.seats.map((k) => byKey[k]?.short || k).join(", ")}`).join("; ")})`).join("\n");
const push = st.pressure?.[seat.key] ? `\nFor you specifically: ${st.pressure[seat.key]}\n` : "";
return `FOUNDER COUNCIL, ROUND 2 OF 3: DEBATE
You hold the ${seat.short.toUpperCase()} seat.
THE BRIEF
${briefBlock(st)}
ROUND 1, EVERY SEAT'S CARD
${cardsBlock(st, 1)}
THE CRUXES THE CHAIR SEES
${cr}
${push}
Answer in your seat's voice, first person, plain text, under 280 words, in exactly this shape:
SEAT: ${seat.short.toUpperCase()}
I DISAGREE MOST WITH: [seat name]. Their argument, in one line, then your rebuttal using your frameworks.
I CONCEDE: the strongest point another seat made against you, and what it changes. "Nothing" only if you can say why their best point fails.
ON THE CRUXES: your answer to each crux, one or two lines each.
STANCE: ...
OPTION SCORES: ${optLine(st)}
PILLAR SCORE: n/10
CONFIDENCE: n/5
RUIN RISK: none | possible | likely
MOVED: no | yes, from X to Y, because ...
MY CONDITIONS FOR YES: up to three, concrete and checkable (a number, a date, a test result).
Rules: engage the actual arguments on the table. Move only for a better argument, never to be agreeable. If everyone agrees with you, attack the weakest part of your own case.`;
}
function round3Prompt(st, seat) {
const d = st.draft;
return `FOUNDER COUNCIL, ROUND 3 OF 3: VOTE ON THE DRAFT RESOLUTION
You hold the ${seat.short.toUpperCase()} seat.
THE BRIEF
${briefBlock(st)}
YOUR ROUND 2 CARD
${st.cards[2][seat.key]?.text || ""}
THE CHAIR'S DRAFT RESOLUTION
Recommendation: ${d.label} on option ${d.option}. ${d.recommendation}
Conditions:
${d.conditions.map((c) => `- ${c}`).join("\n")}
Next steps:
${d.next_steps.map((c) => `- ${c}`).join("\n")}
Cheapest test: ${d.cheapest_test}
Kill criteria: ${d.kill_criteria}
Answer in your seat's voice, first person, under 140 words, in exactly this shape:
SEAT: ${seat.short.toUpperCase()}
VOTE: Endorse | Endorse with amendment | Dissent
OPTION SCORES: ${optLine(st)} (given the resolution's conditions)
FINAL SCORE: n/10 (your support for the draft resolution as written)
FINAL PILLAR SCORE: n/10
AMENDMENT OR DISSENT: one or two sentences. Blank if you endorse.
ONE LINE FOR THE FOUNDER: the thing from your pillar they must not forget.`;
}
// ---------------------------------------------------------------- scoring
export function optionScores(st, round) {
const out = {};
for (const o of st.options) {
let num = 0, den = 0;
const parts = [];
for (const k of st.seats) {
const v = st.cards[round][k]?.parsed.optionScores[o.id];
const w = st.weights[k].weight;
if (typeof v === "number") { num += w * v; den += w; parts.push(`${w}x${v}`); }
}
out[o.id] = { score: den ? Math.round((num / den) * 10) / 10 : null, math: den ? `(${parts.join(" + ")}) / ${den}` : "" };
}
return out;
}
function bandFor(score) {
if (score == null) return "RESHAPE";
if (score >= 7.5) return "GO";
if (score >= 6) return "GO WITH CONDITIONS";
if (score >= 4.5) return "RESHAPE";
return "DON'T DO IT";
}
// ---------------------------------------------------------------- chair calls
async function chairSetup(st) {
const schema = S.obj({
title: S.str,
decision: S.str,
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))),
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
prompt: `A founder brought this to the council:
"""${st.prompt}"""
Set up the room.
- title: the decision in 3 to 7 words.
- decision: one line.
- options: 2 to 4 options with ids A, B, C (D only if truly needed). Always include "don't do it" or "keep doing what you do now", and the obvious smaller version if the founder brought one big idea.
- 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.`,
});
}
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))) })) })),
unanimous: S.bool,
note: S.str,
pressure: S.arr(S.obj({ seat: S.enum(...SEATS.map((s) => s.key)), ask: S.str })),
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
prompt: `${briefBlock(st)}
ROUND 1 CARDS
${cardsBlock(st, 1)}
Name the one to three cruxes: the underlying disagreements that explain why seats split (a fact, a number, or a value such as speed versus safety), with the seats on each side.
Unanimity check: if every seat's top option is the same and their scores for it sit within 1 point, set unanimous true, make the strongest unargued alternative a crux, and say which seats whose pillars are most at risk must argue it at full strength.
note: one or two plain sentences for the founder on what the room is fighting about.
pressure: for each seat that holds a minority view, or that the unanimity check names, one sentence telling it exactly which argument it must answer in Round 2. Leave others out.`,
});
}
async function chairDraft(st, interim) {
const schema = S.obj({
option: S.str,
label: S.enum("GO", "GO WITH CONDITIONS", "RESHAPE", "WAIT", "DON'T DO IT"),
recommendation: S.str,
conditions: S.arr(S.str),
next_steps: S.arr(S.str),
cheapest_test: S.str,
kill_criteria: S.str,
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 3000,
prompt: `${briefBlock(st)}
ROUND 2 CARDS (the debate)
${cardsBlock(st, 2)}
Interim weighted option scores: ${JSON.stringify(Object.fromEntries(Object.entries(interim).map(([k, v]) => [k, v.score])))}
Band rule: 7.5+ GO, 6.0 to 7.4 GO WITH CONDITIONS, 4.5 to 5.9 RESHAPE, under 4.5 DON'T DO IT. Use WAIT when the top option is good but depends on a prerequisite not met yet. Overrides: any seat at RUIN RISK likely caps at RESHAPE until a mitigation it endorsed is in the conditions.
Write the draft resolution. Weigh arguments, not headcount: one seat with a decisive fact beats three with vibes. Merge duplicate conditions, keep each checkable (a number or a date), and where seats gave different numbers pick one and say whose. Next steps carry dates or day counts. recommendation is one or two sentences.`,
});
}
async function chairVerdict(st, finalScores, recommended) {
const lastRound = st.rounds.at(-1);
const schema = S.obj({
label: S.enum("GO", "GO WITH CONDITIONS", "RESHAPE", "WAIT", "DON'T DO IT"),
call: S.str,
override_note: S.str,
why: S.arr(S.obj({ point: S.str, seat: S.str, framework: S.str })),
fights: S.arr(S.obj({ crux: S.str, story: S.str })),
minority: S.obj({ seat: S.str, quote: S.str, would_have_to_be_true: S.str }),
amendments: S.arr(S.obj({ seat: S.str, amendment: S.str, adopted: S.bool, reason: S.str })),
conditions: S.arr(S.str),
next_steps: S.arr(S.obj({ when: S.str, action: S.str })),
cheapest_test: S.str,
kill_criteria: S.str,
revisit: S.str,
});
return ai.json({
model: MODELS.chair, system: CHAIR_SYSTEM, schema, maxTokens: 5000,
prompt: `${briefBlock(st)}
CRUXES: ${JSON.stringify(st.cruxes)}
ROUND 2 CARDS
${cardsBlock(st, 2)}
${lastRound === 3 ? `DRAFT RESOLUTION\n${JSON.stringify(st.draft)}\n\nROUND 3 VOTES\n${cardsBlock(st, 3)}` : "(Quick mode: Round 3 skipped.)"}
FINAL WEIGHTED OPTION SCORES (computed, do not change): ${JSON.stringify(Object.fromEntries(Object.entries(finalScores).map(([k, v]) => [k, v.score])))}
Recommended option by score: ${recommended}. Band for it: ${bandFor(finalScores[recommended]?.score)}.
Any seat at ruin risk likely: ${st.seats.filter((k) => st.cards[lastRound][k]?.parsed.ruin === "likely" || st.cards[2][k]?.parsed.ruin === "likely").join(", ") || "none"}.
Write the verdict for the founder.
- label: the band, or WAIT if the recommended option depends on an unmet prerequisite, or a cap from an override. If you change the band, say why in override_note; otherwise override_note is "".
- call: one or two sentences the founder can act on, naming the option.
- why: 3 to 5 arguments that carried the room, each tagged with the seat and the framework.
- fights: one entry per crux: who was on each side, who moved and why, how it resolved.
- minority: the strongest losing view; quote copies the seat's own words exactly from a card; would_have_to_be_true in one line. If unanimous, use the least-tested assumption instead.
- amendments: every Round 3 amendment, adopted or not, with the reason (empty in quick mode). Adopt when no seat objected or the argument went unanswered.
- conditions, next_steps (with when), cheapest_test, kill_criteria, revisit: final, merged, checkable.`,
});
}
// ---------------------------------------------------------------- the run
async function runSeat(s, st, round, key, prompt) {
const seat = byKey[key];
emit(s, "seat_start", { round, seat: key });
let text = "";
try {
text = await ai.stream({
model: MODELS.seat, system: systemFor(key), maxTokens: 1400,
messages: [{ role: "user", content: prompt }],
onText: (d) => { text += d; emit(s, "delta", { round, seat: key, text: d }); },
});
} catch (e) {
emit(s, "seat_error", { round, seat: key, error: String(e.message || e) });
throw e;
}
const parsed = parseCard(text, st.options.map((o) => o.id));
const quotes = checkQuotes(key, text);
st.cards[round][key] = { text, parsed, quotes };
emit(s, "seat_done", { round, seat: key, text, parsed, quotes, name: seat.name });
}
async function roundAll(s, st, round, promptFn) {
emit(s, "round_start", { round });
// stagger starts slightly so speech bubbles open in a ripple around the table
await Promise.all(st.seats.map((k, i) => new Promise((r) => setTimeout(r, i * 350)).then(() => runSeat(s, st, round, k, promptFn(st, byKey[k])))));
const scores = optionScores(st, round);
st.scores[round] = scores;
emit(s, "round_done", { round, scores });
}
export function startCouncil(prompt, mode = "full") {
const s = newSession(prompt, mode);
run(s).catch((e) => {
s.status = "error";
emit(s, "error", { error: String(e.message || e) });
for (const res of s.subs) res.write(`data: ${JSON.stringify({ type: "end" })}\n\n`);
save(s);
});
return s;
}
async function run(s) {
const st = (s.state = { prompt: s.prompt, mode: s.mode, 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: "" }])),
});
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);
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);
}
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 });
emit(s, "phase", { phase: "round1", label: "Round 1: opening positions" });
st.rounds.push(1);
await roundAll(s, st, 1, round1Prompt);
emit(s, "phase", { phase: "cruxes", label: "The Chair is finding the fault lines" });
const cx = await chairCruxes(st);
st.cruxes = cx.cruxes;
st.pressure = Object.fromEntries((cx.pressure || []).map((p) => [p.seat, p.ask]));
emit(s, "cruxes", { cruxes: cx.cruxes, unanimous: cx.unanimous, note: cx.note, pressure: st.pressure });
emit(s, "phase", { phase: "round2", label: "Round 2: the debate" });
st.rounds.push(2);
await roundAll(s, st, 2, round2Prompt);
const s2 = st.scores[2];
const top2 = Object.entries(s2).sort((a, b) => (b[1].score ?? 0) - (a[1].score ?? 0))[0][0];
const vals = st.seats.map((k) => st.cards[2][k]?.parsed.optionScores[top2]).filter((v) => typeof v === "number");
const spread = vals.length ? Math.max(...vals) - Math.min(...vals) : 0;
const ruin = st.seats.some((k) => st.cards[2][k]?.parsed.ruin === "likely");
const skip3 = s.mode === "quick" && spread <= 3 && !ruin;
if (!skip3) {
emit(s, "phase", { phase: "draft", label: "The Chair is drafting a resolution" });
st.draft = await chairDraft(st, s2);
emit(s, "draft", { draft: st.draft });
emit(s, "phase", { phase: "round3", label: "Round 3: the vote" });
st.rounds.push(3);
await roundAll(s, st, 3, round3Prompt);
} else {
emit(s, "phase", { phase: "skip3", label: `Quick mode: spread ${spread} and no ruin risk, so the vote round is skipped` });
}
const { last, finalScores, recommended, spreadF, confidence, support, votes } = finalNumbers(st);
emit(s, "phase", { phase: "verdict", label: "The Chair is writing the verdict" });
const v = await chairVerdict(st, finalScores, recommended);
st.verdict = { ...v, recommended, scores: finalScores, spread: spreadF, confidence, support, votes, disclaimer: DISCLAIMER };
emit(s, "verdict", { verdict: st.verdict, seats: verdictSeats(st, last) });
s.status = "done";
emit(s, "usage", { usage: ai.usage });
for (const res of s.subs) res.write(`data: ${JSON.stringify({ type: "end" })}\n\n`);
save(s);
}
/** The verdict's numbers, computed from the last round's cards (shared with the folder watcher). */
export function finalNumbers(st) {
const last = st.rounds.at(-1);
const finalScores = st.scores[last] || optionScores(st, last);
const recommended = Object.entries(finalScores).sort((a, b) => (b[1].score ?? 0) - (a[1].score ?? 0))[0][0];
const fv = st.seats.map((k) => st.cards[last][k]?.parsed.optionScores[recommended]).filter((v) => typeof v === "number");
const confs = st.seats.map((k) => st.cards[2][k]?.parsed.confidence ?? st.cards[1][k]?.parsed.confidence).filter((v) => typeof v === "number");
const spreadF = fv.length ? Math.max(...fv) - Math.min(...fv) : 0;
const confidence = confs.length ? Math.max(1, Math.min(10, Math.round((confs.reduce((a, b) => a + b, 0) / confs.length) * 2) - (spreadF >= 5 ? 1 : 0))) : null;
const support = last === 3 ? (() => {
let n = 0, d = 0;
for (const k of st.seats) { const v = st.cards[3][k]?.parsed.finalScore; if (typeof v === "number") { n += v * st.weights[k].weight; d += st.weights[k].weight; } }
return d ? Math.round((n / d) * 10) / 10 : null;
})() : null;
const votes = last === 3 ? st.seats.reduce((acc, k) => { const v = st.cards[3][k]?.parsed.vote || "endorse"; acc[v] = (acc[v] || 0) + 1; return acc; }, {}) : null;
return { last, finalScores, recommended, spreadF, confidence, support, votes };
}
export function verdictSeats(st, last) {
return st.seats.map((k) => ({
key: k, weight: st.weights[k].weight,
stance: st.cards[last][k]?.parsed.vote || st.cards[2][k]?.parsed.stance,
optionScores: st.cards[last][k]?.parsed.optionScores,
pillar: st.cards[last][k]?.parsed.pillar ?? st.cards[2][k]?.parsed.pillar,
moved: st.cards[2][k]?.parsed.moved,
oneLine: st.cards[3][k]?.parsed.oneLine || st.cards[2][k]?.parsed.stance,
}));
}
// ---------------------------------------------------------------- persistence
export function save(s) {
try {
const st = s.state || {};
const dir = path.join(SESSIONS_DIR, `${s.id.slice(0, 10)}-${slugify(st.title || s.prompt)}`);
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} |`)];
fs.writeFileSync(path.join(dir, "brief.md"), lines.join("\n") + "\n");
}
for (const r of st.rounds || []) {
const body = (st.seats || []).map((k) => `## ${byKey[k].name} (weight ${st.weights[k].weight})\n\n${st.cards[r][k]?.text || ""}`).join("\n\n");
fs.writeFileSync(path.join(dir, `round-${r}.md`), `# Round ${r}\n\n${body}\n`);
}
if (st.verdict) fs.writeFileSync(path.join(dir, "verdict.md"), verdictMarkdown(st));
s.dir = dir;
} catch (e) {
console.error("save failed", e);
}
}
function verdictMarkdown(st) {
const v = st.verdict;
const opt = (id) => st.options.find((o) => o.id === id)?.label || id;
const L = [];
L.push(`# Founder Council: ${st.title}`, "", `${new Date().toISOString().slice(0, 10)} · Seats: ${st.seats.map((k) => byKey[k].short).join(", ")} · Rounds: ${st.rounds.length} · Mode: ${st.mode}`, "");
L.push(`## Verdict: ${v.label} (Option ${v.recommended}: ${opt(v.recommended)})`, "", `**The call:** ${v.call}`, "");
L.push(`Option scores: ${st.options.map((o) => `${o.id} ${v.scores[o.id]?.score ?? "-"}`).join(" · ")}${v.support != null ? ` · Support for the resolution ${v.support}/10` : ""} · Confidence ${v.confidence ?? "-"}/10 · Spread ${v.spread}`);
if (v.override_note) L.push("", v.override_note);
L.push("", "Math: " + st.options.map((o) => `${o.id} ${v.scores[o.id]?.math} = ${v.scores[o.id]?.score}`).join(" · "));
L.push("", "## Why the council landed here", "", ...v.why.map((w) => `- ${w.point} (${w.seat}, ${w.framework})`));
L.push("", "## Where they fought", "", ...v.fights.map((f) => `- **${f.crux}** ${f.story}`));
L.push("", "## Minority report", "", `${v.minority.seat}: "${v.minority.quote}" For this to be right: ${v.minority.would_have_to_be_true}`);
if (v.amendments?.length) L.push("", "## Amendments", "", ...v.amendments.map((a) => `- ${a.seat}: ${a.amendment} ${a.adopted ? "Adopted" : "Not adopted"}: ${a.reason}`));
L.push("", "## Conditions", "", ...v.conditions.map((c, i) => `${i + 1}. ${c}`));
L.push("", "## What to do next", "", ...v.next_steps.map((n) => `- **${n.when}:** ${n.action}`));
L.push("", `**Cheapest test:** ${v.cheapest_test}`, `**Kill criteria:** ${v.kill_criteria}`, `**Revisit:** ${v.revisit}`, "", "---", DISCLAIMER, "");
return L.join("\n");
}
export function listSaved() {
if (!fs.existsSync(SESSIONS_DIR)) return [];
return fs.readdirSync(SESSIONS_DIR)
.map((d) => path.join(SESSIONS_DIR, d, "events.json"))
.filter((p) => fs.existsSync(p))
.map((p) => { const j = JSON.parse(fs.readFileSync(p, "utf8")); return { id: j.id, title: j.title || j.prompt.slice(0, 60), prompt: j.prompt, mode: j.mode, status: j.status, file: p }; })
.sort((a, b) => (a.id < b.id ? 1 : -1));
}
export function loadSaved(id) {
const hit = listSaved().find((x) => x.id === id);
return hit ? JSON.parse(fs.readFileSync(hit.file, "utf8")) : null;
}
+28
View File
@@ -0,0 +1,28 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
export const APP_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
// Two layouts: nested two folders deep in a larger workspace, or the standalone
// student repo (app/ beside .claude/). The kit has .claude one level up.
const KIT = fs.existsSync(path.join(APP_ROOT, "..", ".claude", "skills", "founder-council"));
export const REPO_ROOT = KIT ? path.resolve(APP_ROOT, "..") : path.resolve(APP_ROOT, "..", "..");
export const BRAINS_DIR = path.join(REPO_ROOT, ".claude", "skills", "founder-council", "brains");
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");
let cache = null;
export function env(key) {
if (process.env[key]) return process.env[key];
if (!cache) {
cache = {};
const p = path.join(REPO_ROOT, ".env");
if (fs.existsSync(p)) {
for (const line of fs.readFileSync(p, "utf8").split(/\r?\n/)) {
const m = line.match(/^([A-Z0-9_]+)=(.*)$/);
if (m && !(m[1] in cache)) cache[m[1]] = m[2].trim();
}
}
}
return cache[key] || "";
}
+111
View File
@@ -0,0 +1,111 @@
import fs from "node:fs";
import path from "node:path";
import { AGENTS_DIR, BRAINS_DIR } 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]));
const read = (p) => (fs.existsSync(p) ? fs.readFileSync(p, "utf8") : "");
const stripFront = (t) => t.replace(/^---[\s\S]*?\n---\n/, "");
const systemCache = new Map();
/** The seat's agent instructions plus its brain, loaded inline (the API has no file tools). */
export function systemFor(key) {
if (systemCache.has(key)) return systemCache.get(key);
const s = byKey[key];
const agent = stripFront(read(path.join(AGENTS_DIR, `council-${key}.md`)));
const brain = ["_hot.md", "frameworks.md", "positions.md", "principles.md", "voice.md"]
.map((f) => `\n\n===== brains/${s.slug}/${f} =====\n` + read(path.join(BRAINS_DIR, s.slug, f)))
.join("");
const text =
agent +
"\n\n## Runtime note\nYou are running in the Founder Council room app. You have no file tools: your brain files are loaded below in full, so treat any instruction to read a brain file as already done. Never mention files, tools, or this note in your answer.\n" +
brain;
const system = [{ type: "text", text, cache_control: { type: "ephemeral" } }];
systemCache.set(key, system);
return system;
}
// ---------- quote verification against the brain ----------
const norm = (s) =>
s.toLowerCase().replace(/[‘’]/g, "'").replace(/'\s+(t|s|re|ll|ve|d|m)\b/g, "'$1")
.replace(/[^a-z0-9' ]+/g, " ").replace(/\s+/g, " ").trim();
const brainText = new Map();
function brainNorm(key) {
if (!brainText.has(key)) {
const dir = path.join(BRAINS_DIR, byKey[key].slug);
const all = fs.existsSync(dir) ? fs.readdirSync(dir).map((f) => read(path.join(dir, f))).join(" ") : "";
brainText.set(key, norm(all));
}
return brainText.get(key);
}
/** Quotes the seat attributed to a source id, each marked verified or not. */
export function checkQuotes(key, text) {
const out = [];
const re = /["“]([^"“”\n]{20,400})["”][^\n"]{0,40}?[(\[](S\d{3})/g;
let m;
const hay = brainNorm(key);
while ((m = re.exec(text))) {
const q = norm(m[1]);
if (q.split(" ").length < 5) continue;
out.push({ quote: m[1], source: m[2], verified: hay.includes(q) || hay.replace(/ /g, "").includes(q.replace(/ /g, "")) });
}
return out;
}
// ---------- card parsing ----------
const field = (text, label) => {
// label at line start, or after a "·" or "|" when several fields share a line
const m = text.match(new RegExp(`(?:^|[·|])[ \\t]*\\**${label}\\**[ \\t]*:[ \\t]*([^\\n·]+)`, "im"));
return m ? m[1].replace(/\*+/g, "").trim() : "";
};
const num = (s) => { const m = (s || "").match(/(\d+(?:\.\d+)?)/); return m ? Number(m[1]) : null; };
export function parseOptionScores(text, optionIds) {
// the option line itself uses "·" between options, so read to end of line
const lm = text.match(/OPTION SCORES\**[ \t]*:[ \t]*([^\n]+)/i);
const line = (lm ? lm[1] : "").split(/PILLAR SCORE|CONFIDENCE|FINAL SCORE/i)[0];
const scores = {};
for (const id of optionIds) {
const m = line.match(new RegExp(`\\b${id}\\b\\s*[:=]?\\s*(\\d+(?:\\.\\d+)?)`));
if (m) scores[id] = Math.max(0, Math.min(10, Number(m[1])));
}
return scores;
}
export function parseCard(text, optionIds) {
const stance = field(text, "STANCE");
const ruin = (field(text, "RUIN RISK").match(/none|possible|likely/i) || [""])[0].toLowerCase();
const disagree = field(text, "I DISAGREE MOST WITH");
const target = SEATS.find((s) => new RegExp(`\\b(${s.short}|${s.name.split(" ").pop()})\\b`, "i").test(disagree.slice(0, 40)));
const voteRaw = field(text, "VOTE");
const vote = /dissent/i.test(voteRaw) ? "dissent" : /amend/i.test(voteRaw) ? "amend" : /endorse/i.test(voteRaw) ? "endorse" : "";
return {
stance,
call: field(text, "THE CALL"),
optionScores: parseOptionScores(text, optionIds),
pillar: num(field(text, "PILLAR SCORE")) ?? num(field(text, "FINAL PILLAR SCORE")),
finalScore: num(field(text, "FINAL SCORE")),
confidence: num(field(text, "CONFIDENCE")),
ruin,
door: (field(text, "DOOR").match(/one-way|two-way/i) || [""])[0].toLowerCase(),
disagreeWith: target ? target.key : null,
disagreeLine: disagree,
concede: field(text, "I CONCEDE"),
moved: field(text, "MOVED"),
vote,
amendment: field(text, "AMENDMENT OR DISSENT"),
oneLine: field(text, "ONE LINE FOR THE FOUNDER"),
question: field(text, "QUESTION FOR THE FOUNDER"),
risk: field(text, "THE RISK I SEE"),
thisWeek: field(text, "WHAT I'D DO THIS WEEK"),
};
}
+222
View File
@@ -0,0 +1,222 @@
// Viewer mode: /founder-council runs in Claude Code and writes its session folder as it
// goes. This watches the sessions folder and turns those files into the same events the
// API runner emits, so the room plays a Claude Code council live without calling any API.
//
// Files the Chair writes, in order (spec: .claude/skills/founder-council/references/live-room.md):
// council.json -> setup round-1.md -> Round 1 cards cruxes.json -> fault lines
// round-2.md -> debate cards draft.json -> proposal round-3.md -> votes
// verdict.json -> the verdict
import fs from "node:fs";
import path from "node:path";
import { SEATS, byKey, parseCard, checkQuotes } from "./seats.mjs";
import { SESSIONS_DIR } from "./env.mjs";
import { optionScores, finalNumbers, verdictSeats, DISCLAIMER } from "./council.mjs";
const live = new Map(); // folder name -> session
const STALE_MS = 3 * 60 * 60 * 1000; // a folder untouched this long is an abandoned council
const readText = (p) => { try { return fs.readFileSync(p, "utf8"); } catch { return null; } };
const readJson = (p) => { const t = readText(p); if (!t) return null; try { return JSON.parse(t); } catch { return null; } };
/** "Gary V", "garyvee", "GARY V (Marketing)", "Warren Buffett" -> seat key */
export function seatKey(x) {
const t = String(x || "").toLowerCase().replace(/\(.*$/, "").replace(/[^a-z ]/g, " ").replace(/\s+/g, " ").trim();
if (!t) return null;
return SEATS.find((s) => t === s.key || t === s.short.toLowerCase() || t.startsWith(s.short.toLowerCase()) || t === s.name.toLowerCase() || t.split(" ").includes(s.name.split(" ").pop().toLowerCase()))?.key || null;
}
/** Split a round file into seat cards. A card is the text under a "## <Seat>" heading
* (how the skill writes them); without seat headings, each "SEAT:" line starts a card.
* Chair sections are dropped. */
export function splitCards(md) {
const heads = [...md.matchAll(/^#{2,3}[ \t]+(.+)$/gm)];
const seatHeads = heads.filter((h) => !/chair/i.test(h[1]) && seatKey(h[1]));
if (seatHeads.length) {
return seatHeads.map((h) => {
const next = heads.find((n) => n.index > h.index);
const text = md.slice(h.index + h[0].length, next ? next.index : md.length).replace(/(\n\s*(-{3,}|\*{3,}))+\s*$/g, "").trim();
return { key: seatKey(h[1]), text };
}).filter((c) => c.text);
}
const body = md.split(/^#{1,4}[^\n]*\bchair\b[^\n]*$/im)[0];
const marks = [...body.matchAll(/^\**SEAT\**[ \t]*:[ \t]*(.+)$/gim)];
return marks.map((m, i) => {
const end = i + 1 < marks.length ? marks[i + 1].index : body.length;
const text = body.slice(m.index, end).replace(/(\n\s*(#{1,4} [^\n]*|-{3,}|\*{3,}))+\s*$/g, "").trim();
return { key: seatKey(m[1]), text };
}).filter((c) => c.key);
}
function emit(x, type, data = {}) {
const ev = { type, t: Date.now() - x.started, ...data };
x.events.push(ev);
const line = `data: ${JSON.stringify(ev)}\n\n`;
for (const res of x.subs) res.write(line);
}
function finish(x, status) {
x.status = status;
for (const res of x.subs) res.write(`data: ${JSON.stringify({ type: "end" })}\n\n`);
x.subs.clear();
}
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 || "" }));
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 || "" }; }
const seats = (c.seats || []).map(seatKey).filter(Boolean);
const mode = c.mode === "quick" ? "quick" : "full";
return {
title: c.title || "Founder Council", decision: c.decision || "", brief: c.brief || "", mode,
options, assumptions: c.assumptions || [], weights,
seats: seats.length ? [...new Set(seats)] : SEATS.map((s) => s.key),
};
}
function startRound(x, r, label) {
const st = x.st;
st.rounds.push(r);
x.round = r;
emit(x, "phase", { phase: `round${r}`, label });
emit(x, "round_start", { round: r });
for (const k of st.seats) emit(x, "seat_start", { round: r, seat: k });
}
/** Emit the cards in a round file that have not been emitted yet. Returns true once the round is complete. */
function readRound(x, r, force) {
const st = x.st;
const md = readText(path.join(x.dir, `round-${r}.md`));
if (!md) return false;
for (const c of splitCards(md)) {
if (!st.seats.includes(c.key) || st.cards[r][c.key]) continue;
const parsed = parseCard(c.text, st.options.map((o) => o.id));
const quotes = checkQuotes(c.key, c.text);
st.cards[r][c.key] = { text: c.text, parsed, quotes };
emit(x, "seat_done", { round: r, seat: c.key, text: c.text, parsed, quotes, name: byKey[c.key].name });
}
const have = st.seats.filter((k) => st.cards[r][k]).length;
if (have === st.seats.length || (force && have > 0)) {
st.scores[r] = optionScores(st, r);
emit(x, "round_done", { round: r, scores: st.scores[r] });
return true;
}
return false;
}
function sync(x) {
const f = (n) => path.join(x.dir, n);
const has = (n) => fs.existsSync(f(n));
const st = x.st;
if (x.step === "setup") {
const c = readJson(f("council.json"));
if (!c) return;
Object.assign(st, normalizeSetup(c));
x.title = st.title;
x.mode = st.mode;
emit(x, "phase", { phase: "setup", label: "The Chair is reading your question" });
emit(x, "setup", { title: st.title, decision: st.decision, brief: st.brief, options: st.options, assumptions: st.assumptions, weights: st.weights, seats: st.seats, mode: st.mode });
startRound(x, 1, "Round 1: opening positions");
x.step = "r1";
}
if (x.step === "r1") {
if (!readRound(x, 1, has("cruxes.json"))) return;
emit(x, "phase", { phase: "cruxes", label: "The Chair is finding the fault lines" });
x.step = "cruxes";
}
if (x.step === "cruxes") {
const c = readJson(f("cruxes.json"));
if (!c) return;
const cruxes = (c.cruxes || []).map((q) => ({ question: q.question || "", sides: (q.sides || []).map((sd) => ({ position: sd.position || "", seats: (sd.seats || []).map(seatKey).filter(Boolean) })) }));
emit(x, "cruxes", { cruxes, unanimous: Boolean(c.unanimous), note: c.note || "", pressure: {} });
startRound(x, 2, "Round 2: the debate");
x.step = "r2";
}
if (x.step === "r2") {
if (!readRound(x, 2, has("draft.json") || has("verdict.json"))) return;
emit(x, "phase", { phase: "draft", label: "The Chair is weighing the debate" });
x.step = "draft";
}
if (x.step === "draft") {
const d = readJson(f("draft.json"));
if (d) {
st.draft = { option: d.option || "", label: d.label || "", recommendation: d.recommendation || "", conditions: d.conditions || [], next_steps: d.next_steps || [], cheapest_test: d.cheapest_test || "", kill_criteria: d.kill_criteria || "" };
emit(x, "draft", { draft: st.draft });
startRound(x, 3, "Round 3: the vote");
x.step = "r3";
} else if (has("verdict.json")) {
emit(x, "phase", { phase: "skip3", label: "Quick mode: the vote round is skipped" });
x.step = "verdict";
} else return;
}
if (x.step === "r3") {
if (!readRound(x, 3, has("verdict.json"))) return;
emit(x, "phase", { phase: "verdict", label: "The Chair is writing the verdict" });
x.step = "verdict";
}
if (x.step === "verdict") {
const v = readJson(f("verdict.json"));
if (!v) return;
const { last, finalScores, recommended, spreadF, confidence, support, votes } = finalNumbers(st);
const verdict = {
label: v.label || "RESHAPE", call: v.call || "", override_note: v.override_note || "",
why: v.why || [], fights: v.fights || [], minority: v.minority || { seat: "", quote: "", would_have_to_be_true: "" },
amendments: v.amendments || [], conditions: v.conditions || [],
next_steps: (v.next_steps || []).map((n) => (typeof n === "string" ? { when: "", action: n } : n)),
cheapest_test: v.cheapest_test || "", kill_criteria: v.kill_criteria || "", revisit: v.revisit || "",
recommended: v.recommended || recommended, scores: finalScores, spread: spreadF, confidence, support, votes, disclaimer: DISCLAIMER,
};
emit(x, "verdict", { verdict, seats: verdictSeats(st, last) });
x.step = "done";
finish(x, "done");
}
}
function lastTouched(dir) {
try { return Math.max(...fs.readdirSync(dir).map((n) => fs.statSync(path.join(dir, n)).mtimeMs)); } catch { return 0; }
}
function load(name) {
const dir = path.join(SESSIONS_DIR, name);
let x = live.get(name);
if (!x) {
x = { id: name, dir, events: [], subs: new Set(), status: "running", started: Date.now(), step: "setup", title: "", mode: "full",
st: { cards: { 1: {}, 2: {}, 3: {} }, scores: {}, rounds: [] } };
live.set(name, x);
}
if (x.status === "running") {
sync(x);
if (x.status === "running" && Date.now() - lastTouched(dir) > STALE_MS) finish(x, "stopped");
}
return x;
}
/** Folders written by the skill (council.json, no events.json from the API runner). */
function skillFolders() {
if (!fs.existsSync(SESSIONS_DIR)) return [];
return fs.readdirSync(SESSIONS_DIR).filter((d) => fs.existsSync(path.join(SESSIONS_DIR, d, "council.json")) && !fs.existsSync(path.join(SESSIONS_DIR, d, "events.json")));
}
export function scan() {
for (const name of skillFolders()) load(name);
}
export function getLive(id) {
return skillFolders().includes(id) ? load(id) : null;
}
/** The council running right now in Claude Code, if any (newest first). */
export function runningId() {
const r = [...live.values()].filter((x) => x.status === "running" && x.events.length).sort((a, b) => (a.id < b.id ? 1 : -1));
return r[0]?.id || null;
}
export function listLive() {
return skillFolders().map((n) => { const x = load(n); return { id: x.id, title: x.title || n, prompt: "", mode: x.mode, status: x.status, source: "claude-code" }; });
}
export function startWatching() {
scan();
setInterval(scan, 1000);
}
+675
View File
@@ -0,0 +1,675 @@
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => [...r.querySelectorAll(s)];
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
const SAMPLES = [
["Raise my prices?", "I run a coaching business doing $30k a month with 15 active clients at $2,000 each. I want to raise the price to $3,500. Options: raise for everyone now, raise for new clients only, or keep $2,000. Close rate is about 50% on sales calls. I'm leaning toward raising for everyone because I'm underpaid."],
["First salesperson?", "I'm a solo founder of a B2B SaaS at $25k MRR growing 5% a month. I do every sales call myself (about 20 hours a week) and I'm burning out. Should I hire a full-time account executive at $120k base, hire a part-time commission-only closer, or keep selling myself for six more months? I have $150k in the bank."],
["Second product?", "My agency makes $80k a month building AI automations for dentists. A few clients asked for an AI receptionist product. Should I build the receptionist as a separate SaaS, offer it as an add-on to existing clients only, or stay focused on the agency? Team of 6, about $200k cash."],
["Quit my job?", "I make $180k a year at a tech company. My side business (a paid newsletter) makes $6k a month and grew 8% a month this year. I have 9 months of expenses saved. Should I quit now, quit in 6 months, or keep both and hire a writer?"],
];
const SHAPES = ["base", "open", "mid", "blink"];
const portrait = (key, shape = "base") => `/portraits/${key}-${shape}.webp`;
const ROUND_NAME = ["", "Opening", "Debate", "Vote"];
const state = {
seats: [], byKey: {}, session: null, options: [], weights: {}, active: [], round: 0,
cards: { 1: {}, 2: {}, 3: {} }, replaying: false, verdict: null, links: [], geo: {},
};
// ------------------------------------------------------------- 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]));
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();
renderSamples();
bindUI();
new ResizeObserver(() => { layoutStage(); drawLinks(); }).observe($("#stage"));
startBlinking();
reset();
typeIn($("#composer h2"));
typeIn($("#waiting h2"));
const ss = await fetch("/api/sessions").then((x) => x.json());
if (ss.running) attach(ss.running);
else if (ss.live) attach(ss.live);
refreshUsage();
setInterval(watchForLive, 2500);
}
// a council started in Claude Code shows up here on its own
const seenLive = new Set();
async function watchForLive() {
const ss = await fetch("/api/sessions").then((x) => x.json()).catch(() => null);
const id = ss?.live || ss?.running;
if (!id || seenLive.has(id) || id === state.session) return;
seenLive.add(id);
attach(id);
}
// AIS arrival: a heading types in a character at a time, blur to sharp
function typeIn(el) {
if (!el) return;
const text = el.textContent;
el.classList.add("typein");
el.innerHTML = [...text].map((c, i) => `<span class="ch" style="animation-delay:${i * 22}ms">${c === " " ? " " : esc(c)}</span>`).join("");
el.setAttribute("aria-label", text);
}
function renderSamples() {
$("#samples").innerHTML = SAMPLES.map(([t], i) => `<button type="button" data-i="${i}">${esc(t)}</button>`).join("");
$("#samples").addEventListener("click", (e) => {
const b = e.target.closest("button"); if (!b) return;
$("#prompt").value = SAMPLES[b.dataset.i][1];
$("#prompt").focus();
});
}
function renderSeats() {
$("#seats").innerHTML = state.seats.map((s) => `
<div class="seat" id="seat-${s.key}" data-seat="${s.key}" 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) => `
<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();
}
// The table is an ellipse seen from the front. Seats sit along its far edge: the
// middle seat is farthest (higher, smaller), the end seats nearest (lower, bigger).
function layoutStage() {
const stage = $("#stage");
const W = stage.clientWidth;
const narrow = matchMedia("(max-width: 820px)").matches;
const H = narrow ? Math.round(W * 0.62) : stage.clientHeight;
const cx = W / 2, cy = H * (narrow ? 0.98 : 0.9), rx = W * 0.48, ry = H * (narrow ? 0.46 : 0.42);
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) => {
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 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) });
const pl = $(`#plate-${s.key}`);
pl.style.left = `${x}px`;
pl.style.top = `${edge(x) + H * 0.01}px`; // straddles the table edge, over the chest
state.geo[s.key] = { x, head: bottom - size * 0.72, top: bottom - size * 0.9, size };
});
const c = $("#center");
if (narrow) {
stage.style.paddingTop = `${H}px`; // the scene sits on top; captions flow below it
} 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 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` });
}
const sp = state.speaking ? state.geo[state.speaking] : null;
if (sp) moveSpot(state.speaking);
}
function moveSpot(key) {
const g = state.geo[key]; const spot = $("#spot");
if (!g) { spot.classList.remove("on"); return; }
spot.style.left = `${g.x}px`;
spot.style.top = `${g.head}px`;
spot.style.width = spot.style.height = `${g.size * 1.9}px`;
spot.classList.add("on");
}
function bindUI() {
$("#composer").addEventListener("submit", async (e) => {
e.preventDefault();
const prompt = $("#prompt").value.trim();
if (prompt.length < 10) return toast("Give the council a real decision, at least a sentence.");
const mode = $('input[name="mode"]:checked').value;
$("#convene").disabled = true;
const r = await fetch("/api/council", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ prompt, mode }) });
const j = await r.json();
$("#convene").disabled = false;
if (!r.ok) return toast(j.error || "Could not start the council.");
attach(j.id);
});
const openFrom = (e) => { const b = e.target.closest("[data-seat]"); if (b) openCard(b.dataset.seat); };
$("#seats").addEventListener("click", openFrom);
$("#plates").addEventListener("click", openFrom);
$("#seats").addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); openFrom(e); } });
$("#feed").addEventListener("click", (e) => { const c = e.target.closest(".feed-card"); if (c) openCard(c.dataset.seat, Number(c.dataset.round)); });
$("#waitHistory").addEventListener("click", openHistory);
$("#historyBtn").addEventListener("click", openHistory);
$("#newBtn").addEventListener("click", reset);
$("#verdictSheet").addEventListener("click", (e) => { if (e.target.id === "verdictSheet" || e.target.closest("[data-close]")) $("#verdictSheet").hidden = true; });
document.addEventListener("keydown", (e) => { if (e.key === "Escape") $("#verdictSheet").hidden = true; });
$$(".speed button").forEach((b) => b.addEventListener("click", () => {
player.speed = Number(b.dataset.speed);
$$(".speed button").forEach((x) => x.setAttribute("aria-pressed", String(x === b)));
}));
$("#skipBtn").addEventListener("click", () => player.skip());
}
// ------------------------------------------------------------- the player
// Every event goes through one ordered queue. Seats speak one at a time, at a
// readable pace, even though the API answers them in parallel. Skip ahead drains
// whatever is queued instantly; new events after that animate again.
const player = {
q: [], busy: false, epoch: 0, speed: 1, fast: false, timers: new Set(),
push(ev) { this.q.push(ev); this.info(); this.pump(); },
async pump() {
if (this.busy) return;
this.busy = true;
const my = this.epoch;
while (this.q.length && my === this.epoch) {
const ev = this.q.shift();
this.info();
try { await handle(ev); } catch (e) { console.error(e); }
}
if (my === this.epoch) { this.busy = false; this.fast = false; this.info(); }
},
sleep(ms) {
if (this.fast || ms <= 0) return Promise.resolve();
return new Promise((res) => { const t = setTimeout(() => { this.timers.delete(o); res(); }, ms / this.speed); const o = { t, res }; this.timers.add(o); });
},
flushTimers() { for (const o of this.timers) { clearTimeout(o.t); o.res(); } this.timers.clear(); },
skip() { this.fast = true; this.flushTimers(); },
reset() { this.epoch++; this.q.length = 0; this.fast = true; this.flushTimers(); this.busy = false; this.fast = false; this.info(); },
info() {
const waiting = this.q.filter((e) => e.type === "seat_done").length;
$("#queueInfo").textContent = waiting ? `${waiting} lines up next` : "";
},
};
// ------------------------------------------------------------- session wiring
function reset() {
state.es?.close();
player.reset();
Object.assign(state, { session: null, options: [], weights: {}, active: [], round: 0, cards: { 1: {}, 2: {}, 3: {} }, replaying: false, verdict: null, links: [], speaking: null });
$("#stage").classList.remove("live");
$("#topic").hidden = true;
$("#composer").hidden = state.runner !== "api";
$("#waiting").hidden = state.runner === "api";
$("#caption").hidden = true;
$("#cruxes").hidden = true;
$("#plate").hidden = true;
$("#playbar").hidden = true;
$("#newBtn").hidden = true;
$("#verdictSheet").hidden = true;
$("#feed").innerHTML = '<div class="empty">One line per seat as the council talks. Click a seat to read its full card.</div>';
$$(".vote").forEach((b) => b.remove());
$$(".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");
$$(".stepper li").forEach((li) => li.classList.remove("active", "done"));
drawLinks();
}
function begin(id) {
reset();
state.session = id;
$("#composer").hidden = true;
$("#waiting").hidden = true;
$("#newBtn").hidden = false;
$("#playbar").hidden = false;
$("#stage").classList.add("live");
chairSays("The council is taking their seats", { dots: true });
}
function attach(id) {
begin(id);
const es = new EventSource(`/api/stream/${id}`);
state.es = es;
es.onmessage = (m) => {
const ev = JSON.parse(m.data);
if (ev.type === "end") { es.close(); refreshUsage(); return; }
if (ev.type === "delta") return; // seats speak from their finished cards
if (ev.type === "usage") return refreshUsage();
if (ev.type === "seat_error") return toast(`${state.byKey[ev.seat].short} hit an error: ${ev.error}`);
player.push(ev);
};
es.onerror = () => { /* the browser retries; the server replays from the start */ };
}
// ------------------------------------------------------------- event handling
const STEP_OF = { setup: "setup", round1: "round1", cruxes: "cruxes", round2: "round2", draft: "round3", round3: "round3", skip3: "round3", verdict: "verdict" };
const ORDER = ["setup", "round1", "cruxes", "round2", "round3", "verdict"];
function setStep(step) {
const idx = ORDER.indexOf(step);
$$(".stepper li").forEach((li) => {
const i = ORDER.indexOf(li.dataset.step);
li.classList.toggle("done", i < idx);
li.classList.toggle("active", i === idx);
});
}
async function handle(ev) {
switch (ev.type) {
case "phase": {
setStep(STEP_OF[ev.phase] || "setup");
feedPhase(ev.label);
const thinking = ["setup", "cruxes", "draft", "verdict"].includes(ev.phase);
if (thinking || ev.phase === "skip3") {
chairSays(ev.label.replace(/^The Chair is /, "").replace(/^./, (c) => c.toUpperCase()), { dots: thinking });
await player.sleep(1400);
}
break;
}
case "setup": 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;
case "round_done": updateOptions(ev.scores); break;
case "cruxes": await onCruxes(ev); break;
case "draft": await onDraft(ev.draft); break;
case "verdict": onVerdict(ev); break;
case "error": toast(`The council stopped: ${ev.error}`); chairSays(`The council stopped: ${ev.error}`); break;
}
}
function onSetup(ev) {
state.options = ev.options;
state.weights = ev.weights;
state.active = ev.seats;
$("#topic").hidden = false;
$("#topicTitle").textContent = ev.title;
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) {
const absent = !ev.seats.includes(s.key);
$(`#seat-${s.key}`).classList.toggle("absent", absent);
const pl = $(`#plate-${s.key}`);
pl.classList.toggle("absent", absent);
const w = ev.weights[s.key]?.weight || 1;
pl.title = `Weight ${w} of 3: ${ev.weights[s.key]?.reason || ""}`;
}
chairSays(ev.title, { tag: ev.mode === "quick" ? "Quick council" : "Full council" });
}
function updateOptions(scores) {
const best = Object.entries(scores).sort((a, b) => (b[1].score ?? 0) - (a[1].score ?? 0))[0]?.[0];
for (const [id, v] of Object.entries(scores)) {
const el = $(`.opt[data-opt="${id}"]`); if (!el) continue;
$(".val", el).textContent = v.score ?? "-";
$(".bar i", el).style.width = `${(v.score || 0) * 10}%`;
el.classList.toggle("lead", id === best);
el.title = v.math;
}
}
function onRoundStart(round) {
state.round = round;
state.links = [];
drawLinks();
$("#cruxes").hidden = true;
chairSays(`${["", "Round 1: opening positions", "Round 2: the debate", "Round 3: the vote"][round]}`, { dots: true, tag: "The floor is open" });
}
// ------------------------------------------------------------- talking
const clean = (t) => String(t || "").replace(/\s*\((?:S\d+|source[^)]*)[^)]*\)/gi, "").replace(/\*\*/g, "").replace(/\s+/g, " ").trim();
function firstSentences(t, max) {
const parts = t.match(/[^.!?]+[.!?]+["”)]?\s*|[^.!?]+$/g) || [t];
let out = "";
for (const p of parts) { if (out && (out + p).length > max) break; out += p; }
return shorten(out.trim(), max + 40);
}
/** The line a seat says out loud: the headline of its card, not the whole card. */
function lineFor(round, p, max = 170) {
if (round === 1) return firstSentences(clean(p.call || p.stance), max);
if (round === 2) {
let t = clean(p.disagreeLine || p.stance);
// "Graham. His argument..." reads as talking to him: "Graham, his argument..."
t = t.replace(/^([A-Za-z][\w.' ]{0,24})[.:,]\s+(\S+)/, (m, name, next) => !seatKey(name) ? m : `${state.byKey[seatKey(name)].short}, ${/^I('|$)/.test(next) ? next : next[0].toLowerCase() + next.slice(1)}`);
return firstSentences(t, max);
}
return firstSentences(clean(p.oneLine || p.amendment), max);
}
function shapesFor(word) {
const out = [];
for (const ch of word.toLowerCase()) {
const s = "aei".includes(ch) ? "open" : "ouwy".includes(ch) ? "mid" : "mbpf".includes(ch) ? "base" : null;
if (s && s !== out[out.length - 1]) out.push(s);
}
return out.length ? out : ["mid"];
}
function setShape(key, shape) { const b = $(`#seat-${key} .bust`); if (b) b.dataset.shape = shape; }
function setSpeaker(key, target) {
state.speaking = key;
$$(".seat").forEach((el) => { el.classList.toggle("speaking", el.dataset.seat === key); el.classList.toggle("addressed", el.dataset.seat === target); });
$$(".nameplate").forEach((el) => el.classList.toggle("speaking", el.dataset.seat === key));
const el = key && $(`#seat-${key}`);
if (el) {
el.classList.remove("thinking");
// lean toward whoever they're answering
const g = state.geo[key], tg = target && state.geo[target];
el.style.transform = tg ? `translateX(${Math.sign(tg.x - g.x) * g.size * 0.04}px) rotate(${Math.sign(tg.x - g.x) * 2.5}deg) scale(1.05)` : "scale(1.05)";
moveSpot(key);
} else $("#spot").classList.remove("on");
$$(".seat").forEach((s) => { if (s.dataset.seat !== key) s.style.transform = ""; });
}
function captionFor(who) {
$("#cruxes").hidden = true;
$("#plate").hidden = true;
const c = $("#caption");
c.hidden = false;
c.style.animation = "none"; void c.offsetWidth; c.style.animation = "";
const s = state.byKey[who];
$("#capAv").className = `cap-av${s ? "" : " chair"}`;
$("#capAv").innerHTML = `<img src="${s ? portrait(who) : "/brand/ais-symbol.png"}" alt="">`;
$("#capWho").textContent = s ? s.name : "The Chair";
}
function chairSays(text, { dots = false, tag = "" } = {}) {
setSpeaker(null);
captionFor(null);
$("#capTag").textContent = tag;
const p = $("#capText");
p.className = "cap-text chair";
p.innerHTML = esc(text) + (dots ? '<span class="dots"><i></i><i></i><i></i></span>' : "");
$("#capSub").textContent = "";
}
async function speak(key, text, { tag = "", target = null, sub = "" } = {}) {
setSpeaker(key, target);
captionFor(key);
$("#capTag").textContent = tag;
$("#capSub").textContent = "";
const p = $("#capText");
p.className = "cap-text";
const words = text.split(" ").filter(Boolean);
p.innerHTML = words.map((w) => `<span class="w">${esc(w)}</span> `).join("");
const spans = $$(".w", p);
for (let i = 0; i < words.length; i++) {
if (player.fast) break;
const w = words[i];
spans[i].classList.add("on");
const shapes = shapesFor(w.replace(/[^a-z]/gi, ""));
const dur = Math.max(170, w.length * 52);
const per = dur / (shapes.length + 1);
for (const sh of shapes) { setShape(key, sh); await player.sleep(per); }
setShape(key, "base");
await player.sleep(per + (/[.!?]["”)]?$/.test(w) ? 340 : /[,;:]$/.test(w) ? 170 : 25));
}
spans.forEach((s) => s.classList.add("on"));
setShape(key, "base");
$("#capSub").innerHTML = sub;
await player.sleep(1300);
}
// idle blinking for everyone, so the room feels alive between lines
function startBlinking() {
const blink = (key) => {
const b = $(`#seat-${key} .bust`);
if (b && b.dataset.shape === "base") {
b.dataset.shape = "blink";
setTimeout(() => { if (b.dataset.shape === "blink") b.dataset.shape = "base"; }, 130);
}
setTimeout(() => blink(key), 2400 + Math.random() * 4200);
};
state.seats.forEach((s, i) => setTimeout(() => blink(s.key), 600 + i * 530));
}
async function onSeatDone(ev) {
const { round, seat, text, parsed, quotes } = ev;
state.cards[round][seat] = { text, parsed, quotes };
const s = state.byKey[seat];
const top = topOption(parsed.optionScores);
const line = lineFor(round, parsed);
let tag = ROUND_NAME[round], sub = "", target = null;
if (round === 1) {
tag = `${stanceWord(parsed.stance)}${top ? ` · backs ${top.id} (${top.v}/10)` : ""}`;
} else if (round === 2) {
const tgt = parsed.disagreeWith ? state.byKey[parsed.disagreeWith] : null;
if (tgt) {
target = tgt.key;
tag = `Pushes back on ${tgt.short}`;
state.links = state.links.filter((l) => l.from !== seat);
state.links.push({ from: seat, to: tgt.key });
drawLinks();
}
sub = /^yes/i.test(parsed.moved) ? "Changed position" : "";
} else {
const v = parsed.vote || "endorse";
tag = `Votes ${v}`;
}
feedCard(round, seat, parsed);
await speak(seat, line || "I'll put it in my card.", { tag, target, sub });
const pl = $(`#plate-${seat}`);
const chip = $(".chip", pl);
chip.hidden = round === 3; // the vote stamp says it
chip.className = "chip";
if (round === 3) {
const v = parsed.vote || "endorse";
chip.textContent = v;
chip.classList.add(v);
$(`#seat-${seat} .vote`)?.remove();
const stamp = document.createElement("div");
stamp.className = `vote ${v}`;
stamp.textContent = v.toUpperCase();
$(`#seat-${seat}`).appendChild(stamp);
} else chip.textContent = stanceWord(parsed.stance);
if (top) { const sc = $(".score", pl); sc.hidden = false; sc.textContent = `${top.id} ${top.v}`; sc.title = `Highest score: option ${top.id}`; }
setSpeaker(null);
void s;
}
function stanceWord(t = "") {
const m = t.match(/strong yes|conditional yes|strong no|yes|no/i);
if (!m) return "Spoke";
const w = m[0].toLowerCase();
return w === "conditional yes" ? "Yes, if" : w[0].toUpperCase() + w.slice(1);
}
function topOption(scores = {}) {
const e = Object.entries(scores).sort((a, b) => b[1] - a[1])[0];
return e ? { id: e[0], v: e[1] } : null;
}
const shorten = (t, n) => (t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, "") + "…" : t);
const face = (k) => `<img src="${portrait(k)}" alt="${esc(state.byKey[k]?.short || k)}" title="${esc(state.byKey[k]?.short || k)}">`;
async function onCruxes(ev) {
setSpeaker(null);
$("#caption").hidden = true;
const c = $("#cruxes");
c.hidden = false;
c.innerHTML = `<div class="head">${ev.unanimous ? "Too much agreement. The Chair pushes back." : "What they're fighting about"}</div>` +
ev.cruxes.map((x, i) => `<div class="crux" style="animation-delay:${i * 0.18}s"><b>${esc(x.question)}</b><div class="sides">${x.sides.map((sd) => `<span class="side"><span class="faces">${sd.seats.filter((k) => state.byKey[k]).map(face).join("")}</span>${esc(shorten(sd.position, 48))}</span>`).join("")}</div></div>`).join("");
const f = document.createElement("div");
f.className = "feed-note";
f.innerHTML = `<b>The fight:</b> ${ev.cruxes.map((x) => esc(x.question)).join(" ")}`;
feedAppend(f);
await player.sleep(3500 + 1800 * ev.cruxes.length);
}
async function onDraft(d) {
chairSays(`Proposal: ${d.label} on option ${d.option}. ${firstSentences(clean(d.recommendation), 140)}`, { tag: "Up for a vote" });
const f = document.createElement("div");
f.className = "feed-note";
f.innerHTML = `<b>Up for a vote:</b> ${esc(d.label)} on option ${esc(d.option)}.`;
feedAppend(f);
await player.sleep(4200);
}
// ------------------------------------------------------------- rebuttal arcs
function drawLinks() {
const svg = $("#links");
const stage = $("#stage");
const w = stage.clientWidth, h = stage.clientHeight;
svg.setAttribute("viewBox", `0 0 ${w} ${h}`);
const links = state.links || [];
const col = "#38bdf8";
svg.innerHTML = `<defs><marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="${col}"/></marker></defs>` +
links.map(({ from, to }, i) => {
const a = state.geo[from], b = state.geo[to];
if (!a || !b) return "";
const y1 = a.top - 6, y2 = b.top - 6;
const mx = (a.x + b.x) / 2, my = Math.min(y1, y2) - Math.min(90, Math.abs(a.x - b.x) * 0.22) - 10;
return `<path class="${i < links.length - 1 ? "old" : ""}" d="M${a.x},${y1} Q${mx},${my} ${b.x},${y2}" stroke="${col}" marker-end="url(#arrow)"/>`;
}).join("");
}
// ------------------------------------------------------------- feed + cards
function feedAppend(node) {
const feed = $("#feed");
$(".empty", feed)?.remove();
feed.appendChild(node);
feed.scrollTop = feed.scrollHeight;
}
function feedPhase(label) {
const d = document.createElement("div");
d.className = "feed-phase";
d.textContent = label.replace(/^The Chair is /, "Chair: ");
feedAppend(d);
}
function feedCard(round, seat, parsed) {
const s = state.byKey[seat];
const d = document.createElement("div");
d.className = "feed-card";
d.dataset.seat = seat;
d.dataset.round = round;
const top = topOption(parsed.optionScores);
const tgt = parsed.disagreeWith ? state.byKey[parsed.disagreeWith]?.short : "";
const what = round === 1 ? `${stanceWord(parsed.stance)}${top ? `, backs ${top.id}` : ""}` : round === 2 ? (tgt ? `vs ${tgt}` : "Debate") : `Votes ${parsed.vote || "endorse"}`;
d.innerHTML = `<img class="av" src="${portrait(seat)}" alt=""><div><div class="h">${esc(s.short)}<span class="r">${esc(what)}</span></div><p>${esc(lineFor(round, parsed, 105))}</p></div>`;
feedAppend(d);
}
function openCard(seat, round) {
const s = state.byKey[seat];
const rounds = [3, 2, 1].filter((r) => state.cards[r][seat]);
const r = round || rounds[0];
const c = state.cards[r]?.[seat];
$("#cardBody").innerHTML = `
<div class="card-head"><img src="${portrait(seat)}" alt=""><div><div class="label">${esc(s.pillar)}</div><h3>${esc(s.name)}</h3><p class="muted" style="margin:0">Owns the question: ${esc(s.question)}</p></div></div>
${rounds.length > 1 ? `<p style="margin:0 0 6px">${rounds.slice().reverse().map((x) => `<button class="ghost" data-r="${x}" style="margin-right:6px">${ROUND_NAME[x]}</button>`).join("")}</p>` : ""}
${c ? `<pre>${esc(c.text)}</pre>${c.quotes.length ? `<ul class="qcheck">${c.quotes.map((q) => `<li class="${q.verified ? "" : "bad"}">"${esc(shorten(q.quote, 110))}" (${q.source}) ${q.verified ? "verified in the brain" : "not found in the brain"}</li>`).join("")}</ul>` : ""}` : `<p class="muted">This seat has not spoken yet.</p>`}
<p class="muted" style="font-size:12px">A simulated advisor built from ${esc(s.name)}'s public work. Not the person.</p>`;
$$("#cardBody [data-r]").forEach((b) => b.addEventListener("click", () => openCard(seat, Number(b.dataset.r))));
const dlg = $("#cardDialog");
if (!dlg.open) dlg.showModal();
}
// ------------------------------------------------------------- verdict
// the Chair should write display names; map any raw seat key just in case
const seatKey = (x) => { const k = String(x).toLowerCase().replace(/\s+/g, ""); return state.byKey[k] ? k : state.seats.find((s) => s.short.toLowerCase() === String(x).toLowerCase() || s.name.toLowerCase() === String(x).toLowerCase())?.key; };
const seatName = (x) => state.byKey[seatKey(x)]?.short || x;
function labelClass(l) { return /DON'T/.test(l) ? "dont" : /RESHAPE/.test(l) ? "reshape" : /WAIT/.test(l) ? "wait" : "go"; }
function onVerdict(ev) {
const v = ev.verdict;
state.verdict = ev;
setStep("verdict");
setSpeaker(null);
$("#caption").hidden = true;
$("#cruxes").hidden = true;
state.links = [];
drawLinks();
$("#stage").classList.remove("live");
updateOptions(v.scores);
const opt = (id) => state.options.find((o) => o.id === id)?.label || id;
const seats = ev.seats;
const mk = seatKey(v.minority.seat);
const short = (t, n) => esc(shorten(clean(t || ""), n));
const html = `
<div class="v-top">
<div><div class="label">The council's verdict</div><span class="v-label ${labelClass(v.label)}">${esc(v.label)}</span></div>
<button class="ghost" data-close>Back to the table</button>
</div>
<p class="v-call">${esc(v.call)}</p>
<div class="v-grid">
<div class="v-sec"><h3>Scores</h3><div class="v-opts">${state.options.map((o) => `
<div class="opt ${o.id === v.recommended ? "lead" : ""}"><span class="id">${o.id}</span><span class="label">${esc(o.label)}</span><span class="val">${v.scores[o.id]?.score ?? "-"}</span><span class="bar"><i style="width:${(v.scores[o.id]?.score || 0) * 10}%"></i></span></div>`).join("")}</div>
<p class="v-meta">Confidence ${v.confidence ?? "-"}/10${v.votes ? ` · ${v.votes.endorse || 0} endorse, ${v.votes.amend || 0} amend, ${v.votes.dissent || 0} dissent` : ""}</p>
</div>
<div class="v-sec"><h3>Why</h3><ul class="v-why">${v.why.slice(0, 3).map((w) => { const k = seatKey(w.seat); return `<li>${k ? `<img class="av" src="${portrait(k)}" alt="">` : ""}<span>${short(w.point, 150)}</span></li>`; }).join("")}</ul></div>
<div class="v-sec"><h3>Watch out</h3><div class="minority"><div class="who">${mk ? `<img class="av" src="${portrait(mk)}" alt="">` : ""}${esc(seatName(v.minority.seat))}</div><q>${short(v.minority.quote, 170)}</q></div></div>
<div class="v-sec"><h3>Next steps</h3><ul class="v-steps">${v.next_steps.slice(0, 3).map((n) => `<li><b>${esc(n.when)}</b> ${short(n.action, 120)}</li>`).join("")}</ul>
<p class="v-meta"><b>Kill it if:</b> ${short(v.kill_criteria, 140)}</p></div>
</div>
<details class="v-more"><summary>Full detail</summary>
<div class="v-grid">
<div class="v-sec"><h3>Where they fought</h3><ul>${v.fights.map((f) => `<li><b>${esc(f.crux)}</b> ${esc(f.story)}</li>`).join("")}</ul></div>
<div class="v-sec"><h3>Conditions</h3><ol>${v.conditions.map((c) => `<li>${esc(c)}</li>`).join("")}</ol></div>
<div class="v-sec v-wide"><h3>Scorecard</h3>
<table class="scorecard"><thead><tr><th>Seat</th><th>Weight</th>${state.options.map((o) => `<th>${o.id}</th>`).join("")}<th>Their line</th></tr></thead><tbody>
${seats.map((x) => { const s = state.byKey[x.key]; return `<tr><td><span class="who"><img class="av" src="${portrait(x.key)}" alt="">${esc(s.short)}</span></td><td class="n">${x.weight}</td>${state.options.map((o) => `<td class="n">${x.optionScores?.[o.id] ?? "-"}</td>`).join("")}<td class="line">${short(x.oneLine, 150)}</td></tr>`; }).join("")}
</tbody></table>
<p class="muted" style="font-size:11.5px;margin-top:8px">Weighted by how much each pillar matters here. ${state.options.map((o) => `${o.id}: ${esc(v.scores[o.id]?.math || "")}`).join(" · ")}</p></div>
<div class="v-sec"><h3>Cheapest test</h3><p>${esc(v.cheapest_test)}</p><h3>Revisit</h3><p>${esc(v.revisit)}</p></div>
<div class="v-sec"><h3>The strongest objection in full</h3><p>${esc(v.minority.quote)}</p><p class="muted">For this to be right: ${esc(v.minority.would_have_to_be_true)}</p></div>
${v.amendments?.length ? `<div class="v-sec v-wide"><h3>Amendments</h3><ul>${v.amendments.map((a) => `<li><b>${esc(seatName(a.seat))}:</b> ${esc(a.amendment)} <span class="tag">${a.adopted ? "Adopted" : "Not adopted"}: ${esc(a.reason)}</span></li>`).join("")}</ul></div>` : ""}
</div>
</details>
<div class="v-foot"><span class="muted">${esc(v.disclaimer)}</span><button class="ghost" data-close>Back to the table</button></div>`;
$("#verdictBody").innerHTML = html;
const plate = $("#plate");
plate.hidden = false;
plate.innerHTML = `<div class="label">The council's verdict</div><span class="v-label ${labelClass(v.label)}">${esc(v.label)}</span><p>${esc(firstSentences(clean(v.call), 150))}</p><div class="row"><button type="button" id="plateOpen">Read the verdict</button><button type="button" class="alt" id="plateReplay">Replay this council</button></div>`;
$("#plateOpen").addEventListener("click", () => ($("#verdictSheet").hidden = false));
$("#plateReplay").addEventListener("click", () => replay(state.session));
$("#playbar").hidden = true;
const f = document.createElement("div");
f.className = "feed-note";
f.innerHTML = `<b>Verdict: ${esc(v.label)}.</b> ${esc(firstSentences(clean(v.call), 160))}`;
feedAppend(f);
setTimeout(() => { if (state.verdict === ev) $("#verdictSheet").hidden = false; }, 1600);
}
// ------------------------------------------------------------- history + replay
async function openHistory() {
const { sessions } = await fetch("/api/sessions").then((x) => x.json());
$("#historyList").innerHTML = sessions.length
? sessions.map((s) => `<li><button data-id="${esc(s.id)}"><b>${esc(s.title)}</b><small>${esc(s.id.slice(0, 10))} · ${esc(s.mode)} · ${esc(s.status)}</small></button></li>`).join("")
: '<li class="muted">No sessions yet. Convene the council once and it shows up here.</li>';
$$("#historyList button").forEach((b) => b.addEventListener("click", () => { $("#historyDialog").close(); replay(b.dataset.id); }));
$("#historyDialog").showModal();
}
async function replay(id) {
const j = await fetch(`/api/sessions/${encodeURIComponent(id)}`).then((x) => x.json());
begin(id);
state.replaying = true;
for (const ev of j.events) {
if (["delta", "usage", "seat_error", "end"].includes(ev.type)) continue;
player.push(ev);
}
}
// ------------------------------------------------------------- misc
let toastTimer;
function toast(msg) {
const t = $("#toast");
t.textContent = msg;
t.hidden = false;
clearTimeout(toastTimer);
toastTimer = setTimeout(() => (t.hidden = true), 6000);
}
async function refreshUsage() {
const u = await fetch("/api/usage").then((x) => x.json()).catch(() => null);
if (!u || !u.calls) { $("#usage").textContent = ""; return; }
const k = (n) => (n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : `${Math.round(n / 1000)}k`);
$("#usage").textContent = `${u.calls} calls · ${k(u.input + u.cacheRead + u.cacheWrite)} in · ${k(u.output)} out`;
}
boot();
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="118.81170372807807 115.12365191710259 1217.938296271922 510.94555167421254"><path d="M765.25,162.25 764.75,163.75 761.25,168.50 759.75,171.75 758.25,173.25 757.75,174.75 754.25,179.50 752.75,182.75 751.25,184.25 750.75,185.75 749.50,187.00 748.75,188.75 746.00,192.50 745.75,193.75 744.25,195.25 743.75,196.75 742.50,198.00 741.75,199.75 739.00,203.50 738.75,204.75 735.25,209.25 734.75,210.75 731.50,215.25 729.75,218.75 728.25,220.25 727.75,221.75 724.50,226.25 722.75,229.75 721.25,231.25 720.75,232.75 717.75,236.75 715.75,240.75 714.25,242.25 713.75,243.75 710.75,247.75 708.75,251.75 707.25,253.25 706.75,254.75 703.25,259.50 701.75,262.75 700.25,264.25 699.75,265.75 696.25,270.50 694.75,273.75 693.25,275.25 692.75,276.75 689.25,281.50 687.75,284.75 686.25,286.25 685.75,287.75 682.25,292.50 680.75,295.75 679.25,297.25 678.75,298.75 675.25,303.50 673.75,306.75 672.25,308.25 671.75,309.75 668.25,314.50 666.75,317.75 665.25,319.25 664.75,320.75 661.25,325.50 657.75,331.75 656.25,333.25 655.75,334.75 652.50,339.50 651.25,340.75 650.00,341.25 647.53,344.75 647.60,345.48 647.71,346.68 647.81,347.87 647.90,349.06 648.00,350.26 648.08,351.45 648.16,352.65 648.24,353.84 648.31,355.04 648.37,356.23 648.43,357.43 648.49,358.62 648.54,359.82 648.58,361.02 648.62,362.21 648.66,363.41 648.68,364.61 648.71,365.81 648.73,367.00 648.74,368.20 648.75,369.40 648.75,370.60 648.75,371.79 648.74,372.99 648.73,374.19 648.71,375.39 648.68,376.58 648.66,377.78 648.62,378.98 648.58,380.18 648.54,381.37 648.49,382.57 648.43,383.76 648.37,384.96 648.31,386.16 648.24,387.35 648.16,388.55 648.08,389.74 648.00,390.94 647.90,392.13 647.81,393.32 647.71,394.52 647.60,395.71 647.49,396.90 647.37,398.09 647.25,399.29 647.12,400.48 646.99,401.67 646.85,402.86 646.70,404.05 646.56,405.23 646.40,406.42 646.24,407.61 646.08,408.79 645.91,409.98 645.74,411.17 645.56,412.35 645.37,413.53 645.18,414.71 644.99,415.90 644.79,417.08 644.58,418.26 644.37,419.44 644.15,420.61 643.93,421.79 643.71,422.97 643.48,424.14 643.24,425.32 643.00,426.49 642.75,427.66 642.50,428.83 642.24,430.00 641.98,431.17 641.72,432.34 641.44,433.50 641.17,434.67 640.88,435.83 640.60,437.00 640.31,438.16 640.01,439.32 639.71,440.48 639.40,441.63 639.09,442.79 638.77,443.94 638.45,445.10 638.12,446.25 637.79,447.40 637.45,448.55 637.11,449.70 636.76,450.84 636.40,451.99 636.05,453.13 635.68,454.27 635.32,455.41 634.94,456.55 634.57,457.69 634.18,458.82 633.80,459.95 633.40,461.09 633.01,462.21 632.61,463.34 632.20,464.47 631.79,465.59 631.37,466.72 630.95,467.84 630.52,468.96 630.09,470.07 629.65,471.19 629.21,472.30 628.76,473.41 628.31,474.52 627.86,475.63 627.40,476.74 626.93,477.84 626.46,478.94 625.99,480.04 625.51,481.14 625.02,482.23 624.53,483.32 624.04,484.42 623.54,485.50 623.03,486.59 622.53,487.67 622.01,488.76 621.50,489.84 620.97,490.91 620.45,491.99 619.91,493.06 619.38,494.13 618.84,495.20 618.29,496.27 617.74,497.33 617.18,498.39 616.62,499.45 616.06,500.51 615.49,501.56 614.92,502.61 614.34,503.66 613.75,504.71 613.17,505.75 612.58,506.79 611.98,507.83 611.38,508.87 610.77,509.90 610.16,510.93 609.55,511.96 608.93,512.98 608.30,514.00 607.68,515.02 607.04,516.04 606.41,517.06 605.77,518.07 605.12,519.08 604.47,520.08 603.82,521.08 603.16,522.08 602.49,523.08 601.83,524.08 601.16,525.07 600.48,526.06 599.80,527.04 599.11,528.02 598.42,529.00 597.73,529.98 597.03,530.95 596.33,531.92 595.63,532.89 594.92,533.85 594.20,534.82 593.48,535.77 592.76,536.73 592.03,537.68 591.30,538.63 590.57,539.57 589.83,540.52 589.08,541.46 588.34,542.39 587.58,543.32 586.83,544.25 586.07,545.18 585.31,546.10 584.54,547.02 583.77,547.94 582.99,548.85 582.21,549.76 581.43,550.66 580.64,551.56 579.85,552.46 579.05,553.36 578.25,554.25 577.45,555.14 576.64,556.02 575.83,556.90 575.02,557.78 574.20,558.66 573.37,559.53 572.55,560.39 571.72,561.26 570.88,562.12 570.05,562.97 569.21,563.82 568.36,564.67 567.51,565.52 566.66,566.36 565.80,567.20 564.94,568.03 564.08,568.86 563.21,569.69 562.34,570.51 561.47,571.33 560.59,572.14 559.71,572.95 558.83,573.76 557.94,574.56 557.05,575.36 556.15,576.16 555.25,576.95 554.35,577.74 553.44,578.52 552.54,579.30 551.62,580.08 550.71,580.85 549.79,581.62 549.05,582.23 554.50,582.25 555.50,581.75 647.25,581.75 651.75,574.25 651.75,573.50 654.50,569.50 655.75,566.50 658.50,562.50 659.75,559.50 662.50,555.50 663.75,552.50 665.25,550.75 667.75,546.25 667.75,545.50 669.25,543.75 675.00,533.00 676.00,532.00 678.75,526.50 681.50,522.50 682.75,519.50 685.50,515.50 686.75,512.50 689.50,508.75 823.25,508.75 823.75,508.25 823.75,506.25 824.75,505.00 824.75,501.25 825.75,500.00 825.75,496.25 826.75,495.00 826.75,491.25 827.75,490.00 827.75,486.25 828.75,485.00 828.75,481.25 829.75,480.00 829.75,476.25 830.75,475.00 830.75,471.25 831.75,470.00 831.75,466.25 832.75,465.00 832.75,461.25 833.75,460.00 833.75,456.25 834.75,455.00 834.75,451.25 835.75,450.00 835.75,446.25 836.75,445.00 836.75,441.25 837.75,440.00 837.75Line truncated

After

Width:  |  Height:  |  Size: 149 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="6 6 188 188"><path transform="translate(0 0) scale(1)" d="M189.999,99.607 189.997,99.215 189.992,98.822 189.986,98.429 189.979,98.037 189.969,97.644 189.958,97.252 189.945,96.859 189.931,96.467 189.914,96.074 189.896,95.682 189.877,95.290 189.855,94.898 189.832,94.506 189.807,94.114 189.781,93.722 189.753,93.330 189.723,92.939 189.691,92.547 189.658,92.156 189.622,91.765 189.586,91.374 189.547,90.983 189.507,90.592 189.465,90.202 189.421,89.812 189.376,89.422 189.329,89.032 189.280,88.642 189.230,88.253 189.178,87.863 189.124,87.474 189.069,87.086 189.011,86.697 188.953,86.309 188.892,85.921 188.830,85.533 188.766,85.146 188.700,84.759 188.633,84.372 188.564,83.985 188.493,83.599 188.421,83.213 188.346,82.827 188.271,82.442 188.193,82.057 188.114,81.672 188.033,81.288 187.951,80.904 187.867,80.520 187.818,80.305 187.822,80.322 187.832,80.368 187.841,80.415 187.850,80.462 187.859,80.509 187.867,80.556 187.875,80.603 187.883,80.650 187.891,80.698 187.898,80.745 187.904,80.792 187.911,80.840 187.917,80.888 187.923,80.935 187.928,80.983 187.933,81.031 187.938,81.079 187.942,81.127 187.946,81.175 187.950,81.223 187.953,81.271 187.956,81.320 187.959,81.368 187.961,81.417 187.963,81.465 187.965,81.514 187.966,81.563 187.967,81.611 187.968,81.660 187.968,81.709 187.968,81.758 187.968,81.807 187.967,81.857 187.966,81.906 187.965,81.955 187.963,82.005 187.961,82.054 187.959,82.104 187.956,82.154 187.953,82.203 187.950,82.253 187.946,82.303 187.942,82.353 187.937,82.403 187.933,82.453 187.928,82.503 187.922,82.554 187.916,82.604 187.910,82.655 187.904,82.705 187.897,82.756 187.890,82.806 187.883,82.857 187.875,82.908 187.867,82.959 187.858,83.010 187.850,83.061 187.840,83.112 187.831,83.163 187.821,83.214 187.811,83.266 187.801,83.317 187.790,83.369 187.779,83.420 187.767,83.472 187.755,83.523 187.743,83.575 187.731,83.627 187.718,83.679 187.705,83.731 187.691,83.783 187.678,83.835 187.663,83.887 187.649,83.940 187.634,83.992 187.619,84.044 187.603,84.097 187.588,84.149 187.571,84.202 187.555,84.255 187.538,84.307 187.521,84.360 187.503,84.413 187.485,84.466 187.467,84.519 187.449,84.572 187.430,84.625 187.411,84.679 187.391,84.732 187.371,84.785 187.351,84.839 187.331,84.892 187.310,84.946 187.288,84.999 187.267,85.053 187.245,85.107 187.223,85.161 187.200,85.214 187.177,85.268 187.154,85.322 187.131,85.377 187.107,85.431 187.083,85.485 187.058,85.539 187.033,85.594 187.008,85.648 186.982,85.702 186.956,85.757 186.930,85.812 186.904,85.866 186.877,85.921 186.850,85.976 186.822,86.031 186.794,86.086 186.766,86.141 186.737,86.196 186.709,86.251 186.679,86.306 186.650,86.361 186.620,86.416 186.590,86.472 186.559,86.527 186.528,86.583 186.497,86.638 186.466,86.694 186.434,86.749 186.402,86.805 186.369,86.861 186.336,86.917 186.303,86.972 186.269,87.028 186.236,87.084 186.201,87.140 186.167,87.197 186.132,87.253 186.097,87.309 186.061,87.365 186.026,87.422 185.989,87.478 185.953,87.534 185.916,87.591 185.879,87.648 185.841,87.704 185.804,87.761 185.765,87.818 185.727,87.874 185.688,87.931 185.649,87.988 185.610,88.045 185.570,88.102 185.530,88.159 185.489,88.216 185.449,88.273 185.407,88.331 185.366,88.388 185.324,88.445 185.282,88.503 185.240,88.560 185.197,88.618 185.154,88.675 185.111,88.733 185.067,88.790 185.023,88.848 184.979,88.906 184.934,88.964 184.889,89.022 184.844,89.079 184.798,89.137 184.752,89.195 184.706,89.253 184.659,89.312 184.612,89.370 184.565,89.428 184.517,89.486 184.469,89.544 184.421,89.603 184.372,89.661 184.323,89.720 184.274,89.778 184.225,89.837 184.175,89.895 184.125,89.954 184.074,90.013 184.023,90.071 183.972,90.130 183.921,90.189 183.869,90.248 183.817,90.307 183.764,90.366 183.711,90.425 183.658,90.484 183.605,90.543 183.551,90.602 183.497,90.661 183.443,90.720 183.388,90.780 183.333,90.839 183.278,90.898 183.222,90.958 183.166,91.017 183.110,91.077 183.053,91.136 182.996,91.196 182.939,91.255 182.882,91.315 182.824,91.375 182.766,91.435 182.707,91.494 182.648,91.554 182.589,91.614 182.530,91.674 182.470,91.734 182.410,91.794 182.349,91.854 182.289,91.914 182.228,91.974 182.166,92.034 182.105,92.094 182.043,92.155 181.980,92.215 181.918,92.275 181.855,92.336 181.791,92.396 181.728,92.456 181.664,92.517 181.600,92.577 181.535,92.638 181.471,92.698 181.405,92.759 181.340,92.820 181.274,92.880 181.208,92.941 181.142,93.002 181.075,93.063 181.008,93.123 180.941,93.184 180.873,93.245 180.805,93.306 180.737,93.367 180.669,93.428 180.600,93.489 180.531,93.550 180.461,93.611 180.391,93.672 180.321,93.733 180.251,93.795 180.180,93.856 180.109,93.917 180.038,93.978 179.966,94.040 179.894,94.101 179.822,94.162 179.750,94.224 179.677,94.285 179.604,94.347 179.530,94.408 179.457,94.470 179.382,94.531 179.308,94.593 179.233,94.655 179.158,94.716 179.083,94.778 179.008,94.840 178.932,94.901 178.856,94.963 178.779,95.025 178.702,95.087 178.625,95.149 178.548,95.210 178.470,95.272 178.392,95.334 178.314,95.396 178.235,95.458 178.156,95.520 178.077,95.582 1Line truncated

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+130
View File
@@ -0,0 +1,130 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Founder Council · AI Automation Society</title>
<link rel="icon" href="/brand/favicon-ais.png" type="image/png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<header class="topbar">
<div class="brand">
<img class="brand-logo" src="/brand/ais-horizontal.svg" alt="AI Automation Society">
<span class="brand-rule" aria-hidden="true"></span>
<span class="brand-name">Founder Council</span>
</div>
<ol class="stepper" id="stepper" aria-label="Council progress">
<li data-step="setup">Brief</li>
<li data-step="round1">Openings</li>
<li data-step="cruxes">Fault lines</li>
<li data-step="round2">Debate</li>
<li data-step="round3">Vote</li>
<li data-step="verdict">Verdict</li>
</ol>
<div class="top-actions">
<span class="usage" id="usage" title="Tokens used by this app since it started"></span>
<button class="ghost" id="historyBtn" type="button">Past sessions</button>
<button class="ghost" id="newBtn" type="button" hidden>New question</button>
</div>
</header>
<div class="topic" id="topic" hidden>
<div class="topic-main">
<div class="label">On the table</div>
<h1 id="topicTitle"></h1>
</div>
<div class="options" id="options"></div>
</div>
<main class="layout">
<section class="stage-wrap" aria-label="The council table">
<div class="stage" id="stage">
<div class="wall" aria-hidden="true"></div>
<div class="spot" id="spot" aria-hidden="true"></div>
<div id="seats"></div>
<div class="table" id="table" aria-hidden="true"><img class="etch" src="/brand/ais-symbol.png" alt=""></div>
<div id="plates"></div>
<svg class="links" id="links" aria-hidden="true"></svg>
<div class="center" id="center">
<div class="waiting" id="waiting" hidden>
<span class="pulse"><i></i>Waiting for a council</span>
<h2 data-type>Run the council from Claude Code</h2>
<p>Open Claude Code in this folder and type the line below with your decision. The council shows up here and plays live as it runs.</p>
<code>/founder-council should I ...</code>
<div class="row"><button class="ghost" type="button" id="waitHistory">Watch a past council</button></div>
</div>
<form class="composer" id="composer" hidden>
<h2 data-type>What decision do you need help with?</h2>
<textarea id="prompt" rows="3" placeholder="Give them the decision, your options, a few numbers (revenue, cash, team), and which way you're leaning." required minlength="10"></textarea>
<div class="samples" id="samples"></div>
<div class="composer-row">
<div class="mode" role="radiogroup" aria-label="Council size">
<label><input type="radio" name="mode" value="full" checked><span>Full council <small>7 seats, 3 rounds</small></span></label>
<label><input type="radio" name="mode" value="quick"><span>Quick <small>4 seats, 2 rounds</small></span></label>
</div>
<button class="convene" type="submit" id="convene">Convene the council</button>
</div>
</form>
<div class="caption" id="caption" hidden>
<div class="cap-head">
<span class="cap-av" id="capAv"></span>
<span class="cap-who" id="capWho"></span>
<span class="cap-tag" id="capTag"></span>
</div>
<p class="cap-text" id="capText"></p>
<div class="cap-sub" id="capSub"></div>
</div>
<div class="cruxes" id="cruxes" hidden></div>
<div class="plate" id="plate" hidden></div>
</div>
<div class="playbar" id="playbar" hidden>
<span class="queue" id="queueInfo"></span>
<div class="speed" role="radiogroup" aria-label="Playback speed">
<button type="button" data-speed="1" aria-pressed="true">1x</button>
<button type="button" data-speed="1.6" aria-pressed="false">1.6x</button>
<button type="button" data-speed="2.5" aria-pressed="false">2.5x</button>
</div>
<button type="button" class="skip" id="skipBtn">Skip ahead</button>
</div>
</div>
</section>
<aside class="panel" aria-label="Key points">
<div class="panel-head">Key points</div>
<div class="tabpanel" id="feed">
<div class="empty">One line per seat as the council talks. Click a seat to read its full card.</div>
</div>
</aside>
</main>
<div class="sheet" id="verdictSheet" hidden>
<div class="sheet-inner" id="verdictBody"></div>
</div>
<dialog id="cardDialog" class="card-dialog">
<div id="cardBody"></div>
<form method="dialog"><button class="ghost">Close</button></form>
</dialog>
<dialog id="historyDialog" class="card-dialog">
<h3>Past sessions</h3>
<p class="muted">Replay a council exactly as it happened.</p>
<ul class="history" id="historyList"></ul>
<form method="dialog"><button class="ghost">Close</button></form>
</dialog>
<div class="toast" id="toast" hidden></div>
<p class="disclaimer">Simulated advisors built from each person's public work and drawn as caricatures. They are not the people and do not speak for them.</p>
<script src="/app.js" type="module"></script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+426
View File
@@ -0,0 +1,426 @@
/* AI Automation Society. Brand guidelines v1 (Oct 2026): Montserrat only, dark blue grounds,
black and white lead, AIS Blue #37bdf8 as the accent only, no blue fills or gradients. */
:root {
--canvas: #07121c;
--surface: #0a1824;
--surface-2: #0d2031;
--surface-3: #16293a;
--hairline: rgba(255, 255, 255, 0.08);
--hairline-strong: rgba(255, 255, 255, 0.16);
--ink: #ffffff;
--ink-soft: #c9d1dc;
--ink-mute: #96a2b5;
--accent: #37bdf8;
--accent-deep: #37bdf8;
--accent-soft: rgba(55, 189, 248, 0.12);
--go: #3fcf8e;
--amend: #ff9025;
--dissent: #ff5a4f;
--font-display: "Montserrat", "Helvetica Neue", Arial, sans-serif;
--font-text: "Montserrat", "Helvetica Neue", Arial, sans-serif;
--track-head: -0.04em;
--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
--r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
background: var(--canvas);
color: var(--ink-soft);
font: 400 14.5px/1.55 var(--font-text);
min-height: 100vh;
-webkit-font-smoothing: antialiased;
font-variant-numeric: tabular-nums;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--ink-mute); }
::selection { background: rgba(55, 189, 248, 0.3); color: var(--ink); }
* { caret-color: var(--accent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #21252b; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
/* ---------------- top bar ---------------- */
.topbar {
display: flex; align-items: center; gap: 24px; padding: 12px 24px;
border-bottom: 1px solid var(--hairline); background: rgba(7, 18, 28, 0.86); backdrop-filter: blur(10px);
position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-rule { width: 1px; height: 22px; background: var(--hairline-strong); }
.brand-name { font: 500 15px/1 var(--font-display); color: var(--ink); letter-spacing: -0.02em; }
.stepper { display: flex; gap: 2px; list-style: none; margin: 0 auto; padding: 0; }
.stepper li {
font-size: 12.5px; font-weight: 500; color: var(--ink-mute);
padding: 6px 12px; border-radius: 999px; display: flex; align-items: center; gap: 7px; white-space: nowrap;
transition: color .3s, background .3s;
}
.stepper li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); transition: background .3s; }
.stepper li.done { color: var(--ink-soft); }
.stepper li.done::before { background: var(--accent); }
.stepper li.active { color: var(--ink); }
.stepper li.active::before { background: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .25); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.usage { font-size: 12px; color: var(--ink-mute); }
.ghost {
background: transparent; border: 1px solid var(--hairline-strong); color: var(--ink-soft);
padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: 13px; transition: border-color .2s, color .2s;
}
.ghost:hover { border-color: var(--accent); color: var(--ink); }
/* ---------------- topic banner ---------------- */
.topic {
display: flex; gap: 28px; align-items: center; justify-content: space-between;
margin: 16px 24px 0; padding: 16px 22px; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r);
}
.label { font-size: 11px; color: var(--ink-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.topic h1 { font: 500 26px/1.15 var(--font-display); color: var(--ink); margin: 6px 0 6px; letter-spacing: var(--track-head); }
.topic p { margin: 0; color: var(--ink-soft); max-width: 72ch; font-size: 14px; }
.options { display: grid; gap: 8px; min-width: 300px; max-width: 440px; flex: 0 1 440px; }
.opt { display: grid; grid-template-columns: 26px 1fr 38px; gap: 10px; align-items: center; font-size: 13px; }
.opt .id { font: 700 13px/1 var(--font-display); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-soft); }
.opt.lead .id { background: #ffffff; color: #07121c; }
.opt .label { color: var(--ink-soft); line-height: 1.3; font-weight: 400; font-size: 13px; text-transform: none; letter-spacing: 0; }
.opt .bar { grid-column: 2; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: -4px; }
.opt .bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .9s var(--ease-out); }
.opt .val { grid-row: 1 / span 2; grid-column: 3; font: 600 18px/1 var(--font-display); text-align: right; color: var(--ink); }
/* ---------------- layout ---------------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; padding: 16px 24px 28px; align-items: start; }
.stage-wrap { min-width: 0; }
/* ---------------- the stage ---------------- */
.stage {
position: relative; width: 100%; aspect-ratio: 16 / 9.4; max-height: calc(100vh - 120px); min-height: 520px;
border-radius: 20px; overflow: hidden; border: 1px solid var(--hairline);
background:
radial-gradient(70% 40% at 50% 52%, rgba(55, 189, 248, 0.07), transparent 70%),
linear-gradient(180deg, #0a1a28 0%, #07121c 60%, #050d15 100%);
}
.wall {
position: absolute; inset: 0; pointer-events: none;
background:
repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 120px),
linear-gradient(180deg, transparent 0 46%, rgba(56, 189, 248, 0.05) 46.2%, transparent 47%);
}
.spot {
position: absolute; width: 380px; height: 380px; border-radius: 50%; pointer-events: none; z-index: 2;
background: radial-gradient(circle, rgba(255, 255, 255, 0.10), rgba(55, 189, 248, 0.05) 45%, transparent 70%);
opacity: 0; transform: translate(-50%, -50%); transition: left .55s var(--ease-out), top .55s var(--ease-out), opacity .4s;
}
.spot.on { opacity: 1; }
/* seats: a cartoon bust per seat, behind the table edge */
.seat {
position: absolute; z-index: 10; transform-origin: 50% 100%;
transition: filter .45s, opacity .45s, transform .55s var(--ease-out);
cursor: pointer;
}
.seat .bust { position: relative; width: 100%; height: 100%; transform-origin: 50% 90%; animation: breathe 5.5s ease-in-out infinite; }
.seat .bust img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; user-select: none; }
.seat .bust[data-shape="base"] img.base,
.seat .bust[data-shape="open"] img.open,
.seat .bust[data-shape="mid"] img.mid,
.seat .bust[data-shape="blink"] img.blink { opacity: 1; }
@keyframes breathe { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-1px) scale(1.006); } }
.stage.live .seat { filter: brightness(.62) saturate(.8); }
.stage.live .seat.speaking { filter: none; z-index: 25 !important; }
.stage.live .seat.addressed { filter: brightness(.9); }
.seat.speaking .bust { animation: talk 1.6s ease-in-out infinite; }
@keyframes talk {
0%, 100% { transform: translateY(0) rotate(0); }
25% { transform: translateY(-3px) rotate(-1.2deg); }
50% { transform: translateY(-1px) rotate(.6deg); }
75% { transform: translateY(-4px) rotate(1.1deg); }
}
.seat.absent { opacity: .2; filter: grayscale(1) brightness(.5) !important; }
.seat:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
/* thinking dots over a head */
.think {
position: absolute; left: 50%; top: 2%; translate: -50% -100%; display: none; gap: 4px; padding: 7px 10px;
background: var(--surface-2); border: 1px solid var(--hairline-strong); border-radius: 999px; z-index: 3;
}
.seat.thinking .think { display: flex; }
.think i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.1s infinite ease-in-out; }
.think i:nth-child(2) { animation-delay: .15s; }
.think i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(-4px); opacity: 1; } }
/* vote stamp on the chest */
.vote {
position: absolute; left: 50%; bottom: 30%; translate: -50% 0; rotate: -8deg; z-index: 4;
font: 800 12px/1 var(--font-display); letter-spacing: .08em; padding: 6px 9px; border-radius: 7px; border: 2px solid currentColor;
background: rgba(7, 18, 28, .9); animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.vote.endorse { color: var(--go); }
.vote.amend { color: var(--amend); }
.vote.dissent { color: var(--dissent); }
@keyframes stamp { from { opacity: 0; scale: 2.2; } }
/* the table */
.table {
position: absolute; z-index: 30; border-radius: 50%; pointer-events: none;
background:
radial-gradient(70% 60% at 50% 30%, #11263a 0%, #0b1a29 55%, #07121c 100%);
box-shadow:
inset 0 1.5px 0 rgba(255, 255, 255, 0.22),
inset 0 18px 40px rgba(255, 255, 255, 0.03),
0 -18px 70px rgba(55, 189, 248, 0.07);
}
.table .etch { position: absolute; left: 50%; top: 30%; width: 11%; translate: -50% -50%; opacity: .06; }
/* nameplates on the table edge */
.nameplate {
position: absolute; z-index: 32; translate: -50% -50%; text-align: center; cursor: pointer;
background: rgba(7, 18, 28, .86); border: 1px solid var(--hairline-strong); border-radius: 10px; padding: 5px 10px 6px;
min-width: 96px; backdrop-filter: blur(6px); transition: border-color .3s, opacity .4s, box-shadow .3s;
}
.nameplate b { display: block; font: 600 13px/1.15 var(--font-display); color: var(--ink); white-space: nowrap; }
.nameplate small { display: block; font-size: 10.5px; color: var(--ink-mute); white-space: nowrap; }
.nameplate .meta { display: flex; gap: 5px; justify-content: center; align-items: center; margin-top: 4px; }
.nameplate .meta:not(:has(.chip:not([hidden]), .score:not([hidden]), .pips i)) { display: none; }
.stage.live .nameplate small, .stage:has(.chip:not([hidden])) .nameplate small { display: none; }
.nameplate.speaking { border-color: #ffffff; }
.nameplate.absent { opacity: .3; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--surface-3); }
.pips i.on { background: var(--accent); }
.chip { max-width: 84px; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-soft); white-space: nowrap; }
.chip.endorse { color: var(--go); } .chip.amend { color: var(--amend); } .chip.dissent { color: var(--dissent); }
.score { white-space: nowrap; font: 600 11px/1 var(--font-display); padding: 3px 6px; border-radius: 6px; background: var(--surface-3); color: var(--ink); }
/* rebuttal arcs */
.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 34; }
.links path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 7 7; animation: dash 1.1s linear infinite; }
.links path.old { opacity: .28; }
@keyframes dash { to { stroke-dashoffset: -28; } }
/* the middle of the table: composer, captions, fault lines, verdict plate */
.center { position: absolute; z-index: 36; display: grid; place-items: start center; }
.composer { width: min(620px, 100%); display: grid; gap: 10px; text-align: center; }
.composer h2 { font: 500 clamp(20px, 2vw, 28px)/1.15 var(--font-display); margin: 0; color: var(--ink); letter-spacing: var(--track-head); }
.composer textarea {
width: 100%; resize: vertical; min-height: 72px; max-height: 200px; border-radius: 12px; border: 1px solid var(--hairline-strong);
background: rgba(8, 10, 14, .78); color: var(--ink); padding: 11px 14px; font: 14px/1.45 var(--font-text); outline: none;
}
.composer textarea::placeholder { color: var(--ink-mute); }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .18); }
.samples { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.samples button {
background: rgba(255, 255, 255, .04); color: var(--ink-soft); border: 1px solid var(--hairline-strong);
border-radius: 999px; padding: 4px 11px; font-size: 12px; transition: border-color .2s, color .2s;
}
.samples button:hover { border-color: var(--accent); color: var(--ink); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mode { display: flex; gap: 6px; }
.mode label { cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: block; text-align: left; padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--hairline-strong); color: var(--ink-soft); background: rgba(8, 10, 14, .6); }
.mode small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-mute); }
.mode input:checked + span { border-color: #ffffff; color: var(--ink); background: rgba(255, 255, 255, .06); }
.mode input:focus-visible + span { outline: 2px solid var(--accent); }
.convene {
background: #ffffff; color: #07121c; border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 600; font-size: 14px;
transition: background .2s;
}
.convene:hover { background: #e6edf5; }
.convene:disabled { opacity: .6; cursor: progress; }
.caption { width: 100%; text-align: left; animation: rise .35s var(--ease-out) both; }
.cap-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cap-av { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: var(--surface-3); flex: none; display: grid; place-items: center; border: 1px solid var(--hairline-strong); }
.cap-av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.cap-av.chair img { width: 70%; height: 70%; object-fit: contain; }
.cap-who { font: 600 15px/1.1 var(--font-display); color: var(--ink); }
.cap-tag { margin-left: auto; font-size: 10.5px; color: var(--ink-mute); font-weight: 600; text-align: right; text-transform: uppercase; letter-spacing: .1em; }
.cap-text { margin: 0; font: 500 clamp(16px, 1.5vw, 20px)/1.45 var(--font-display); color: var(--ink); letter-spacing: -0.02em; min-height: 3em; }
.cap-text .w { opacity: .14; transition: opacity .12s; }
.cap-text .w.on { opacity: 1; }
.cap-text.chair { color: var(--ink-soft); font-weight: 400; }
.cap-sub { margin-top: 8px; font-size: 12.5px; color: var(--ink-mute); min-height: 1em; }
.dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
.cruxes { display: grid; gap: 8px; width: 100%; text-align: left; }
.cruxes .head { font: 600 15px/1.25 var(--font-display); color: var(--ink); }
.cruxes .note { font-size: 13px; color: var(--ink-soft); margin-top: -2px; }
.crux { background: rgba(8, 10, 14, .7); border: 1px solid var(--hairline-strong); border-radius: 12px; padding: 9px 12px; animation: rise .5s var(--ease-out) both; }
.crux b { display: block; font-size: 13.5px; color: var(--ink); margin-bottom: 5px; font-weight: 600; }
.crux .sides { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.crux .side { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.crux .faces { display: inline-flex; }
.crux .faces img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; margin-right: -6px; border: 1.5px solid var(--surface); background: var(--surface-3); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.plate { display: grid; gap: 10px; justify-items: center; width: 100%; text-align: center; animation: rise .6s var(--ease-out) both; }
.plate p { margin: 0; font: 500 clamp(15px, 1.4vw, 18px)/1.38 var(--font-display); color: var(--ink); }
.plate .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.plate .row button { background: #ffffff; color: #07121c; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 13px; }
.plate .row button.alt { background: transparent; color: var(--ink); border: 1px solid var(--hairline-strong); }
/* playback controls */
.playbar {
position: absolute; z-index: 38; right: 14px; bottom: 12px; display: flex; gap: 8px; align-items: center;
background: rgba(7, 18, 28, .82); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px 4px 4px 12px; backdrop-filter: blur(6px);
}
.playbar .queue { font-size: 11.5px; color: var(--ink-mute); white-space: nowrap; }
.speed { display: flex; gap: 2px; }
.speed button, .skip { background: transparent; border: 0; color: var(--ink-mute); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 999px; }
.speed button[aria-pressed="true"] { background: #ffffff; color: #07121c; }
.skip { color: var(--ink-soft); border: 1px solid var(--hairline-strong); }
.skip:hover, .speed button:hover { color: var(--ink); }
/* ---------------- side panel ---------------- */
.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); position: sticky; top: 72px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--hairline); }
.tabs button { flex: 1; background: none; border: 0; padding: 12px 8px; font-weight: 600; font-size: 13px; color: var(--ink-mute); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: .4; cursor: default; }
.tabpanel { overflow-y: auto; padding: 14px 14px 20px; display: grid; gap: 10px; align-content: start; }
.empty { color: var(--ink-mute); font-size: 13.5px; padding: 18px 4px; }
.feed-phase { font: 600 10.5px/1 var(--font-text); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-mute); padding: 10px 0 2px; display: flex; align-items: center; gap: 8px; }
.feed-phase::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.feed-card { border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); cursor: pointer; animation: rise .35s var(--ease-out) both; transition: border-color .2s; }
.feed-card:hover { border-color: var(--accent); }
.feed-card .h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: var(--surface-3); flex: none; border: 1px solid var(--hairline-strong); }
.feed-card .h .r { margin-left: auto; font-size: 11px; color: var(--ink-mute); font-weight: 500; }
.feed-card p { margin: 7px 0 0; font-size: 13px; color: var(--ink-soft); }
.feed-card .q { font-size: 11.5px; color: var(--ink-mute); margin-top: 6px; }
.feed-note { font-size: 13px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 12px; color: var(--ink-soft); }
.feed-note b { color: var(--ink); font-weight: 600; }
.feed-note ul { margin: 6px 0 0; padding-left: 18px; }
.brief-block h4 { margin: 12px 0 4px; font: 600 14px/1.2 var(--font-display); color: var(--ink); }
.brief-block p, .brief-block li { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 4px; }
.brief-block ul { padding-left: 18px; margin: 0; }
.wtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.wtable td { padding: 6px 4px; border-top: 1px solid var(--hairline); vertical-align: top; color: var(--ink-soft); }
.wtable td:first-child { font-weight: 600; color: var(--ink); white-space: nowrap; }
/* ---------------- dialogs ---------------- */
.card-dialog { border: 1px solid var(--hairline-strong); border-radius: 18px; padding: 22px 24px; width: min(660px, 92vw); max-height: 86vh; background: var(--surface); color: var(--ink-soft); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); }
.card-dialog::backdrop { background: rgba(4, 6, 9, .66); backdrop-filter: blur(3px); }
.card-dialog pre { white-space: pre-wrap; font: 14px/1.6 var(--font-text); color: var(--ink-soft); margin: 10px 0 14px; }
.card-dialog h3 { font: 600 22px/1.2 var(--font-display); margin: 0 0 4px; color: var(--ink); }
.card-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.card-head img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: var(--surface-3); border: 1px solid var(--hairline-strong); }
.qcheck { font-size: 12px; margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 4px; }
.qcheck li::before { content: "✓ "; color: var(--go); font-weight: 800; }
.qcheck li.bad::before { content: "? "; color: var(--dissent); }
.history { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.history button { width: 100%; text-align: left; background: var(--surface-2); color: var(--ink); border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; }
.history button:hover { border-color: var(--accent); }
.history small { display: block; color: var(--ink-mute); }
/* ---------------- verdict sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(4, 6, 9, .7); display: grid; place-items: end center; overflow-y: auto; padding: 40px 16px 0; animation: fadein .3s both; }
@keyframes fadein { from { opacity: 0; } }
.sheet-inner { width: min(980px, 100%); background: var(--surface); border: 1px solid var(--hairline-strong); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 30px 36px 50px; animation: slideup .55s var(--ease-out) both; }
@keyframes slideup { from { transform: translateY(80px); opacity: 0; } }
.v-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.v-label { display: inline-block; font: 700 clamp(24px, 3.4vw, 38px)/1 var(--font-display); letter-spacing: -0.03em; padding: 10px 18px; border-radius: 14px; color: #04140b; background: var(--go); animation: stampbig .6s .2s cubic-bezier(.2, 1.5, .4, 1) both; margin-top: 6px; }
.v-label.reshape, .v-label.wait { background: var(--amend); color: #1c1203; }
.v-label.dont { background: var(--dissent); color: #1e0505; }
@keyframes stampbig { from { transform: scale(1.6) rotate(-6deg); opacity: 0; } }
.v-call { font: 500 clamp(18px, 1.9vw, 22px)/1.4 var(--font-display); margin: 18px 0 8px; color: var(--ink); letter-spacing: -0.03em; }
.v-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 22px; }
.v-stats span { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; color: var(--ink-soft); }
.v-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 34px; }
.v-sec h3 { font: 600 16px/1.2 var(--font-display); margin: 0 0 10px; color: var(--ink); }
.v-sec ul, .v-sec ol { margin: 0; padding-left: 18px; }
.v-sec li { margin-bottom: 7px; font-size: 14px; color: var(--ink-soft); }
.v-sec li b { color: var(--ink); font-weight: 600; }
.v-sec .tag { font-size: 11.5px; color: var(--ink-mute); }
.v-wide { grid-column: 1 / -1; }
.v-opts { display: grid; gap: 10px; }
.scorecard { width: 100%; border-collapse: collapse; font-size: 13px; }
.scorecard th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-mute); padding: 6px; border-bottom: 1px solid var(--hairline); }
.scorecard td { padding: 8px 6px; border-bottom: 1px solid var(--hairline); vertical-align: middle; color: var(--ink-soft); }
.scorecard td.n { font: 600 15px/1 var(--font-display); text-align: center; color: var(--ink); }
.scorecard .who { display: flex; gap: 8px; align-items: center; font-weight: 600; white-space: nowrap; color: var(--ink); }
.scorecard .line { font-size: 12.5px; }
.minority { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 14px; padding: 14px 16px; }
.minority .who { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.minority q { font: 500 15px/1.45 var(--font-display); display: block; margin: 8px 0; color: var(--ink); }
.boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.box { border: 1px solid var(--hairline); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-soft); }
.box b { display: block; font: 600 14px/1.2 var(--font-display); color: var(--ink); margin-bottom: 4px; }
.v-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; gap: 12px; flex-wrap: wrap; }
.v-foot .muted { font-size: 12px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface-3); color: var(--ink); border: 1px solid var(--hairline-strong); padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 13.5px; max-width: 90vw; }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--ink-mute); margin: 0 0 18px; padding: 0 16px; }
/* ---------------- responsive ---------------- */
@media (max-width: 1220px) {
.layout { grid-template-columns: minmax(0, 1fr); }
.panel { position: static; max-height: 70vh; }
.stepper li { padding: 6px 8px; }
}
@media (max-width: 820px) {
.topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
.stepper { order: 3; width: 100%; overflow-x: auto; margin: 0; }
.usage { display: none; }
.topic { flex-direction: column; align-items: stretch; margin: 12px 16px 0; padding: 14px 16px; }
.options { min-width: 0; max-width: none; flex: none; }
.layout { padding: 12px 16px 24px; }
body { overflow-x: hidden; }
.stage { aspect-ratio: auto; min-height: 0; max-height: none; overflow: visible; display: flex; flex-direction: column; }
.stage .scene { position: relative; }
.nameplate { min-width: 0; padding: 3px 6px 4px; border-radius: 8px; }
.nameplate small, .nameplate .meta .pips { display: none; }
.nameplate b { font-size: 11px; }
.center { position: relative !important; left: auto !important; top: auto !important; width: auto !important; height: auto !important; padding: 16px; border-top: 1px solid var(--hairline); background: var(--canvas); border-radius: 0 0 20px 20px; }
.composer-row { justify-content: center; }
.mode { flex-wrap: wrap; justify-content: center; }
.playbar { position: static; margin: 0 16px 14px; justify-content: space-between; align-self: stretch; }
.think { padding: 4px 6px; }
.think i { width: 4px; height: 4px; }
.v-grid, .boxes { grid-template-columns: 1fr; }
.sheet-inner { padding: 22px 18px 40px; }
.scorecard .line { display: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* AIS arrival: blocks fade and rise, headings type in per character */
.arrive { animation: rise 1s var(--ease-out) both; }
.typein .ch { display: inline-block; opacity: 0; filter: blur(6px); animation: chin .5s var(--ease-out) forwards; white-space: pre; }
@keyframes chin { to { opacity: 1; filter: blur(0); } }
/* viewer mode: waiting for a council started in Claude Code */
.waiting { display: grid; gap: 12px; justify-items: center; text-align: center; width: min(560px, 100%); }
.waiting h2 { font: 500 clamp(20px, 2vw, 28px)/1.15 var(--font-display); margin: 0; color: var(--ink); letter-spacing: var(--track-head); }
.waiting p { margin: 0; color: var(--ink-soft); font-size: 14px; max-width: 48ch; }
.waiting code { font: 600 13px/1 var(--font-text); color: var(--ink); background: var(--surface-2); border: 1px solid var(--hairline-strong); border-radius: 8px; padding: 7px 10px; }
.waiting .pulse { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.waiting .pulse i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.6s infinite ease-in-out; }
.waiting .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
/* simplified record and verdict */
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--hairline); font: 600 11px/1 var(--font-text); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.feed-card { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 10px 12px; }
.feed-card .h { font-size: 13px; }
.feed-card p { margin: 3px 0 0; font-size: 12.5px; line-height: 1.45; }
.feed-note b { font-weight: 600; }
.v-meta { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-mute); }
.v-meta b { color: var(--ink-soft); font-weight: 600; }
.v-why, .v-steps { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 10px; }
.v-why li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; margin: 0 !important; }
.v-steps li { margin: 0 !important; }
.v-steps li b { display: inline-block; min-width: 64px; color: var(--ink); font-weight: 600; }
.v-more { margin-top: 28px; border-top: 1px solid var(--hairline); padding-top: 16px; }
.v-more summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-soft); list-style: none; display: inline-flex; align-items: center; gap: 8px; }
.v-more summary::-webkit-details-marker { display: none; }
.v-more summary::before { content: "+"; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--hairline-strong); display: grid; place-items: center; font-size: 13px; }
.v-more[open] summary::before { content: "−"; }
.v-more[open] summary { margin-bottom: 20px; }
.v-sec p { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; }
.nameplate small, .nameplate .pips { display: none !important; }
+28
View File
@@ -0,0 +1,28 @@
// Smoke test: one Chair setup call and one seat card, no full council.
import { SEATS, systemFor, parseCard, checkQuotes } from "../lib/seats.mjs";
import * as ai from "../lib/anthropic.mjs";
import { MODELS } from "../lib/council.mjs";
const sys = systemFor("hormozi");
console.log("hormozi system chars:", sys[0].text.length);
const t0 = Date.now();
const card = await ai.stream({
model: MODELS.seat, system: sys, maxTokens: 900,
messages: [{ role: "user", content: `FOUNDER COUNCIL, ROUND 1 OF 3: OPENING POSITION
You hold the HORMOZI seat. THE BRIEF: A $30k/month coaching business wants to raise prices from $2,000 to $3,500. Options: (A) raise for everyone now, (B) raise for new clients only, (C) keep $2,000.
Answer under 200 words in this shape:
SEAT: HORMOZI
STANCE: ...
OPTION SCORES: A n/10 · B n/10 · C n/10
PILLAR SCORE: n/10
CONFIDENCE: n/5
RUIN RISK: none | possible | likely
DOOR: one-way | two-way
THE CALL: one sentence.
WHY: 1. with a framework and source id, e.g. (Value Equation, S014)` }],
});
console.log(`seat card in ${((Date.now() - t0) / 1000).toFixed(1)}s\n`, card);
console.log(parseCard(card, ["A", "B", "C"]));
console.log(checkQuotes("hormozi", card));
console.log(ai.usage);
+78
View File
@@ -0,0 +1,78 @@
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 { 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" };
let running = null; // one council at a time (API runner)
// "viewer" (default): the room plays councils that /founder-council runs in Claude Code.
// "api": the room can also run councils itself on ANTHROPIC_API_KEY (COUNCIL_RUNNER=api in .env).
const RUNNER = (process.env.COUNCIL_RUNNER || env("COUNCIL_RUNNER") || "viewer").toLowerCase() === "api" ? "api" : "viewer";
watch.startWatching();
function send(res, code, body, type = "application/json") {
res.writeHead(code, { "content-type": type, "cache-control": "no-store" });
res.end(typeof body === "string" ? body : JSON.stringify(body));
}
async function readJson(req) {
let raw = "";
for await (const c of req) { raw += c; if (raw.length > 1e5) throw new Error("body too large"); }
return raw ? JSON.parse(raw) : {};
}
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/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 /founder-council in Claude Code, or set COUNCIL_RUNNER=api in .env." });
if (running && getSession(running)?.status === "running") return send(res, 409, { error: "A council is already in session. Wait for its verdict." });
const { prompt, mode } = await readJson(req);
if (!prompt || prompt.trim().length < 10) return send(res, 400, { error: "Give the council a real decision (at least a sentence)." });
const s = startCouncil(prompt.trim().slice(0, 4000), mode === "quick" ? "quick" : "full");
running = s.id;
return send(res, 200, { id: s.id });
}
if (p.startsWith("/api/stream/")) {
const id = decodeURIComponent(p.split("/").pop());
const s = getSession(id) || watch.getLive(id);
if (!s) return send(res, 404, { error: "no such session" });
res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-store", connection: "keep-alive" });
res.write(": connected\n\n");
const ping = setInterval(() => res.write(": ping\n\n"), 15000);
res.on("close", () => clearInterval(ping));
return subscribe(s, res);
}
if (p === "/api/sessions") {
const all = [...listSaved(), ...watch.listLive()].sort((a, b) => (a.id < b.id ? 1 : -1));
const apiRunning = running && getSession(running)?.status === "running" ? running : null;
return send(res, 200, { sessions: all, running: apiRunning, live: watch.runningId() });
}
if (p.startsWith("/api/sessions/")) {
const id = decodeURIComponent(p.split("/").pop());
const x = watch.getLive(id);
const j = loadSaved(id) || (x && { id, title: x.title, mode: x.mode, status: x.status, events: x.events });
return j ? send(res, 200, j) : send(res, 404, { error: "not found" });
}
// static
const file = path.normalize(path.join(PUBLIC, p === "/" ? "index.html" : p));
if (!file.startsWith(PUBLIC) || !fs.existsSync(file) || fs.statSync(file).isDirectory()) return send(res, 404, "Not found", "text/plain");
res.writeHead(200, { "content-type": TYPES[path.extname(file)] || "application/octet-stream", "cache-control": "no-store" });
fs.createReadStream(file).pipe(res);
} catch (e) {
send(res, 500, { error: String(e.message || e) });
}
});
server.listen(PORT, "127.0.0.1", () => console.log(`Founder Council room on http://localhost:${PORT} (${RUNNER === "api" ? "viewer + API runner" : "viewer: run /founder-council in Claude Code"})`));