diff --git a/CLAUDE.md b/CLAUDE.md index 4f6b084..8fafdb6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,7 +16,7 @@ Planning tool for beginners building web apps with AI builders. A deterministic ## Map - `data/` is the product's knowledge. `src/engine/load.ts` parses it with `schema.ts`; `integrity.ts` holds the cross-file checks `data.test.ts` enforces. -- `src/engine/talk.ts` builds the brief for talking one part through (connection, setup, checks, cost, facts, alternatives with verdicts, the note), answers from it without Claude (`answerFromFacts`), and drafts notes. `src/ai/talk.ts` asks Claude with that brief; `src/app/api/talk` falls back to the facts. `src/components/AskPanel.tsx` is the one place to talk to AI: a chat pane docked on the left of the canvas (Cmd+K, the Ask button, double-click, right-click "Ask about this"), one conversation per plan, with starters when it's empty and a composer whose answerer menu sends each message to a terminal agent, a built-in AI (with a model picker beside it), or StackWise's facts. It shares the left side with the panels: opening one closes the other (`openPanel`, `toggleAsk` in Workspace). `NoteEditor.tsx` is the note, in Details and in a connection. +- `src/engine/talk.ts` builds the brief for talking one part through (connection, setup, checks, cost, facts, alternatives with verdicts, the note), answers from it without Claude (`answerFromFacts`), and drafts notes. `src/ai/talk.ts` asks Claude with that brief; `src/app/api/talk` falls back to the facts. `src/components/AskPanel.tsx` is the one place to talk to AI: a chat pane docked on the left of the canvas (Cmd+K, the Ask button, double-click, right-click "Ask about this"), one conversation per plan, with starters when it's empty and a composer whose answerer menu sends each message to a terminal agent, a built-in AI (with a model picker beside it), or StackWise's facts. On a window 1100px or wider a left panel (Overview, Parts, Checklist, Project, Learn) floats beside it (`.ws[data-ask="open"] .ws-float--left`); narrower than that, opening one closes the other (`roomForBoth`, `openPanel`, `toggleAsk` in Workspace). While the pane opens or closes, `data-settling` on `.ws` turns on 240ms transitions for the canvas, bar, dock, sheet and panel, so nothing pops; dragging the pane's edge stays immediate. `NoteEditor.tsx` is the note, in Details and in a connection. - `src/engine/wiring.ts` turns a stack into connections and the environment variables that travel along each one (names, where each value comes from, whether the browser can read it), plus the `.env` file text. It never holds a value. - `src/engine/evaluate.ts` produces verdicts. `score.ts` ranks and searches (branch and bound, tested against brute force; domains rank on first-year and renewal price, payments on the fee from a $20 sale). `cost.ts` adds yearly and one-time costs (domains, `planning.json` `fees`) and counts a shared plan once (`shared_plans`, or one option in two parts). `followups.ts` picks questions. `stats.ts` turns facts into the stats on cards, nodes, Details, Compare and the strip above the canvas. `cost.ts`, `spec.ts`, `checklist.ts`, `decisions.ts`, `share.ts`, `staleness.ts`, `summary.ts`, `prefill.ts` do what their names say. - `data/logos.json` says where each logo comes from (Simple Icons slug or the service's site); `scripts/logos.ts` fetches them into `public/logos/`, which is committed. `Logo` in `src/components/ui.tsx` falls back to a letter if a file is missing. diff --git a/src/ai/providers.ts b/src/ai/providers.ts index 20223b2..2265d83 100644 --- a/src/ai/providers.ts +++ b/src/ai/providers.ts @@ -61,6 +61,8 @@ export interface ModelInfo { /** What it's for, in the provider's words. */ note: string; context: string; + /** The same window as a number of tokens, for the ring that shows how much of it a conversation uses. */ + contextTokens: number; output: string; /** Input / output, per million tokens. */ price: string; @@ -69,13 +71,13 @@ export interface ModelInfo { } const CLAUDE_MODELS = "https://platform.claude.com/docs/en/models/overview"; export const MODEL_INFO: Record = { - "claude-opus-5": { id: "claude-opus-5", name: "Opus 5", note: "The Opus before 5.5, still available.", context: "1M", output: "128K", price: "$5 / $25", source: "https://platform.claude.com/docs/en/models/opus-5/overview", checked_on: "2026-10-22" }, - "claude-fable-5-1": { id: "claude-fable-5-1", name: "Fable 5.1", note: "For demanding reasoning and long-horizon agentic work.", context: "1M", output: "128K", price: "$10 / $50", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, - "claude-opus-5-5": { id: "claude-opus-5-5", name: "Opus 5.5", note: "For long-running agentic coding and knowledge work.", context: "1M", output: "128K", price: "$4 / $20", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, - "claude-sonnet-5-5": { id: "claude-sonnet-5-5", name: "Sonnet 5.5", note: "The best combination of speed and intelligence.", context: "1M", output: "128K", price: "$2 / $10", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, - "claude-haiku-5-5": { id: "claude-haiku-5-5", name: "Haiku 5.5", note: "For high-volume, latency-sensitive tasks.", context: "1M", output: "128K", price: "from $0.10 / $0.50", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, - "gpt-6-luna": { id: "gpt-6-luna", name: "GPT-6 Luna", note: "OpenAI's most efficient model for focused, high-volume tasks.", context: "1.05M", output: "128K", price: "$0.10 / $0.50", source: "https://developers.openai.com/api/docs/models/gpt-6-luna", checked_on: "2026-10-22" }, - "gemini-3.8-flash": { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash", note: "Google's most intelligent Flash model, for long-horizon software engineering and agents.", context: "1M", output: "64K", price: "$0.75 / $3.75", source: "https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash", checked_on: "2026-10-22" }, + "claude-opus-5": { id: "claude-opus-5", name: "Opus 5", note: "The Opus before 5.5, still available.", context: "1M", contextTokens: 1_000_000, output: "128K", price: "$5 / $25", source: "https://platform.claude.com/docs/en/models/opus-5/overview", checked_on: "2026-10-22" }, + "claude-fable-5-1": { id: "claude-fable-5-1", name: "Fable 5.1", note: "For demanding reasoning and long-horizon agentic work.", context: "1M", contextTokens: 1_000_000, output: "128K", price: "$10 / $50", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, + "claude-opus-5-5": { id: "claude-opus-5-5", name: "Opus 5.5", note: "For long-running agentic coding and knowledge work.", context: "1M", contextTokens: 1_000_000, output: "128K", price: "$4 / $20", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, + "claude-sonnet-5-5": { id: "claude-sonnet-5-5", name: "Sonnet 5.5", note: "The best combination of speed and intelligence.", context: "1M", contextTokens: 1_000_000, output: "128K", price: "$2 / $10", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, + "claude-haiku-5-5": { id: "claude-haiku-5-5", name: "Haiku 5.5", note: "For high-volume, latency-sensitive tasks.", context: "1M", contextTokens: 1_000_000, output: "128K", price: "from $0.10 / $0.50", source: CLAUDE_MODELS, checked_on: "2026-10-22" }, + "gpt-6-luna": { id: "gpt-6-luna", name: "GPT-6 Luna", note: "OpenAI's most efficient model for focused, high-volume tasks.", context: "1.05M", contextTokens: 1_050_000, output: "128K", price: "$0.10 / $0.50", source: "https://developers.openai.com/api/docs/models/gpt-6-luna", checked_on: "2026-10-22" }, + "gemini-3.8-flash": { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash", note: "Google's most intelligent Flash model, for long-horizon software engineering and agents.", context: "1M", contextTokens: 1_048_576, output: "64K", price: "$0.75 / $3.75", source: "https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash", checked_on: "2026-10-22" }, }; /** The short name the pickers show for a model id, or the id itself. */ export function modelName(id: string): string { diff --git a/src/app/globals.css b/src/app/globals.css index 5b79a33..59be2eb 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1675,6 +1675,38 @@ html[data-desktop] .ws[data-ask="open"] .ws-bar { .ws[data-ask="open"] .ws-dock { left: calc(var(--ask-w) + (100% - var(--ask-w)) / 2); } +/* A left panel opens beside the pane, not over it. */ +.ws[data-ask="open"] .ws-float--left { + left: calc(var(--ask-w) + 12px); +} +/* The pane slides in, and while it opens or closes everything that makes room for it glides. */ +.ws-ask { + animation: ws-slide-in 240ms var(--mk-ease); +} +@keyframes ws-slide-in { + from { + transform: translateX(-100%); + } +} +.ws[data-settling="yes"] .ws-canvas, +.ws[data-settling="yes"] .ws-sheet-wrap, +.ws[data-settling="yes"] .ws-bar, +.ws[data-settling="yes"] .ws-dock, +.ws[data-settling="yes"] .ws-float--left { + transition: left 240ms var(--mk-ease); +} +@media (prefers-reduced-motion: reduce) { + .ws-ask { + animation: none; + } + .ws[data-settling="yes"] .ws-canvas, + .ws[data-settling="yes"] .ws-sheet-wrap, + .ws[data-settling="yes"] .ws-bar, + .ws[data-settling="yes"] .ws-dock, + .ws[data-settling="yes"] .ws-float--left { + transition: none; + } +} /* In the Mac app the traffic lights sit in the pane's top row, or in the bar when the pane is closed. */ html[data-desktop] .ws-ask__top { padding-left: 84px; @@ -1703,39 +1735,32 @@ html[data-desktop] .ws-ask__top { height: var(--bar-h); padding: 0 10px 0 12px; } -.ws-ask__hide svg { - transform: rotate(180deg); +/* The header: the plan's name, then new chat and hide as plain icons, like a sidebar's own controls. */ +.ws-ask__plan { + flex: 1; + min-width: 0; + overflow: hidden; + padding: 0 4px; + color: var(--mk-text); + font-size: 0.93em; + font-weight: 600; + text-overflow: ellipsis; + white-space: nowrap; } -.ws-ask__new { - flex: none; +.ws-ask__top .ws-iconbtn { + width: 28px; height: 28px; - padding: 0 12px; - border: 0; - border-radius: 999px; + background: transparent; +} +.ws-ask__top .ws-iconbtn:hover:not(:disabled) { background: var(--ws-fill); color: var(--mk-text); - font: inherit; - font-size: 0.86em; - font-weight: 600; - cursor: pointer; } -.ws-ask__new:hover:not(:disabled) { - background: var(--ws-fill-hover); -} -.ws-ask__new:disabled { +.ws-ask__top .ws-iconbtn:disabled { color: var(--mk-text-faint); + opacity: 0.5; cursor: default; } -.ws-ask__plan { - flex: 1; - min-width: 0; - overflow: hidden; - padding: 0 6px; - color: var(--mk-text-faint); - font-size: 0.86em; - text-overflow: ellipsis; - white-space: nowrap; -} .ws-iconbtn.is-on { background: var(--mk-accent); color: #fff; @@ -1760,6 +1785,17 @@ html[data-desktop] .ws-ask__top { color: var(--mk-text-muted); font-weight: 500; } +.ws-ask__ctx { + display: inline-grid; + flex: none; + place-items: center; + width: 24px; + height: 28px; + color: var(--mk-text-muted); +} +.ws-ask__ctx.is-full { + color: var(--mk-warn); +} .ws-answerer:disabled { cursor: default; opacity: 0.6; @@ -2467,6 +2503,12 @@ html[data-desktop] .ws-ask__top { .ws[data-ask="open"] .ws-dock { left: 50%; } + .ws[data-ask="open"] .ws-float--left { + left: 8px; + } + .ws-ask { + animation: ws-pop var(--mk-dur) var(--mk-ease); + } .ws-bar__nav, .ws-ask .ws-edge-grip { display: none; diff --git a/src/components/AskPanel.tsx b/src/components/AskPanel.tsx index 5558548..e71c82d 100644 --- a/src/components/AskPanel.tsx +++ b/src/components/AskPanel.tsx @@ -40,6 +40,9 @@ export interface AskRequest { const EXPLAIN = "Explain my plan"; const HISTORY_TURNS = 20; +/** What a question carries besides the conversation: the part's brief (facts, checks, setup), about this many characters. */ +const BRIEF_CHARS = 6000; +const CHARS_PER_TOKEN = 4; interface Starter { label: string; @@ -130,6 +133,22 @@ function Formatted({ text }: { text: string }) { return <>{blocks}; } +/** How much of the model's context window the next message would use, as a ring that fills. */ +function ContextRing({ used, window: limit }: { used: number; window: number }) { + const share = Math.min(1, used / limit); + const r = 5.5; + const round = r * 2 * Math.PI; + const label = `Context: about ${used < 1000 ? used : `${Math.round(used / 1000)}K`} of ${limit >= 1_000_000 ? `${(limit / 1_000_000).toFixed(limit % 1_000_000 ? 2 : 0)}M` : `${Math.round(limit / 1000)}K`} tokens`; + return ( + 0.8 && "is-full")} title={label} aria-label={label} role="img"> + + + ); +} + function StateDot({ state }: { state: Recipient["state"] }) { const on = state === "listening" || state === "working" || state === "ready"; return ; @@ -652,7 +671,7 @@ export function AskPanel({ const known = info(m); items.push({ label: `${known?.name ?? m}${!viaAgent && m === api.defaultModel ? " (default)" : ""}`, - hint: known ? `${known.context} context · ${known.price} per M` : undefined, + hint: known?.price, checked: viaAgent ? agentModel === m : recipient.id === `api:${api.id}` && current === m, onSelect: () => { if (viaAgent) { @@ -669,8 +688,23 @@ export function AskPanel({ if (provider.id === "facts") items.push({ label: "Facts only, no AI", checked: true, onSelect: () => setChosen("facts") }); setMenu({ x: box.left, y: box.top - 6, items }); }; + // The ring: what the next message would send (this part's brief, the recent turns, the draft) against the model's window. + const apiModelInfo = api && !agent ? api.modelInfo?.find((x) => x.id === (api.model || api.defaultModel)) : undefined; + const contextUsed = Math.round( + (BRIEF_CHARS + + question.length + + plan.chat + .filter((t) => t.about === slot) + .slice(-HISTORY_TURNS) + .reduce((n, t) => n + t.text.length, 0)) / + CHARS_PER_TOKEN, + ); + + // The bubble names the model alone; the provider bubble already says whose it is. const modelLabel = agent - ? `${agentRecipient?.label ?? agentName(agent)}${agentModel && api ? ` · ${modelNameOf(api, agentModel)}` : ""}` + ? agentModel && api + ? modelNameOf(api, agentModel) + : "Default model" : provider.id === "facts" ? "Facts only" : api @@ -698,29 +732,30 @@ export function AskPanel({ }} >
+ + {plan.appName.trim() || "Untitled app"} + {slot !== "framework" && ` · ${index.slotsById.get(slot)?.label ?? slot}`} + - - {plan.appName.trim() || "Untitled app"} - {slot !== "framework" && ` · ${index.slotsById.get(slot)?.label ?? slot}`} - {mixed && ( )}
@@ -794,6 +829,7 @@ export function AskPanel({ {modelLabel} + {apiModelInfo && } diff --git a/src/components/Planner.tsx b/src/components/Planner.tsx index 31bde15..6d0d510 100644 --- a/src/components/Planner.tsx +++ b/src/components/Planner.tsx @@ -23,7 +23,7 @@ export interface ProviderInfo { modelEnv?: string; models?: string[]; /** What's known about each offered model: a short name, context window, output limit, price. */ - modelInfo?: { id: string; name: string; note: string; context: string; output: string; price: string; source: string; checked_on: string }[]; + modelInfo?: { id: string; name: string; note: string; context: string; contextTokens: number; output: string; price: string; source: string; checked_on: string }[]; defaultModel?: string; /** What it still needs in .env.local, by name. Older servers leave it out. */ needs?: string[]; diff --git a/src/components/Workspace.tsx b/src/components/Workspace.tsx index a8474d5..eede1b9 100644 --- a/src/components/Workspace.tsx +++ b/src/components/Workspace.tsx @@ -106,12 +106,25 @@ export default function Workspace({ catalog, problems }: { catalog: Catalog; pro // Private windows: the pane's state lasts until the tab closes. } }, [ask.open]); - // The chat pane and the left panel share the left side of the canvas: opening one closes the other. - const closeAsk = useCallback(() => setAsk((a) => (a.open ? { ...a, open: false, request: null } : a)), []); + // The chat pane and a left panel can share the left side when the window has room for both: + // the panel then floats beside the pane. On a narrow window, opening one closes the other. + const roomForBoth = () => window.innerWidth >= 1100; + /** While the pane opens or closes, the canvas, the bar and the dock glide to their new place (CSS reads this). */ + const [settling, setSettling] = useState(false); + const settleTimer = useRef(0); + const settle = useCallback(() => { + setSettling(true); + window.clearTimeout(settleTimer.current); + settleTimer.current = window.setTimeout(() => setSettling(false), 300); + }, []); + const closeAsk = useCallback(() => { + settle(); + setAsk((a) => (a.open ? { ...a, open: false, request: null } : a)); + }, [settle]); const openPanel = useCallback( (next: Panel) => { setPanel(next); - closeAsk(); + if (!roomForBoth()) closeAsk(); }, [closeAsk], ); @@ -120,9 +133,10 @@ export default function Workspace({ catalog, problems }: { catalog: Catalog; pro else openPanel(next); }; const toggleAsk = useCallback(() => { - if (!ask.open) setPanel(null); + if (!ask.open && !roomForBoth()) setPanel(null); + settle(); setAsk((a) => ({ ...a, open: !a.open, request: null })); - }, [ask.open]); + }, [ask.open, settle]); const [menu, setMenu] = useState(null); const [dragging, setDragging] = useState(null); const [showAll, setShowAll] = useState(false); @@ -306,9 +320,10 @@ export default function Workspace({ catalog, problems }: { catalog: Catalog; pro setConnection(null); }, []); const openAsk = useCallback((slot: SlotId, question?: string) => { - setPanel(null); + if (!roomForBoth()) setPanel(null); + if (!ask.open) settle(); setAsk({ open: true, slot, request: question ? { slot, question, nonce: Date.now() } : null }); - }, []); + }, [ask.open, settle]); const openAdd = useCallback((slot?: SlotId) => setAdding({ focus: slot ?? null }), []); /** @@ -411,7 +426,7 @@ export default function Workspace({ catalog, problems }: { catalog: Catalog; pro label: `Build this with ${builderAgent.label}`, icon: "terminal", onSelect: () => { - setPanel(null); + if (!roomForBoth()) setPanel(null); setAsk({ open: true, slot: task.slot, request: { slot: task.slot, question: taskBrief(tasks, taskId, plan.appName, testPlan(index, model.input, rec.selection, task, plan.appName))!, nonce: Date.now(), to: builderAgent.id } }); }, }, @@ -653,7 +668,7 @@ export default function Workspace({ catalog, problems }: { catalog: Catalog; pro const answererState = answerer.id === "facts" ? "Connect" : answerer.group === "api" ? "Ready" : STATE_TEXT[answerer.state]; return ( -
+