Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 9 additions & 7 deletions src/ai/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -69,13 +71,13 @@ export interface ModelInfo {
}
const CLAUDE_MODELS = "https://platform.claude.com/docs/en/models/overview";
export const MODEL_INFO: Record<string, ModelInfo> = {
"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 {
Expand Down
92 changes: 67 additions & 25 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
56 changes: 46 additions & 10 deletions src/components/AskPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
<span className={cx("ws-ask__ctx", share > 0.8 && "is-full")} title={label} aria-label={label} role="img">
<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
<circle cx="8" cy="8" r={r} fill="none" stroke="currentColor" strokeOpacity="0.25" strokeWidth="2" />
<circle cx="8" cy="8" r={r} fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeDasharray={`${Math.max(0.6, share * round)} ${round}`} transform="rotate(-90 8 8)" />
</svg>
</span>
);
}

function StateDot({ state }: { state: Recipient["state"] }) {
const on = state === "listening" || state === "working" || state === "ready";
return <span className={cx("ws-status-dot", on && "is-on", state === "stopped" && "is-warn")} aria-hidden />;
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -698,29 +732,30 @@ export function AskPanel({
}}
>
<header className="ws-ask__top">
<span className="ws-ask__plan" title={slot === "framework" ? "This conversation belongs to this plan" : `About ${aboutLabel(slot)}. Right-click a part to ask about it; naming a part in a message works too.`}>
{plan.appName.trim() || "Untitled app"}
{slot !== "framework" && ` · ${index.slotsById.get(slot)?.label ?? slot}`}
</span>
<button
type="button"
className="ws-ask__new"
className="ws-iconbtn ws-ask__new"
disabled={plan.chat.length === 0}
title="Clears the built-in AI's answers in this browser. Agent messages stay with the shared plan."
aria-label="New chat"
title="New chat. Clears the built-in AI's answers in this browser; agent messages stay with the shared plan."
onClick={() => {
dispatch({ type: "clearChat" });
onToast("New chat. Agent messages stay with the shared plan.");
}}
>
New chat
<Icon name="plus" size={15} />
</button>
<span className="ws-ask__plan" title={slot === "framework" ? "This conversation belongs to this plan" : `About ${aboutLabel(slot)}. Right-click a part to ask about it; naming a part in a message works too.`}>
{plan.appName.trim() || "Untitled app"}
{slot !== "framework" && ` · ${index.slotsById.get(slot)?.label ?? slot}`}
</span>
{mixed && (
<button type="button" className={cx("ws-iconbtn", onlyThis && "is-on")} aria-pressed={onlyThis} title={onlyThis ? `Showing only ${aboutLabel(slot)}` : `Show only ${aboutLabel(slot)}`} onClick={() => setOnlyThis((v) => !v)}>
<Icon name="target" size={14} />
</button>
)}
<button type="button" className="ws-iconbtn ws-ask__hide" onClick={onClose} aria-label="Hide the chat" title={`Hide the chat (${mod}K)`}>
<Icon name="chevron" size={14} />
<Icon name="sidebar" size={16} />
</button>
</header>

Expand Down Expand Up @@ -794,6 +829,7 @@ export function AskPanel({
<span>{modelLabel}</span>
<Icon name="down" size={11} />
</button>
{apiModelInfo && <ContextRing used={contextUsed} window={apiModelInfo.contextTokens} />}
<button type="submit" className="ws-ask__send" disabled={busy || !question.trim()} aria-label="Send">
<Icon name="send" size={15} />
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Planner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
Loading
Loading