@alibaba-group/open-code-review 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/LICENSE +201 -0
- package/NPM-README.md +95 -0
- package/README.md +95 -0
- package/bin/ocr.js +14 -0
- package/package.json +28 -0
- package/scripts/install.js +224 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v1.0.0 (2026-05-20)
|
|
4
|
+
|
|
5
|
+
First public release of OpenCodeReview.
|
|
6
|
+
|
|
7
|
+
- feat: AI-powered code review with OpenAI-compatible LLM endpoints
|
|
8
|
+
- feat: three review modes — workspace changes, branch range, single commit
|
|
9
|
+
- feat: Agent mode with context-aware file reading and `git grep` search
|
|
10
|
+
- feat: plan phase for large diffs (>50 lines) with risk analysis
|
|
11
|
+
- feat: concurrent file reviews with configurable parallelism
|
|
12
|
+
- feat: session viewer WebUI for inspecting review history
|
|
13
|
+
- feat: cross-platform support (linux/darwin, amd64/arm64)
|
|
14
|
+
- feat: npm distribution with automatic binary download
|
|
15
|
+
|
|
16
|
+
## v0.2.2 (2026-05-18)
|
|
17
|
+
|
|
18
|
+
- feat(viewer): Enhance session viewer UI and tool call handling (d9a425a)
|
|
19
|
+
- chore(release): bump version to v0.2.1 (e58eb56)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## v0.2.1 (2026-05-16)
|
|
23
|
+
|
|
24
|
+
- fix(version): correct program name output from 'opencodereview' to 'open-code-review' (a97ff48)
|
|
25
|
+
- chore(release): bump version to v0.2.0 (2911231)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## v0.2.0 (2026-05-16)
|
|
29
|
+
|
|
30
|
+
- fix(publish): use sparse checkout in git add for internal repo copy (b9278cc)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## v0.1.8 (2026-05-16)
|
|
34
|
+
|
|
35
|
+
- feat: add User-Agent header and update LLM client context handling (93e02db)
|
|
36
|
+
- chore(release): bump version to v0.1.7 (3586cf7)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## v0.1.7 (2026-05-15)
|
|
40
|
+
|
|
41
|
+
- fix: display timestamps in Asia/Shanghai timezone in viewer (0e02aaf)
|
|
42
|
+
- feat: rm CHANGELOG.md (32ed4f4)
|
|
43
|
+
- chore(release): bump version to v0.1.6 (b36b867)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## v0.1.6 (2026-05-14)
|
|
47
|
+
|
|
48
|
+
- chore: Optimize release process and change log management (16e28fb)
|
|
49
|
+
- feat: task template to english (e54c56c)
|
|
50
|
+
- feat: remove llm provider (acf2bb6)
|
|
51
|
+
- chore(release): bump version to v0.1.5 (c3439c2)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## v0.1.5 (2026-05-14)
|
|
55
|
+
|
|
56
|
+
- refactor: rename per-file timeout to concurrent task timeout and improve CLI help docs (067084d)
|
|
57
|
+
- chore(release): bump version to v0.1.4 (b6269d9)
|
|
58
|
+
|
|
59
|
+
## v0.1.4 (2026-05-13)
|
|
60
|
+
|
|
61
|
+
- feat: ocr.js 可执行权限 (3b1f793)
|
|
62
|
+
- chore(release): bump version to v0.1.3 (33d6380)
|
|
63
|
+
- feat: update publish readme (c79d952)
|
|
64
|
+
|
|
65
|
+
## v0.1.3 (2026-05-13)
|
|
66
|
+
|
|
67
|
+
- feat: remove deprecated sh (0ec83ae)
|
|
68
|
+
- feat: 为 llm test 增加来源和 url (f40872f)
|
|
69
|
+
- chore(release): bump version to v0.1.2 (92c4119)
|
|
70
|
+
- feat: fix bug (d9f9cb3)
|
|
71
|
+
|
|
72
|
+
## v0.1.2 (2026-05-13)
|
|
73
|
+
|
|
74
|
+
- feat: 增加发包的 readme (1d4b783)
|
|
75
|
+
- feat: 增加内部打包分发的脚本 (fd3b5d3)
|
|
76
|
+
- feat: 增加内部打包分发的脚本 (01a809a)
|
|
77
|
+
- feat: update --audience agent (8391e1e)
|
|
78
|
+
- feat: update output note (dd12b72)
|
|
79
|
+
- feat: update scripts/release.sh (1319f3a)
|
|
80
|
+
- feat: Adding the parameter distinguishes between human and agent input. (5f09e5e)
|
|
81
|
+
- feat: fix tokens count (b73e05c)
|
|
82
|
+
- feat: add TODO note (1135690)
|
|
83
|
+
- feat: update Examples (2babfe8)
|
|
84
|
+
- feat: 记忆压缩三层分区 + 双阈值异步压 (14adf6f)
|
|
85
|
+
- feat: 四层模型端点,适配 anthropic (8a93673)
|
|
86
|
+
- feat: 增加一些边界提示 (b680c29)
|
|
87
|
+
- feat: 区分没有diff和没有评论的反馈 (a217a6f)
|
|
88
|
+
- feat: --format json 模式下静默进度输出,保持 stdout 纯净 (5aea3ac)
|
|
89
|
+
- feat: 增加 git 仓库校验 (39d02d1)
|
|
90
|
+
- feat: 修改配置项内容 (22d93ed)
|
|
91
|
+
- feat: 增加评论块与diff渲染 (d0e4832)
|
|
92
|
+
- chore: 移除 .claude 追踪并更新 .gitignore (e99092a)
|
|
93
|
+
- feat: 增加viewer能力 (d99e3eb)
|
|
94
|
+
- feat: 配置化默认允许评审的文件 (576180d)
|
|
95
|
+
- feat: 大diff拦截 (21a4b66)
|
|
96
|
+
- feat: add license (2cd09e6)
|
|
97
|
+
- feat: 修改文件名 (84df403)
|
|
98
|
+
- feat: 更新readme (49cb629)
|
|
99
|
+
- feat: token used 展示拆分成 input 和 output (1c76de0)
|
|
100
|
+
- feat: 移除历史文件索引 (9589cb6)
|
|
101
|
+
- feat: 支持类似claude code 会话历史的能力 (daa7181)
|
|
102
|
+
- feat: add .gitignore (edd6854)
|
|
103
|
+
- feat: 修复一些问题 (9ecadd7)
|
|
104
|
+
- feat: 修复一些问题 (52e035d)
|
|
105
|
+
- feat: 修复一些问题 (07b6ba2)
|
|
106
|
+
- feat: 修复一些问题 (e2d6a54)
|
|
107
|
+
- feat: 增加 --debug模式 (a896ba5)
|
|
108
|
+
- feat: 修复评论重复的问题 (223a6ef)
|
|
109
|
+
- feat: 改名 (2f2aaa1)
|
|
110
|
+
- feat: argus 改名 opencodereview (3d2029d)
|
|
111
|
+
- feat: 修复了一些问题 (9e449d5)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this definition, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a complaint) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that you distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act on
|
|
170
|
+
Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the same
|
|
186
|
+
"printed page" as the copyright notice for easier identification within
|
|
187
|
+
third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Alibaba
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NPM-README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# OpenCodeReview CLI
|
|
2
|
+
|
|
3
|
+
AI-powered code review tool that reads Git diffs, sends changed files to a configurable LLM via OpenAI-compatible API, and generates structured review comments. It goes beyond surface-level analysis — the Agent can read project context for deep reviews.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @alibaba-group/open-code-review
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
After installation, the `ocr` command is available globally.
|
|
12
|
+
|
|
13
|
+
### Version Control
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install specific version
|
|
17
|
+
OCR_VERSION=v1.0.0 npm install -g @alibaba-group/open-code-review
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
**You must configure an LLM provider before using `ocr`.** The tool requires access to an OpenAI-compatible API endpoint (OpenAI, Claude, local models, etc.).
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ocr config set llm.url https://api.anthropic.com/v1/messages \
|
|
26
|
+
&& ocr config set llm.auth_token {{your-api-key}} \
|
|
27
|
+
&& ocr config set llm.model claude-opus-4-6 \
|
|
28
|
+
&& ocr config set llm.use_anthropic true \
|
|
29
|
+
&& ocr config set language Chinese
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Config is stored in `~/.open-code-review/config.json`.
|
|
33
|
+
|
|
34
|
+
Or via environment variables:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
|
|
38
|
+
export OCR_LLM_TOKEN=your-api-key
|
|
39
|
+
export OCR_LLM_MODEL=claude-opus-4-6
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Test Connectivity
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ocr llm test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
Navigate to any Git repository and run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Review all workspace changes
|
|
54
|
+
ocr review
|
|
55
|
+
|
|
56
|
+
# Review diff between two branches
|
|
57
|
+
ocr review --from main --to feature-branch
|
|
58
|
+
|
|
59
|
+
# Review a single commit
|
|
60
|
+
ocr review --commit abc123
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Commands
|
|
64
|
+
|
|
65
|
+
| Command | Description |
|
|
66
|
+
|---------|-------------|
|
|
67
|
+
| `ocr review` / `ocr r` | Start code review |
|
|
68
|
+
| `ocr config set <key> <value>` | Manage configuration |
|
|
69
|
+
| `ocr llm test` | Test LLM connectivity |
|
|
70
|
+
| `ocr viewer` | Start WebUI session viewer |
|
|
71
|
+
| `ocr version` | Show version info |
|
|
72
|
+
|
|
73
|
+
## Common Options
|
|
74
|
+
|
|
75
|
+
| Flag | Shorthand | Default | Description |
|
|
76
|
+
|------|-----------|---------|-------------|
|
|
77
|
+
| `--repo` | | current dir | Git repository root |
|
|
78
|
+
| `--from` | | | Source ref (e.g., `main`) |
|
|
79
|
+
| `--to` | | | Target ref (e.g., `feature-branch`) |
|
|
80
|
+
| `--commit` | `-c` | | Review a single commit |
|
|
81
|
+
| `--format` | `-f` | `text` | Output format: `text` or `json` |
|
|
82
|
+
| `--concurrency` | | `4` | Max concurrent file reviews |
|
|
83
|
+
| `--timeout` | | `10` | Per-file timeout (minutes) |
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- **Three review modes**: workspace changes, branch range, single commit
|
|
88
|
+
- **Context-aware**: Agent reads arbitrary files, searches code via `git grep`, inspects diffs
|
|
89
|
+
- **Plan phase**: Large changes (>50 lines) get risk analysis first
|
|
90
|
+
- **Any LLM**: Works with OpenAI, Claude-compatible endpoints, local models
|
|
91
|
+
- **Concurrent**: Files reviewed in parallel (configurable workers)
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# OpenCodeReview CLI
|
|
2
|
+
|
|
3
|
+
AI-powered code review tool that reads Git diffs, sends changed files to a configurable LLM via OpenAI-compatible API, and generates structured review comments. It goes beyond surface-level analysis — the Agent can read project context for deep reviews.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @alibaba-group/open-code-review
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
After installation, the `ocr` command is available globally.
|
|
12
|
+
|
|
13
|
+
### Version Control
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install specific version
|
|
17
|
+
OCR_VERSION=v1.0.0 npm install -g @alibaba-group/open-code-review
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
**You must configure an LLM provider before using `ocr`.** The tool requires access to an OpenAI-compatible API endpoint (OpenAI, Claude, local models, etc.).
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ocr config set llm.url https://api.anthropic.com/v1/messages \
|
|
26
|
+
&& ocr config set llm.auth_token {{your-api-key}} \
|
|
27
|
+
&& ocr config set llm.model claude-opus-4-6 \
|
|
28
|
+
&& ocr config set llm.use_anthropic true \
|
|
29
|
+
&& ocr config set language Chinese
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Config is stored in `~/.open-code-review/config.json`.
|
|
33
|
+
|
|
34
|
+
Or via environment variables:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
|
|
38
|
+
export OCR_LLM_TOKEN=your-api-key
|
|
39
|
+
export OCR_LLM_MODEL=claude-opus-4-6
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Test Connectivity
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ocr llm test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
Navigate to any Git repository and run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Review all workspace changes
|
|
54
|
+
ocr review
|
|
55
|
+
|
|
56
|
+
# Review diff between two branches
|
|
57
|
+
ocr review --from main --to feature-branch
|
|
58
|
+
|
|
59
|
+
# Review a single commit
|
|
60
|
+
ocr review --commit abc123
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Commands
|
|
64
|
+
|
|
65
|
+
| Command | Description |
|
|
66
|
+
|---------|-------------|
|
|
67
|
+
| `ocr review` / `ocr r` | Start code review |
|
|
68
|
+
| `ocr config set <key> <value>` | Manage configuration |
|
|
69
|
+
| `ocr llm test` | Test LLM connectivity |
|
|
70
|
+
| `ocr viewer` | Start WebUI session viewer |
|
|
71
|
+
| `ocr version` | Show version info |
|
|
72
|
+
|
|
73
|
+
## Common Options
|
|
74
|
+
|
|
75
|
+
| Flag | Shorthand | Default | Description |
|
|
76
|
+
|------|-----------|---------|-------------|
|
|
77
|
+
| `--repo` | | current dir | Git repository root |
|
|
78
|
+
| `--from` | | | Source ref (e.g., `main`) |
|
|
79
|
+
| `--to` | | | Target ref (e.g., `feature-branch`) |
|
|
80
|
+
| `--commit` | `-c` | | Review a single commit |
|
|
81
|
+
| `--format` | `-f` | `text` | Output format: `text` or `json` |
|
|
82
|
+
| `--concurrency` | | `4` | Max concurrent file reviews |
|
|
83
|
+
| `--timeout` | | `10` | Per-file timeout (minutes) |
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- **Three review modes**: workspace changes, branch range, single commit
|
|
88
|
+
- **Context-aware**: Agent reads arbitrary files, searches code via `git grep`, inspects diffs
|
|
89
|
+
- **Plan phase**: Large changes (>50 lines) get risk analysis first
|
|
90
|
+
- **Any LLM**: Works with OpenAI, Claude-compatible endpoints, local models
|
|
91
|
+
- **Concurrent**: Files reviewed in parallel (configurable workers)
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0
|
package/bin/ocr.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const binaryPath = path.join(__dirname, "opencodereview");
|
|
8
|
+
|
|
9
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
env: process.env,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
process.exit(result.status ?? (result.error ? 1 : 0));
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alibaba-group/open-code-review",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenCodeReview CLI — AI-powered code review tool",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ocr": "bin/ocr.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/install.js",
|
|
10
|
+
"prepublishOnly": "cp NPM-README.md README.md",
|
|
11
|
+
"postpublish": "git checkout README.md"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/alibaba/open-code-review.git"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"ocrConfig": {
|
|
21
|
+
"urlPattern": "https://github.com/alibaba/open-code-review/releases/download/v{version}/opencodereview-v{version}-{os}-{arch}",
|
|
22
|
+
"checksumPattern": "https://github.com/alibaba/open-code-review/releases/download/v{version}/sha256sum.txt"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=14"
|
|
26
|
+
},
|
|
27
|
+
"license": "Apache-2.0"
|
|
28
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const crypto = require("crypto");
|
|
8
|
+
|
|
9
|
+
const BINARY_NAME = "opencodereview";
|
|
10
|
+
|
|
11
|
+
const packageRoot = path.join(__dirname, "..");
|
|
12
|
+
const binDir = path.join(packageRoot, "bin");
|
|
13
|
+
const binaryDest = path.join(binDir, BINARY_NAME);
|
|
14
|
+
|
|
15
|
+
function info(msg) {
|
|
16
|
+
console.log(`[INFO] ${msg}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function warn(msg) {
|
|
20
|
+
console.warn(`[WARN] ${msg}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function error(msg) {
|
|
24
|
+
console.error(`[ERROR] ${msg}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function detectPlatform() {
|
|
28
|
+
const os = process.platform;
|
|
29
|
+
let arch = process.arch;
|
|
30
|
+
|
|
31
|
+
switch (arch) {
|
|
32
|
+
case "x64":
|
|
33
|
+
arch = "amd64";
|
|
34
|
+
break;
|
|
35
|
+
case "arm64":
|
|
36
|
+
arch = "arm64";
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Unsupported architecture: ${arch}. Supported: amd64 (x64), arm64`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (os !== "linux" && os !== "darwin") {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Unsupported operating system: ${os}. Supported: linux, darwin`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { os, arch };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function loadPackageJson() {
|
|
54
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
55
|
+
if (!pkg.version) {
|
|
56
|
+
throw new Error("Missing version field in package.json");
|
|
57
|
+
}
|
|
58
|
+
if (!pkg.ocrConfig || !pkg.ocrConfig.urlPattern) {
|
|
59
|
+
throw new Error("Missing ocrConfig.urlPattern in package.json");
|
|
60
|
+
}
|
|
61
|
+
return pkg;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveVersion(pkg) {
|
|
65
|
+
const envVersion = process.env.OCR_VERSION;
|
|
66
|
+
if (envVersion) {
|
|
67
|
+
const v = envVersion.startsWith("v") ? envVersion.slice(1) : envVersion;
|
|
68
|
+
info(`Using pinned version from OCR_VERSION: ${v}`);
|
|
69
|
+
return v;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
info(`Using version from package.json: ${pkg.version}`);
|
|
73
|
+
return pkg.version;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function buildUrl(pattern, vars) {
|
|
77
|
+
return pattern
|
|
78
|
+
.replace(/\{version\}/g, vars.version)
|
|
79
|
+
.replace(/\{os\}/g, vars.os)
|
|
80
|
+
.replace(/\{arch\}/g, vars.arch);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function download(url, maxRedirects = 10) {
|
|
84
|
+
if (!url.startsWith("https")) {
|
|
85
|
+
return Promise.reject(new Error(`Refusing non-HTTPS download: ${url}`));
|
|
86
|
+
}
|
|
87
|
+
if (maxRedirects <= 0) {
|
|
88
|
+
return Promise.reject(new Error(`Too many redirects fetching ${url}`));
|
|
89
|
+
}
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
https.get(url, (res) => {
|
|
92
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
93
|
+
res.resume();
|
|
94
|
+
download(res.headers.location, maxRedirects - 1).then(resolve).catch(reject);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (res.statusCode !== 200) {
|
|
98
|
+
res.resume();
|
|
99
|
+
reject(new Error(`HTTP ${res.statusCode} fetching ${url}`));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
resolve(res);
|
|
103
|
+
}).on("error", reject);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function downloadText(url) {
|
|
108
|
+
const res = await download(url);
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
let data = "";
|
|
111
|
+
res.on("data", (chunk) => (data += chunk));
|
|
112
|
+
res.on("end", () => resolve(data));
|
|
113
|
+
res.on("error", reject);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function downloadBinary(url, destPath) {
|
|
118
|
+
const res = await download(url);
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
const fileStream = fs.createWriteStream(destPath);
|
|
121
|
+
res.on("error", (err) => {
|
|
122
|
+
fileStream.destroy();
|
|
123
|
+
fs.unlink(destPath, () => {});
|
|
124
|
+
reject(err);
|
|
125
|
+
});
|
|
126
|
+
res.pipe(fileStream);
|
|
127
|
+
fileStream.on("finish", () => fileStream.close(() => resolve()));
|
|
128
|
+
fileStream.on("error", (err) => {
|
|
129
|
+
fs.unlink(destPath, () => {});
|
|
130
|
+
reject(err);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function computeChecksum(filePath) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const hash = crypto.createHash("sha256");
|
|
138
|
+
const stream = fs.createReadStream(filePath);
|
|
139
|
+
stream.on("data", (chunk) => hash.update(chunk));
|
|
140
|
+
stream.on("end", () => resolve(hash.digest("hex")));
|
|
141
|
+
stream.on("error", reject);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function main() {
|
|
146
|
+
info("OpenCodeReview Installer");
|
|
147
|
+
info("=========================");
|
|
148
|
+
|
|
149
|
+
const { os, arch } = detectPlatform();
|
|
150
|
+
info(`Detected platform: ${os}/${arch}`);
|
|
151
|
+
|
|
152
|
+
const pkg = loadPackageJson();
|
|
153
|
+
const version = resolveVersion(pkg);
|
|
154
|
+
const config = pkg.ocrConfig;
|
|
155
|
+
|
|
156
|
+
if (!fs.existsSync(binDir)) {
|
|
157
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const jsWrapper = path.join(binDir, "ocr.js");
|
|
161
|
+
if (fs.existsSync(jsWrapper)) {
|
|
162
|
+
try {
|
|
163
|
+
fs.chmodSync(jsWrapper, 0o755);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
warn(`Could not make ocr.js executable: ${e.message}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const vars = { version, os, arch };
|
|
170
|
+
const downloadUrl = buildUrl(config.urlPattern, vars);
|
|
171
|
+
info(`Downloading ${downloadUrl} ...`);
|
|
172
|
+
|
|
173
|
+
await downloadBinary(downloadUrl, binaryDest);
|
|
174
|
+
fs.chmodSync(binaryDest, 0o755);
|
|
175
|
+
|
|
176
|
+
if (config.checksumPattern) {
|
|
177
|
+
try {
|
|
178
|
+
const checksumUrl = buildUrl(config.checksumPattern, vars);
|
|
179
|
+
info("Verifying checksum...");
|
|
180
|
+
const shaContent = await downloadText(checksumUrl);
|
|
181
|
+
const actualSha = await computeChecksum(binaryDest);
|
|
182
|
+
|
|
183
|
+
let verified = false;
|
|
184
|
+
for (const line of shaContent.split("\n")) {
|
|
185
|
+
const trimmed = line.trim();
|
|
186
|
+
if (trimmed.includes(`-${os}-${arch}`)) {
|
|
187
|
+
const expectedSha = trimmed.split(/\s+/)[0].toLowerCase();
|
|
188
|
+
if (expectedSha) {
|
|
189
|
+
if (actualSha !== expectedSha) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Checksum mismatch! Expected: ${expectedSha}, Got: ${actualSha}`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
info("Checksum verified.");
|
|
195
|
+
verified = true;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!verified) {
|
|
201
|
+
warn("No matching checksum entry found; skipping verification.");
|
|
202
|
+
}
|
|
203
|
+
} catch (e) {
|
|
204
|
+
if (e.message.includes("mismatch")) {
|
|
205
|
+
throw e;
|
|
206
|
+
}
|
|
207
|
+
warn(`Could not verify checksum: ${e.message}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
info(`Installed: ${binaryDest}`);
|
|
212
|
+
info("");
|
|
213
|
+
info("OpenCodeReview is ready!");
|
|
214
|
+
info("");
|
|
215
|
+
info("Quick start:");
|
|
216
|
+
info(" ocr version Show version info");
|
|
217
|
+
info(" ocr config set Configure your LLM provider");
|
|
218
|
+
info(" ocr review Start a code review");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
main().catch((err) => {
|
|
222
|
+
error(err.message);
|
|
223
|
+
process.exit(1);
|
|
224
|
+
});
|