Skip to content
Closed
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
29 changes: 19 additions & 10 deletions src/cli/ui/Wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
import type { LanguageCode } from "../../i18n/types.js";
import { type CatalogEntry, MCP_CATALOG } from "../../mcp/catalog.js";
import { MultiSelect, type SelectItem, SingleSelect } from "./Select.js";
import { PRESET_DESCRIPTIONS } from "./presets.js";
import { ThemeProvider, useTheme } from "./theme/context.js";
import { type ThemeName, listThemeNames } from "./theme/tokens.js";

Expand Down Expand Up @@ -597,10 +596,10 @@ function McpArgsStep({
return (
<StepFrame title={t("wizard.mcpArgsTitle", { name: entry.name })} step={2} total={3}>
<Box flexDirection="column">
<Text>{entry.summary}</Text>
{entry.note ? (
<Text>{mcpCatalogSummary(entry)}</Text>
{mcpCatalogNote(entry) ? (
<Box marginTop={1}>
<Text dimColor>{entry.note}</Text>
<Text dimColor>{mcpCatalogNote(entry)}</Text>
</Box>
) : null}
<Box marginTop={1}>
Expand Down Expand Up @@ -705,19 +704,20 @@ function SummaryLine({ label, value }: { label: string; value: string }) {
);
}

function presetItems(): SelectItem<PresetName>[] {
export function presetItems(): SelectItem<PresetName>[] {
return (["auto", "flash", "pro"] as const).map((name) => ({
value: name as PresetName,
label: `${name} — ${PRESET_DESCRIPTIONS[name].headline}`,
hint: PRESET_DESCRIPTIONS[name].cost,
label: `${name} — ${t(`wizard.presetDescriptions.${name}.headline`)}`,
hint: t(`wizard.presetDescriptions.${name}.cost`),
}));
}

function mcpItems(): SelectItem<string>[] {
export function mcpItems(): SelectItem<string>[] {
return MCP_CATALOG.map((entry) => {
const hintParts: string[] = [entry.summary];
const hintParts: string[] = [mcpCatalogSummary(entry)];
if (entry.userArgs) hintParts.push(t("wizard.mcpUserArgsHint", { arg: entry.userArgs }));
if (entry.note) hintParts.push(entry.note);
const note = mcpCatalogNote(entry);
if (note) hintParts.push(note);
return {
value: entry.name,
label: entry.name,
Expand All @@ -726,6 +726,15 @@ function mcpItems(): SelectItem<string>[] {
});
}

function mcpCatalogSummary(entry: CatalogEntry): string {
return t(`wizard.mcpCatalog.${entry.name}.summary`);
}

function mcpCatalogNote(entry: CatalogEntry): string | undefined {
if (!entry.note) return undefined;
return t(`wizard.mcpCatalog.${entry.name}.note`);
}

function placeholderFor(entry: CatalogEntry): string {
if (entry.name === "filesystem") return "e.g. /tmp/carboncode-sandbox";
if (entry.name === "sqlite") return "e.g. ./notes.sqlite";
Expand Down
35 changes: 35 additions & 0 deletions src/i18n/EN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,41 @@ export const EN: TranslationSchema = {
"github-light": "GitHub light",
"high-contrast": "Accessibility",
},
presetDescriptions: {
auto: {
headline: "flash → pro on hard turns",
cost: "default · ~96% turns stay on flash · pro kicks in only when needed",
},
flash: {
headline: "v4-flash always",
cost: "cheapest · predictable · /pro still works for a one-turn bump",
},
pro: {
headline: "v4-pro always",
cost: "~3× flash (5/31 discount) / ~12× full price · for hard multi-turn work",
},
},
mcpCatalog: {
filesystem: {
summary: "read/write/search files inside a sandboxed directory",
note: "the directory is a hard sandbox — the server refuses access outside it",
},
memory: {
summary: "persistent key-value memory across sessions",
},
github: {
summary: "read issues, PRs, code search (needs GITHUB_PERSONAL_ACCESS_TOKEN)",
note: "set GITHUB_PERSONAL_ACCESS_TOKEN in your env before spawning",
},
puppeteer: {
summary: "browser automation — take screenshots, click, type",
note: "downloads Chromium on first run (~200 MB)",
},
everything: {
summary: "official test server — exercises every MCP feature",
note: "useful for debugging your Carbon Code setup",
},
},
reviewLabelTheme: "Theme",
presetTitle: "Pick a preset",
mcpTitle: "Which MCP servers should Carbon Code wire up for you?",
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ export interface TranslationSchema {
themeSampleHeading: string;
themeFooter: string;
themeCaption: Record<string, string>;
presetDescriptions: Record<"auto" | "flash" | "pro", { headline: string; cost: string }>;
mcpCatalog: Record<
"filesystem" | "memory" | "github" | "puppeteer" | "everything",
{ summary: string; note?: string }
>;
reviewTitle: string;
reviewLabelApiKey: string;
reviewLabelLanguage: string;
Expand Down
35 changes: 35 additions & 0 deletions src/i18n/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,41 @@ export const zhCN: TranslationSchema = {
"github-light": "GitHub 浅色",
"high-contrast": "高对比度(无障碍)",
},
presetDescriptions: {
auto: {
headline: "困难轮次从 flash 升级到 pro",
cost: "默认 · 大多数轮次使用 flash · 需要时才启用 pro",
},
flash: {
headline: "始终使用 v4-flash",
cost: "最便宜 · 可预测 · 仍可用 /pro 临时提升一轮",
},
pro: {
headline: "始终使用 v4-pro",
cost: "约 3 倍 flash(5/31 折扣)/ 原价约 12 倍 · 适合困难的多轮工作",
},
},
mcpCatalog: {
filesystem: {
summary: "在沙箱目录内读取、写入和搜索文件",
note: "该目录是严格沙箱 — 服务器会拒绝访问目录外的路径",
},
memory: {
summary: "跨会话保存持久化键值记忆",
},
github: {
summary: "读取 issues、PR 和代码搜索(需要 GITHUB_PERSONAL_ACCESS_TOKEN)",
note: "启动前请在环境变量中设置 GITHUB_PERSONAL_ACCESS_TOKEN",
},
puppeteer: {
summary: "浏览器自动化 — 截图、点击、输入",
note: "首次运行会下载 Chromium(约 200 MB)",
},
everything: {
summary: "官方测试服务器 — 覆盖所有 MCP 功能",
note: "适合调试 Carbon Code 设置",
},
},
reviewLabelTheme: "主题",
presetTitle: "选择预设",
mcpTitle: "Carbon Code 要为你接入哪些 MCP 服务器?",
Expand Down
48 changes: 47 additions & 1 deletion tests/wizard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import { render } from "ink-testing-library";
import React from "react";
import { afterEach, describe, expect, it } from "vitest";
import { Wizard, buildSpec, validateDeepSeekApiKey } from "../src/cli/ui/Wizard.js";
import {
Wizard,
buildSpec,
mcpItems,
presetItems,
validateDeepSeekApiKey,
} from "../src/cli/ui/Wizard.js";
import { setLanguageRuntime } from "../src/i18n/index.js";
import { parseMcpSpec } from "../src/mcp/spec.js";

Expand Down Expand Up @@ -66,6 +72,46 @@ describe("Wizard — first-launch language picker", () => {
});
});

describe("Wizard — localized preset descriptions", () => {
afterEach(() => {
setLanguageRuntime("EN");
});

it("shows preset descriptions in zh-CN when runtime language is Simplified Chinese", () => {
setLanguageRuntime("zh-CN");
const items = presetItems();

expect(items.map((item) => item.label)).toEqual([
"auto — 困难轮次从 flash 升级到 pro",
"flash — 始终使用 v4-flash",
"pro — 始终使用 v4-pro",
]);
expect(items.map((item) => item.hint).join("\n")).not.toContain("hard turns");
});
});

describe("Wizard — localized MCP catalog descriptions", () => {
afterEach(() => {
setLanguageRuntime("EN");
});

it("shows MCP catalog summaries and notes in zh-CN", () => {
setLanguageRuntime("zh-CN");
const items = mcpItems();
const filesystem = items.find((item) => item.value === "filesystem");
const github = items.find((item) => item.value === "github");

expect(filesystem?.hint).toContain("在沙箱目录内读取、写入和搜索文件");
expect(filesystem?.hint).toContain("需要你提供 <dir>");
expect(filesystem?.hint).toContain("服务器会拒绝访问目录外的路径");
expect(github?.hint).toContain("读取 issues、PR 和代码搜索");
expect(github?.hint).toContain("启动前请在环境变量中设置 GITHUB_PERSONAL_ACCESS_TOKEN");
expect(items.map((item) => item.hint).join("\n")).not.toContain(
"read/write/search files inside a sandboxed directory",
);
});
});

describe("Wizard API-key validation", () => {
it("accepts a key when DeepSeek auth check succeeds", async () => {
const fetcher = async () => new Response(JSON.stringify({ data: [] }), { status: 200 });
Expand Down