mofox-plugin-dev-toolkit 0.2.1__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. mofox_plugin_dev_toolkit-0.2.7/PKG-INFO +570 -0
  2. mofox_plugin_dev_toolkit-0.2.7/README.md +518 -0
  3. mofox_plugin_dev_toolkit-0.2.7/mofox_plugin_dev_toolkit.egg-info/PKG-INFO +570 -0
  4. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mofox_plugin_dev_toolkit.egg-info/SOURCES.txt +1 -0
  5. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mofox_plugin_dev_toolkit.egg-info/requires.txt +1 -0
  6. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/__init__.py +1 -1
  7. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/cli.py +28 -24
  8. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/commands/check.py +91 -13
  9. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/commands/dev.py +4 -8
  10. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/commands/generate.py +134 -71
  11. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/commands/init.py +20 -13
  12. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/dev/bridge_plugin/discovery_server.py +13 -15
  13. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/dev/bridge_plugin/plugin.py +3 -5
  14. mofox_plugin_dev_toolkit-0.2.7/mpdt/utils/code_parser.py +402 -0
  15. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/config_manager.py +46 -46
  16. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/plugin_parser.py +2 -3
  17. mofox_plugin_dev_toolkit-0.2.7/mpdt/validators/auto_fix_validator.py +996 -0
  18. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/base.py +8 -0
  19. mofox_plugin_dev_toolkit-0.2.7/mpdt/validators/component_validator.py +840 -0
  20. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/config_validator.py +18 -72
  21. mofox_plugin_dev_toolkit-0.2.7/mpdt/validators/metadata_validator.py +110 -0
  22. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/style_validator.py +29 -34
  23. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/type_validator.py +0 -2
  24. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/pyproject.toml +2 -1
  25. mofox_plugin_dev_toolkit-0.2.1/PKG-INFO +0 -409
  26. mofox_plugin_dev_toolkit-0.2.1/README.md +0 -358
  27. mofox_plugin_dev_toolkit-0.2.1/mofox_plugin_dev_toolkit.egg-info/PKG-INFO +0 -409
  28. mofox_plugin_dev_toolkit-0.2.1/mpdt/validators/auto_fix_validator.py +0 -182
  29. mofox_plugin_dev_toolkit-0.2.1/mpdt/validators/component_validator.py +0 -415
  30. mofox_plugin_dev_toolkit-0.2.1/mpdt/validators/metadata_validator.py +0 -125
  31. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/LICENSE +0 -0
  32. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/MANIFEST.in +0 -0
  33. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mofox_plugin_dev_toolkit.egg-info/dependency_links.txt +0 -0
  34. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mofox_plugin_dev_toolkit.egg-info/entry_points.txt +0 -0
  35. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mofox_plugin_dev_toolkit.egg-info/top_level.txt +0 -0
  36. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/__main__.py +0 -0
  37. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/commands/__init__.py +0 -0
  38. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/dev/bridge_plugin/__init__.py +0 -0
  39. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/__init__.py +0 -0
  40. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/action_template.py +0 -0
  41. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/adapter_template.py +0 -0
  42. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/chatter_template.py +0 -0
  43. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/event_template.py +0 -0
  44. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/plus_command_template.py +0 -0
  45. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/prompt_template.py +0 -0
  46. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/router_template.py +0 -0
  47. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/templates/tool_template.py +0 -0
  48. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/__init__.py +0 -0
  49. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/color_printer.py +0 -0
  50. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/config_loader.py +0 -0
  51. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/file_ops.py +0 -0
  52. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/license_generator.py +0 -0
  53. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/utils/template_engine.py +0 -0
  54. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/__init__.py +0 -0
  55. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/mpdt/validators/structure_validator.py +0 -0
  56. {mofox_plugin_dev_toolkit-0.2.1 → mofox_plugin_dev_toolkit-0.2.7}/setup.cfg +0 -0
@@ -0,0 +1,570 @@
1
+ Metadata-Version: 2.4
2
+ Name: mofox-plugin-dev-toolkit
3
+ Version: 0.2.7
4
+ Summary: 开发工具集,用于快速创建、开发和测试 MoFox-Bot 插件
5
+ Author-email: MoFox-Studio <mofox.studio@example.com>
6
+ License: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/MoFox-Studio/mofox-plugin-toolkit
8
+ Project-URL: Documentation, https://docs.mofox.studio/mpdt
9
+ Project-URL: Repository, https://github.com/MoFox-Studio/mofox-plugin-toolkit
10
+ Project-URL: Bug Tracker, https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues
11
+ Keywords: mofox,plugin,toolkit,cli,development
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: click>=8.1.7
22
+ Requires-Dist: rich>=13.7.0
23
+ Requires-Dist: questionary>=2.0.1
24
+ Requires-Dist: jinja2>=3.1.2
25
+ Requires-Dist: toml>=0.10.2
26
+ Requires-Dist: tomli>=2.0.1
27
+ Requires-Dist: tomli-w>=1.0.0
28
+ Requires-Dist: pydantic>=2.5.0
29
+ Requires-Dist: watchdog>=3.0.0
30
+ Requires-Dist: websockets>=12.0
31
+ Requires-Dist: libcst>=1.8.6
32
+ Requires-Dist: aiohttp>=3.9.0
33
+ Requires-Dist: uvicorn>=0.24.0
34
+ Requires-Dist: fastapi>=0.104.0
35
+ Requires-Dist: ruff>=0.1.6
36
+ Requires-Dist: mypy>=1.7.0
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=7.4.3; extra == "dev"
39
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
40
+ Requires-Dist: pytest-asyncio>=0.21.1; extra == "dev"
41
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.7.0; extra == "dev"
43
+ Requires-Dist: ruff>=0.1.6; extra == "dev"
44
+ Provides-Extra: check
45
+ Requires-Dist: mypy>=1.7.0; extra == "check"
46
+ Requires-Dist: ruff>=0.1.6; extra == "check"
47
+ Requires-Dist: bandit>=1.7.5; extra == "check"
48
+ Provides-Extra: docs
49
+ Requires-Dist: mkdocs>=1.5.3; extra == "docs"
50
+ Requires-Dist: mkdocs-material>=9.4.0; extra == "docs"
51
+ Dynamic: license-file
52
+
53
+ # MoFox Plugin Dev Toolkit (MPDT)
54
+
55
+ [![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
56
+ [![License](https://img.shields.io/badge/license-GPL--3.0-green.svg)](LICENSE)
57
+ [![Version](https://img.shields.io/badge/version-0.2.1-orange.svg)](https://github.com/MoFox-Studio/mofox-plugin-toolkit)
58
+
59
+ 一个类似于 Vite 的 Python 开发工具,专门为 MoFox-Bot 插件系统设计,提供快速创建、开发、检查和热重载的完整工具链。
60
+
61
+ ## ✨ 特性
62
+
63
+ ### 核心功能
64
+
65
+ - 🚀 **快速初始化** - 一键创建标准化的插件项目结构,支持 6 种模板(basic、action、tool、plus_command、full、adapter)
66
+ - 🎨 **代码生成** - 快速生成 8 种组件类型(Action、Tool、Event、Adapter、Prompt、PlusCommand、Router、Chatter),始终生成异步方法
67
+ - 🔍 **完整的静态检查系统** - 集成 6 层验证体系:
68
+ - ✅ **结构检查** - 验证插件目录结构、必需文件和推荐文件
69
+ - ✅ **元数据检查** - 检查 `__plugin_meta__` 配置的完整性和正确性
70
+ - ✅ **组件检查** - 验证组件注册、命名规范和导入路径
71
+ - ✅ **配置检查** - 检查 `config.toml` 的语法和必需配置
72
+ - ✅ **类型检查** - 使用 mypy 进行严格的类型检查
73
+ - ✅ **代码风格检查** - 使用 ruff 检查代码规范并自动修复
74
+ - 🔥 **热重载开发模式** - 基于 WebSocket 的实时热重载系统:
75
+ - 🔄 文件变化自动检测和重载
76
+ - 📡 通过 WebSocket 与主程序通信
77
+ - 🚦 自动管理插件生命周期
78
+ - 📊 实时显示重载状态和日志
79
+ - 🎯 **Git 集成** - 支持自动初始化 Git 仓库和提取用户信息
80
+ - 🎨 **美观的交互界面** - 基于 Rich 和 Questionary 的现代化命令行体验
81
+ - 📜 **多种许可证** - 支持 GPL-v3.0、MIT、Apache-2.0、BSD-3-Clause
82
+
83
+ ## 📦 安装
84
+
85
+ ```bash
86
+ # 从源码安装
87
+ cd mofox-plugin-toolkit
88
+ pip install -e .
89
+
90
+ # 安装开发依赖
91
+ pip install -e ".[dev]"
92
+ ```
93
+
94
+ ## 🚀 快速开始
95
+
96
+ ### 1. 创建新插件
97
+
98
+ ```bash
99
+ # 交互式创建
100
+ mpdt init
101
+
102
+ # 或直接指定插件名和模板
103
+ mpdt init my_awesome_plugin --template action
104
+
105
+ # 创建带示例和文档的完整插件
106
+ mpdt init my_plugin --template full --with-examples --with-docs
107
+
108
+ # 指定作者和许可证
109
+ mpdt init my_plugin --author "Your Name" --license MIT
110
+ ```
111
+
112
+ 支持的模板类型:
113
+ - `basic` - 基础插件模板(最小化结构)
114
+ - `action` - 包含 Action 组件的模板
115
+ - `tool` - 包含 Tool 组件的模板
116
+ - `plus_command` - 包含 PlusCommand 组件的模板
117
+ - `full` - 完整功能模板(包含多种组件示例)
118
+ - `adapter` - 适配器模板(用于创建平台适配器)
119
+
120
+ ### 2. 生成组件
121
+
122
+ ```bash
123
+ cd my_awesome_plugin
124
+
125
+ # 交互式生成(推荐)- 通过问答选择组件类型和配置
126
+ mpdt generate
127
+
128
+ # 生成 Action 组件
129
+ mpdt generate action SendMessage --description "发送消息"
130
+
131
+ # 生成 Tool 组件
132
+ mpdt generate tool MessageFormatter --description "消息格式化工具"
133
+
134
+ # 生成 PlusCommand 组件(用于 Plus 系统)
135
+ mpdt generate plus-command CustomCommand --description "自定义 Plus 命令"
136
+
137
+ # 生成其他组件
138
+ mpdt generate event MessageReceived --description "消息接收事件处理器"
139
+ mpdt generate adapter CustomAdapter --description "自定义适配器"
140
+ mpdt generate prompt SystemPrompt --description "系统提示词"
141
+ mpdt generate router MessageRouter --description "消息路由器"
142
+ mpdt generate chatter ChatHandler --description "对话处理器"
143
+ ```
144
+
145
+ **支持的组件类型**:
146
+ - `action` - Action 组件(用于执行具体操作)
147
+ - `tool` - Tool 组件(可供 AI 调用的工具)
148
+ - `event` - Event Handler 组件(事件处理器)
149
+ - `adapter` - Adapter 组件(平台适配器)
150
+ - `prompt` - Prompt 组件(提示词模板)
151
+ - `plus-command` - PlusCommand 组件(Plus 系统命令)
152
+ - `router` - Router 组件(路由器)
153
+ - `chatter` - Chatter 组件(对话处理器)
154
+
155
+ **注意**:所有生成的组件方法都是异步的(async),符合 MoFox-Bot 的异步架构。
156
+
157
+ ### 3. 开发模式(热重载)
158
+
159
+ ```bash
160
+ # 启动开发模式(需要先配置 MoFox-Bot 主程序路径)
161
+ mpdt dev
162
+
163
+ # 首次运行会提示配置
164
+ # 之后会自动:
165
+ # 1. 注入开发桥接插件到主程序
166
+ # 2. 启动主程序
167
+ # 3. 建立 WebSocket 连接
168
+ # 4. 监控文件变化
169
+ # 5. 自动热重载插件
170
+
171
+ # 开发模式功能:
172
+ # - 🔄 文件保存后自动重载插件
173
+ # - 📊 实时显示重载状态和耗时
174
+ # - 🚦 自动管理插件生命周期
175
+ # - 📝 实时查看主程序日志
176
+ # - ⚡ 无需手动重启主程序
177
+ ```
178
+
179
+ ### 4. 检查插件
180
+
181
+ ```bash
182
+ # 运行所有检查(包含 6 个检查器)
183
+ mpdt check
184
+
185
+ # 自动修复可修复的问题
186
+ mpdt check --fix
187
+
188
+ # 只显示错误级别的问题
189
+ mpdt check --level error
190
+
191
+ # 生成 Markdown 格式的检查报告
192
+ mpdt check --report markdown --output check_report.md
193
+
194
+ # 跳过特定检查
195
+ mpdt check --no-type # 跳过类型检查
196
+ mpdt check --no-style # 跳过代码风格检查
197
+ mpdt check --no-component # 跳过组件检查
198
+
199
+ # 组合使用
200
+ mpdt check --fix --level warning --report markdown -o report.md
201
+ ```
202
+
203
+ **检查项说明**:
204
+ - **结构检查** (structure) - 验证目录结构、必需文件(`__init__.py`、`plugin.py`、`config/config.toml`)和推荐文件(`README.md`、`pyproject.toml`、`tests/`)
205
+ - **元数据检查** (metadata) - 检查 `__plugin_meta__` 的存在性、类型和必需字段(name、description、usage)
206
+ - **组件检查** (component) - 验证组件注册、命名规范、导入路径和类型正确性
207
+ - **配置检查** (config) - 检查 `config.toml` 的语法、必需配置项和数据类型
208
+ - **类型检查** (type) - 使用 mypy 进行严格的类型检查,确保类型安全
209
+ - **代码风格检查** (style) - 使用 ruff 检查代码规范,支持自动修复格式问题
210
+
211
+ ## 📖 命令参考
212
+
213
+ ### `mpdt init` - 初始化插件
214
+
215
+ 创建新的插件项目,支持多种模板和自动化配置。
216
+
217
+ ```bash
218
+ mpdt init [PLUGIN_NAME] [OPTIONS]
219
+
220
+ 选项:
221
+ -t, --template TEXT 模板类型: basic, action, tool, plus_command, full, adapter
222
+ -a, --author TEXT 作者名称(可从 Git 配置自动获取)
223
+ -l, --license TEXT 开源协议: GPL-v3.0, MIT, Apache-2.0, BSD-3-Clause
224
+ --with-examples 包含示例代码和用法说明
225
+ --with-docs 创建文档目录和基础文档文件
226
+ --init-git 初始化 Git 仓库(默认)
227
+ --no-init-git 不初始化 Git 仓库
228
+ -o, --output PATH 输出目录(默认为当前目录)
229
+
230
+ 示例:
231
+ mpdt init my_plugin # 交互式创建
232
+ mpdt init my_plugin -t action -a "张三" # 指定参数创建
233
+ mpdt init my_plugin -t full --with-examples # 创建完整模板
234
+ ```
235
+
236
+ ### `mpdt generate` - 生成组件
237
+
238
+ 生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
239
+
240
+ ```bash
241
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
242
+
243
+ 组件类型:
244
+ action Action 组件 - 执行具体操作
245
+ tool Tool 组件 - 可供 AI 调用的工具
246
+ event Event Handler 组件 - 事件处理器
247
+ adapter Adapter 组件 - 平台适配器
248
+ prompt Prompt 组件 - 提示词模板
249
+ plus-command PlusCommand 组件 - Plus 系统命令
250
+ router Router 组件 - 路由器
251
+ chatter Chatter 组件 - 对话处理器
252
+
253
+ 选项:
254
+ -d, --description TEXT 组件描述信息
255
+ -o, --output PATH 输出目录(默认自动选择对应组件目录)
256
+ -f, --force 覆盖已存在的文件
257
+
258
+ 示例:
259
+ mpdt generate # 交互式生成
260
+ mpdt generate action SendMsg -d "发送消息" # 命令行生成
261
+ mpdt generate tool Formatter --force # 强制覆盖
262
+ ```
263
+
264
+ **注意**:不提供参数时将进入交互式问答模式,更易于使用。
265
+
266
+ ### `mpdt dev` - 开发模式
267
+
268
+ 启动带热重载的开发模式,实时监控文件变化并自动重载插件。
269
+
270
+ ```bash
271
+ mpdt dev [OPTIONS]
272
+ ```
273
+
274
+ 功能特性:
275
+ - 🔄 自动检测文件变化并热重载
276
+ - 📡 基于 WebSocket 与主程序通信
277
+ - 🚦 自动管理插件生命周期
278
+ - 📊 实时显示重载状态和耗时
279
+ - 📝 显示主程序运行日志
280
+
281
+ 首次运行:
282
+ 首次运行会提示配置 MoFox 主程序路径
283
+ 配置将保存到 ~/.mpdt/config.toml 或者
284
+
285
+ 工作流程:
286
+ 1. 自动注入开发桥接插件到主程序
287
+ 2. 启动主程序并建立连接
288
+ 3. 监控插件目录的文件变化
289
+ 4. 检测到变化时通过 WebSocket 通知主程序重载
290
+ 5. 主程序自动卸载旧版本并加载新版本
291
+
292
+ 示例:
293
+ mpdt dev # 在插件目录中运行
294
+
295
+ ### `mpdt check` - 检查插件
296
+
297
+ 对插件进行全面的静态检查,包括 6 个检查器。
298
+
299
+ ```bash
300
+ mpdt check [PATH] [OPTIONS]
301
+
302
+ 选项:
303
+ -l, --level TEXT 显示问题级别: error, warning, info(默认显示所有)
304
+ --fix 自动修复可修复的问题(主要是代码风格)
305
+ --report TEXT 报告格式: console(默认), markdown
306
+ -o, --output PATH 报告输出路径(仅用于 markdown 格式)
307
+ --no-structure 跳过结构检查
308
+ --no-metadata 跳过元数据检查
309
+ --no-component 跳过组件检查
310
+ --no-config 跳过配置检查
311
+ --no-type 跳过类型检查
312
+ --no-style 跳过代码风格检查
313
+
314
+ 检查器说明:
315
+ structure - 检查目录结构、必需文件和推荐文件
316
+ metadata - 检查 __plugin_meta__ 的完整性
317
+ component - 检查组件注册和命名规范
318
+ config - 检查 config.toml 配置文件
319
+ type - 使用 mypy 进行类型检查
320
+ style - 使用 ruff 进行代码风格检查
321
+
322
+ 示例:
323
+ mpdt check # 运行所有检查
324
+ mpdt check --fix # 自动修复问题
325
+ mpdt check --level error # 只显示错误
326
+ mpdt check --report markdown -o report.md # 生成报告
327
+ mpdt check --no-type --no-style # 跳过耗时检查
328
+ ```
329
+
330
+ ---
331
+
332
+ ## 🏗️ 插件结构
333
+
334
+ MPDT 创建的插件遵循 MoFox-Bot 标准结构:
335
+
336
+ ```
337
+ my_plugin/ # 插件根目录
338
+ ├── __init__.py # ⭐ 插件元数据(必需)
339
+ │ # 必须包含 __plugin_meta__ 变量
340
+ ├── plugin.py # ⭐ 插件主类(必需)
341
+ │ # 继承自 BasePlugin
342
+ ├── config/ # ⭐ 配置目录(必需)
343
+ │ └── config.toml # ⭐ 配置文件(必需)
344
+ ├── components/ # 组件目录(可选但推荐)
345
+ │ ├── actions/ # Action 组件目录
346
+ │ │ └── send_message.py
347
+ │ ├── tools/ # Tool 组件目录
348
+ │ │ └── formatter.py
349
+ │ ├── events/ # Event Handler 目录
350
+ │ ├── adapters/ # Adapter 目录
351
+ │ ├── prompts/ # Prompt 目录
352
+ │ ├── plus_commands/ # PlusCommand 目录
353
+ │ ├── routers/ # Router 目录
354
+ │ └── chatters/ # Chatter 目录
355
+ ├── utils/ # 工具函数目录(可选)
356
+ │ └── helpers.py
357
+ ├── tests/ # 📋 测试目录(推荐)
358
+ │ ├── conftest.py
359
+ │ └── test_plugin.py
360
+ ├── docs/ # 📋 文档目录(推荐)
361
+ │ └── README.md
362
+ ├── pyproject.toml # 📋 项目配置(推荐)
363
+ ├── requirements.txt # 📋 依赖列表(推荐)
364
+ ├── .gitignore # Git 忽略文件
365
+ ├── LICENSE # 开源许可证
366
+ └── README.md # 📋 插件说明(推荐)
367
+ ```
368
+
369
+
370
+ ## 🎯 开发状态
371
+
372
+ ### ✅ 已完成功能(v0.2.1)
373
+
374
+ #### 1. ✅ 插件初始化 (`mpdt init`)
375
+ - 支持 6 种模板类型
376
+ - 交互式问答模式
377
+ - Git 自动初始化和用户信息提取
378
+ - 多种开源协议支持
379
+ - 自动生成标准化项目结构
380
+
381
+ #### 2. ✅ 组件生成 (`mpdt generate`)
382
+ - 支持 8 种组件类型
383
+ - 所有方法自动生成为异步
384
+ - 自动更新插件主类注册代码
385
+ - 交互式和命令行两种模式
386
+ - 组件文件自动放置到正确目录
387
+
388
+ #### 3. ✅ 静态检查系统 (`mpdt check`)
389
+ - **结构验证器** - 目录和文件完整性检查
390
+ - **元数据验证器** - `__plugin_meta__` 验证
391
+ - **组件验证器** - 组件注册和规范检查
392
+ - **配置验证器** - `config.toml` 验证
393
+ - **类型检查器** - mypy 集成,严格类型检查
394
+ - **代码风格检查器** - ruff 集成,自动修复
395
+ - 支持生成 Markdown 格式报告
396
+ - 灵活的级别过滤(error/warning/info)
397
+
398
+ #### 4. ✅ 热重载开发模式 (`mpdt dev`)
399
+ - 基于 WebSocket 的实时通信
400
+ - 自动注入开发桥接插件
401
+ - 文件变化自动检测(使用 watchdog)
402
+ - 插件生命周期自动管理
403
+ - 实时状态显示和日志查看
404
+ - 支持主程序自动启动和停止
405
+
406
+ ### 🚧 计划中功能
407
+
408
+ #### 测试框架 (`mpdt test`)
409
+ - 自动运行插件测试
410
+ - 覆盖率报告生成
411
+ - 并行测试执行
412
+ - 测试报告输出
413
+
414
+ #### 构建打包 (`mpdt build`)
415
+ - 插件打包为发布格式
416
+ - 版本号自动管理
417
+ - 依赖项打包
418
+ - 多种打包格式支持
419
+
420
+ #### 配置管理
421
+ - 项目级配置文件 `.mpdtrc.toml`
422
+ - 全局配置管理
423
+ - 配置验证和迁移
424
+
425
+ ---
426
+
427
+ ## 🤝 贡献指南
428
+
429
+ 欢迎贡献代码和建议!
430
+
431
+ ### 贡献方式
432
+ 1. Fork 项目仓库
433
+ 2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
434
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
435
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
436
+ 5. 创建 Pull Request
437
+
438
+ ### 开发环境设置
439
+ ```bash
440
+ # 克隆仓库
441
+ git clone https://github.com/MoFox-Studio/mofox-plugin-toolkit.git
442
+ cd mofox-plugin-toolkit
443
+
444
+ # 安装开发依赖
445
+ pip install -e ".[dev]"
446
+
447
+ # 运行测试
448
+ pytest
449
+
450
+ # 代码检查
451
+ ruff check .
452
+ mypy mpdt
453
+ ```
454
+
455
+ ---
456
+
457
+ ## 📄 许可证
458
+
459
+ 本项目采用 GPL-3.0-or-later 许可证。详见 [LICENSE](LICENSE) 文件。
460
+
461
+ ---
462
+
463
+ ## 🔗 相关链接
464
+
465
+ - [MoFox-Bot 主仓库](https://github.com/MoFox-Studio/MoFox-Core)
466
+ - [插件开发文档](https://docs.mofox.studio/plugin-development)
467
+ - [问题反馈](https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues)
468
+ - [更新日志](CHANGELOG.md)
469
+
470
+ ---
471
+
472
+ ## 📊 技术栈
473
+
474
+ ### 核心框架
475
+ - **CLI 框架**: [Click](https://click.palletsprojects.com/) - 强大的命令行工具框架
476
+ - **交互式界面**: [Questionary](https://github.com/tmbo/questionary) - 美观的交互式问答
477
+ - **美化输出**: [Rich](https://github.com/Textualize/rich) - 富文本终端输出
478
+
479
+ ### 开发工具
480
+ - **模板引擎**: [Jinja2](https://jinja.palletsprojects.com/) - 灵活的模板系统
481
+ - **配置管理**: [TOML](https://toml.io/), [Pydantic](https://docs.pydantic.dev/) - 配置解析和验证
482
+ - **代码检查**:
483
+ - [Mypy](https://mypy.readthedocs.io/) - 静态类型检查
484
+ - [Ruff](https://docs.astral.sh/ruff/) - 快速的 Python 代码检查器和格式化工具
485
+
486
+ ### 开发模式
487
+ - **文件监控**: [Watchdog](https://python-watchdog.readthedocs.io/) - 跨平台文件系统监控
488
+ - **WebSocket**: [websockets](https://websockets.readthedocs.io/) - 异步 WebSocket 库
489
+ - **HTTP 客户端**: [aiohttp](https://docs.aiohttp.org/) - 异步 HTTP 客户端/服务器
490
+
491
+ ---
492
+
493
+ ## 🛠️ 完整依赖清单
494
+
495
+ ```toml
496
+ dependencies = [
497
+ "click>=8.1.7", # CLI 框架
498
+ "rich>=13.7.0", # 终端美化
499
+ "questionary>=2.0.1", # 交互式问答
500
+ "jinja2>=3.1.2", # 模板引擎
501
+ "toml>=0.10.2", # TOML 解析
502
+ "tomli>=2.0.1", # TOML 读取
503
+ "tomli-w>=1.0.0", # TOML 写入
504
+ "pydantic>=2.5.0", # 数据验证
505
+ "watchdog>=3.0.0", # 文件监控
506
+ "websockets>=12.0", # WebSocket
507
+ "aiohttp>=3.9.0", # 异步 HTTP
508
+ "uvicorn>=0.24.0", # ASGI 服务器
509
+ "fastapi>=0.104.0", # Web 框架
510
+ "ruff>=0.1.6", # 代码检查
511
+ "mypy>=1.7.0" # 类型检查
512
+ ]
513
+ ```
514
+
515
+ ---
516
+
517
+ ## 💡 常见问题
518
+
519
+ ### Q: 如何配置开发模式?
520
+ A: 首次运行 `mpdt dev` 时会提示输入 MMC 主程序路径,配置会保存到 `~/.mpdt/config.toml`。
521
+
522
+ ### Q: 检查器报错怎么办?
523
+ A: 首先尝试使用 `mpdt check --fix` 自动修复。如果仍有问题,查看具体错误信息和建议。
524
+
525
+ ### Q: 如何跳过某些检查?
526
+ A: 使用 `--no-<checker>` 选项,例如 `mpdt check --no-type --no-style`。
527
+
528
+ ### Q: 生成的组件在哪里?
529
+ A: 组件会自动放置到对应的目录,例如 Action 放在 `components/actions/`。
530
+
531
+ ### Q: 如何更新工具?
532
+ A: 如果是从源码安装,执行 `git pull && pip install -e .`。
533
+
534
+ ---
535
+
536
+ ## 📝 更新日志
537
+
538
+ ### v0.2.1 (2025-12-14)
539
+ - ✅ 实现完整的热重载开发模式 (`mpdt dev`)
540
+ - ✅ 添加 WebSocket 通信机制
541
+ - ✅ 实现开发桥接插件自动注入
542
+ - ✅ 改进文件监控和自动重载
543
+ - ✅ 优化用户交互体验
544
+
545
+ ### v0.2.0
546
+ - ✅ 完成 6 个检查器实现
547
+ - ✅ 添加自动修复功能
548
+ - ✅ 支持 Markdown 报告生成
549
+ - ✅ 改进错误提示和建议
550
+
551
+ ### v0.1.x
552
+ - ✅ 基础插件初始化功能
553
+ - ✅ 组件生成功能
554
+ - ✅ 交互式问答模式
555
+
556
+ ---
557
+
558
+ ## 🎉 致谢
559
+
560
+ 感谢所有为 MoFox Plugin Dev Toolkit 贡献的开发者!
561
+
562
+ ---
563
+
564
+ <div align="center">
565
+
566
+ **[⬆ 回到顶部](#mofox-plugin-dev-toolkit-mpdt)**
567
+
568
+ Made with ❤️ by MoFox-Studio
569
+
570
+ </div>