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

+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"})`));