- Add 'config' to known zh/en doc structure differences - Remove trailing whitespace from docs/zh/faq.md - Remove trailing whitespace from docs/en/dev/plugin-platform-adapter.md - Ensure all README files end with newline
2.2 KiB
Setup commands
Core
uv tool install -e . --force
astrbot init
astrbot run # start the bot
astrbot run --backend-only # start the backend only
Exposed an API server on http://localhost:6185 by default.
Dashboard(WebUI)
cd dashboard
bun install # First time only.
bun dev
Runs on http://localhost:3000 by default.
Dev environment tips
-
When modifying the WebUI, be sure to maintain componentization and clean code. Avoid duplicate code.
-
Do not add any report files such as xxx_SUMMARY.md.
-
After finishing, use
ruff format .andruff check .to format and check the code. -
When committing, ensure to use conventional commits messages, such as
feat: add new agent for data analysisorfix: resolve bug in provider manager. -
Use English for all new comments.
-
For path handling, use
pathlib.Pathinstead of string paths, and useastrbot.core.utils.path_utilsto get the AstrBot data and temp directory. -
Use Python 3.12+ type hinting syntax (e.g.,
list[str]overList[str],int | NoneoverOptional[int]). Avoid usingAnyandcast()- use proper TypedDict, dataclass, or Protocol instead. When encountering dict access issues (e.g.,msg.get("key")where ty infers wrong type), define a TypedDict withtotal=Falseto explicitly declare allowed keys.Good example:
class MessageComponent(TypedDict, total=False): type: str text: str path: strBad example (avoid):
msg: Any = something msg = cast(dict, msg) -
When introducing new environment variables:
- Use the
ASTRBOT_prefix for naming (e.g.,ASTRBOT_ENABLE_FEATURE). - Add the variable and description to
.env.example. - Update
astrbot/cli/commands/cmd_run.py:- Add to the module docstring under "Environment Variables Used in Project".
- Add to the
keys_to_printlist in therunfunction for debug output.
- Use the
-
To check all available CLI commands and their usage recursively, run
astrbot help --all. -
uv sync --group dev && uv run pytest --cov=astrbot tests/
PR instructions
- Title format: use conventional commit messages
- Use English to write PR title and descriptions.