Skip to content

Commit 4e9c0b2

Browse files
author
Sisyphus Agent
committed
docs: 添加安装说明和超时测试脚本
新增文件: - INSTALL_AND_USAGE.md: 完整的安装和使用说明 - test_timeout.sh: 超时配置测试脚本 内容: - 超时问题 3 种解决方案 - 从源码编译安装步骤 - 环境配置指南 - 常用命令速查 - 故障排查流程 - 超时配置参考表
1 parent 5cc4817 commit 4e9c0b2

2 files changed

Lines changed: 276 additions & 0 deletions

File tree

INSTALL_AND_USAGE.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# oho CLI 安装和使用说明
2+
3+
## 🚨 重要:超时问题解决方案
4+
5+
如果你遇到 `context deadline exceeded` 错误,请按以下步骤操作:
6+
7+
### 问题原因
8+
9+
- ✅ 消息已成功提交到服务器
10+
- ✅ AI 正在处理你的请求
11+
- ❌ 但客户端等待超时(默认 5 分钟)
12+
13+
### 解决方案(3 选 1)
14+
15+
#### 方案 1: 增加超时时间(推荐)
16+
17+
```bash
18+
# 设置 10 分钟超时
19+
export OPENCODE_CLIENT_TIMEOUT=600
20+
21+
# 然后发送消息
22+
oho message add -s ses_xxx "复杂任务"
23+
```
24+
25+
#### 方案 2: 不等待响应
26+
27+
```bash
28+
# 发送消息但不等待 AI 响应
29+
oho message add -s ses_xxx "任务" --no-reply
30+
31+
# 稍后查看结果
32+
sleep 30
33+
oho message list -s ses_xxx --limit 3
34+
```
35+
36+
#### 方案 3: 异步提交
37+
38+
```bash
39+
# 异步提交任务(后台处理)
40+
oho message prompt-async -s ses_xxx "任务"
41+
42+
# 检查状态
43+
oho session status
44+
```
45+
46+
---
47+
48+
## 📦 安装说明
49+
50+
### 从源码编译
51+
52+
```bash
53+
cd /path/to/opencode_cli/oho
54+
55+
# 编译并安装到 ~/.local/bin(推荐)
56+
go build -o ~/.local/bin/oho ./cmd
57+
58+
# 或安装到 /usr/local/bin
59+
sudo go build -o /usr/local/bin/oho ./cmd
60+
```
61+
62+
### 验证安装
63+
64+
```bash
65+
# 检查 oho 路径
66+
which oho
67+
68+
# 应该看到:/root/.local/bin/oho 或 /usr/local/bin/oho
69+
70+
# 测试连接
71+
oho config get
72+
```
73+
74+
---
75+
76+
## 🔧 环境配置
77+
78+
### 基本配置
79+
80+
```bash
81+
# 服务器连接
82+
export OPENCODE_SERVER_HOST=127.0.0.1
83+
export OPENCODE_SERVER_PORT=4096
84+
export OPENCODE_SERVER_PASSWORD=your-password
85+
86+
# 超时配置(可选)
87+
export OPENCODE_CLIENT_TIMEOUT=600 # 10 分钟
88+
```
89+
90+
### 永久配置(推荐)
91+
92+
将以下内容添加到 `~/.bashrc``~/.zshrc`
93+
94+
```bash
95+
# OpenCode oho CLI 配置
96+
export OPENCODE_SERVER_HOST=127.0.0.1
97+
export OPENCODE_SERVER_PORT=4096
98+
export OPENCODE_SERVER_PASSWORD=your-password
99+
export OPENCODE_CLIENT_TIMEOUT=600
100+
```
101+
102+
然后执行:
103+
```bash
104+
source ~/.bashrc # 或 source ~/.zshrc
105+
```
106+
107+
---
108+
109+
## 📋 常用命令
110+
111+
### 会话管理
112+
113+
```bash
114+
# 创建会话
115+
oho session create
116+
117+
# 列出会话
118+
oho session list
119+
120+
# 查看会话详情
121+
oho session get -s ses_xxx
122+
123+
# 中止会话
124+
oho session abort -s ses_xxx
125+
```
126+
127+
### 消息管理
128+
129+
```bash
130+
# 发送消息(等待响应)
131+
oho message add -s ses_xxx "你好"
132+
133+
# 发送消息(不等待响应)
134+
oho message add -s ses_xxx "分析项目" --no-reply
135+
136+
# 异步发送消息
137+
oho message prompt-async -s ses_xxx "任务"
138+
139+
# 查看消息历史
140+
oho message list -s ses_xxx
141+
142+
# 带文件附件
143+
oho message add -s ses_xxx "分析这个文件" --file /path/to/file.go
144+
```
145+
146+
### 配置管理
147+
148+
```bash
149+
# 查看配置
150+
oho config get
151+
152+
# 查看可用模型
153+
oho config providers
154+
```
155+
156+
---
157+
158+
## 🐛 故障排查
159+
160+
### 1. 超时错误
161+
162+
```
163+
Error: context deadline exceeded
164+
```
165+
166+
**解决**:
167+
```bash
168+
export OPENCODE_CLIENT_TIMEOUT=600
169+
oho message add -s ses_xxx "任务" --no-reply
170+
```
171+
172+
### 2. 认证失败
173+
174+
```
175+
Error: API 错误 [401]: 认证失败
176+
```
177+
178+
**解决**:
179+
```bash
180+
export OPENCODE_SERVER_PASSWORD=your-password
181+
```
182+
183+
### 3. 连接被拒绝
184+
185+
```
186+
Error: connection refused
187+
```
188+
189+
**解决**:
190+
```bash
191+
# 启动 OpenCode 服务器
192+
opencode serve --port 4096
193+
```
194+
195+
### 4. 运行诊断脚本
196+
197+
```bash
198+
# 完整诊断
199+
export OPENCODE_SERVER_PASSWORD=xxx
200+
./debug_message.sh
201+
202+
# 快速测试
203+
./test_timeout.sh
204+
```
205+
206+
---
207+
208+
## 📊 超时配置参考
209+
210+
| 任务类型 | 推荐超时 | 命令示例 |
211+
|----------|----------|----------|
212+
| 简单问答 | 60 秒 | `export OPENCODE_CLIENT_TIMEOUT=60` |
213+
| 代码分析 | 300 秒(默认) | `export OPENCODE_CLIENT_TIMEOUT=300` |
214+
| 复杂重构 | 600 秒 | `export OPENCODE_CLIENT_TIMEOUT=600` |
215+
| 批量任务 | 900 秒 | `export OPENCODE_CLIENT_TIMEOUT=900` |
216+
217+
---
218+
219+
## 🔗 相关文档
220+
221+
- [问题排查指南](docs/oho-cli-usage/09-troubleshooting.md)
222+
- [快速参考卡片](docs/oho-cli-usage/QUICK_REFERENCE.md)
223+
- [超时修复总结](TIMEOUT_FIX_SUMMARY.md)
224+
- [完整教程](docs/oho-cli-usage/README.md)
225+
226+
---
227+
228+
*最后更新:2026-03-15*

test_timeout.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# 超时配置测试脚本
3+
4+
echo "========================================="
5+
echo "oho 超时配置测试"
6+
echo "========================================="
7+
echo ""
8+
9+
# 测试 1: 默认超时(300 秒)
10+
echo "测试 1: 默认超时配置(300 秒)"
11+
echo "命令:oho session list"
12+
timeout 10 oho session list > /dev/null 2>&1 && echo "✓ 默认超时工作正常" || echo "✗ 默认超时失败"
13+
echo ""
14+
15+
# 测试 2: 自定义超时(10 秒)
16+
echo "测试 2: 自定义超时配置(10 秒)"
17+
echo "命令:OPENCODE_CLIENT_TIMEOUT=10 oho session list"
18+
OPENCODE_CLIENT_TIMEOUT=10 timeout 15 oho session list > /dev/null 2>&1 && echo "✓ 自定义超时工作正常" || echo "✗ 自定义超时失败"
19+
echo ""
20+
21+
# 测试 3: 检查 oho 路径
22+
echo "测试 3: 检查 oho 安装路径"
23+
OHO_PATH=$(which oho)
24+
echo "oho 路径:$OHO_PATH"
25+
if [ "$OHO_PATH" = "/root/.local/bin/oho" ]; then
26+
echo "✓ 使用正确的 oho 版本"
27+
else
28+
echo "⚠ 可能使用了旧版本 oho"
29+
fi
30+
echo ""
31+
32+
# 测试 4: 检查二进制文件大小(新版本应该更大)
33+
echo "测试 4: 检查二进制文件"
34+
if [ -f /root/.local/bin/oho ]; then
35+
SIZE=$(ls -lh /root/.local/bin/oho | awk '{print $5}')
36+
echo "/root/.local/bin/oho 大小:$SIZE"
37+
echo "✓ 主要安装路径正确"
38+
fi
39+
echo ""
40+
41+
echo "========================================="
42+
echo "测试完成"
43+
echo "========================================="
44+
echo ""
45+
echo "建议:"
46+
echo "1. 长时间任务设置:export OPENCODE_CLIENT_TIMEOUT=600"
47+
echo "2. 或使用 --no-reply 不等待响应"
48+
echo "3. 或使用 prompt-async 异步提交"

0 commit comments

Comments
 (0)