|
1 | | -# AstrBot Development Instructions |
2 | | - |
3 | | -AstrBot is a multi-platform LLM chatbot and development framework written in Python with a Vue.js dashboard. It supports multiple messaging platforms (QQ, Telegram, Discord, etc.) and various LLM providers (OpenAI, Anthropic, Google Gemini, etc.). |
4 | | - |
5 | | -Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. |
6 | | - |
7 | | -## Working Effectively |
8 | | - |
9 | | -### Bootstrap and Install Dependencies |
10 | | -- **Python 3.10+ required** - Check `.python-version` file |
11 | | -- Install UV package manager: `pip install uv` |
12 | | -- Install project dependencies: `uv sync` -- takes 6-7 minutes. NEVER CANCEL. Set timeout to 10+ minutes. |
13 | | -- Create required directories: `mkdir -p data/plugins data/config data/temp` |
14 | | - |
15 | | -### Running the Application |
16 | | -- Run main application: `uv run main.py` -- starts in ~3 seconds |
17 | | -- Application creates WebUI on http://localhost:6185 (default credentials: `astrbot`/`astrbot`) |
18 | | -- Application loads plugins automatically from `packages/` and `data/plugins/` directories |
19 | | - |
20 | | -### Dashboard Build (Vue.js/Node.js) |
21 | | -- **Prerequisites**: Node.js 20+ and npm 10+ required |
22 | | -- Navigate to dashboard: `cd dashboard` |
23 | | -- Install dashboard dependencies: `npm install` -- takes 2-3 minutes. NEVER CANCEL. Set timeout to 5+ minutes. |
24 | | -- Build dashboard: `npm run build` -- takes 25-30 seconds. NEVER CANCEL. |
25 | | -- Dashboard creates optimized production build in `dashboard/dist/` |
26 | | - |
27 | | -### Testing |
28 | | -- Do not generate test files for now. |
29 | | - |
30 | | -### Code Quality and Linting |
31 | | -- Install ruff linter: `uv add --dev ruff` |
32 | | -- Check code style: `uv run ruff check .` -- takes <1 second |
33 | | -- Check formatting: `uv run ruff format --check .` -- takes <1 second |
34 | | -- Fix formatting: `uv run ruff format .` |
35 | | -- **ALWAYS** run `uv run ruff check .` and `uv run ruff format .` before committing changes |
36 | | - |
37 | | -### Plugin Development |
38 | | -- Plugins load from `packages/` (built-in) and `data/plugins/` (user-installed) |
39 | | -- Plugin system supports function tools and message handlers |
40 | | -- Key plugins: python_interpreter, web_searcher, astrbot, reminder, session_controller |
41 | | - |
42 | | -### Common Issues and Workarounds |
43 | | -- **Dashboard download fails**: Known issue with "division by zero" error - application still works |
44 | | -- **Import errors in tests**: Ensure `uv run` is used to run tests in proper environment |
45 | | -=- **Build timeouts**: Always set appropriate timeouts (10+ minutes for uv sync, 5+ minutes for npm install) |
46 | | - |
47 | | -## CI/CD Integration |
48 | | -- GitHub Actions workflows in `.github/workflows/` |
49 | | -- Docker builds supported via `Dockerfile` |
50 | | -- Pre-commit hooks enforce ruff formatting and linting |
51 | | - |
52 | | -## Docker Support |
53 | | -- Primary deployment method: `docker run soulter/astrbot:latest` |
54 | | -- Compose file available: `compose.yml` |
55 | | -- Exposes ports: 6185 (WebUI), 6195 (WeChat), 6199 (QQ), etc. |
56 | | -- Volume mount required: `./data:/AstrBot/data` |
57 | | - |
58 | | -## Multi-language Support |
59 | | -- Documentation in Chinese (README.md), English (README_en.md), Japanese (README_ja.md) |
60 | | -- UI supports internationalization |
61 | | -- Default language is Chinese |
62 | | - |
63 | | -Remember: This is a production chatbot framework with real users. Always test thoroughly and ensure changes don't break existing functionality. |
| 1 | +# AstrBot 开发指南 |
| 2 | + |
| 3 | +AstrBot 是一个使用 Python 编写、配备 Vue.js 仪表盘的多平台 LLM 聊天机器人开发框架。它支持多个消息平台(QQ、Telegram、Discord 等)和多种 LLM 提供商(OpenAI、Anthropic、Google Gemini 等)。 |
| 4 | + |
| 5 | +始终优先参考这些指南,仅在遇到与此处信息不符的意外情况时才回退到搜索或 bash 命令。 |
| 6 | + |
| 7 | +## 高效工作 |
| 8 | + |
| 9 | +### 引导和安装依赖 |
| 10 | +- **需要 Python 3.10+** - 检查 `.python-version` 文件 |
| 11 | +- 安装 UV 包管理器:`pip install uv` |
| 12 | +- 安装项目依赖:`uv sync` -- 很快几分钟。绝不要取消。设置超时时间为 10+ 分钟。 |
| 13 | +- 创建必需的目录:`mkdir -p data/plugins data/config data/temp` |
| 14 | + |
| 15 | +### 运行应用程序 |
| 16 | +- 运行主应用程序:`uv run main.py` -- 约 3 秒启动 |
| 17 | +- 应用程序在 http://localhost:6185 创建 WebUI(默认凭据:`astrbot`/`astrbot`) |
| 18 | +- 应用程序自动从 `packages/` 和 `data/plugins/` 目录加载插件 |
| 19 | + |
| 20 | +### 仪表盘构建(Vue.js/Node.js) |
| 21 | +- **前置要求**:需要 Node.js 20+ 和 npm 10+ |
| 22 | +- 导航到仪表盘:`cd dashboard` |
| 23 | +- 安装仪表盘依赖:`npm install` -- 需要 2-3 分钟。绝不要取消。设置超时时间为 5+ 分钟。 |
| 24 | +- 构建仪表盘:`npm run build` -- 需要 25-30 秒。绝不要取消。 |
| 25 | +- 仪表盘在 `dashboard/dist/` 创建优化的生产构建 |
| 26 | + |
| 27 | +### 测试 |
| 28 | +- 暂时不要生成测试文件。 |
| 29 | + |
| 30 | +### 代码质量和检查 |
| 31 | +- 安装 ruff 检查器:`uv add --dev ruff` |
| 32 | +- 检查代码风格:`uv run ruff check .` -- 耗时 <1 秒 |
| 33 | +- 检查格式:`uv run ruff format --check .` -- 耗时 <1 秒 |
| 34 | +- 修复格式:`uv run ruff format .` |
| 35 | +- **始终**在提交更改前运行 `uv run ruff check .` 和 `uv run ruff format .` |
| 36 | + |
| 37 | +### 插件开发 |
| 38 | +- 插件从 `packages/`(内置)和 `data/plugins/`(用户安装)加载 |
| 39 | +- 插件系统支持函数工具和消息处理器 |
| 40 | +- 关键插件:python_interpreter、web_searcher、astrbot、reminder、session_controller |
| 41 | + |
| 42 | +### 常见问题和解决方法 |
| 43 | +- **仪表盘下载失败**:已知的"除以零"错误问题 - 应用程序仍可正常工作 |
| 44 | +- **测试中的导入错误**:确保使用 `uv run` 在适当的环境中运行测试 |
| 45 | +- **构建超时**:始终设置适当的超时时间(uv sync 为 10+ 分钟,npm install 为 5+ 分钟) |
| 46 | + |
| 47 | +## CI/CD 集成 |
| 48 | +- GitHub Actions 工作流在 `.github/workflows/` 中 |
| 49 | +- 通过 `Dockerfile` 支持 Docker 构建 |
| 50 | +- Pre-commit 钩子强制执行 ruff 格式化和检查 |
| 51 | + |
| 52 | +## Docker 支持 |
| 53 | +- 主要部署方法:`docker run soulter/astrbot:latest` |
| 54 | +- 可用的 Compose 文件:`compose.yml` |
| 55 | +- 暴露端口:6185(WebUI)、6195(WeChat)、6199(QQ)等 |
| 56 | +- 需要挂载卷:`./data:/AstrBot/data` |
| 57 | + |
| 58 | +## 多语言支持 |
| 59 | +- 文档包括中文(README.md)、英文(README_en.md)、日文(README_ja.md) |
| 60 | +- UI 支持国际化 |
| 61 | +- 默认语言为中文 |
| 62 | + |
| 63 | +请记住:这是一个有真实用户的生产聊天机器人框架。始终进行彻底测试,确保更改不会破坏现有功能。 |
0 commit comments