| 1 | import Link from "next/link"; |
| 2 | import { buildPageMetadata } from "@/lib/page-meta"; |
| 3 | |
| 4 | export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { |
| 5 | const { locale } = await params; |
| 6 | const isZh = locale === "zh"; |
| 7 | return buildPageMetadata({ |
| 8 | path: "/docs/constitution", |
| 9 | locale, |
| 10 | title: isZh ? "宪法与 /constitution · Codewhale 文档" : "Constitution and /constitution · Codewhale Docs", |
| 11 | description: isZh |
| 12 | ? "用户全局宪法、仓库本地法、项目说明和运行时边界。" |
| 13 | : "User-global constitution, repo-local law, project instructions, and runtime boundaries.", |
| 14 | }); |
| 15 | } |
| 16 | |
| 17 | export default async function ConstitutionPage({ params }: { params: Promise<{ locale: string }> }) { |
| 18 | const { locale } = await params; |
| 19 | const isZh = locale === "zh"; |
| 20 | |
| 21 | return ( |
| 22 | <section className="space-y-10"> |
| 23 | <section id="overview" className="scroll-mt-32"> |
| 24 | <h2 className="font-display text-3xl mb-1"> |
| 25 | {isZh ? "宪法与 /constitution" : "Constitution and /constitution"}{" "} |
| 26 | <span className="font-cjk text-indigo text-2xl ml-2"> |
| 27 | {isZh ? "Constitution" : "宪法与 /constitution"} |
| 28 | </span> |
| 29 | </h2> |
| 30 | {isZh ? ( |
| 31 | <p className="text-ink-soft mt-3 leading-[1.9] tracking-wide"> |
| 32 | Codewhale 先给 Agent 一个可追责的地址,再给上下文冲突一套法律。 |
| 33 | <code className="inline">/constitution</code> 是管理个人常驻宪法的主入口: |
| 34 | 它把结构化的用户全局设置保存在 <code className="inline">$CODEWHALE_HOME/constitution.json</code>, |
| 35 | 再渲染成模型可读的 prose block。仓库仍可通过{" "} |
| 36 | <code className="inline">.codewhale/constitution.json</code> 增加本地 law;runtime |
| 37 | policy 独立负责模式、审批、沙箱、成本和工具边界。 |
| 38 | </p> |
| 39 | ) : ( |
| 40 | <p className="text-ink-soft mt-3 leading-relaxed"> |
| 41 | Codewhale gives the agent an accountable address, then a legal system for |
| 42 | context conflicts. <code className="inline">/constitution</code> is the |
| 43 | primary personal constitution surface: guided setup stores structured |
| 44 | user-global data in <code className="inline">$CODEWHALE_HOME/constitution.json</code> |
| 45 | and renders it as model-facing prose. Repos can still add local law via{" "} |
| 46 | <code className="inline">.codewhale/constitution.json</code>; runtime policy |
| 47 | separately encodes modes, approval, sandbox, cost, and tool boundaries. |
| 48 | </p> |
| 49 | )} |
| 50 | <div className="hairline-t hairline-b mt-6 grid md:grid-cols-3 col-rule"> |
| 51 | {[ |
| 52 | { |
| 53 | name: "User-global", |
| 54 | cn: "用户全局", |
| 55 | en: "Use /constitution for standing personal law across projects. It is structured data rendered to prose, not a raw prompt editor.", |
| 56 | zh: "用 /constitution 管理跨项目个人常驻法。它是结构化数据渲染成 prose,不是裸 prompt 编辑器。", |
| 57 | }, |
| 58 | { |
| 59 | name: "Repo-local", |
| 60 | cn: "仓库本地", |
| 61 | en: ".codewhale/constitution.json is optional project policy for protected invariants, branch rules, verification, and escalation.", |
| 62 | zh: ".codewhale/constitution.json 是可选项目 law,用于不变量、分支规则、验证和升级条件。", |
| 63 | }, |
| 64 | { |
| 65 | name: "Runtime", |
| 66 | cn: "运行时", |
| 67 | en: "Constitution text may express preferences, but approval, sandbox, shell, network, trust, and MCP permissions remain enforced config.", |
| 68 | zh: "宪法文本可以表达偏好;审批、沙箱、Shell、网络、信任和 MCP 权限仍由运行时配置强制执行。", |
| 69 | }, |
| 70 | ].map((row) => ( |
| 71 | <div key={row.name} className="p-5"> |
| 72 | <div className="font-display text-lg text-indigo mb-1"> |
| 73 | {row.name} <span className="font-cjk text-sm ml-1.5">{row.cn}</span> |
| 74 | </div> |
| 75 | <p className={`text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 76 | {isZh ? row.zh : row.en} |
| 77 | </p> |
| 78 | </div> |
| 79 | ))} |
| 80 | </div> |
| 81 | <p className={`mt-4 text-sm text-ink-soft ${isZh ? "leading-[1.9] tracking-wide" : "leading-relaxed"}`}> |
| 82 | {isZh |
| 83 | ? "普通项目说明仍放在 AGENTS.md;记忆和交接低于宪法与项目说明;完整 base prompt Markdown 覆盖只是专家逃生口,不是普通设置路径。详见 " |
| 84 | : "Standard project instructions still live in AGENTS.md; memory and handoffs rank below constitutions and project instructions; the full base-prompt Markdown override is an expert escape hatch, not the normal setup path. See "} |
| 85 | <Link |
| 86 | href="https://github.com/Hmbown/CodeWhale/blob/main/docs/CONFIGURATION.md#constitution-project-instructions-and-repo-authority" |
| 87 | className="body-link" |
| 88 | > |
| 89 | {isZh ? "configuration docs" : "configuration docs"} |
| 90 | </Link> |
| 91 | {isZh ? "。" : "."} |
| 92 | </p> |
| 93 | </section> |
| 94 | <section id="source" className="hairline-t pt-8"> |
| 95 | <p className="text-sm text-ink-mute"> |
| 96 | {isZh |
| 97 | ? "来源文档:docs/ARCHITECTURE.md · 更新时请同步修改 docs-map.ts。" |
| 98 | : "Source document: docs/ARCHITECTURE.md · Update docs-map.ts when changing."} |
| 99 | </p> |
| 100 | </section> |
| 101 | </section> |
| 102 | ); |
| 103 | } |
| 104 |