| 1 | import { buildPageMetadata } from "@/lib/page-meta"; |
| 2 | |
| 3 | export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) { |
| 4 | const { locale } = await params; |
| 5 | const isZh = locale === "zh"; |
| 6 | return buildPageMetadata({ |
| 7 | path: "/docs/modes", |
| 8 | locale, |
| 9 | title: isZh ? "模式 · Codewhale 文档" : "Modes · Codewhale Docs", |
| 10 | description: isZh |
| 11 | ? "Plan、Act、Operate 三种运行模式与独立的权限姿态。" |
| 12 | : "Plan, Act, Operate modes and independent permission postures.", |
| 13 | }); |
| 14 | } |
| 15 | |
| 16 | export default async function ModesPage({ params }: { params: Promise<{ locale: string }> }) { |
| 17 | const { locale } = await params; |
| 18 | const isZh = locale === "zh"; |
| 19 | const bodyClass = isZh |
| 20 | ? "text-ink-soft leading-[1.9] tracking-wide" |
| 21 | : "text-ink-soft leading-relaxed"; |
| 22 | const modes = isZh |
| 23 | ? [ |
| 24 | { |
| 25 | name: "Plan", |
| 26 | description: |
| 27 | "用于只读调查与规划。Codewhale 可以检查工作区,但不能执行 Shell 命令或修改文件。", |
| 28 | }, |
| 29 | { |
| 30 | name: "Act", |
| 31 | description: |
| 32 | "用于常规交互式编码。Codewhale 可以检查、编辑并使用工具;Shell 是否可用以及何时请求批准,取决于当前配置和权限姿态。", |
| 33 | }, |
| 34 | { |
| 35 | name: "Operate", |
| 36 | description: |
| 37 | "用于从同一个输入区协调多项任务。父回合可以直接检查、编辑并使用 Shell 或 MCP 工具,其权限姿态、沙箱和安全规则与 Act 相同。独立、并行、后台或长时间工作会优先交给 Fleet worker,但并非所有可执行步骤都必须委派。只有需要有序阶段、门禁或确定性汇总时才需要 Workflow。", |
| 38 | }, |
| 39 | ] |
| 40 | : [ |
| 41 | { |
| 42 | name: "Plan", |
| 43 | description: |
| 44 | "Read-only investigation and planning. Codewhale can inspect the workspace, but it cannot run shell commands or edit files.", |
| 45 | }, |
| 46 | { |
| 47 | name: "Act", |
| 48 | description: |
| 49 | "Normal interactive coding. Codewhale can inspect, edit, and use tools; shell availability and approval prompts follow the active configuration and permission posture.", |
| 50 | }, |
| 51 | { |
| 52 | name: "Operate", |
| 53 | description: |
| 54 | "Multitask coordination from the same composer. The parent can inspect, edit, and use shell or MCP tools under the same permission posture, sandbox, and safety rules as Act. Fleet workers are preferred for independent, parallel, background, or long-running work, but delegation is not required for every executable step. Workflow is optional unless the work needs ordered phases, gates, or deterministic fan-in.", |
| 55 | }, |
| 56 | ]; |
| 57 | const postures = isZh |
| 58 | ? [ |
| 59 | { |
| 60 | name: "Ask", |
| 61 | description: "在可能产生重要后果的工具执行前询问你。", |
| 62 | }, |
| 63 | { |
| 64 | name: "Auto-Review", |
| 65 | description: "自动评估工具风险,只在确实需要你决定时询问。", |
| 66 | }, |
| 67 | { |
| 68 | name: "Full Access", |
| 69 | description: |
| 70 | "无需批准提示即可运行工具,并启用受信任工作区访问。仓库规则和托管约束仍然有效;仅在你信任的工作区中使用。", |
| 71 | }, |
| 72 | ] |
| 73 | : [ |
| 74 | { |
| 75 | name: "Ask", |
| 76 | description: "Ask before tools that can make consequential changes.", |
| 77 | }, |
| 78 | { |
| 79 | name: "Auto-Review", |
| 80 | description: "Review tool risk automatically and ask when a decision needs you.", |
| 81 | }, |
| 82 | { |
| 83 | name: "Full Access", |
| 84 | description: |
| 85 | "Run tools without approval prompts and enable trusted-workspace access. Repository rules and managed constraints still apply; use it only in a workspace you trust.", |
| 86 | }, |
| 87 | ]; |
| 88 | |
| 89 | return ( |
| 90 | <section className="space-y-10"> |
| 91 | <section id="overview" className="scroll-mt-32"> |
| 92 | <h2 className="font-display text-3xl mb-1">{isZh ? "模式" : "Modes"}</h2> |
| 93 | <p className={`${bodyClass} mt-3`}> |
| 94 | {isZh |
| 95 | ? "模式决定 Codewhale 如何组织工作;权限姿态决定它如何处理具有后果的工具调用。两者相互独立。" |
| 96 | : "A mode decides how Codewhale handles the work. A permission posture decides how it handles consequential tool calls. They are separate controls."} |
| 97 | </p> |
| 98 | <div className="hairline-t mt-6"> |
| 99 | {modes.map((mode) => ( |
| 100 | <section key={mode.name} className="py-4 hairline-b"> |
| 101 | <h3 className="font-display text-xl">{mode.name}</h3> |
| 102 | <p className={`${bodyClass} mt-1 text-sm`}>{mode.description}</p> |
| 103 | </section> |
| 104 | ))} |
| 105 | </div> |
| 106 | </section> |
| 107 | |
| 108 | <section id="switching" className="scroll-mt-32"> |
| 109 | <h2 className="font-display text-2xl mb-1"> |
| 110 | {isZh ? "切换模式" : "Switch modes"} |
| 111 | </h2> |
| 112 | <p className={`${bodyClass} mt-3`}> |
| 113 | {isZh ? ( |
| 114 | <> |
| 115 | 输入区空闲时,按 <kbd className="font-mono text-xs px-1.5 py-0.5 hairline">Tab</kbd>{" "} |
| 116 | 循环 Plan → Act → Operate。补全菜单打开时,Tab 接受补全;回合运行时,它可以把当前草稿排入下一个跟进消息。 |
| 117 | </> |
| 118 | ) : ( |
| 119 | <> |
| 120 | When the composer is idle, press{" "} |
| 121 | <kbd className="font-mono text-xs px-1.5 py-0.5 hairline">Tab</kbd> to cycle Plan → |
| 122 | Act → Operate. When a completion menu is open, Tab accepts the completion; during |
| 123 | an active turn, it can queue the current draft as the next follow-up. |
| 124 | </> |
| 125 | )} |
| 126 | </p> |
| 127 | <p className={`${bodyClass} mt-3`}> |
| 128 | {isZh |
| 129 | ? "运行 /mode 打开模式选择器,或使用以下命令直接切换:" |
| 130 | : "Run /mode to open the picker, or switch directly:"} |
| 131 | </p> |
| 132 | <pre className="code-block mt-4">{`/mode plan |
| 133 | /mode act |
| 134 | /mode operate`}</pre> |
| 135 | </section> |
| 136 | |
| 137 | <section id="permissions" className="scroll-mt-32"> |
| 138 | <h2 className="font-display text-2xl mb-1"> |
| 139 | {isZh ? "权限姿态" : "Permission postures"} |
| 140 | </h2> |
| 141 | <p className={`${bodyClass} mt-3`}> |
| 142 | {isZh ? ( |
| 143 | <> |
| 144 | Plan 始终为只读。在 Act 或 Operate 中且输入区空闲时,按{" "} |
| 145 | <kbd className="font-mono text-xs px-1.5 py-0.5 hairline">Shift+Tab</kbd> 循环 Ask |
| 146 | → Auto-Review → Full Access。运行 <code className="inline">/config</code>{" "} |
| 147 | 可查看或编辑当前会话权限;项目或托管策略可能会锁定或收紧它。 |
| 148 | </> |
| 149 | ) : ( |
| 150 | <> |
| 151 | Plan is always Read Only. When the composer is idle in Act or Operate, press{" "} |
| 152 | <kbd className="font-mono text-xs px-1.5 py-0.5 hairline">Shift+Tab</kbd> to cycle Ask |
| 153 | → Auto-Review → Full Access. Run <code className="inline">/config</code> to inspect |
| 154 | or edit the current session permission; project or managed policy may lock or |
| 155 | tighten it. |
| 156 | </> |
| 157 | )} |
| 158 | </p> |
| 159 | <div className="hairline-t mt-6"> |
| 160 | {postures.map((posture) => ( |
| 161 | <section key={posture.name} className="py-4 hairline-b"> |
| 162 | <h3 className="font-display text-lg">{posture.name}</h3> |
| 163 | <p className={`${bodyClass} mt-1 text-sm`}>{posture.description}</p> |
| 164 | </section> |
| 165 | ))} |
| 166 | </div> |
| 167 | </section> |
| 168 | |
| 169 | <section id="source" className="hairline-t pt-8"> |
| 170 | <p className="text-sm text-ink-mute"> |
| 171 | {isZh |
| 172 | ? "来源文档:docs/MODES.md · 更新时请同步修改 docs-map.ts。" |
| 173 | : "Source document: docs/MODES.md · Update docs-map.ts when changing."} |
| 174 | </p> |
| 175 | </section> |
| 176 | </section> |
| 177 | ); |
| 178 | } |
| 179 |