| 1 | import Link from "next/link"; |
| 2 | import { Icon } from "@/components/icon"; |
| 3 | import { PageHeader, Section } from "@/components/page-header"; |
| 4 | import { Status } from "@/components/status-badge"; |
| 5 | import { ThinkingTrace } from "@/components/thinking-trace"; |
| 6 | import { getConstitution, pickText } from "@/lib/i18n/dictionaries"; |
| 7 | import { buildPageMetadata } from "@/lib/page-meta"; |
| 8 | |
| 9 | export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { |
| 10 | const { locale } = await params; |
| 11 | const t = getConstitution(locale); |
| 12 | return buildPageMetadata({ |
| 13 | path: "/constitution", |
| 14 | locale, |
| 15 | title: t.metaTitle, |
| 16 | description: t.metaDescription, |
| 17 | }); |
| 18 | } |
| 19 | |
| 20 | /** The three layers, rendered as a card row on this page and (compact) on the homepage. */ |
| 21 | const LAYERS = [ |
| 22 | { |
| 23 | n: "01", |
| 24 | name: { en: "Bundled Constitution", zh: "内置宪章" }, |
| 25 | path: { en: "compiled into every binary", zh: "编译进每一个二进制" }, |
| 26 | body: { |
| 27 | 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.", |
| 28 | zh: "基础法。其中的位阶条款为一切冲突固定裁决顺序——过期的交接不会稀里糊涂地压过刚跑出的测试结果。", |
| 29 | }, |
| 30 | }, |
| 31 | { |
| 32 | n: "02", |
| 33 | name: { en: "/constitution — your standing law", zh: "/constitution——你的常备法" }, |
| 34 | path: { en: "$CODEWHALE_HOME/constitution.json", zh: "$CODEWHALE_HOME/constitution.json" }, |
| 35 | body: { |
| 36 | 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.", |
| 37 | zh: "结构化数据,不是裸的提示词编辑器:引导式设置把它渲染成面向模型的 prose 区块。可由模型协助起草,经你批准生效,跨项目随身携带。", |
| 38 | }, |
| 39 | }, |
| 40 | { |
| 41 | n: "03", |
| 42 | name: { en: "Your repo's law", zh: "仓库自己的法" }, |
| 43 | path: { en: ".codewhale/constitution.json", zh: ".codewhale/constitution.json" }, |
| 44 | body: { |
| 45 | en: "Protected invariants, branch policy, verification requirements, escalation conditions — loaded as a repo-local authority block above project instructions, memory, and handoffs.", |
| 46 | zh: "受保护的不变量、分支策略、验证要求、升级条件——作为仓库本地的权威区块加载,位阶高于项目说明、记忆与交接。", |
| 47 | }, |
| 48 | }, |
| 49 | ]; |
| 50 | |
| 51 | export default async function ConstitutionPage({ params }: { params: Promise<{ locale: string }> }) { |
| 52 | const { locale } = await params; |
| 53 | const t = getConstitution(locale); |
| 54 | |
| 55 | return ( |
| 56 | <> |
| 57 | <PageHeader |
| 58 | seal="法" |
| 59 | kicker={t.kicker} |
| 60 | title={t.title} |
| 61 | titleAside={t.titleAside} |
| 62 | titleAsideLang={t.titleAsideLang} |
| 63 | lede={t.lede} |
| 64 | pose="read" |
| 65 | > |
| 66 | <div className="callout"> |
| 67 | <p className="callout-title"> |
| 68 | <Status tone="accent">{t.since}</Status> |
| 69 | </p> |
| 70 | <p>{t.sinceBody}</p> |
| 71 | </div> |
| 72 | </PageHeader> |
| 73 | |
| 74 | <div className="page-body"> |
| 75 | <Section |
| 76 | id="constitution-rank" |
| 77 | seal="序" |
| 78 | title={t.rankTitle} |
| 79 | scope={t.rankScope} |
| 80 | > |
| 81 | <ol className="steps"> |
| 82 | {LAYERS.map((layer, index) => ( |
| 83 | <li key={layer.n}> |
| 84 | <span className="gs-step-index" aria-hidden="true">{index + 1}</span> |
| 85 | <h3>{pickText(layer.name, locale)}</h3> |
| 86 | <p className="dir-meta">{pickText(layer.path, locale)}</p> |
| 87 | <p>{pickText(layer.body, locale)}</p> |
| 88 | </li> |
| 89 | ))} |
| 90 | </ol> |
| 91 | <div className="callout mt-5"> |
| 92 | <p className="callout-title"> |
| 93 | <Icon name="shield" className="icon" /> |
| 94 | {t.boundaryTitle} |
| 95 | </p> |
| 96 | <p>{t.boundaryBody}</p> |
| 97 | </div> |
| 98 | </Section> |
| 99 | |
| 100 | <Section |
| 101 | id="constitution-trace" |
| 102 | seal="证" |
| 103 | title={t.traceTitle} |
| 104 | scope={t.traceScope} |
| 105 | > |
| 106 | <ThinkingTrace locale={locale} /> |
| 107 | </Section> |
| 108 | |
| 109 | <section className="page-section"> |
| 110 | <div className="actions"> |
| 111 | <Link href={`/${locale}/install`} className="btn btn-primary btn-lg"> |
| 112 | {t.install} |
| 113 | </Link> |
| 114 | <Link |
| 115 | href="https://github.com/codewhale-hq/CodeWhale/blob/main/docs/CONFIGURATION.md#constitution-project-instructions-and-repo-authority" |
| 116 | className="btn btn-ghost btn-lg" |
| 117 | > |
| 118 | {t.configuration} |
| 119 | <Icon name="external" className="icon" /> |
| 120 | </Link> |
| 121 | </div> |
| 122 | </section> |
| 123 | </div> |
| 124 | </> |
| 125 | ); |
| 126 | } |
| 127 |