# 模块一览

> For the complete documentation index, see [llms.txt](https://simbot.forte.love/llms.txt).

> **TL;DR**
> 本页用于从模块层面快速理解 simbot 的生态： 标准 API、核心实现、公共库、扩展库，以及官方组件库分别负责什么。

## 分层理解

从使用视角看，simbot 的模块通常可以分为下面几层：

1.

`simbot-api`

标准 API。定义 `Application`、`Bot`、`Event`、`Message`、`Plugin`、`Component`、`Resource` 等核心抽象，本身不提供任何具体平台实现。

2.

核心实现库

主要是 `simbot-core` 与 `simbot-core-spring-boot-starter`， 负责把 `simbot-api` 里的抽象真正运行起来。

3.

公共基础库

位于 `simbot-commons/*`，提供 `ID`、时间戳、集合工具、原子类型、 `SuspendReserve`、状态循环等跨模块复用能力。

4.

扩展库与周边库

例如 `simbot-extension-continuous-session`、`simbot-logger`、 `simbot-quantcat-common`、`simbot-test` 等。

5.

组件库

平台能力由组件库提供。自 `5.0` 起，QQ、KOOK、OneBot 组件在主仓库中维护， 随标准库统一版本发布。

## 标准 API 与核心实现

### 标准 API

simbot-api
: 标准库、抽象层。
:
:
:
: * 定义能力接口：`SendSupport`、`ReplySupport`、`DeleteSupport` 等。
:
: * 定义运行时核心：`Application`、`Bot`、`BotManager`、`EventDispatcher`。
:
: * 定义通用模型：`Actor`、`Guild`、`ChatGroup`、`Contact`、`Message`、`Resource`。
:
: * JVM 侧还提供 Java 友好桥接，例如 `launchApplicationAsync(...)`、 `launchApplicationBlocking(...)`、`EventListeners.block(...)` 等。

simbot-core
: 核心实现库。
:
:
:
: * 提供 `SimpleApplication`、`SimpleEventDispatcher` 等基础实现。
:
: * 适合希望直接控制组件安装、Bot 注册和事件监听流程的场景。
:
: * 大多数组件页中的“核心库使用方式”都是以它为基础。

simbot-core-spring-boot-starter
: Spring Boot 3 Starter。
:
:
:
: * 为 Spring Boot 3 / Java 17+ 提供自动装配与注解驱动集成。
:
: * 常用于 `@EnableSimbot`、`@Listener`、Bot 配置文件等开发方式。

simbot-core-spring-boot-starter-common
: Spring Boot Starter 公共支持模块。
:
:
:
: * 承载 `love.forte.simbot.spring.common` 下的通用类型、异常与配置模型。
:
: * 同时被 Starter 3 与 Starter 2 复用。
:
: * 通常由两个 Starter 传递引入，不需要单独依赖。

simbot-core-spring-boot-starter-v2
: Spring Boot 2 Starter。
:
:
:
: * 面向仍停留在 Spring Boot 2.x 的项目。
:
: * 作用与 Starter 3 类似，但依赖的 Spring 生态版本不同。

## 公共基础库

这些模块大多不是“必须手动安装”的使用入口， 但它们构成了文档中很多基础概念的真实来源。

simbot-common-core
: 公共核心工具库。
:
:
:
: * `ID` / `UUID`
:
: * `Async`
:
: * 协程工具与 `Dispatchers`
:
: * `Services`
:
: * 文本、弱引用、属性容器等
:
:
:
: > **Tip:**
: > 自 `5.0` 起还提供 `Dispatchers.IOOrUnconfined`：JVM、Native 使用 `Dispatchers.IO`， 其他平台使用 `Dispatchers.Unconfined`；`runCatchingCancellable(...)` 在捕获其他异常的同时继续传播 `CancellationException`。

simbot-common-time
: 时间戳与时间单位相关支持。
:
:
:
: * `Timestamp`
:
: * 多平台时间实现
:
:
:
: > **Tip:**
: > 自 `5.0` 起，这些时间类型从 `simbot-common-core` 迁入本模块，包名保持不变， 并新增基于 `kotlin.time.Instant` 的 `StandardInstantTimestamp`。参见 [时间戳 Timestamp](basic-timestamp.html)。

simbot-common-collection
: 跨平台集合与并发容器工具。
:
:
:
: * `ConcurrentMap`
:
: * 队列工具
:
: * `Flow` 相关集合辅助

simbot-common-atomic
: 跨平台原子类型支持。

simbot-common-streamable
: `Streamable` 抽象支持。

simbot-common-stage-loop
: 阶段循环状态机支持。

simbot-common-suspend-runner
: Java 友好桥接相关支持。
:
:
:
: * `SuspendReserve`
:
: * `SuspendReserves`
:
: * `@ST` / `@STP`

simbot-common-annotations
: 通用标记性注解。

simbot-common-apidefinition
: 通用 API 定义模型，主要用于 REST API 风格封装。

simbot-common-ktor-inputfile
: 基于 Ktor 的 `InputFile` 上传抽象。

## 扩展与周边

simbot-extension-continuous-session
: 持续会话扩展。
:
:
:
: 适合实现多轮会话、流程式对话、事件上下文延续等场景。

simbot-logger / simbot-logger-slf4j2-impl
: 日志抽象与 JVM 上的 SLF4J 2.x 实现。

simbot-quantcat-common
: 注解驱动监听能力支持。
:
:
:
: `@Listener`、参数绑定、过滤、拦截等开发体验与它密切相关。

simbot-test
: 测试工具模块，提供测试用 Bot、组件、事件和消息实现。

## 官方组件库

以下 QQ、KOOK、OneBot 模块统一使用版本 `5.0.0-Alpha2`。

普通应用开发者最常直接依赖的是它们的 `*-core` 模块。

### QQ 组件

源码目录：[simbot-component-qq](https://github.com/simple-robot/simpler-robot/tree/dev/simbot-component-qq)

simbot-component-qq-common
: > **Tip:**
: > since 5.0
:
:
:
: 共享常量、模型标记与选择加入注解，例如 `QQ`、`ApiModel`、`QGInternalInheritanceApi`。

simbot-component-qq-api
: QQ 机器人官方 API 的底层封装。

simbot-component-qq-stdlib
: 基于 API 的低限度 Bot 实现与事件处理支持。

simbot-component-qq-core
: 真正作为 simbot 组件使用的核心模块，通常也是普通开发者应直接使用的模块。

simbot-component-qq-internal-ed25519
: 内部签名支持模块，一般无需直接使用。

### KOOK 组件

源码目录：[simbot-component-kook](https://github.com/simple-robot/simpler-robot/tree/dev/simbot-component-kook)

simbot-component-kook-api
: KOOK API 封装。

simbot-component-kook-stdlib
: Bot 基础实现与事件处理支持。

simbot-component-kook-core
: 完整的 simbot KOOK 组件模块，普通开发通常直接使用它。

### OneBot 组件

源码目录：[simbot-component-onebot](https://github.com/simple-robot/simpler-robot/tree/dev/simbot-component-onebot)

simbot-component-onebot-common
: OneBot 通用定义。

simbot-component-onebot-v11-common
: OneBot v11 通用模型与共享定义。

simbot-component-onebot-v11-event
: OneBot v11 原始事件数据模型。

simbot-component-onebot-v11-message
: OneBot v11 原始消息段数据模型。

simbot-component-onebot-v11-core
: OneBot v11 的核心组件实现，也是普通开发者最常用的模块。

### Telegram 与 Discord

Telegram 与 Discord 仍处于开发或预告阶段。

## 如何选模块

如果你只是想开发一个应用，通常按下面的顺序选择即可：

1. 先选一个 `Application` 实现：`simbot-core` 或 Spring Boot starter。

2. 再选一个或多个组件核心模块，例如 `simbot-component-kook-core`。

3. 如果需要注解监听体验，再关注 Spring Boot starter 与 `quantcat` 相关章节。

4. 只有在你明确知道自己在做更底层封装时，才需要直接依赖 `api` 或 `stdlib` 模块。

如果你是在开发组件、扩展或公共库， 还会接触 `simbot-gradle-suspendtransforms` 一类构建辅助模块； 这类模块更适合在 [组件库开发](component-dev.html) 与 [编译器插件](component-dev-compiler-plugin.html) 中阅读， 而不是作为普通应用运行时依赖来选择。

