import Link from "next/link"; import { fetchFeed, fetchRepoStats } from "@/lib/github"; import { getDispatch, getEnv } from "@/lib/kv"; import { getFacts } from "@/lib/facts"; import { Ticker } from "@/components/ticker"; import { StatGrid } from "@/components/stat-grid"; import { Seal } from "@/components/seal"; import { ThinkingTrace } from "@/components/thinking-trace"; import { MermaidDiagram } from "@/components/mermaid-diagram"; import type { CuratedDispatch, FeedItem, RepoStats } from "@/lib/types"; export const revalidate = 1800; const FALLBACK_STATS: RepoStats = { stars: 0, forks: 0, openIssues: 0, openPulls: 0, contributors: 141, fetchedAt: new Date().toISOString(), }; const RELEASE_CONTRIBUTORS = [ "@cy2311", "@LING71671", "@axobase001", "@dzyuan", "@mvanhorn", "@malsony", "@gaord", "@yuanchenglu", "@idling11", "@h3c-hexin", "@AdityaVG13", "@Sskift", "@cyq1017", "@HUQIANTAO", "@New2Niu", "@AiurArtanis", "@Lee-take", "@nightt5879", "@AresNing", "@AccMoment", "@reidliu41", "@aboimpinto", "@zhuangbiaowei", "@donglovejava", "@hongqitai", "@zlh124", "@encyc", "@Implementist", "@lihuan215", "@LeoAlex0", "@jimmyzhuu", "@rockyzhang", "@mo-vic", "@hufanexplore", "@hoclaptrinh33", "@BryonGo", ]; const RELEASE_HELPERS = [ "@buko", "@yyyCode", "@gaslebinh-glitch", "@Dr3259", "@lpeng1711694086-lang", "@VerrPower", "@yan-zay", "@jretz", "@Neo-millunnium", "@caeserchen", "@T-Phuong-Nguyen", "@zhyuzhyu", "@0gl20shk0sbt36", "@hatakes", "@goodvecn-dev", "@bevis-wong", "@PurplePulse", "@nbiish", ]; const FALLBACK_DISPATCH_EN: CuratedDispatch = { generatedAt: new Date().toISOString(), headline: "Quiet release week — install paths and contributor guides up to date.", summary: "This dispatch is regenerated by DeepSeek V4-Flash on a six-hour cron. Until the cron fills in fresh repo activity, the static links below are the best starting points.", highlights: [ { title: "Install", href: "/install", tag: "shipped", blurb: "npm, Cargo, Homebrew, or a direct download." }, { title: "Open issues", href: "https://github.com/Hmbown/CodeWhale/issues", tag: "opened", blurb: "Start with anything labelled good first issue." }, { title: "Roadmap", href: "/roadmap", tag: "discussion", blurb: "What is confirmed, what is being weighed, what is ruled out." }, ], movers: [], }; const FALLBACK_DISPATCH_ZH: CuratedDispatch = { generatedAt: new Date().toISOString(), headline: "本周发布平稳——安装路径和贡献指南已同步。", summary: "本「今日要闻」由 DeepSeek V4-Flash 每六小时重新生成。在 cron 写入真实仓库动态之前,下面的固定链接是最实用的入口。", highlights: [ { title: "安装", href: "/zh/install", tag: "shipped", blurb: "npm、Cargo、Homebrew,或直接下载。" }, { title: "开放议题", href: "https://github.com/Hmbown/CodeWhale/issues", tag: "opened", blurb: "从 good first issue 标签开始。" }, { title: "路线图", href: "/zh/roadmap", tag: "discussion", blurb: "已确认、审议中、以及已排除的功能。" }, ], movers: [], }; export default async function HomePage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = await params; const isZh = locale === "zh"; const env = await getEnv(); const facts = await getFacts(); let stats: RepoStats = FALLBACK_STATS; let feed: FeedItem[] = []; let dispatch: CuratedDispatch = isZh ? FALLBACK_DISPATCH_ZH : FALLBACK_DISPATCH_EN; try { [stats, feed] = await Promise.all([ fetchRepoStats(env.GITHUB_TOKEN), fetchFeed(env.GITHUB_TOKEN, 12), ]); } catch (e) { console.error("github fetch failed", e); } try { const cached = await getDispatch(); if (cached) dispatch = cached; } catch { /* keep fallback */ } const highlights = isZh && dispatch.highlightsZh ? dispatch.highlightsZh : dispatch.highlights; return ( <> {/* HERO */}
{isZh ? "开源 · 多模型 · 本地优先" : "Open source · multi-model · local-first"}

{isZh ? "面向最佳可用模型的终端智能体。" : "An agentic terminal for the best available models."}

CodeWhale {isZh ? " 是社区共建的终端智能体,本地运行,支持你真正在用的模型——GLM、DeepSeek、Kimi、MiniMax、OpenRouter 等等。完整的工具面、审批闸门、快照回滚、子智能体与可恢复会话,都在你的终端里。" : " is a community-built terminal agent that runs locally and works with the models you actually use — GLM, DeepSeek, Kimi, MiniMax, OpenRouter, and more. A full tool surface, approval gates, snapshots you can roll back, sub-agents, and sessions you can resume."}

{/* COMMUNITY CALLOUT */}
{isZh ? ( <> 社区共建 在公开环境中打造,目标是把最好的智能体工具带给最多的人。无论你经验如何,议题和 PR 都欢迎。 ) : ( <> Built in the open Community-shaped to bring the best agent harness to the most people. Issues and pull requests are welcome at any experience level. )}
{isZh ? "立即安装 →" : "Install →"} ★ GitHub {isZh ? "阅读文档" : "Docs"}
{isZh ? "独立维护者 Hmbown" : "Maintained by Hmbown"} · {facts.version ?? "v0.8.x"} · {facts.providers.length} providers
{isZh ? "一行安装" : "one-line install"}
                {isZh ? (
                  <>
                    # npm(推荐,无需 Rust 工具链){"\n"}
                    $ npm install -g codewhale{"\n"}
                    $ codewhale{"\n"}
                    
# Cargo / Homebrew / 直接下载请见{"\n"} # /install ) : ( <> # npm — no Rust toolchain required{"\n"} $ npm install -g codewhale{"\n"} $ codewhale{"\n"}
# Cargo / Homebrew / direct download:{"\n"} # /install )}
{isZh ? "需要 Node 或 Rust 1.88+" : "needs Node or Rust 1.88+"} {isZh ? "其他方式 →" : "other ways →"}
{/* SEE HOW IT DECIDES — real reasoning traces prove the constitution operates */}

{isZh ? "看它如何决策" : "See how it decides"}

{isZh ? "别的 Agent 声称自己「对齐」「可信」。CodeWhale 能证明——因为宪法会在模型的推理中现身:它决策时会援引「第 II 条」「第 V 条」。下面是真实会话中的推理摘录,以及它们所促成的决定。" : "Every agent claims to be aligned and trustworthy. CodeWhale can prove it — the Constitution shows up in the model's reasoning, citing \"Article II\" and \"Article V\" as it decides. These are real traces from an actual session, paired with the decision each produced."}

{isZh ? "这些是真实推理的忠实摘录,非杜撰。宪法不是墙上的口号,而是模型决策时真正遵循的顺序。" : "Faithful excerpts from real reasoning — not invented. The constitution isn't a poster on the wall; it's the order the model actually follows when it decides."}
{/* WHAT IT IS — the core ideas behind the harness */}

{isZh ? "判断栈" : "The judgment stack"}

{isZh ? "模型会生成文本;Agent 会留下后果。CodeWhale 把后果需要的结构放在模型外面:自我、权威、证据、工具,各在其位。" : "A model generates text; an agent leaves consequences. CodeWhale puts the structure for those consequences around the model: self, authority, evidence, and tools, each in its place."}

{isZh ? ( <>
01 · 自我模型

责任要有地址

Agent 不是模型卡片,也不是排行榜数字。它是这个终端、这个工作区、这个会话里的实例。先有地址,责任才有落点。

02 · 嵌套宪法

冲突时有法律

全局 Constitution、当前用户请求、运行时规则、仓库本地 law、实时证据、记忆、个性和旧交接各有顺位。冲突时不靠感觉。

03 · 本地执行

证据留在本地

文件、Shell、Git、Web、MCP、子 Agent、回滚和诊断都由 runtime 管理。模型不需要假装验证;它必须留下证据。

) : ( <>
01 · self-model

Responsibility needs an address

The agent is not a model card or leaderboard score. It is an instance in this terminal, this workspace, this session. Give it an address before you ask it to act.

02 · nested constitution

Conflict has law

Global Constitution, current user request, runtime statutes, repo-local law, live evidence, memory, personality, and old handoffs each have a rank. When they conflict, the agent has an order to follow.

03 · local execution

Evidence stays local

Files, shell, git, web, MCP, sub-agents, rollback, and diagnostics are runtime surfaces. The model does not claim verification as a mood; it has to leave evidence.

)}
{isZh ? "内建提供商" : "Built-in providers"}
{facts.providers.map((p) => ( {p.label} ))}
{/* MAINTAINER LOOP */}
{isZh ? "维护者循环" : "maintainer loop"}

{isZh ? "长任务要能被继承" : "Long work has to be inheritable"}

{isZh ? "难点不是让模型一次做更多事,而是让用户意图、权威顺序、证据和贡献者上下文足够清楚,让下一个维护者可以接住。" : "The hard part is not making the model do more at once. It is keeping intent, authority, evidence, and contributor context clear enough for the next maintainer to inherit."}

{isZh ? "好的 Agent 工作不是一团活动记录,而是一条可以复核的线:请求、调查、补丁、验证、署名。" : "Good agent work is not a pile of activity. It is a reviewable line: request, investigation, patch, verification, credit."}

{isZh ? "框架承担了繁重工作:宪政提示、结构化信任、反馈循环、回滚和跨会话存活的交接。模型可以把注意力放在任务本身。" : "The harness carries the heavy parts: constitutional prompts, structured trust, feedback loops, rollback, and handoffs that survive the session. The model can keep its attention on the task itself."}

{isZh ? "阅读宪法 →" : "Read the docs →"} {isZh ? "贡献指南 →" : "Contribute →"}
CodeWhale / review loop
{isZh ? "维护者工作流" : "maintainer workflow"}
{(isZh ? [ { n: "01", t: "意图", d: "当前用户请求定义目标、约束和成功标准。" }, { n: "02", t: "调查", d: "Agent 读取代码、调用工具、必要时分派子 Agent,并保留证据。" }, { n: "03", t: "补丁", d: "输出保持小、可复现、可测试,并尊重现有分支和贡献者上下文。" }, { n: "04", t: "审查", d: "维护者看到改变、验证结果、风险和应被感谢的人。" }, ] : [ { n: "01", t: "Intent", d: "The current user request defines the goal, constraints, and success bar." }, { n: "02", t: "Investigation", d: "The agent reads code, uses tools, delegates when useful, and keeps the evidence visible." }, { n: "03", t: "Patch", d: "The output stays small, reproducible, testable, and respectful of branch and contributor context." }, { n: "04", t: "Review", d: "The maintainer sees what changed, what was verified, what risk remains, and who deserves credit." }, ] ).map((item) => (
{item.n}

{item.t}

{item.d}

))}
{/* HOW IT WORKS */}

{isZh ? "运作方式" : "How it works"}

(TUI · ratatui)"] -->|Op channel| B["Engine
turn loop + tools"] B -->|HTTPS / SSE| C["DeepSeek API
V4 family"] C -->|stream events| B B -->|tool call| T["read_file · edit_file · grep
apply_patch · exec_shell
mcp_<server>_<tool>"] T -->|approval Y/N| P["审批对话框
approval dialog"] P --> B T -->|exec| S["沙箱
seatbelt · landlock · win32"] classDef accent fill:#e9eefe,stroke:#0e0e10,stroke-width:1px; classDef api fill:#0e0e10,stroke:#0e0e10,color:#ffffff; class C api; class T,P,S accent;` : `flowchart TD A["You type
(TUI · ratatui)"] -->|Op channel| B["Engine
turn loop + tools"] B -->|HTTPS / SSE| C["DeepSeek API
V4 family"] C -->|stream events| B B -->|tool call| T["read_file · edit_file · grep
apply_patch · exec_shell
mcp_<server>_<tool>"] T -->|approval Y/N| P["Approval
dialog"] P --> B T -->|exec| S["Sandbox
seatbelt · landlock · win32"] classDef accent fill:#e9eefe,stroke:#0e0e10,stroke-width:1px; classDef api fill:#0e0e10,stroke:#0e0e10,color:#ffffff; class C api; class T,P,S accent;` } />
{/* TODAY'S DISPATCH — slim editorial column */}
{isZh ? "今日要闻" : "Today's Dispatch"}
{new Date(dispatch.generatedAt).toISOString().slice(0, 10)}
DeepSeek V4-Flash · 6h cron

{isZh && dispatch.headlineZh ? dispatch.headlineZh : dispatch.headline}

{isZh && dispatch.summaryZh ? dispatch.summaryZh : dispatch.summary}

    {highlights.slice(0, 3).map((h, i) => (
  • {h.tag}
    {h.title}

    {h.blurb}

  • ))}
{isZh ? "全部活动 →" : "All activity →"}
{/* RELEASE CREDITS */}
{isZh ? "v0.8.56 致谢" : "v0.8.56 credits"}

{isZh ? "每个补丁和报告都算数" : "Every patch and report counts"}

{isZh ? "这一版合并和吸收了来自社区的大量工作。完整条目在 CHANGELOG 中;这里保留最新发布的公开致谢入口。" : "This release merged and harvested a large community tranche. The full notes live in the changelog; this keeps the latest public credit surface easy to find."}

{isZh ? "查看完整 changelog →" : "Full changelog →"}
{isZh ? "已合并 / 已吸收贡献" : "Merged and harvested contributions"}
{RELEASE_CONTRIBUTORS.map((handle) => ( {handle} ))}
{isZh ? "报告、复现和验证" : "Reports, repros, and verification"}
{RELEASE_HELPERS.map((handle) => ( {handle} ))}
{/* JOIN IN */}
{isZh ? "加入" : "Join in"}

{isZh ? "小项目。你的每个补丁都重要。" : "A small project. Your patch matters."}

{isZh ? "无 CLA,无赞助商优先通道。维护者亲自阅读每一条内容,议题公开分类,版本从 main 分支发布。" : "No CLA. No sponsor lockouts. The maintainer reads everything personally, issues are triaged in the open, and releases cut from main."}

★ {isZh ? "Star on GitHub" : "Star on GitHub"} {isZh ? "参与贡献 →" : "Contribute →"}
{isZh ? "版本" : "version"} {facts.version ?? "v0.8.x"}
{isZh ? "提供商" : "providers"} {facts.providers.length}
{isZh ? "许可证" : "license"} {facts.license ?? "MIT"}
); }