Skip to content

Commit baa2693

Browse files
committed
docs(readme): add uninstall instructions and multi-provider configuration details
Added detailed uninstallation guide for all platforms and updated configuration documentation to support multiple AI providers (OpenAI, Anthropic). Also included provider-specific environment variable examples and CLI usage with --provider flag.
1 parent 09fa577 commit baa2693

File tree

3 files changed

+173
-21
lines changed

3 files changed

+173
-21
lines changed

README.md

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ After installation, restart your terminal and run:
2525
tricode --help
2626
```
2727

28+
### Uninstall
29+
30+
Quick uninstall:
31+
32+
- Linux/macOS:
33+
```bash
34+
curl -sSL https://raw.githubusercontent.com/Trirrin/Tricode-cli/main/uninstall_tricode.sh | bash
35+
```
36+
37+
- Windows (PowerShell):
38+
```powershell
39+
irm https://raw.githubusercontent.com/Trirrin/Tricode-cli/main/uninstall_tricode.ps1 | iex
40+
```
41+
42+
Manual removal:
43+
- Linux/macOS: delete `~/.local/bin/tricode` (or wherever you put it) and remove any custom PATH entry you added.
44+
- Windows: delete `%LOCALAPPDATA%\Tricode\tricode.exe` and remove `%LOCALAPPDATA%\Tricode` from your User PATH via Environment Variables if still present.
45+
2846
### Update
2947

3048
Keep your `tricode` up to date with the latest release:
@@ -108,39 +126,66 @@ nano ~/.tricode/settings.json
108126

109127
Configuration is stored in `~/.tricode/settings.json`.
110128

111-
On first run, a default config file will be created at `~/.tricode/settings.json`. Edit it to add your settings:
129+
On first run, a default config file will be created at `~/.tricode/settings.json`. Edit it to add your settings. The config is provider-based and supports multiple backends (e.g., OpenAI, Anthropic):
112130

113131
```bash
114132
nano ~/.tricode/settings.json
115133
```
116134

117135
```json
118136
{
119-
"openai_api_key": "sk-your-api-key-here",
120-
"openai_base_url": "https://api.openai.com/v1",
121-
"openai_model": "gpt-4o-mini"
137+
"default_provider": "openai",
138+
"providers": {
139+
"openai": {
140+
"api_key": "sk-your-api-key-here",
141+
"base_url": "https://api.openai.com/v1",
142+
"provider": "openai",
143+
"model": "gpt-4o-mini"
144+
},
145+
"anthropic": {
146+
"api_key": "",
147+
"base_url": "https://api.anthropic.com/v1",
148+
"provider": "anthropic",
149+
"model": "claude-3-5-sonnet-20241022"
150+
}
151+
}
122152
}
123153
```
124154

125155
### Configuration Options
126156

127-
- `openai_api_key`: Your OpenAI API key (required)
128-
- `openai_base_url`: Custom API endpoint (optional, defaults to OpenAI's official API)
129-
- `openai_model`: Model to use (optional, defaults to gpt-4o-mini)
157+
- `default_provider`: Which provider to use by default (e.g., `openai`, `anthropic`)
158+
- `providers.openai.api_key`: Your OpenAI API key (required for OpenAI)
159+
- `providers.openai.base_url`: API base URL (optional)
160+
- `providers.openai.model`: Model name (defaults to `gpt-4o-mini`)
161+
- `providers.anthropic.api_key`: Your Anthropic API key (required for Anthropic)
162+
- `providers.anthropic.base_url`: API base URL (optional)
163+
- `providers.anthropic.model`: Model name (e.g., `claude-3-5-sonnet-20241022`)
130164

131165
### Environment Variable Override
132166

133-
All configuration options can be overridden via environment variables, which take precedence over `settings.json`.
167+
Environment variables take precedence over `settings.json`.
168+
169+
Two levels are supported:
134170

135-
Environment variable naming: `TRICODE_` + UPPERCASE config key
171+
1) Global keys (rarely needed): `TRICODE_` + UPPERCASE of top-level key
136172

173+
2) Provider-specific keys (recommended): `TRICODE_{PROVIDER}_{KEY}`
174+
175+
Examples:
137176
```bash
177+
# OpenAI
138178
export TRICODE_OPENAI_API_KEY="sk-your-api-key"
139179
export TRICODE_OPENAI_BASE_URL="https://api.openai.com/v1"
140-
export TRICODE_OPENAI_MODEL="gpt-4o"
180+
export TRICODE_OPENAI_MODEL="gpt-4o-mini"
181+
182+
# Anthropic
183+
export TRICODE_ANTHROPIC_API_KEY="ak-your-api-key"
184+
export TRICODE_ANTHROPIC_BASE_URL="https://api.anthropic.com/v1"
185+
export TRICODE_ANTHROPIC_MODEL="claude-3-5-sonnet-20241022"
141186
```
142187

143-
Priority: **Environment Variables > settings.json > Defaults**
188+
Priority: Environment Variables > settings.json > Defaults
144189

145190
## Usage
146191

@@ -171,6 +216,9 @@ Features:
171216
# Start TUI with restricted tools
172217
./tricode.py --tui --tools "read_file,search_context"
173218

219+
# Choose provider explicitly
220+
./tricode.py --tui --provider anthropic
221+
174222
# Resume a session in TUI mode
175223
./tricode.py --tui --resume abc123
176224
```
@@ -199,6 +247,7 @@ Features:
199247
- Code generation: `--tools "read_file,create_file,edit_file"`
200248
- Command execution: `--tools "run_command,read_file"`
201249
- `--override-system-prompt`: Replace default system prompt with AGENTS.md content
250+
- `--provider <NAME>`: Select provider for this run (overrides `default_provider`)
202251
- `-r, --resume <SESSION_ID>`: Resume a previous conversation session
203252
- `-l, --list-conversations`: List all available conversation sessions
204253

README_CN.md

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ irm https://raw.githubusercontent.com/Trirrin/Tricode-cli/main/install_tricode.p
2525
tricode --help
2626
```
2727

28+
### 卸载
29+
30+
一键卸载:
31+
32+
- Linux/macOS:
33+
```bash
34+
curl -sSL https://raw.githubusercontent.com/Trirrin/Tricode-cli/main/uninstall_tricode.sh | bash
35+
```
36+
37+
- Windows(PowerShell):
38+
```powershell
39+
irm https://raw.githubusercontent.com/Trirrin/Tricode-cli/main/uninstall_tricode.ps1 | iex
40+
```
41+
42+
手动卸载:
43+
- Linux/macOS:删除 `~/.local/bin/tricode`(或你放置二进制的位置),并从 PATH 中移除你手动添加的目录。
44+
- Windows:删除 `%LOCALAPPDATA%\Tricode\tricode.exe`,必要时在“环境变量”中从用户 PATH 移除 `%LOCALAPPDATA%\Tricode`
45+
2846
### 支持的平台
2947

3048
- **Linux**: x86_64, ARM64
@@ -94,39 +112,66 @@ nano ~/.tricode/settings.json
94112

95113
配置保存在 `~/.tricode/settings.json`
96114

97-
首次运行时,默认配置文件会生成在 `~/.tricode/settings.json`。你可以通过以下命令编辑它
115+
首次运行时,会在 `~/.tricode/settings.json` 生成默认配置。配置采用“提供商”结构,支持多后端(如 OpenAI、Anthropic)
98116

99117
```bash
100118
nano ~/.tricode/settings.json
101119
```
102120

103121
```json
104122
{
105-
"openai_api_key": "sk-your-api-key-here",
106-
"openai_base_url": "https://api.openai.com/v1",
107-
"openai_model": "gpt-4o-mini"
123+
"default_provider": "openai",
124+
"providers": {
125+
"openai": {
126+
"api_key": "sk-your-api-key-here",
127+
"base_url": "https://api.openai.com/v1",
128+
"provider": "openai",
129+
"model": "gpt-4o-mini"
130+
},
131+
"anthropic": {
132+
"api_key": "",
133+
"base_url": "https://api.anthropic.com/v1",
134+
"provider": "anthropic",
135+
"model": "claude-3-5-sonnet-20241022"
136+
}
137+
}
108138
}
109139
```
110140

111141
### 配置选项
112142

113-
- `openai_api_key`:你的 OpenAI API 密钥(必填)
114-
- `openai_base_url`:自定义 API 端点(可选,默认为 OpenAI 官方 API)
115-
- `openai_model`:所使用的模型(可选,默认为 gpt-4o-mini)
143+
- `default_provider`:默认使用的提供商(如 `openai``anthropic`
144+
- `providers.openai.api_key`:OpenAI 的 API 密钥(使用 OpenAI 时必填)
145+
- `providers.openai.base_url`:API 基地址(可选)
146+
- `providers.openai.model`:模型名称(默认 `gpt-4o-mini`
147+
- `providers.anthropic.api_key`:Anthropic 的 API 密钥(使用 Anthropic 时必填)
148+
- `providers.anthropic.base_url`:API 基地址(可选)
149+
- `providers.anthropic.model`:模型名称(如 `claude-3-5-sonnet-20241022`
116150

117151
### 环境变量覆盖
118152

119153
所有配置项都可以通过环境变量覆盖,环境变量优先级高于 `settings.json`
120154

121-
环境变量命名规则:`TRICODE_` + 大写配置项名
155+
支持两级覆盖:
156+
157+
1)全局顶层(较少使用):`TRICODE_` + 顶层键大写
122158

159+
2)按提供商(推荐):`TRICODE_{PROVIDER}_{KEY}`
160+
161+
示例:
123162
```bash
163+
# OpenAI
124164
export TRICODE_OPENAI_API_KEY="sk-your-api-key"
125165
export TRICODE_OPENAI_BASE_URL="https://api.openai.com/v1"
126-
export TRICODE_OPENAI_MODEL="gpt-4o"
166+
export TRICODE_OPENAI_MODEL="gpt-4o-mini"
167+
168+
# Anthropic
169+
export TRICODE_ANTHROPIC_API_KEY="ak-your-api-key"
170+
export TRICODE_ANTHROPIC_BASE_URL="https://api.anthropic.com/v1"
171+
export TRICODE_ANTHROPIC_MODEL="claude-3-5-sonnet-20241022"
127172
```
128173

129-
优先级:**环境变量 > settings.json > 默认值**
174+
优先级:环境变量 > settings.json > 默认值
130175

131176
## 使用方法
132177

@@ -157,6 +202,9 @@ export TRICODE_OPENAI_MODEL="gpt-4o"
157202
# 使用受限工具启动 TUI
158203
./tricode.py --tui --tools "read_file,search_context"
159204

205+
# 指定本次使用的提供商
206+
./tricode.py --tui --provider anthropic
207+
160208
# 在 TUI 模式下恢复会话
161209
./tricode.py --tui --resume abc123
162210
```
@@ -185,6 +233,7 @@ export TRICODE_OPENAI_MODEL="gpt-4o"
185233
- 代码生成:`--tools "read_file,create_file,edit_file"`
186234
- 命令执行:`--tools "run_command,read_file"`
187235
- `--override-system-prompt`:用 AGENTS.md 内容替换默认系统提示词
236+
- `--provider <NAME>`:选择本次运行的提供商(覆盖 `default_provider`
188237
- `-r, --resume <SESSION_ID>`:恢复之前的对话会话
189238
- `-l, --list-conversations`:列出所有可用的对话会话
190239

uninstall_tricode.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
# Tricode-cli Uninstaller for Linux/macOS
3+
# Safely removes the installed binary and PATH modifications made by install_tricode.sh
4+
5+
set -u
6+
7+
REPO="Trirrin/Tricode-cli"
8+
INSTALL_DIR="$HOME/.local/bin"
9+
BIN_PATH="$INSTALL_DIR/tricode"
10+
11+
info() { printf '%s\n' "$1"; }
12+
warn() { printf '%s\n' "$1" >&2; }
13+
error_exit() { printf '\n[ERROR] %s\n' "$1" >&2; exit "${2:-1}"; }
14+
15+
info "Uninstalling Tricode-cli..."
16+
17+
# 1) Remove binary
18+
if [ -f "$BIN_PATH" ]; then
19+
rm -f "$BIN_PATH" || error_exit "Failed to remove $BIN_PATH" 1
20+
info "Removed binary: $BIN_PATH"
21+
else
22+
info "Binary not found at: $BIN_PATH (already removed)"
23+
fi
24+
25+
# 2) Remove PATH modification from common shell profiles (precise, non-destructive)
26+
cleanup_profile() {
27+
local file="$1"
28+
[ -f "$file" ] || return 0
29+
local tmp="${file}.tricode.tmp"
30+
awk -v install_dir="$INSTALL_DIR" '
31+
BEGIN { skip_next = 0 }
32+
{
33+
if (skip_next == 1) {
34+
# Remove only if this exact next line exports PATH with our install dir
35+
if ($0 ~ "^export[[:space:]]+PATH=.*" install_dir ".*\\$PATH") { skip_next = 0; next }
36+
skip_next = 0
37+
}
38+
if ($0 == "# Added by Tricode-cli installer") { skip_next = 1; next }
39+
print $0
40+
}
41+
' "$file" > "$tmp" && mv "$tmp" "$file"
42+
}
43+
44+
cleanup_profile "$HOME/.bashrc"
45+
cleanup_profile "$HOME/.zshrc"
46+
cleanup_profile "$HOME/.profile"
47+
48+
# 3) Done
49+
printf '\n[Success] Tricode-cli uninstalled.\n'
50+
printf 'Note: Restart your terminal or run: source ~/.bashrc (or ~/.zshrc)\n'
51+
printf '提示: 重启终端或执行: source ~/.bashrc(或 ~/.zshrc)\n'
52+
53+
exit 0
54+

0 commit comments

Comments
 (0)