| 1 | import { PageHeader } from "@/components/page-header"; |
| 2 | import { InlineCode } from "@/components/route/inline-code"; |
| 3 | import { Status, type StatusTone } from "@/components/status-badge"; |
| 4 | import { BUILD_FACTS } from "@/lib/facts"; |
| 5 | import { capabilityViews, runtimeCapabilityContext } from "@/lib/capabilities"; |
| 6 | import type { LocalizedText } from "@/lib/content/vocabulary"; |
| 7 | import { featureDocsHref, type FeatureStatus, type SurfaceStatus } from "@/lib/features"; |
| 8 | import { fill, getFeatures, pickText } from "@/lib/i18n/dictionaries"; |
| 9 | import { stateLabel } from "@/lib/surface-states"; |
| 10 | import { buildPageMetadata, SITE_URL } from "@/lib/page-meta"; |
| 11 | |
| 12 | const TONES: Record<FeatureStatus | SurfaceStatus, StatusTone> = { |
| 13 | stable: "ready", flagged: "attention", experimental: "idle", partial: "attention", preview: "attention", none: "idle", |
| 14 | }; |
| 15 | |
| 16 | const OVERVIEW_HEADING: LocalizedText = { |
| 17 | en: "Core capabilities", |
| 18 | zh: "核心能力", |
| 19 | }; |
| 20 | |
| 21 | const OVERVIEW_ITEMS: readonly { id: string; title: LocalizedText; body: LocalizedText }[] = [ |
| 22 | { |
| 23 | id: "any-model", |
| 24 | title: { en: "Any model", zh: "任意模型" }, |
| 25 | body: { |
| 26 | en: "Switch between built-in providers, OpenAI-compatible endpoints, or local models with `/provider` and `/model` between turns.", |
| 27 | zh: "通过 `/provider` 和 `/model` 在内置提供商、OpenAI 兼容端点或本地模型之间按轮切换。", |
| 28 | }, |
| 29 | }, |
| 30 | { |
| 31 | id: "receipts-undo", |
| 32 | title: { en: "Session receipts and /undo", zh: "会话回执与 /undo" }, |
| 33 | body: { |
| 34 | en: "Every session records the files changed, the commands run, and each approval, and `/undo` reverts recorded file edits.", |
| 35 | zh: "每次会话都会记录修改的文件、运行的命令和每次审批,使用 `/undo` 可撤销已记录的文件改动。", |
| 36 | }, |
| 37 | }, |
| 38 | { |
| 39 | id: "multi-agent-fleets", |
| 40 | title: { en: "Multi-agent Fleets", zh: "多智能体 Fleet" }, |
| 41 | body: { |
| 42 | en: "Split one task across sub-agents with distinct roles while a Fleet ledger tracks progress across restarts.", |
| 43 | zh: "将一项任务拆分给不同角色的子智能体协作完成,并由 Fleet 账本在重启后保留进度。", |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | id: "os-sandbox", |
| 48 | title: { en: "Default-on OS sandbox", zh: "默认开启的系统沙箱" }, |
| 49 | body: { |
| 50 | en: "Commands run inside an OS sandbox on macOS and Linux by default, keeping your approval posture explicit.", |
| 51 | zh: "在 macOS 和 Linux 上默认于系统沙箱内执行命令,并保持明确的审批姿态。", |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | id: "no-account", |
| 56 | title: { en: "No account required", zh: "无需账号" }, |
| 57 | body: { |
| 58 | en: "Install Codewhale and run it in any repository using your own model key or a local model without signing in.", |
| 59 | zh: "安装 Codewhale 后即可在任意仓库中使用自有模型密钥或本地模型运行,无需登录。", |
| 60 | }, |
| 61 | }, |
| 62 | ]; |
| 63 | |
| 64 | export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { |
| 65 | const { locale } = await params; |
| 66 | const t = getFeatures(locale); |
| 67 | const meta = buildPageMetadata({ path: "/features", locale, title: `${t.title} · Codewhale`, description: t.description }); |
| 68 | return { |
| 69 | ...meta, |
| 70 | alternates: { |
| 71 | ...meta.alternates, |
| 72 | languages: { |
| 73 | ...meta.alternates?.languages, |
| 74 | en: `${SITE_URL}/en/features`, |
| 75 | zh: `${SITE_URL}/zh/features`, |
| 76 | "x-default": `${SITE_URL}/en/features`, |
| 77 | }, |
| 78 | }, |
| 79 | }; |
| 80 | } |
| 81 | |
| 82 | export default async function FeaturesPage({ params }: { params: Promise<{ locale: string }> }) { |
| 83 | const { locale } = await params; |
| 84 | const t = getFeatures(locale); |
| 85 | const views = capabilityViews(runtimeCapabilityContext(BUILD_FACTS)); |
| 86 | return <> |
| 87 | <PageHeader title={t.title} lede={t.description} actions={<a href="/features.json" className="btn btn-secondary">{t.exportJson}</a>} /> |
| 88 | <div className="page-body"> |
| 89 | <section className="page-section" aria-labelledby="features-overview-title"> |
| 90 | <div className="section-head"> |
| 91 | <h2 id="features-overview-title" className="section-title">{pickText(OVERVIEW_HEADING, locale)}</h2> |
| 92 | </div> |
| 93 | <dl className="ruled-list"> |
| 94 | {OVERVIEW_ITEMS.map((item) => ( |
| 95 | <div key={item.id} id={item.id}> |
| 96 | <dt>{pickText(item.title, locale)}</dt> |
| 97 | <dd><InlineCode text={pickText(item.body, locale)} /></dd> |
| 98 | </div> |
| 99 | ))} |
| 100 | </dl> |
| 101 | </section> |
| 102 | <p className="muted">{fill(t.notice, { count: views.length, version: BUILD_FACTS.version ?? "?" })}</p> |
| 103 | <div className="feature-catalogue"> |
| 104 | {views.map(({ feature, availability, name, summary }) => <article key={feature.id} id={feature.id} className="feature-entry"> |
| 105 | <div lang="en" dir="ltr"> |
| 106 | <h2><a href={`#${feature.id}`}>{name}</a></h2> |
| 107 | <p>{summary}</p> |
| 108 | </div> |
| 109 | <div className="feature-states"> |
| 110 | <Status tone={TONES[feature.status]}>{t[feature.status]}</Status> |
| 111 | {Object.entries(feature.surfaces).map(([surface, state]) => <Status key={surface} tone={TONES[state]}><bdi>{surface.toUpperCase()}</bdi>: {t[state]}</Status>)} |
| 112 | {feature.flag && <code dir="ltr">{feature.flag}</code>} |
| 113 | {availability === "in_source" |
| 114 | ? <Status tone="idle">{stateLabel("in_source", locale)}</Status> |
| 115 | : feature.since && <code dir="ltr">v{feature.since}</code>} |
| 116 | </div> |
| 117 | <a className="section-link" href={featureDocsHref(feature)}>{feature.docs ? t.docs : t.source}</a> |
| 118 | </article>)} |
| 119 | </div> |
| 120 | </div> |
| 121 | </>; |
| 122 | } |
| 123 |