| 1 | import Link from "next/link"; |
| 2 | import { Seal } from "@/components/seal"; |
| 3 | import { ThinkingTrace } from "@/components/thinking-trace"; |
| 4 | import { buildPageMetadata } from "@/lib/page-meta"; |
| 5 | |
| 6 | export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { |
| 7 | const { locale } = await params; |
| 8 | const isZh = locale === "zh"; |
| 9 | return buildPageMetadata({ |
| 10 | path: "/constitution", |
| 11 | locale, |
| 12 | title: isZh ? "三层法 · Codewhale" : "Three layers of law · Codewhale", |
| 13 | description: isZh |
| 14 | ? "Codewhale 的嵌套宪法:内置基础法、你的常备法(/constitution)、仓库自己的法(.codewhale/constitution.json)。位阶由执行框架强制生效,换掉模型也不失效。" |
| 15 | : "Codewhale's nested constitution: bundled base law, your standing law (/constitution), and your repo's law (.codewhale/constitution.json). Rank is enforced in the harness and survives a model swap.", |
| 16 | }); |
| 17 | } |
| 18 | |
| 19 | /** The three layers, rendered as a card row on this page and (compact) on the homepage. */ |
| 20 | const LAYERS = [ |
| 21 | { |
| 22 | n: "01", |
| 23 | name: { en: "Bundled Constitution", zh: "内置宪法" }, |
| 24 | path: "compiled into every binary", |
| 25 | pathZh: "编译进每一个二进制", |
| 26 | en: "The base law. Its priority article fixes the authority order for any conflict, so a stale handoff can never outrank a fresh test result by accident.", |
| 27 | zh: "基础法。其中的位阶条款为一切冲突固定裁决顺序——过期的交接不会稀里糊涂地压过刚跑出的测试结果。", |
| 28 | }, |
| 29 | { |
| 30 | n: "02", |
| 31 | name: { en: "/constitution — your standing law", zh: "/constitution——你的常备法" }, |
| 32 | path: "$CODEWHALE_HOME/constitution.json", |
| 33 | pathZh: "$CODEWHALE_HOME/constitution.json", |
| 34 | en: "Structured data, not a raw prompt editor: guided setup renders it into a model-facing prose block. Drafted with your model's help, ratified by you, and carried across every project.", |
| 35 | zh: "结构化数据,不是裸的提示词编辑器:引导式设置把它渲染成面向模型的 prose 区块。可由模型协助起草,经你批准生效,跨项目随身携带。", |
| 36 | }, |
| 37 | { |
| 38 | n: "03", |
| 39 | name: { en: "Your repo's law", zh: "仓库自己的法" }, |
| 40 | path: ".codewhale/constitution.json", |
| 41 | pathZh: ".codewhale/constitution.json", |
| 42 | en: "Protected invariants, branch policy, verification requirements, escalation conditions — loaded as a repo-local authority block above project instructions, memory, and handoffs.", |
| 43 | zh: "受保护的不变量、分支策略、验证要求、升级条件——作为仓库本地的权威区块加载,位阶高于项目说明、记忆与交接。", |
| 44 | }, |
| 45 | ]; |
| 46 | |
| 47 | export default async function ConstitutionPage({ params }: { params: Promise<{ locale: string }> }) { |
| 48 | const { locale } = await params; |
| 49 | const isZh = locale === "zh"; |
| 50 | const p = (path: string) => (isZh ? `/zh${path}` : `/en${path}`); |
| 51 | |
| 52 | return ( |
| 53 | <> |
| 54 | {/* THE THESIS */} |
| 55 | <section className="mx-auto max-w-[1100px] px-6 pt-12 pb-10"> |
| 56 | <div className="flex items-baseline gap-4 mb-3"> |
| 57 | <Seal char="法" /> |
| 58 | <div className="eyebrow">{isZh ? "立论" : "The thesis"}</div> |
| 59 | </div> |
| 60 | <h1 className="font-display tracking-crisp mb-6"> |
| 61 | {isZh ? "三层法" : "Three layers of law"} |
| 62 | <span className="font-cjk text-indigo text-3xl sm:text-5xl ml-3"> |
| 63 | {isZh ? "Three layers of law" : "三层法"} |
| 64 | </span> |
| 65 | </h1> |
| 66 | <p className={`max-w-2xl text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 67 | {isZh |
| 68 | ? "项目一变老,指令就开始堆积、彼此冲突:最初的规格、后来推翻它的重构、陈旧的记忆、上一个智能体的交接、你此刻的要求、刚跑出的与交接说法不符的测试结果。扁平的系统提示词让模型靠猜来化解;Codewhale 用一部嵌套的宪法给出明确的位阶。顺序由执行框架强制生效——有测试断言它不会漂移——换掉模型,结构依然完好。" |
| 69 | : "As a project ages, instructions pile up and conflict: the original spec, a refactor that contradicts it, stale memory, a previous agent's handoff, your current request, fresh test output that doesn't match what the handoff claimed. A flat system prompt makes the model resolve that by guess. Codewhale uses a nested constitution so there is a defined rank instead of vibes — the order is enforced in the harness, with tests asserting it can't drift, and it stays intact when you swap models."} |
| 70 | </p> |
| 71 | |
| 72 | {/* v0.9.0 flagship framing */} |
| 73 | <div className="mt-7 max-w-2xl px-4 py-3 hairline-t hairline-b hairline-l hairline-r"> |
| 74 | <span className="pill pill-new mr-2">{isZh ? "v0.9.0 新增" : "New in v0.9.0"}</span> |
| 75 | <span className={`text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 76 | {isZh |
| 77 | ? "宪法优先的初始设置——首次启动依次引导语言、模型、安全姿态和你的宪法;之后随时 /setup。模型可以起草,由你批准。" |
| 78 | : "Constitution-first setup — first launch walks language, model, posture, and your constitution; /setup any time. The model can draft it. You ratify it."} |
| 79 | </span> |
| 80 | </div> |
| 81 | </section> |
| 82 | |
| 83 | {/* THE THREE LAYERS */} |
| 84 | <section className="mx-auto max-w-[1100px] px-6 py-10 hairline-t"> |
| 85 | <div className="flex items-baseline gap-4 mb-6"> |
| 86 | <Seal char="序" /> |
| 87 | <div className="eyebrow">{isZh ? "位阶,从最稳到最活" : "The rank, most-static first"}</div> |
| 88 | </div> |
| 89 | |
| 90 | <div className="grid md:grid-cols-3 gap-0 col-rule hairline-t hairline-b"> |
| 91 | {LAYERS.map((layer) => ( |
| 92 | <div key={layer.n} className="p-6"> |
| 93 | <div className="font-mono uppercase tracking-widest mb-2 text-[0.7rem] text-indigo">{layer.n}</div> |
| 94 | <h2 className="font-display text-xl mb-1">{isZh ? layer.name.zh : layer.name.en}</h2> |
| 95 | <div className="font-mono text-[0.68rem] text-ink-mute mb-3 break-all"> |
| 96 | {isZh ? layer.pathZh : layer.path} |
| 97 | </div> |
| 98 | <p className={`text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 99 | {isZh ? layer.zh : layer.en} |
| 100 | </p> |
| 101 | </div> |
| 102 | ))} |
| 103 | </div> |
| 104 | |
| 105 | <p className={`mt-5 max-w-2xl text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 106 | {isZh |
| 107 | ? "三层之下依次是项目说明(AGENTS.md)、记忆与交接。你此刻的要求和实时工具证据仍然主宰当前回合——模型可以被给到很多层,但它绝不能报告一个工具没有返回的事实。" |
| 108 | : "Below the three layers rank project instructions (AGENTS.md), then memory and handoffs. Your current request and live tool evidence still control the active turn — the model may be given many layers, but it may never report a fact the tools did not return."} |
| 109 | </p> |
| 110 | |
| 111 | {/* The honest boundary */} |
| 112 | <div className="mt-6 max-w-2xl px-4 py-3 hairline-t hairline-b hairline-l hairline-r text-sm"> |
| 113 | <div className="eyebrow mb-1.5">{isZh ? "诚实的边界" : "The honest boundary"}</div> |
| 114 | <p className={`text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 115 | {isZh |
| 116 | ? "审批、沙箱、网络与信任控制由代码强制执行——宪法文本永远越不过它们。" |
| 117 | : "Approval, sandbox, network, and trust controls are enforced in code — constitution text never overrides them."} |
| 118 | </p> |
| 119 | </div> |
| 120 | </section> |
| 121 | |
| 122 | {/* OBSERVABLE IN THE REASONING */} |
| 123 | <section className="mx-auto max-w-[1100px] px-6 py-10 hairline-t"> |
| 124 | <div className="flex items-baseline gap-4 mb-3"> |
| 125 | <Seal char="证" /> |
| 126 | <div className="eyebrow">{isZh ? "在推理里可以被看到" : "Observable in the reasoning"}</div> |
| 127 | </div> |
| 128 | <p className={`mb-6 max-w-2xl text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 129 | {isZh |
| 130 | ? "位阶不是落地页上的一句宣称。下面是真实会话的忠实片段——模型在裁决时直接援引条款。" |
| 131 | : "The rank is not a claim on a landing page. These are faithful excerpts from a real session — the model cites the articles as it decides."} |
| 132 | </p> |
| 133 | <ThinkingTrace locale={locale} /> |
| 134 | </section> |
| 135 | |
| 136 | {/* WHERE TO GO NEXT */} |
| 137 | <section className="mx-auto max-w-[1100px] px-6 py-8 hairline-t"> |
| 138 | <div className="flex flex-wrap items-center gap-3"> |
| 139 | <Link |
| 140 | href={p("/install")} |
| 141 | className="px-5 py-3 bg-ink text-paper font-mono text-sm uppercase tracking-wider hover:bg-indigo transition-colors" |
| 142 | > |
| 143 | {isZh ? "安装 →" : "Install →"} |
| 144 | </Link> |
| 145 | <Link |
| 146 | href={p("/docs/constitution")} |
| 147 | className="px-5 py-3 hairline-t hairline-b hairline-l hairline-r font-mono text-sm uppercase tracking-wider hover:bg-paper-deep transition-colors" |
| 148 | > |
| 149 | {isZh ? "参考细节:文档 →" : "Reference detail: docs →"} |
| 150 | </Link> |
| 151 | <Link |
| 152 | href="https://github.com/Hmbown/CodeWhale/blob/main/docs/CONFIGURATION.md#constitution-project-instructions-and-repo-authority" |
| 153 | className="px-5 py-3 font-mono text-sm uppercase tracking-wider text-ink-mute hover:text-indigo transition-colors" |
| 154 | > |
| 155 | {isZh ? "配置文档 ↗" : "Configuration ↗"} |
| 156 | </Link> |
| 157 | </div> |
| 158 | </section> |
| 159 | </> |
| 160 | ); |
| 161 | } |
| 162 |