# 安裝與 CLI（0.12.6 以上）

官網：https://sudolimit.com/redactleaf/agents
機器可讀指引：https://sudolimit.com/redactleaf/agents.md

從官網安裝符合系統的 RedactLeaf；不要求安裝 Python、Node、Xcode 或 .NET SDK。安裝／放行提示由使用者完成，不自動停用安全保護。以目前 Agent 平台的 skill 安裝方式載入此資料夾；也可以讓 Agent 直接閱讀使用者指定的 `SKILL.md`。不要自行覆寫已有 skill 或修改全域環境。

macOS（若 App 安裝於其他位置，使用該實際路徑）：

```sh
redact="/Applications/RedactLeaf.app/Contents/MacOS/LocalRedactCLI"
"$redact" help
"$redact" agent-analyze "/使用者指定/文件.docx"
"$redact" agent-status "/使用者指定/文件.docx"
"$redact" agent-export "/使用者指定/文件.docx"
"$redact" agent-check "/上一步回傳的路徑/document.docx"
"$redact" agent-recommend "/Agent輸出/整理稿.pptx"
"$redact" agent-restore "/Agent輸出/整理稿.pptx" --candidate auto
```

Windows PowerShell（安裝程式會使用符合 CPU 的資料夾；只檢查這兩個已知路徑是否存在，不掃描使用者資料）：

```powershell
$base = Join-Path $env:LOCALAPPDATA 'Programs/RedactLeaf'
$choices = @('app-arm64/worker/RedactLeaf.Cli.exe', 'app-x64/worker/RedactLeaf.Cli.exe')
$redact = $choices | ForEach-Object { Join-Path $base $_ } | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if (-not $redact) { throw '請先安裝 RedactLeaf 0.12.6 以上，或由使用者指定 CLI 路徑。' }
& $redact help
& $redact agent-analyze 'C:/使用者指定/文件.docx'
& $redact agent-status 'C:/使用者指定/文件.docx'
& $redact agent-export 'C:/使用者指定/文件.docx'
& $redact agent-check 'C:/上一步回傳的路徑/document.docx'
& $redact agent-recommend 'C:/Agent輸出/整理稿.pptx'
& $redact agent-restore 'C:/Agent輸出/整理稿.pptx' --candidate auto
```

上述路徑是示意，不是可直接複製執行的批次腳本。逐步看 JSON 再決定下一步，不能不看狀態一路執行。`help` 必須包含 `agent-*` 指令；沒有就請使用者更新，不使用舊指令冒充等價流程。

| 指令 | 預期狀態 | 下一步 |
|---|---|---|
| agent-analyze / agent-status | awaiting_review、readable:false | 等使用者在 GUI 檢查及確認 |
| agent-status | ready、readable:false | 可要求匯出，仍不能讀原文 |
| agent-export | exported、readable:true、path、sha256、restorable | 準備對回傳的副本做 agent-check |
| agent-check | verified、readable:true | 可讀取此核准副本 |
| agent-recommend | candidates、recommendedId、candidates | 唯一完整且未加密才自動還原；其餘 GUI 處理 |
| agent-restore | restored、readable:false、containsPersonalData:true、path | 只交付路徑，禁止讀回 |
| 任一指令失敗 | blocked 或非零退出碼 | GUI 檢查，不讀日誌、原文或對照 |

不同平台的 `agent-*` 操作名稱與主要 JSON 欄位相同。設定與文件確認由 GUI 操作；Agent 不要替使用者降低辨識等級、切換為純規則模式或重設歷程。索引和對照由應用程式保管，不需要 Agent 找出還原檔。

軟體的檢查、下載與安全安裝另見 [安全更新（0.12.7 起）](updates.md)，不要用文件處理命令代替更新。
