-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.html
More file actions
121 lines (103 loc) · 6.62 KB
/
Copy pathinstall.html
File metadata and controls
121 lines (103 loc) · 6.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="assets/favicon.svg" type="image/svg+xml">
<title>安裝指南 · OpenCodeReview 繁中教學站</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Noto+Sans+TC:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/site.css">
</head>
<body>
<div class="container">
<nav class="topnav">
<a href="index.html">首頁</a>
<a href="map.html">概念地圖</a>
<a href="learning-path.html">學習路線</a>
<a href="install.html">安裝指南</a>
<a href="docs/index.html">文件教學</a>
<a href="docs/code/index.html">程式碼對照</a>
<a href="docs/worked.html">實作案例</a>
<a href="about.html">關於</a>
</nav>
<div class="back-link"><a href="index.html">← 回首頁</a></div>
<header>
<h1>安裝指南</h1>
<div class="subtitle">六種受支援的方式,讓 ocr CLI 在你機器上跑起來</div>
</header>
<div class="guide">
<div class="callout warn"><strong>先記住這件事</strong>:OCR 需要 <strong>Git ≥ 2.41</strong> 與 <strong>Node.js ≥ 18</strong>(除非你用 release 二進位)。裝完跑 <code>ocr version</code> 確認。若你用<a href="docs/delegate.html">委託模式</a>(如 Claude Code / OpenCode 內),就不需要自己配置 LLM API key。</div>
<h2>Step 1 — 安裝 CLI(npm,推薦)</h2>
<pre><code>npm install -g @alibaba-group/open-code-review
ocr version</code></pre>
<p>用 npm 安裝時,<code>ocr</code> 預設會<strong>自動保持最新</strong>:每次執行靜默檢查 registry,18 分鐘冷卻(<code>OCR_UPDATE_INTERVAL</code> 分鐘調整)。關閉自動更新:<code>OCR_NO_UPDATE=1</code>。</p>
<h2>Step 1' — 其他安裝方式</h2>
<pre><code># Homebrew(macOS / Linux)
brew install open-code-review
# MacPorts(macOS)
sudo port install open-code-review
# curl | sh 安裝腳本(CI 基礎鏡像 / 無界面環境)
curl -fsSL https://raw.githubusercontent.com/alibaba/open-code-review/main/install.sh | sh
# Windows(PowerShell 5.1+)
irm https://raw.githubusercontent.com/alibaba/open-code-review/main/install.ps1 | iex</code></pre>
<p class="hint">curl/sh 與 PowerShell 腳本支援 <code>OCR_INSTALL_DIR</code>(預設 /usr/local/bin 或 %LOCALAPPDATA%\Programs\ocr)與 <code>OCR_VERSION</code> 環境變數。</p>
<h2>Step 2 — 配置 LLM</h2>
<pre><code>ocr config provider # 選擇內建或自訂 provider、填入 API key、挑 model
ocr config model # 之後換模型
ocr llm test # 驗證連通性</code></pre>
<p class="hint">非互動環境(CI / 無 TUI)用 <code>ocr config set</code>:<code>ocr config set provider anthropic</code>、<code>ocr config set model claude-opus-4-6</code>、<code>ocr config set providers.anthropic.api_key sk-ant-xxx</code>。</p>
<div class="callout info"><strong>不用設也行</strong>:若你已配好 Claude Code 的 <code>ANTHROPIC_*</code>,或 OCR 自己的 <code>OCR_LLM_*</code> 環境變數,OCR 會自動識別。完整 provider 表與環境變數見 <a href="docs/configuration.html">設定</a>。</div>
<h2>Step 3 — 第一次評審</h2>
<pre><code>cd path/to/your-repo
ocr review # 工作區模式:staged + unstaged + untracked
ocr review --from main --to feature-branch
ocr review --commit abc123</code></pre>
<h2>GitHub Release 二進位(不想裝 Node.js)</h2>
<pre><code># macOS(Apple Silicon)
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-darwin-arm64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
# Linux x86_64
curl -Lo ocr https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-linux-amd64
chmod +x ocr && sudo mv ocr /usr/local/bin/ocr
# Windows(AMD64)
curl -Lo ocr.exe https://github.com/alibaba/open-code-review/releases/latest/download/opencodereview-windows-amd64.exe</code></pre>
<p class="hint">每個 release 旁有 <code>sha256sum.txt</code> 供校驗。</p>
<h2>從原始碼建置</h2>
<pre><code>git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # 產出 dist/opencodereview
sudo cp dist/opencodereview /usr/local/bin/ocr
make test # LC_ALL=C go test -v -race -count=1 ./...</code></pre>
<p class="hint">需求:Go ≥ 1.25、Git、Make。</p>
<h2>Shell 補全(可選)</h2>
<pre><code>source <(ocr completion bash) # bash
ocr completion zsh > "${fpath[1]}/_ocr" # zsh
ocr completion fish | source # fish
ocr completion powershell | Out-String | Invoke-Expression # PowerShell</code></pre>
<h2>OCR 在哪裡存放狀態</h2>
<table class="platform-table">
<tr><th>路徑</th><th>內容</th></tr>
<tr><td><code>~/.opencodereview/config.json</code></td><td>LLM 端點、語言、遙測配置(<code>ocr config set</code> 管理)</td></tr>
<tr><td><code>~/.opencodereview/rule.json</code></td><td>可選的全域評審規則</td></tr>
<tr><td><code>~/.opencodereview/sessions/…</code></td><td>每次評審的 JSONL 轉錄(供 ocr viewer)</td></tr>
<tr><td><code><repo>/.opencodereview/rule.json</code></td><td>可選的專案級評審規則——可安全提交</td></tr>
</table>
<h2>疑難排解</h2>
<table class="platform-table">
<tr><th>問題</th><th>解決方式</th></tr>
<tr><td><code>command not found: ocr</code></td><td>確認安裝位置在 <code>$PATH</code>(<code>which ocr</code>)</td></tr>
<tr><td><code>no valid LLM endpoint configured</code></td><td>用 <code>ocr config set</code> 或環境變數補齊 (URL, token, model) 三元組,再 <code>ocr llm test</code></td></tr>
<tr><td><code>not a git repository</code></td><td><code>cd</code> 進 repo,或 <code>--repo /path/to/repo</code></td></tr>
<tr><td>評審跑在「No tool calls parsed」重試</td><td>模型不支援原生工具呼叫——換 qwen3 等有 tools 的模型(見 FAQ)</td></tr>
</table>
<p class="hint">完整除錯見 <a href="docs/faq.html">FAQ</a> 與 <a href="docs/quickstart.html">快速開始</a>。</p>
</div>
<footer>
<div>這是 <a href="https://github.com/alibaba/open-code-review">alibaba/open-code-review</a> 的非官方繁體中文教學站。</div>
<div>內容 © <a href="https://github.com/alibaba/open-code-review">alibaba/open-code-review Contributors</a>(Apache-2.0)· 本站與 Alibaba 無關 · 對齊上游 main @ 9148bfd</div>
</footer>
</div>
</body>
</html>