ai-agent-cli
Claude Code¶
Claude Code 是 Anthropic 官方 CLI 级智能体工具。
Claude Code 定位不是聊天,而是在本地代码仓库中执行高权限、可上下文感知的工程任务。Claude Code 除了可以写代码外,还可以调用服务器上的命令工具完成各种复杂的任务。
安装¶
$ module load nodejs/18.19.0
$ npm install @anthropic-ai/claude-code
added 5 packages in 3s
4 packages are looking for funding
run `npm fund` for details
# 设置环境变量,同时写入 ~/.bashrc 中
$ export PATH="/public/home/software/opt/bio/software/nodejs/18.19.0/bin/:$HOME/node_modules/.bin/:$PATH"
$ claude -v
2.1.92 (Claude Code)
配置使用¶
API 配置¶
由于 Anthropic 未对国内提供 Claude 模型服务,因此这里使用国内的模型 API,这里以字节方舟 coding plan 为例,
$ cat ~/.claude/settings.json
{
"env":
{
"ANTHROPIC_AUTH_TOKEN": "<ARK_API_KEY>",
"ANTHROPIC_BASE_URL": "https://ark.cn-beijing.volces.com/api/coding",
"ANTHROPIC_MODEL": "<Model_Name>"
}
}
https://www.volcengine.com/docs/82379/1928262?lang=zh
https://www.runoob.com/ai-agent/claude-code.html
https://www.runoob.com/claude-code/claude-code-tutorial.html
https://code.claude.com/docs/zh-CN/
opencode¶
OpenCode 是一个开源的 AI 编码代理。它提供终端界面、桌面应用和 IDE 扩展等多种使用方式。
官方文档 https://opencode.ai/docs/zh-cn/
安装¶
由于官方的预编译版本依赖高版本的glibc,这里使用 opencode-legacy-glibc,其使用 opencode 官方代码自动构建、可在低版本 glibc 上运行的 opencode。
$ mkdir ~/opt/
$ wget https://github.com/pedropombeiro/opencode-legacy-glibc/releases/download/v1.3.17/opencode-v1.3.17-linux-x64-legacy-glibc.tar.gz
$ tar xf opencode-v1.3.17-linux-x64-legacy-glibc.tar.gz
$ mv opencode/ ~/opt/
# 写入 ~/.bashrc
$ export PATH="$HOME/opt/opencode/bin/:$PATH"
$ opencode -v
1.3.17
配置使用¶
更改主题¶
默认主题(themes)在集群上使用时,输入的文字看不清,打开 opencode 后输入执行 /themes 更改主题,这里搜索使用 tokyonight。
$ opencode
>/themes
免费模型¶
opencode 提供了一些免费的模型可用,打开 opencode 后输入执行 /models 选择模型,标记为 Free 都为官方免费测试模型,这里选择使用 Big Pickle。
$ opencode
>/models
配置模型¶
opencode 支持配置自己的模型,这里以字节方舟 coding plan 为例。
$ mkdir -p ~/.config/opencode/
$ cat ~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"model": "volcengine-plan/ark-code-latest",
"provider": {
"volcengine-plan": {
"npm": "@ai-sdk/openai-compatible",
"name": "Volcano Engine",
"options": {
"baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
"apiKey": "YOUR-API-KEY"
},
"models": {
"ark-code-latest": {
"name": "ark-code-latest",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-code": {
"name": "doubao-seed-code",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-4.7": {
"name": "glm-4.7",
"limit": {
"context": 200000,
"output": 4096
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"deepseek-v3.2": {
"name": "deepseek-v3.2",
"limit": {
"context": 128000,
"output": 4096
}
},
"doubao-seed-2.0-code": {
"name": "doubao-seed-2.0-code",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.0-pro": {
"name": "doubao-seed-2.0-pro",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.0-lite": {
"name": "doubao-seed-2.0-lite",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"minimax-m2.5": {
"name": "minimax-m2.5",
"limit": {
"context": 200000,
"output": 4096
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"kimi-k2.5": {
"name": "kimi-k2.5",
"limit": {
"context": 256000,
"output": 4096
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
}
}
}
}
}
参考:
https://www.runoob.com/ai-agent/opencode-coding-agent.html
本文阅读量 次本站总访问量 次