Skip to content

Commit bd2ddbe

Browse files
committed
feat: add install script
1 parent 1ad8f8d commit bd2ddbe

7 files changed

Lines changed: 169 additions & 34 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ go.work.sum
3333
.codebot/
3434

3535
docs/
36+
refer/

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,41 @@ Each layer has one job. No layer knows about the layers above it.
5252
- Non-interactive print mode for pipes and scripts (`-p`)
5353
- Slash commands: `/model`, `/compact`, `/plan`, `/resume`, `/copy`, ...
5454

55-
## Quick Start
55+
## Installation
56+
57+
**Pre-built binary (recommended):**
5658

5759
```bash
58-
# Install
59-
go install github.com/voocel/codebot/cmd/codebot@latest
60+
# Linux / macOS
61+
curl -fsSL https://raw.githubusercontent.com/voocel/codebot/main/scripts/install.sh | sh
6062

61-
# Set API key and run
62-
export ANTHROPIC_API_KEY=sk-ant-...
63-
codebot
63+
# Windows (PowerShell)
64+
irm https://raw.githubusercontent.com/voocel/codebot/main/scripts/install.ps1 | iex
65+
```
66+
67+
Or download directly from [GitHub Releases](https://github.com/voocel/codebot/releases).
68+
69+
**With Go:**
70+
71+
```bash
72+
go install github.com/voocel/codebot/cmd/codebot@latest
6473
```
6574

66-
Or build from source:
75+
**Build from source:**
6776

6877
```bash
6978
git clone https://github.com/voocel/codebot.git
7079
cd codebot && go build -o codebot ./cmd/codebot
7180
```
7281

82+
## Quick Start
83+
84+
```bash
85+
# Set API key and run
86+
export ANTHROPIC_API_KEY=sk-ant-...
87+
codebot
88+
```
89+
7390
Supported environment variables: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`. For more options see [settings.example.jsonc](settings.example.jsonc).
7491

7592
## Usage
@@ -103,8 +120,8 @@ All fields are optional. See [settings.example.jsonc](settings.example.jsonc) fo
103120

104121
## Requirements
105122

106-
- Go 1.25+
107123
- API key for at least one provider
124+
- Go 1.25+ (only if installing via `go install` or building from source)
108125

109126
## License
110127

README_zh.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,41 @@
5252
- 非交互管道模式(`-p`
5353
- 斜杠命令:`/model`, `/compact`, `/plan`, `/resume`, `/copy`, ...
5454

55-
## 快速开始
55+
## 安装
56+
57+
**预编译二进制(推荐):**
5658

5759
```bash
58-
# 安装
59-
go install github.com/voocel/codebot/cmd/codebot@latest
60+
# Linux / macOS
61+
curl -fsSL https://raw.githubusercontent.com/voocel/codebot/main/scripts/install.sh | sh
6062

61-
# 设置 API Key 并运行
62-
export ANTHROPIC_API_KEY=sk-ant-...
63-
codebot
63+
# Windows (PowerShell)
64+
irm https://raw.githubusercontent.com/voocel/codebot/main/scripts/install.ps1 | iex
65+
```
66+
67+
或直接从 [GitHub Releases](https://github.com/voocel/codebot/releases) 下载。
68+
69+
**通过 Go 安装:**
70+
71+
```bash
72+
go install github.com/voocel/codebot/cmd/codebot@latest
6473
```
6574

66-
或从源码构建:
75+
**从源码构建:**
6776

6877
```bash
6978
git clone https://github.com/voocel/codebot.git
7079
cd codebot && go build -o codebot ./cmd/codebot
7180
```
7281

82+
## 快速开始
83+
84+
```bash
85+
# 设置 API Key 并运行
86+
export ANTHROPIC_API_KEY=sk-ant-...
87+
codebot
88+
```
89+
7390
支持的环境变量:`ANTHROPIC_API_KEY``OPENAI_API_KEY``GEMINI_API_KEY`。更多配置项参考 [settings.example.jsonc](settings.example.jsonc)
7491

7592
## 使用
@@ -103,8 +120,8 @@ codebot -policy-profile strict
103120

104121
## 环境要求
105122

106-
- Go 1.25+
107123
- 至少一个 Provider 的 API Key
124+
- Go 1.25+(仅通过 `go install` 或源码构建时需要)
108125

109126
## 许可证
110127

go.mod

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ require (
88
github.com/charmbracelet/bubbletea v1.3.10
99
github.com/charmbracelet/glamour v0.10.0
1010
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
11-
github.com/modelcontextprotocol/go-sdk v1.3.1
11+
github.com/modelcontextprotocol/go-sdk v1.4.0
1212
github.com/muesli/reflow v0.3.0
13-
github.com/voocel/agentcore v1.5.0
13+
github.com/voocel/agentcore v1.5.1
1414
)
1515

1616
require (
@@ -40,20 +40,15 @@ require (
4040
github.com/rivo/uniseg v0.4.7 // indirect
4141
github.com/segmentio/asm v1.1.3 // indirect
4242
github.com/segmentio/encoding v0.5.3 // indirect
43-
github.com/voocel/litellm v1.5.8 // indirect
43+
github.com/voocel/litellm v1.6.0 // indirect
4444
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
4545
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
4646
github.com/yuin/goldmark v1.7.13 // indirect
4747
github.com/yuin/goldmark-emoji v1.0.5 // indirect
4848
golang.org/x/image v0.36.0 // indirect
4949
golang.org/x/net v0.47.0 // indirect
50-
golang.org/x/oauth2 v0.30.0 // indirect
51-
golang.org/x/sys v0.38.0 // indirect
50+
golang.org/x/oauth2 v0.34.0 // indirect
51+
golang.org/x/sys v0.40.0 // indirect
5252
golang.org/x/term v0.37.0 // indirect
5353
golang.org/x/text v0.34.0 // indirect
5454
)
55-
56-
replace (
57-
github.com/voocel/agentcore => ../agentcore
58-
github.com/voocel/litellm => ../litellm
59-
)

go.sum

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK
4444
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
4545
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
4646
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
47-
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
48-
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
47+
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
48+
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
4949
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
5050
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5151
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
@@ -65,8 +65,8 @@ github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byF
6565
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
6666
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
6767
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
68-
github.com/modelcontextprotocol/go-sdk v1.3.1 h1:TfqtNKOIWN4Z1oqmPAiWDC2Jq7K9OdJaooe0teoXASI=
69-
github.com/modelcontextprotocol/go-sdk v1.3.1/go.mod h1:DgVX498dMD8UJlseK1S5i1T4tFz2fkBk4xogC3D15nw=
68+
github.com/modelcontextprotocol/go-sdk v1.4.0 h1:u0kr8lbJc1oBcawK7Df+/ajNMpIDFE41OEPxdeTLOn8=
69+
github.com/modelcontextprotocol/go-sdk v1.4.0/go.mod h1:Nxc2n+n/GdCebUaqCOhTetptS17SXXNu9IfNTaLDi1E=
7070
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
7171
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
7272
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
@@ -83,6 +83,10 @@ github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
8383
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
8484
github.com/segmentio/encoding v0.5.3 h1:OjMgICtcSFuNvQCdwqMCv9Tg7lEOXGwm1J5RPQccx6w=
8585
github.com/segmentio/encoding v0.5.3/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
86+
github.com/voocel/agentcore v1.5.1 h1:gEVpBXZfXH4fkq4fLISo2dYfoQ+SaJ0NsetU/Y0hKrI=
87+
github.com/voocel/agentcore v1.5.1/go.mod h1:fjksENApgfL1QXbcJY8RUUU5Gl03YOYExFAZ040X/zU=
88+
github.com/voocel/litellm v1.6.0 h1:jc0Y7q+cp6QQcag3Mhmd6wMKkfzf7mXjXY0Uvj5VBQw=
89+
github.com/voocel/litellm v1.6.0/go.mod h1:6MBUu3I4DHm7h72Vl+3nqLruSwYmgqMf/I9BGoordJ4=
8690
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
8791
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
8892
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
@@ -98,12 +102,12 @@ golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc=
98102
golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4=
99103
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
100104
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
101-
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
102-
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
105+
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
106+
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
103107
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
104108
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
105-
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
106-
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
109+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
110+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
107111
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
108112
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
109113
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=

scripts/install.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$Repo = "voocel/codebot"
4+
$Binary = "codebot"
5+
6+
# Detect architecture.
7+
$Arch = if ([Environment]::Is64BitOperatingSystem) {
8+
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x86_64" }
9+
} else {
10+
Write-Error "Unsupported: 32-bit OS"; exit 1
11+
}
12+
13+
# Determine version.
14+
$Version = if ($args.Count -gt 0) { $args[0] }
15+
elseif ($env:CODEBOT_VERSION) { $env:CODEBOT_VERSION }
16+
else {
17+
$release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
18+
$release.tag_name
19+
}
20+
21+
if (-not $Version) { Write-Error "Failed to fetch latest version"; exit 1 }
22+
23+
$VersionNum = $Version.TrimStart("v")
24+
$Filename = "${Binary}_${VersionNum}_Windows_${Arch}.zip"
25+
$Url = "https://github.com/$Repo/releases/download/$Version/$Filename"
26+
27+
Write-Host "Downloading $Binary $Version (Windows/$Arch)..."
28+
$TmpDir = Join-Path $env:TEMP "codebot-install"
29+
New-Item -ItemType Directory -Force -Path $TmpDir | Out-Null
30+
31+
try {
32+
Invoke-WebRequest -Uri $Url -OutFile "$TmpDir\$Filename"
33+
Expand-Archive -Path "$TmpDir\$Filename" -DestinationPath $TmpDir -Force
34+
35+
# Install to user-local bin directory.
36+
$InstallDir = Join-Path $env:LOCALAPPDATA "codebot"
37+
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
38+
Move-Item -Force "$TmpDir\$Binary.exe" "$InstallDir\$Binary.exe"
39+
40+
# Add to PATH if not already present.
41+
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
42+
if ($UserPath -notlike "*$InstallDir*") {
43+
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
44+
Write-Host "Added $InstallDir to user PATH (restart terminal to take effect)"
45+
}
46+
47+
Write-Host "$Binary $Version installed to $InstallDir\$Binary.exe"
48+
} finally {
49+
Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue
50+
}

scripts/install.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
set -e
3+
4+
REPO="voocel/codebot"
5+
BINARY="codebot"
6+
INSTALL_DIR="/usr/local/bin"
7+
8+
# Detect OS and architecture.
9+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
10+
ARCH=$(uname -m)
11+
12+
case "$OS" in
13+
linux) OS="Linux" ;;
14+
darwin) OS="Darwin" ;;
15+
*) echo "Unsupported OS: $OS"; exit 1 ;;
16+
esac
17+
18+
case "$ARCH" in
19+
x86_64|amd64) ARCH="x86_64" ;;
20+
arm64|aarch64) ARCH="arm64" ;;
21+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
22+
esac
23+
24+
# Determine version: use argument, env var, or fetch latest.
25+
VERSION="${1:-${CODEBOT_VERSION:-}}"
26+
if [ -z "$VERSION" ]; then
27+
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
28+
if [ -z "$VERSION" ]; then
29+
echo "Failed to fetch latest version"; exit 1
30+
fi
31+
fi
32+
33+
FILENAME="${BINARY}_${VERSION#v}_${OS}_${ARCH}.tar.gz"
34+
URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILENAME}"
35+
36+
echo "Downloading ${BINARY} ${VERSION} (${OS}/${ARCH})..."
37+
TMPDIR=$(mktemp -d)
38+
trap 'rm -rf "$TMPDIR"' EXIT
39+
40+
curl -fsSL "$URL" -o "${TMPDIR}/${FILENAME}"
41+
tar -xzf "${TMPDIR}/${FILENAME}" -C "$TMPDIR"
42+
43+
# Install binary.
44+
if [ -w "$INSTALL_DIR" ]; then
45+
mv "${TMPDIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
46+
else
47+
echo "Need sudo to install to ${INSTALL_DIR}"
48+
sudo mv "${TMPDIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
49+
fi
50+
51+
echo "${BINARY} ${VERSION} installed to ${INSTALL_DIR}/${BINARY}"

0 commit comments

Comments
 (0)