Skip to content

Commit f9385be

Browse files
committed
update version
1 parent b6492bd commit f9385be

5 files changed

Lines changed: 117 additions & 29 deletions

File tree

README-en.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![CodeQL](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml/badge.svg)](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml)
55
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
66

7-
Read-only, LLM-powered code review for local development and CI workflows.
7+
An LLM-powered code review agent for local development and CI workflows.
88

99
English | [简体中文](README.md)
1010

@@ -15,39 +15,34 @@ Zadig Review Agent reviews Git changes, asks a configured language model to iden
1515
Key properties:
1616

1717
- reviews a workspace, one commit, or a ref range;
18-
- supports OpenAI, Gemini, and Anthropic protocols through their official Go SDKs;
18+
- supports OpenAI, Gemini, and Anthropic protocols;
1919
- applies built-in or repository-specific review rules;
2020
- exposes only read-only repository tools to the model;
2121
- returns deterministic exit codes suitable for CI quality gates;
22-
- never writes comments back to a forge or modifies the reviewed repository.
2322

2423
This project is a review assistant, not a substitute for tests, security analysis, or human review. Model output can be incomplete or incorrect.
2524

2625
## Requirements
2726

28-
- Go 1.24 or later when building from source
27+
- Go 1.25.12 or later when building from source
2928
- Git and a Git repository to review
3029
- credentials for one supported model provider (not needed for `--preview`)
3130

3231
## Installation
3332

3433
### Go install
3534

36-
After the first tagged release is available:
37-
3835
```bash
3936
go install github.com/koderover/zadig-review-agent@latest
4037
```
4138

42-
`go install` honors the standard `GOPROXY` setting. To use a trusted organization or regional proxy for one installation:
39+
`go install` honors the standard `GOPROXY` setting. To use a trusted proxy for one installation:
4340

4441
```bash
45-
GOPROXY=https://your-go-proxy.example,direct \
42+
GOPROXY=https://goproxy.cn,direct \
4643
go install github.com/koderover/zadig-review-agent@latest
4744
```
4845

49-
Use an explicit version such as `@v0.1.0` when reproducible installation is more important than tracking the latest release.
50-
5146
### Release archive
5247

5348
Download the archive for Linux, macOS, or Windows from [GitHub Releases](https://github.com/koderover/zadig-review-agent/releases), then verify it with `checksums.txt`.

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![CodeQL](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml/badge.svg)](https://github.com/koderover/zadig-review-agent/actions/workflows/codeql.yml)
55
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
66

7-
面向本地开发和 CI 工作流的只读大模型代码审查工具
7+
面向本地开发和 CI 工作流的大模型代码审查 Agent 工具
88

99
[English](README-en.md) | 简体中文
1010

@@ -15,39 +15,34 @@ Zadig Review Agent 读取 Git 变更,使用用户配置的大语言模型识
1515
主要特性:
1616

1717
- 支持审查工作区、单个提交或两个 ref 之间的变更;
18-
- 通过官方 Go SDK 支持 OpenAI、Gemini 和 Anthropic 协议;
18+
- 支持 OpenAI、Gemini 和 Anthropic 协议;
1919
- 支持内置规则和仓库自定义规则;
2020
- 只向模型提供只读仓库工具;
2121
- 提供适合 CI 质量门禁的确定性退出码;
22-
- 不向代码托管平台回写评论,也不修改被审查仓库。
2322

2423
本项目是审查辅助工具,不能替代测试、安全扫描或人工审查。模型输出可能不完整或不准确。
2524

2625
## 环境要求
2726

28-
- 从源码构建时需要 Go 1.24 或更高版本
27+
- 从源码构建时需要 Go 1.25.12 或更高版本
2928
- Git 以及一个待审查的 Git 仓库
30-
- 一个受支持模型服务的凭证`--preview` 不需要)
29+
- 一个支持的 LLM 服务的凭证`--preview` 不需要)
3130

3231
## 安装
3332

3433
### 使用 Go 安装
3534

36-
首个标签版本发布后可执行:
37-
3835
```bash
3936
go install github.com/koderover/zadig-review-agent@latest
4037
```
4138

42-
`go install` 支持标准 `GOPROXY` 配置。单次安装可以使用可信的企业或区域代理
39+
`go install` 支持标准 `GOPROXY` 配置:
4340

4441
```bash
45-
GOPROXY=https://your-go-proxy.example,direct \
42+
GOPROXY=https://goproxy.cn,direct \
4643
go install github.com/koderover/zadig-review-agent@latest
4744
```
4845

49-
如果需要可复现安装,请使用 `@v0.1.0` 等明确版本,不要使用 `@latest`
50-
5146
### 下载发布包
5247

5348
[GitHub Releases](https://github.com/koderover/zadig-review-agent/releases) 下载 Linux、macOS 或 Windows 压缩包,并使用 `checksums.txt` 校验。
@@ -152,12 +147,12 @@ zadig-review-agent review \
152147

153148
退出码保持稳定:
154149

155-
| 退出码 | 含义 |
156-
| --- | --- |
157-
| `0` | 审查完整,且没有 finding 命中 `fail_on`|
158-
| `1` | 审查完整,且至少一个 finding 命中 `fail_on`|
159-
| `2` | 配置、Git、Provider、过滤或审查流程不完整。 |
160-
| `130` | 进程被取消。 |
150+
| 退出码 | 含义 |
151+
| ------ | --------------------------------------------- |
152+
| `0` | 审查完整,且没有 finding 命中 `fail_on` |
153+
| `1` | 审查完整,且至少一个 finding 命中 `fail_on`|
154+
| `2` | 配置、Git、Provider、过滤或审查流程不完整。 |
155+
| `130` | 进程被取消。 |
161156

162157
默认质量门禁在出现 `critical``high` finding 时失败,可通过 `review.fail_on``--fail-on` 调整。
163158

internal/cli/cli_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ func TestVersion(t *testing.T) {
3333
}
3434
}
3535

36+
version.Version, version.Commit, version.Date = "v0.1.0", "unknown", "unknown"
37+
{
38+
var stdout, stderr bytes.Buffer
39+
code, err := Run(context.Background(), []string{"version"}, &stdout, &stderr)
40+
if err != nil || code != 0 {
41+
t.Fatalf("code=%d err=%v stderr=%s", code, err, stderr.String())
42+
}
43+
if got, want := strings.TrimSpace(stdout.String()), "zadig-review-agent v0.1.0"; got != want {
44+
t.Fatalf("got %q want %q", got, want)
45+
}
46+
}
47+
3648
version.Version = "v1.2.3"
3749
version.Commit = "0123456789abcdef"
3850
version.Date = "2026-07-20T08:00:00Z"

internal/version/version.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package version
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"runtime/debug"
6+
)
47

58
var (
69
Version = "dev"
@@ -9,7 +12,34 @@ var (
912
)
1013

1114
func String() string {
12-
return fmt.Sprintf("zadig-review-agent %s (commit %s, built %s)", Version, shortCommit(Commit), Date)
15+
info, ok := debug.ReadBuildInfo()
16+
buildVersion, commit, date := resolveBuildInfo(Version, Commit, Date, info, ok)
17+
if buildVersion != "dev" && commit == "unknown" && date == "unknown" {
18+
return fmt.Sprintf("zadig-review-agent %s", buildVersion)
19+
}
20+
return fmt.Sprintf("zadig-review-agent %s (commit %s, built %s)", buildVersion, shortCommit(commit), date)
21+
}
22+
23+
func resolveBuildInfo(version, commit, date string, info *debug.BuildInfo, ok bool) (string, string, string) {
24+
if !ok || version != "dev" || info.Main.Version == "" || info.Main.Version == "(devel)" {
25+
return version, commit, date
26+
}
27+
28+
version = info.Main.Version
29+
for _, setting := range info.Settings {
30+
switch setting.Key {
31+
case "vcs.revision":
32+
if commit == "unknown" && setting.Value != "" {
33+
commit = setting.Value
34+
}
35+
case "vcs.time":
36+
if date == "unknown" && setting.Value != "" {
37+
date = setting.Value
38+
}
39+
}
40+
}
41+
42+
return version, commit, date
1343
}
1444

1545
func shortCommit(commit string) string {

internal/version/version_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package version
2+
3+
import (
4+
"runtime/debug"
5+
"testing"
6+
)
7+
8+
func TestResolveBuildInfoUsesModuleVersion(t *testing.T) {
9+
info := &debug.BuildInfo{
10+
Main: debug.Module{Version: "v0.1.0"},
11+
Settings: []debug.BuildSetting{
12+
{Key: "vcs.revision", Value: "0123456789abcdef"},
13+
{Key: "vcs.time", Value: "2026-07-20T08:00:00Z"},
14+
},
15+
}
16+
17+
version, commit, date := resolveBuildInfo("dev", "unknown", "unknown", info, true)
18+
if version != "v0.1.0" {
19+
t.Fatalf("version = %q, want %q", version, "v0.1.0")
20+
}
21+
if commit != "0123456789abcdef" {
22+
t.Fatalf("commit = %q, want %q", commit, "0123456789abcdef")
23+
}
24+
if date != "2026-07-20T08:00:00Z" {
25+
t.Fatalf("date = %q, want %q", date, "2026-07-20T08:00:00Z")
26+
}
27+
}
28+
29+
func TestResolveBuildInfoPreservesInjectedValues(t *testing.T) {
30+
info := &debug.BuildInfo{Main: debug.Module{Version: "v0.1.0"}}
31+
32+
version, commit, date := resolveBuildInfo(
33+
"v1.2.3",
34+
"fedcba9876543210",
35+
"2026-07-21T08:00:00Z",
36+
info,
37+
true,
38+
)
39+
if version != "v1.2.3" || commit != "fedcba9876543210" || date != "2026-07-21T08:00:00Z" {
40+
t.Fatalf("got (%q, %q, %q), want injected values", version, commit, date)
41+
}
42+
}
43+
44+
func TestResolveBuildInfoIgnoresDevelopmentBuild(t *testing.T) {
45+
info := &debug.BuildInfo{
46+
Main: debug.Module{Version: "(devel)"},
47+
Settings: []debug.BuildSetting{
48+
{Key: "vcs.revision", Value: "0123456789abcdef"},
49+
},
50+
}
51+
52+
version, commit, date := resolveBuildInfo("dev", "unknown", "unknown", info, true)
53+
if version != "dev" || commit != "unknown" || date != "unknown" {
54+
t.Fatalf("got (%q, %q, %q), want development defaults", version, commit, date)
55+
}
56+
}

0 commit comments

Comments
 (0)