|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file is for guiding code agents (like Claude Code, GitHub Copilot, OpenAI Codex, etc.) to work in LangBot project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +LangBot is a open-source LLM native instant messaging bot development platform, aiming to provide an out-of-the-box IM robot development experience, with Agent, RAG, MCP and other LLM application functions, supporting global instant messaging platforms, and providing rich API interfaces, supporting custom development. |
| 8 | + |
| 9 | +LangBot has a comprehensive frontend, all operations can be performed through the frontend. The project splited into these major parts: |
| 10 | + |
| 11 | +- `./pkg`: The core python package of the project backend. |
| 12 | + - `./pkg/platform`: The platform module of the project, containing the logic of message platform adapters, bot managers, message session managers, etc. |
| 13 | + - `./pkg/provider`: The provider module of the project, containing the logic of LLM providers, tool providers, etc. |
| 14 | + - `./pkg/pipeline`: The pipeline module of the project, containing the logic of pipelines, stages, query pool, etc. |
| 15 | + - `./pkg/api`: The api module of the project, containing the http api controllers and services. |
| 16 | + - `./pkg/plugin`: LangBot bridge for connecting with plugin system. |
| 17 | +- `./libs`: Some SDKs we previously developed for the project, such as `qq_official_api`, `wecom_api`, etc. |
| 18 | +- `./templates`: Templates of config files, components, etc. |
| 19 | +- `./web`: Frontend codebase, built with Next.js + **shadcn** + **Tailwind CSS**. |
| 20 | +- `./docker`: docker-compose deployment files. |
| 21 | + |
| 22 | +## Backend Development |
| 23 | + |
| 24 | +We use `uv` to manage dependencies. |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install uv |
| 28 | +uv sync --dev |
| 29 | +``` |
| 30 | + |
| 31 | +Start the backend and run the project in development mode. |
| 32 | + |
| 33 | +```bash |
| 34 | +uv run main.py |
| 35 | +``` |
| 36 | + |
| 37 | +Then you can access the project at `http://127.0.0.1:5300`. |
| 38 | + |
| 39 | +## Frontend Development |
| 40 | + |
| 41 | +We use `pnpm` to manage dependencies. |
| 42 | + |
| 43 | +```bash |
| 44 | +cd web |
| 45 | +cp .env.example .env |
| 46 | +pnpm install |
| 47 | +pnpm dev |
| 48 | +``` |
| 49 | + |
| 50 | +Then you can access the project at `http://127.0.0.1:3000`. |
| 51 | + |
| 52 | +## Plugin System Architecture |
| 53 | + |
| 54 | +LangBot is composed of various internal components such as Large Language Model tools, commands, messaging platform adapters, LLM requesters, and more. To meet extensibility and flexibility requirements, we have implemented a production-grade plugin system. |
| 55 | + |
| 56 | +Each plugin runs in an independent process, managed uniformly by the Plugin Runtime. It has two operating modes: `stdio` and `websocket`. When LangBot is started directly by users (not running in a container), it uses `stdio` mode, which is common for personal users or lightweight environments. When LangBot runs in a container, it uses `websocket` mode, designed specifically for production environments. |
| 57 | + |
| 58 | +Plugin Runtime automatically starts each installed plugin and interacts through stdio. In plugin development scenarios, developers can use the lbp command-line tool to start plugins and connect to the running Runtime via WebSocket for debugging. |
| 59 | + |
| 60 | +> Plugin SDK, CLI, Runtime, and entities definitions shared between LangBot and plugins are contained in the [`langbot-plugin-sdk`](https://github.com/langbot-app/langbot-plugin-sdk) repository. |
| 61 | +
|
| 62 | +## Some Development Tips and Standards |
| 63 | + |
| 64 | +- LangBot is a global project, any comments in code should be in English, and user experience should be considered in all aspects. |
| 65 | +- Thus you should consider the i18n support in all aspects. |
| 66 | +- LangBot is widely adopted in both toC and toB scenarios, so you should consider the compatibility and security in all aspects. |
| 67 | + |
| 68 | +## Some Principles |
| 69 | + |
| 70 | +- Keep it simple, stupid. |
| 71 | +- Entities should not be multiplied unnecessarily |
| 72 | +- 八荣八耻 |
| 73 | + |
| 74 | + 以瞎猜接口为耻,以认真查询为荣。 |
| 75 | + 以模糊执行为耻,以寻求确认为荣。 |
| 76 | + 以臆想业务为耻,以人类确认为荣。 |
| 77 | + 以创造接口为耻,以复用现有为荣。 |
| 78 | + 以跳过验证为耻,以主动测试为荣。 |
| 79 | + 以破坏架构为耻,以遵循规范为荣。 |
| 80 | + 以假装理解为耻,以诚实无知为荣。 |
| 81 | + 以盲目修改为耻,以谨慎重构为荣。 |
0 commit comments