Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit 2820386

Browse files
author
astrbot-docs-agent[bot]
committed
docs: update for AstrBotDevs/AstrBot#4787
1 parent e9aa976 commit 2820386

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

.vitepress/config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export default defineConfig({
196196
{ text: "插件指南(旧)", link: "/plugin" },
197197
],
198198
},
199+
{ text: "CLI 测试器", link: "/cli-tester" },
199200
{
200201
text: "接入平台适配器",
201202
link: "/plugin-platform-adapter",
@@ -413,6 +414,7 @@ export default defineConfig({
413414
{ text: "Publish Plugin", link: "/plugin-publish" },
414415
],
415416
},
417+
{ text: "CLI Tester", link: "/cli-tester" },
416418
{
417419
text: "Platform Adapter Integration",
418420
link: "/plugin-platform-adapter",

en/dev/cli-tester.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CLI Tester
2+
3+
The CLI Tester is a tool designed specifically for plugin developers to build a fast feedback loop, supporting the "Vibe Coding" development mode.
4+
5+
Traditional plugin development requires: writing code → restarting the bot → logging into an IM platform → sending test messages → checking results → modifying code... This process has a long feedback cycle and can be distracting.
6+
7+
CLI Tester allows you to: **write code → test via command line → see results immediately → modify code...**
8+
9+
## Core Values
10+
11+
-**Instant Feedback**: Test directly from the command line without logging into IM platforms.
12+
- 🔄 **Fast Iteration**: Shorten the feedback loop and improve development efficiency.
13+
- 🎯 **Focused Development**: Focus on plugin logic rather than platform interaction.
14+
- 🧪 **Independent Testing**: Isolated sessions for each request, supporting concurrent testing.
15+
16+
## Enabling CLI Tester
17+
18+
Enable the CLI platform in the management panel, or add the configuration in `data/config/platforms.json`:
19+
20+
```json
21+
{
22+
"type": "cli",
23+
"enable": true,
24+
"mode": "socket",
25+
"socket_path": "/tmp/astrbot.sock"
26+
}
27+
```
28+
29+
> **Note**: CLI Tester is disabled by default. It is recommended to enable it only in development environments.
30+
31+
## Usage
32+
33+
### 1. Basic Testing
34+
35+
You can use the built-in `astrbot-cli` tool to send messages.
36+
37+
```bash
38+
# Test inside the container
39+
docker exec astrbot python3 /AstrBot/astrbot-cli "Hello"
40+
41+
# Test plugin commands
42+
docker exec astrbot python3 /AstrBot/astrbot-cli "/help"
43+
44+
# JSON format output (includes rich media like images)
45+
docker exec astrbot python3 /AstrBot/astrbot-cli -j "/time"
46+
```
47+
48+
### 2. Create a Global Command (Optional)
49+
50+
For convenience, you can create a wrapper script on the host machine:
51+
52+
```bash
53+
# Create wrapper script on host
54+
cat > /usr/local/bin/astrbot-cli << 'EOF'
55+
#!/bin/bash
56+
docker exec astrbot python3 /AstrBot/astrbot-cli "$@"
57+
EOF
58+
59+
chmod +x /usr/local/bin/astrbot-cli
60+
61+
# Use directly
62+
astrbot-cli "Test message"
63+
```
64+
65+
## Core Features
66+
67+
1. **Unix Socket Mode**: Provides synchronous request-response via `/tmp/astrbot.sock`.
68+
2. **Session Isolation**: Supports concurrent testing; each request can have an independent session (requires `use_isolated_sessions` enabled in config).
69+
3. **Rich Media Support**: Automatically handles rich media content like images (Base64 encoded).
70+
4. **Whitelist Exemption**: The CLI platform automatically bypasses whitelist checks for easier local debugging.
71+
72+
## Technical Characteristics
73+
74+
- 📦 **Zero External Dependencies**: Uses only the Python standard library.
75+
- 💾 **Lightweight**: Total size is about 35KB.
76+
- 🏗️ **Unix Philosophy**: Atomic modules, explicit I/O, and pipeline orchestration.

zh/dev/cli-tester.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CLI 测试器 (CLI Tester)
2+
3+
CLI 测试器是一个专为插件开发者设计的工具,旨在构建快速反馈循环,支持 Vibe Coding 开发模式。
4+
5+
传统插件开发流程需要:编写代码 → 重启机器人 → 登录 IM 平台 → 发送测试消息 → 查看结果 → 修改代码... 这个流程反馈周期长,且容易分散注意力。
6+
7+
CLI 测试器允许你:**编写代码 → 命令行测试 → 立即查看结果 → 修改代码...**
8+
9+
## 核心价值
10+
11+
-**即时反馈**:无需登录 IM 平台,命令行直接测试。
12+
- 🔄 **快速迭代**:缩短反馈循环,提升开发效率。
13+
- 🎯 **专注开发**:专注于插件逻辑,而非平台交互。
14+
- 🧪 **独立测试**:每个请求独立会话,支持并发测试。
15+
16+
## 启用 CLI 测试器
17+
18+
在管理面板中启用 CLI 平台,或在 `data/config/platforms.json` 中添加配置:
19+
20+
```json
21+
{
22+
"type": "cli",
23+
"enable": true,
24+
"mode": "socket",
25+
"socket_path": "/tmp/astrbot.sock"
26+
}
27+
```
28+
29+
> **注意**:CLI 测试器默认是关闭的,建议仅在开发环境启用。
30+
31+
## 使用方法
32+
33+
### 1. 基础测试
34+
35+
你可以使用内置的 `astrbot-cli` 工具发送消息。
36+
37+
```bash
38+
# 在容器内测试
39+
docker exec astrbot python3 /AstrBot/astrbot-cli "你好"
40+
41+
# 测试插件命令
42+
docker exec astrbot python3 /AstrBot/astrbot-cli "/help"
43+
44+
# JSON 格式输出(包含图片等富媒体)
45+
docker exec astrbot python3 /AstrBot/astrbot-cli -j "/time"
46+
```
47+
48+
### 2. 创建全局命令(可选)
49+
50+
为了方便使用,你可以在宿主机创建一个包装脚本:
51+
52+
```bash
53+
# 在宿主机创建包装脚本
54+
cat > /usr/local/bin/astrbot-cli << 'EOF'
55+
#!/bin/bash
56+
docker exec astrbot python3 /AstrBot/astrbot-cli "$@"
57+
EOF
58+
59+
chmod +x /usr/local/bin/astrbot-cli
60+
61+
# 直接使用
62+
astrbot-cli "测试消息"
63+
```
64+
65+
## 核心功能
66+
67+
1. **Unix Socket 模式**:通过 `/tmp/astrbot.sock` 提供同步请求-响应。
68+
2. **会话隔离**:支持并发测试,每个请求可以拥有独立会话(需在配置中开启 `use_isolated_sessions`)。
69+
3. **富媒体支持**:自动处理图片等富媒体内容(Base64 编码)。
70+
4. **白名单豁免**:CLI 平台自动豁免白名单检查,方便本地调试。
71+
72+
## 技术特点
73+
74+
- 📦 **零外部依赖**:仅使用 Python 标准库。
75+
- 💾 **轻量级**:总计约 35KB。
76+
- 🏗️ **遵循 Unix 哲学**:原子化模块、显式 I/O、管道编排。

0 commit comments

Comments
 (0)