mofox-plugin-dev-toolkit 0.5.2__tar.gz → 0.6.0__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 (90) hide show
  1. {mofox_plugin_dev_toolkit-0.5.2/mofox_plugin_dev_toolkit.egg-info → mofox_plugin_dev_toolkit-0.6.0}/PKG-INFO +17 -67
  2. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/README.md +14 -64
  3. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0/mofox_plugin_dev_toolkit.egg-info}/PKG-INFO +17 -67
  4. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/SOURCES.txt +28 -18
  5. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/requires.txt +1 -1
  6. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/__init__.py +1 -1
  7. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/__init__.py +15 -0
  8. {mofox_plugin_dev_toolkit-0.5.2/mpdt/validators → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/base.py +87 -0
  9. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/__init__.py +17 -0
  10. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/attribute_fixer.py +212 -0
  11. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/decorator_fixer.py +70 -0
  12. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/import_fixer.py +339 -0
  13. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/manifest_fixer.py +71 -0
  14. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/method_fixer.py +270 -0
  15. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/style_fixer.py +71 -0
  16. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/fixers/transformers.py +445 -0
  17. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/__init__.py +3 -10
  18. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/component_validator.py +217 -323
  19. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/config_validator.py +2 -2
  20. mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers/validators/import_validator.py +172 -0
  21. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/metadata_validator.py +51 -20
  22. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/structure_validator.py +1 -1
  23. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/style_validator.py +1 -1
  24. {mofox_plugin_dev_toolkit-0.5.2/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/type_validator.py +3 -3
  25. mofox_plugin_dev_toolkit-0.6.0/mpdt/cli.py +710 -0
  26. mofox_plugin_dev_toolkit-0.6.0/mpdt/commands/build.py +120 -0
  27. mofox_plugin_dev_toolkit-0.6.0/mpdt/commands/bump.py +134 -0
  28. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/check.py +223 -187
  29. mofox_plugin_dev_toolkit-0.6.0/mpdt/commands/depend.py +624 -0
  30. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/dev.py +60 -58
  31. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/generate.py +39 -76
  32. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/init.py +59 -226
  33. mofox_plugin_dev_toolkit-0.6.0/mpdt/commands/market.py +843 -0
  34. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/__init__.py +28 -0
  35. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/code_parser.py +181 -0
  36. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/color_printer.py +467 -0
  37. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/file_ops.py +0 -39
  38. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/__init__.py +20 -0
  39. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/config_manager.py +359 -0
  40. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/git_manager.py +579 -0
  41. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/github_manager.py +515 -0
  42. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/manifest_manager.py +948 -0
  43. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/market_manager.py +435 -0
  44. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/package_manager.py +293 -0
  45. mofox_plugin_dev_toolkit-0.6.0/mpdt/utils/managers/pypi_manager.py +199 -0
  46. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/plugin_parser.py +14 -1
  47. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/template_engine.py +2 -2
  48. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/pyproject.toml +4 -4
  49. mofox_plugin_dev_toolkit-0.5.2/mpdt/cli.py +0 -538
  50. mofox_plugin_dev_toolkit-0.5.2/mpdt/commands/build.py +0 -387
  51. mofox_plugin_dev_toolkit-0.5.2/mpdt/commands/market.py +0 -460
  52. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/__init__.py +0 -1
  53. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/client.py +0 -153
  54. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/config.py +0 -44
  55. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/git.py +0 -109
  56. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/github.py +0 -145
  57. mofox_plugin_dev_toolkit-0.5.2/mpdt/market/manifest.py +0 -158
  58. mofox_plugin_dev_toolkit-0.5.2/mpdt/utils/__init__.py +0 -10
  59. mofox_plugin_dev_toolkit-0.5.2/mpdt/utils/color_printer.py +0 -99
  60. mofox_plugin_dev_toolkit-0.5.2/mpdt/utils/config_loader.py +0 -171
  61. mofox_plugin_dev_toolkit-0.5.2/mpdt/utils/config_manager.py +0 -166
  62. mofox_plugin_dev_toolkit-0.5.2/mpdt/utils/manifest_metadata.py +0 -251
  63. mofox_plugin_dev_toolkit-0.5.2/mpdt/validators/auto_fix_validator.py +0 -1107
  64. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/LICENSE +0 -0
  65. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/MANIFEST.in +0 -0
  66. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/dependency_links.txt +0 -0
  67. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/entry_points.txt +0 -0
  68. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/top_level.txt +0 -0
  69. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/__main__.py +0 -0
  70. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/__init__.py +0 -0
  71. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/__init__.py +0 -0
  72. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/cleanup_handler.py +0 -0
  73. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/dev_config.py +0 -0
  74. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/file_watcher.py +0 -0
  75. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/manifest.json +0 -0
  76. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/plugin.py +0 -0
  77. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/__init__.py +0 -0
  78. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/action_template.py +0 -0
  79. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/adapter_template.py +0 -0
  80. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/chatter_template.py +0 -0
  81. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/collection_template.py +0 -0
  82. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/config_template.py +0 -0
  83. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/event_template.py +0 -0
  84. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/plus_command_template.py +0 -0
  85. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/prompt_template.py +0 -0
  86. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/router_template.py +0 -0
  87. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/service_template.py +0 -0
  88. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/tool_template.py +0 -0
  89. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/license_generator.py +0 -0
  90. {mofox_plugin_dev_toolkit-0.5.2 → mofox_plugin_dev_toolkit-0.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mofox-plugin-dev-toolkit
3
- Version: 0.5.2
3
+ Version: 0.6.0
4
4
  Summary: 开发工具集,用于快速创建、开发和测试 MoFox-Bot 插件
5
5
  Author-email: MoFox-Studio <wwwww95915@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.mofox.studio/mpdt
9
9
  Project-URL: Repository, https://github.com/MoFox-Studio/mofox-plugin-toolkit
10
10
  Project-URL: Bug Tracker, https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues
11
11
  Keywords: mofox,plugin,toolkit,cli,development
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
15
  Classifier: Programming Language :: Python :: 3
@@ -30,11 +30,11 @@ Requires-Dist: watchdog>=3.0.0
30
30
  Requires-Dist: websockets>=12.0
31
31
  Requires-Dist: libcst>=1.8.6
32
32
  Requires-Dist: aiohttp>=3.9.0
33
- Requires-Dist: pillow>=11.2.0
34
33
  Requires-Dist: uvicorn>=0.24.0
35
34
  Requires-Dist: fastapi>=0.104.0
36
35
  Requires-Dist: ruff>=0.1.6
37
36
  Requires-Dist: mypy>=1.7.0
37
+ Requires-Dist: packaging>=23.0
38
38
  Provides-Extra: dev
39
39
  Requires-Dist: pytest>=7.4.3; extra == "dev"
40
40
  Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
@@ -225,8 +225,8 @@ mpdt dev
225
225
  # 指定主程序路径
226
226
  mpdt dev --neo-mofox-path /path/to/neo-mofox
227
227
 
228
- # 指定插件路径
229
- mpdt dev --plugin-path /path/to/plugin
228
+ # 指定插件路径(作为参数)
229
+ mpdt dev /path/to/plugin
230
230
 
231
231
  # 首次运行会提示配置
232
232
  # 之后会自动:
@@ -306,62 +306,7 @@ mpdt build --with-docs --bump patch --output release
306
306
 
307
307
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
308
308
 
309
- ### 6. 发布到插件市场
310
-
311
- MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
312
-
313
- 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
314
-
315
- ```bash
316
- set GITHUB_TOKEN=ghp_xxx
317
- set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
318
- set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
319
- ```
320
-
321
- 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
322
-
323
- ```bash
324
- mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
325
- ```
326
-
327
- 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
328
-
329
- 在插件目录执行一键发布:
330
-
331
- ```bash
332
- mpdt market publish --owner your-github-user-or-org
333
- ```
334
-
335
- 该命令会依次执行:
336
-
337
- 1. 读取 `manifest.json`。
338
- 2. 构建 `.mfp` 包并计算 sha256。
339
- 3. 如果 GitHub 仓库不存在则自动创建。
340
- 4. 初始化或复用本地 git 仓库。
341
- 5. 提交当前插件代码。
342
- 6. 创建版本 tag,例如 `v1.0.0`。
343
- 7. 推送分支和 tag 到 GitHub。
344
- 8. 创建或复用 GitHub Release。
345
- 9. 上传 `.mfp` Release 资产。
346
- 10. 注册或更新中心服务器插件元数据。
347
- 11. 提交新版本;如果版本已存在则同步版本元数据。
348
-
349
- 常用参数:
350
-
351
- ```bash
352
- mpdt market publish \
353
- --owner MoFox-Studio \
354
- --repo my_plugin \
355
- --release-notes "First public release"
356
- ```
357
-
358
- 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
359
-
360
- ```bash
361
- mpdt market publish --owner MoFox-Studio --skip-push
362
- ```
363
-
364
- ### 7. 配置管理
309
+ ### 6. 配置管理
365
310
 
366
311
  ```bash
367
312
  # 交互式配置向导
@@ -391,7 +336,6 @@ mpdt config set-mofox /path/to/neo-mofox
391
336
  mpdt [OPTIONS] COMMAND [ARGS]...
392
337
 
393
338
  选项:
394
- -v, --verbose 详细输出模式
395
339
  --no-color 禁用彩色输出
396
340
  --version 显示版本信息
397
341
  --help 显示帮助信息
@@ -423,7 +367,7 @@ mpdt init [PLUGIN_NAME] [OPTIONS]
423
367
  生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
424
368
 
425
369
  ```bash
426
- mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
370
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [PATH] [OPTIONS]
427
371
 
428
372
  组件类型:
429
373
  action Action 组件 - 执行具体操作
@@ -437,16 +381,19 @@ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
437
381
  service Service 组件 - 服务类
438
382
  config Config 组件 - 配置类
439
383
 
384
+ 位置参数:
385
+ PATH 插件根目录路径(默认为当前目录)
386
+
440
387
  选项:
441
388
  -d, --description TEXT 组件描述信息
442
- -o, --output PATH 输出目录(默认自动选择对应组件目录)
443
389
  -f, --force 覆盖已存在的文件
390
+ --root 在插件根目录生成组件文件,而不是 components/ 文件夹
444
391
 
445
392
  示例:
446
393
  mpdt generate # 交互式生成
447
394
  mpdt generate action SendMsg -d "发送消息" # 命令行生成
448
395
  mpdt generate tool Formatter --force # 强制覆盖
449
- mpdt generate service DataService # 生成服务类
396
+ mpdt generate service DataService ./my_plugin # 在指定插件中生成服务类
450
397
  ```
451
398
 
452
399
  **注意**:不提供参数时将进入交互式问答模式,更易于使用。
@@ -517,11 +464,13 @@ mpdt build [PLUGIN_PATH] [OPTIONS]
517
464
  启动带热重载的开发模式,实时监控文件变化并自动重载插件。
518
465
 
519
466
  ```bash
520
- mpdt dev [OPTIONS]
467
+ mpdt dev [PATH] [OPTIONS]
468
+
469
+ 位置参数:
470
+ PATH 插件路径(默认当前目录)
521
471
 
522
472
  选项:
523
473
  --neo-mofox-path PATH Neo-MoFox 主程序路径
524
- --plugin-path PATH 插件路径(默认当前目录)
525
474
 
526
475
  功能特性:
527
476
  - 🔄 自动检测文件变化并热重载
@@ -544,6 +493,7 @@ mpdt dev [OPTIONS]
544
493
 
545
494
  示例:
546
495
  mpdt dev # 在插件目录中运行
496
+ mpdt dev /path/to/plugin # 指定插件路径
547
497
  mpdt dev --neo-mofox-path /path/to/neo-mofox # 指定主程序路径
548
498
  ```
549
499
 
@@ -172,8 +172,8 @@ mpdt dev
172
172
  # 指定主程序路径
173
173
  mpdt dev --neo-mofox-path /path/to/neo-mofox
174
174
 
175
- # 指定插件路径
176
- mpdt dev --plugin-path /path/to/plugin
175
+ # 指定插件路径(作为参数)
176
+ mpdt dev /path/to/plugin
177
177
 
178
178
  # 首次运行会提示配置
179
179
  # 之后会自动:
@@ -253,62 +253,7 @@ mpdt build --with-docs --bump patch --output release
253
253
 
254
254
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
255
255
 
256
- ### 6. 发布到插件市场
257
-
258
- MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
259
-
260
- 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
261
-
262
- ```bash
263
- set GITHUB_TOKEN=ghp_xxx
264
- set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
265
- set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
266
- ```
267
-
268
- 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
269
-
270
- ```bash
271
- mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
272
- ```
273
-
274
- 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
275
-
276
- 在插件目录执行一键发布:
277
-
278
- ```bash
279
- mpdt market publish --owner your-github-user-or-org
280
- ```
281
-
282
- 该命令会依次执行:
283
-
284
- 1. 读取 `manifest.json`。
285
- 2. 构建 `.mfp` 包并计算 sha256。
286
- 3. 如果 GitHub 仓库不存在则自动创建。
287
- 4. 初始化或复用本地 git 仓库。
288
- 5. 提交当前插件代码。
289
- 6. 创建版本 tag,例如 `v1.0.0`。
290
- 7. 推送分支和 tag 到 GitHub。
291
- 8. 创建或复用 GitHub Release。
292
- 9. 上传 `.mfp` Release 资产。
293
- 10. 注册或更新中心服务器插件元数据。
294
- 11. 提交新版本;如果版本已存在则同步版本元数据。
295
-
296
- 常用参数:
297
-
298
- ```bash
299
- mpdt market publish \
300
- --owner MoFox-Studio \
301
- --repo my_plugin \
302
- --release-notes "First public release"
303
- ```
304
-
305
- 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
306
-
307
- ```bash
308
- mpdt market publish --owner MoFox-Studio --skip-push
309
- ```
310
-
311
- ### 7. 配置管理
256
+ ### 6. 配置管理
312
257
 
313
258
  ```bash
314
259
  # 交互式配置向导
@@ -338,7 +283,6 @@ mpdt config set-mofox /path/to/neo-mofox
338
283
  mpdt [OPTIONS] COMMAND [ARGS]...
339
284
 
340
285
  选项:
341
- -v, --verbose 详细输出模式
342
286
  --no-color 禁用彩色输出
343
287
  --version 显示版本信息
344
288
  --help 显示帮助信息
@@ -370,7 +314,7 @@ mpdt init [PLUGIN_NAME] [OPTIONS]
370
314
  生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
371
315
 
372
316
  ```bash
373
- mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
317
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [PATH] [OPTIONS]
374
318
 
375
319
  组件类型:
376
320
  action Action 组件 - 执行具体操作
@@ -384,16 +328,19 @@ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
384
328
  service Service 组件 - 服务类
385
329
  config Config 组件 - 配置类
386
330
 
331
+ 位置参数:
332
+ PATH 插件根目录路径(默认为当前目录)
333
+
387
334
  选项:
388
335
  -d, --description TEXT 组件描述信息
389
- -o, --output PATH 输出目录(默认自动选择对应组件目录)
390
336
  -f, --force 覆盖已存在的文件
337
+ --root 在插件根目录生成组件文件,而不是 components/ 文件夹
391
338
 
392
339
  示例:
393
340
  mpdt generate # 交互式生成
394
341
  mpdt generate action SendMsg -d "发送消息" # 命令行生成
395
342
  mpdt generate tool Formatter --force # 强制覆盖
396
- mpdt generate service DataService # 生成服务类
343
+ mpdt generate service DataService ./my_plugin # 在指定插件中生成服务类
397
344
  ```
398
345
 
399
346
  **注意**:不提供参数时将进入交互式问答模式,更易于使用。
@@ -464,11 +411,13 @@ mpdt build [PLUGIN_PATH] [OPTIONS]
464
411
  启动带热重载的开发模式,实时监控文件变化并自动重载插件。
465
412
 
466
413
  ```bash
467
- mpdt dev [OPTIONS]
414
+ mpdt dev [PATH] [OPTIONS]
415
+
416
+ 位置参数:
417
+ PATH 插件路径(默认当前目录)
468
418
 
469
419
  选项:
470
420
  --neo-mofox-path PATH Neo-MoFox 主程序路径
471
- --plugin-path PATH 插件路径(默认当前目录)
472
421
 
473
422
  功能特性:
474
423
  - 🔄 自动检测文件变化并热重载
@@ -491,6 +440,7 @@ mpdt dev [OPTIONS]
491
440
 
492
441
  示例:
493
442
  mpdt dev # 在插件目录中运行
443
+ mpdt dev /path/to/plugin # 指定插件路径
494
444
  mpdt dev --neo-mofox-path /path/to/neo-mofox # 指定主程序路径
495
445
  ```
496
446
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mofox-plugin-dev-toolkit
3
- Version: 0.5.2
3
+ Version: 0.6.0
4
4
  Summary: 开发工具集,用于快速创建、开发和测试 MoFox-Bot 插件
5
5
  Author-email: MoFox-Studio <wwwww95915@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.mofox.studio/mpdt
9
9
  Project-URL: Repository, https://github.com/MoFox-Studio/mofox-plugin-toolkit
10
10
  Project-URL: Bug Tracker, https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues
11
11
  Keywords: mofox,plugin,toolkit,cli,development
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
15
  Classifier: Programming Language :: Python :: 3
@@ -30,11 +30,11 @@ Requires-Dist: watchdog>=3.0.0
30
30
  Requires-Dist: websockets>=12.0
31
31
  Requires-Dist: libcst>=1.8.6
32
32
  Requires-Dist: aiohttp>=3.9.0
33
- Requires-Dist: pillow>=11.2.0
34
33
  Requires-Dist: uvicorn>=0.24.0
35
34
  Requires-Dist: fastapi>=0.104.0
36
35
  Requires-Dist: ruff>=0.1.6
37
36
  Requires-Dist: mypy>=1.7.0
37
+ Requires-Dist: packaging>=23.0
38
38
  Provides-Extra: dev
39
39
  Requires-Dist: pytest>=7.4.3; extra == "dev"
40
40
  Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
@@ -225,8 +225,8 @@ mpdt dev
225
225
  # 指定主程序路径
226
226
  mpdt dev --neo-mofox-path /path/to/neo-mofox
227
227
 
228
- # 指定插件路径
229
- mpdt dev --plugin-path /path/to/plugin
228
+ # 指定插件路径(作为参数)
229
+ mpdt dev /path/to/plugin
230
230
 
231
231
  # 首次运行会提示配置
232
232
  # 之后会自动:
@@ -306,62 +306,7 @@ mpdt build --with-docs --bump patch --output release
306
306
 
307
307
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
308
308
 
309
- ### 6. 发布到插件市场
310
-
311
- MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
312
-
313
- 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
314
-
315
- ```bash
316
- set GITHUB_TOKEN=ghp_xxx
317
- set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
318
- set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
319
- ```
320
-
321
- 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
322
-
323
- ```bash
324
- mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
325
- ```
326
-
327
- 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
328
-
329
- 在插件目录执行一键发布:
330
-
331
- ```bash
332
- mpdt market publish --owner your-github-user-or-org
333
- ```
334
-
335
- 该命令会依次执行:
336
-
337
- 1. 读取 `manifest.json`。
338
- 2. 构建 `.mfp` 包并计算 sha256。
339
- 3. 如果 GitHub 仓库不存在则自动创建。
340
- 4. 初始化或复用本地 git 仓库。
341
- 5. 提交当前插件代码。
342
- 6. 创建版本 tag,例如 `v1.0.0`。
343
- 7. 推送分支和 tag 到 GitHub。
344
- 8. 创建或复用 GitHub Release。
345
- 9. 上传 `.mfp` Release 资产。
346
- 10. 注册或更新中心服务器插件元数据。
347
- 11. 提交新版本;如果版本已存在则同步版本元数据。
348
-
349
- 常用参数:
350
-
351
- ```bash
352
- mpdt market publish \
353
- --owner MoFox-Studio \
354
- --repo my_plugin \
355
- --release-notes "First public release"
356
- ```
357
-
358
- 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
359
-
360
- ```bash
361
- mpdt market publish --owner MoFox-Studio --skip-push
362
- ```
363
-
364
- ### 7. 配置管理
309
+ ### 6. 配置管理
365
310
 
366
311
  ```bash
367
312
  # 交互式配置向导
@@ -391,7 +336,6 @@ mpdt config set-mofox /path/to/neo-mofox
391
336
  mpdt [OPTIONS] COMMAND [ARGS]...
392
337
 
393
338
  选项:
394
- -v, --verbose 详细输出模式
395
339
  --no-color 禁用彩色输出
396
340
  --version 显示版本信息
397
341
  --help 显示帮助信息
@@ -423,7 +367,7 @@ mpdt init [PLUGIN_NAME] [OPTIONS]
423
367
  生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
424
368
 
425
369
  ```bash
426
- mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
370
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [PATH] [OPTIONS]
427
371
 
428
372
  组件类型:
429
373
  action Action 组件 - 执行具体操作
@@ -437,16 +381,19 @@ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
437
381
  service Service 组件 - 服务类
438
382
  config Config 组件 - 配置类
439
383
 
384
+ 位置参数:
385
+ PATH 插件根目录路径(默认为当前目录)
386
+
440
387
  选项:
441
388
  -d, --description TEXT 组件描述信息
442
- -o, --output PATH 输出目录(默认自动选择对应组件目录)
443
389
  -f, --force 覆盖已存在的文件
390
+ --root 在插件根目录生成组件文件,而不是 components/ 文件夹
444
391
 
445
392
  示例:
446
393
  mpdt generate # 交互式生成
447
394
  mpdt generate action SendMsg -d "发送消息" # 命令行生成
448
395
  mpdt generate tool Formatter --force # 强制覆盖
449
- mpdt generate service DataService # 生成服务类
396
+ mpdt generate service DataService ./my_plugin # 在指定插件中生成服务类
450
397
  ```
451
398
 
452
399
  **注意**:不提供参数时将进入交互式问答模式,更易于使用。
@@ -517,11 +464,13 @@ mpdt build [PLUGIN_PATH] [OPTIONS]
517
464
  启动带热重载的开发模式,实时监控文件变化并自动重载插件。
518
465
 
519
466
  ```bash
520
- mpdt dev [OPTIONS]
467
+ mpdt dev [PATH] [OPTIONS]
468
+
469
+ 位置参数:
470
+ PATH 插件路径(默认当前目录)
521
471
 
522
472
  选项:
523
473
  --neo-mofox-path PATH Neo-MoFox 主程序路径
524
- --plugin-path PATH 插件路径(默认当前目录)
525
474
 
526
475
  功能特性:
527
476
  - 🔄 自动检测文件变化并热重载
@@ -544,6 +493,7 @@ mpdt dev [OPTIONS]
544
493
 
545
494
  示例:
546
495
  mpdt dev # 在插件目录中运行
496
+ mpdt dev /path/to/plugin # 指定插件路径
547
497
  mpdt dev --neo-mofox-path /path/to/neo-mofox # 指定主程序路径
548
498
  ```
549
499
 
@@ -11,9 +11,29 @@ mofox_plugin_dev_toolkit.egg-info/top_level.txt
11
11
  mpdt/__init__.py
12
12
  mpdt/__main__.py
13
13
  mpdt/cli.py
14
+ mpdt/checkers/__init__.py
15
+ mpdt/checkers/base.py
16
+ mpdt/checkers/fixers/__init__.py
17
+ mpdt/checkers/fixers/attribute_fixer.py
18
+ mpdt/checkers/fixers/decorator_fixer.py
19
+ mpdt/checkers/fixers/import_fixer.py
20
+ mpdt/checkers/fixers/manifest_fixer.py
21
+ mpdt/checkers/fixers/method_fixer.py
22
+ mpdt/checkers/fixers/style_fixer.py
23
+ mpdt/checkers/fixers/transformers.py
24
+ mpdt/checkers/validators/__init__.py
25
+ mpdt/checkers/validators/component_validator.py
26
+ mpdt/checkers/validators/config_validator.py
27
+ mpdt/checkers/validators/import_validator.py
28
+ mpdt/checkers/validators/metadata_validator.py
29
+ mpdt/checkers/validators/structure_validator.py
30
+ mpdt/checkers/validators/style_validator.py
31
+ mpdt/checkers/validators/type_validator.py
14
32
  mpdt/commands/__init__.py
15
33
  mpdt/commands/build.py
34
+ mpdt/commands/bump.py
16
35
  mpdt/commands/check.py
36
+ mpdt/commands/depend.py
17
37
  mpdt/commands/dev.py
18
38
  mpdt/commands/generate.py
19
39
  mpdt/commands/init.py
@@ -24,12 +44,6 @@ mpdt/dev/bridge_plugin/dev_config.py
24
44
  mpdt/dev/bridge_plugin/file_watcher.py
25
45
  mpdt/dev/bridge_plugin/manifest.json
26
46
  mpdt/dev/bridge_plugin/plugin.py
27
- mpdt/market/__init__.py
28
- mpdt/market/client.py
29
- mpdt/market/config.py
30
- mpdt/market/git.py
31
- mpdt/market/github.py
32
- mpdt/market/manifest.py
33
47
  mpdt/templates/__init__.py
34
48
  mpdt/templates/action_template.py
35
49
  mpdt/templates/adapter_template.py
@@ -45,19 +59,15 @@ mpdt/templates/tool_template.py
45
59
  mpdt/utils/__init__.py
46
60
  mpdt/utils/code_parser.py
47
61
  mpdt/utils/color_printer.py
48
- mpdt/utils/config_loader.py
49
- mpdt/utils/config_manager.py
50
62
  mpdt/utils/file_ops.py
51
63
  mpdt/utils/license_generator.py
52
- mpdt/utils/manifest_metadata.py
53
64
  mpdt/utils/plugin_parser.py
54
65
  mpdt/utils/template_engine.py
55
- mpdt/validators/__init__.py
56
- mpdt/validators/auto_fix_validator.py
57
- mpdt/validators/base.py
58
- mpdt/validators/component_validator.py
59
- mpdt/validators/config_validator.py
60
- mpdt/validators/metadata_validator.py
61
- mpdt/validators/structure_validator.py
62
- mpdt/validators/style_validator.py
63
- mpdt/validators/type_validator.py
66
+ mpdt/utils/managers/__init__.py
67
+ mpdt/utils/managers/config_manager.py
68
+ mpdt/utils/managers/git_manager.py
69
+ mpdt/utils/managers/github_manager.py
70
+ mpdt/utils/managers/manifest_manager.py
71
+ mpdt/utils/managers/market_manager.py
72
+ mpdt/utils/managers/package_manager.py
73
+ mpdt/utils/managers/pypi_manager.py
@@ -10,11 +10,11 @@ watchdog>=3.0.0
10
10
  websockets>=12.0
11
11
  libcst>=1.8.6
12
12
  aiohttp>=3.9.0
13
- pillow>=11.2.0
14
13
  uvicorn>=0.24.0
15
14
  fastapi>=0.104.0
16
15
  ruff>=0.1.6
17
16
  mypy>=1.7.0
17
+ packaging>=23.0
18
18
 
19
19
  [check]
20
20
  mypy>=1.7.0
@@ -4,7 +4,7 @@ MoFox Plugin Dev Toolkit
4
4
  一个用于 MoFox-Bot 插件开发的工具集
5
5
  """
6
6
 
7
- __version__ = "0.4.11"
7
+ __version__ = "0.6.0"
8
8
  __author__ = "MoFox-Studio"
9
9
  __license__ = "GPL-3.0-or-later"
10
10
 
@@ -0,0 +1,15 @@
1
+ """检查器模块
2
+
3
+ 包含验证器(validators)和修复器(fixers)两个子模块
4
+ """
5
+
6
+ from .base import BaseFixer, BaseValidator, FixResult, ValidationIssue, ValidationLevel, ValidationResult
7
+
8
+ __all__ = [
9
+ "BaseValidator",
10
+ "ValidationResult",
11
+ "ValidationIssue",
12
+ "ValidationLevel",
13
+ "BaseFixer",
14
+ "FixResult",
15
+ ]
@@ -36,6 +36,9 @@ class ValidationResult:
36
36
  validator_name: str
37
37
  issues: list[ValidationIssue] = field(default_factory=list)
38
38
  success: bool = True
39
+ fixes_applied: list[str] = field(default_factory=list)
40
+ fixes_failed: list[str] = field(default_factory=list)
41
+ fixed_issues: list[ValidationIssue] = field(default_factory=list)
39
42
 
40
43
  def add_error(self, message: str, file_path: str | None = None, line_number: int | None = None, suggestion: str | None = None) -> None:
41
44
  """添加错误"""
@@ -97,6 +100,47 @@ class ValidationResult:
97
100
  self.success = True
98
101
 
99
102
 
103
+ @dataclass
104
+ class FixResult:
105
+ """修复结果"""
106
+
107
+ fixer_name: str
108
+ fixes_applied: list[str] = field(default_factory=list)
109
+ fixes_failed: list[str] = field(default_factory=list)
110
+ fixed_issues: list[ValidationIssue] = field(default_factory=list)
111
+ success: bool = True
112
+
113
+ def add_fix(self, message: str, issue: ValidationIssue | None = None) -> None:
114
+ """添加成功的修复
115
+
116
+ Args:
117
+ message: 修复描述
118
+ issue: 被修复的问题(可选)
119
+ """
120
+ self.fixes_applied.append(message)
121
+ if issue:
122
+ self.fixed_issues.append(issue)
123
+
124
+ def add_failure(self, message: str) -> None:
125
+ """添加失败的修复
126
+
127
+ Args:
128
+ message: 失败原因描述
129
+ """
130
+ self.fixes_failed.append(message)
131
+ self.success = False
132
+
133
+ @property
134
+ def fix_count(self) -> int:
135
+ """成功修复数量"""
136
+ return len(self.fixes_applied)
137
+
138
+ @property
139
+ def failure_count(self) -> int:
140
+ """失败修复数量"""
141
+ return len(self.fixes_failed)
142
+
143
+
100
144
  class BaseValidator(ABC):
101
145
  """验证器基类"""
102
146
 
@@ -118,6 +162,49 @@ class BaseValidator(ABC):
118
162
  """
119
163
  pass
120
164
 
165
+ def _get_plugin_name(self) -> str | None:
166
+ """获取插件名称(从目录名)
167
+
168
+ 插件结构: my_plugin/plugin.py
169
+ """
170
+ return extract_plugin_name(self.plugin_path)
171
+
172
+
173
+ class BaseFixer(ABC):
174
+ """修复器基类"""
175
+
176
+ def __init__(self, plugin_path: Path):
177
+ """初始化修复器
178
+
179
+ Args:
180
+ plugin_path: 插件路径
181
+ """
182
+ self.plugin_path = plugin_path
183
+ self.result = FixResult(fixer_name=self.__class__.__name__)
184
+
185
+ @abstractmethod
186
+ def fix(self, issues: list[ValidationIssue]) -> FixResult:
187
+ """执行修复
188
+
189
+ Args:
190
+ issues: 需要修复的问题列表
191
+
192
+ Returns:
193
+ FixResult: 修复结果
194
+ """
195
+ pass
196
+
197
+ def can_fix(self, issue: ValidationIssue) -> bool:
198
+ """判断是否可以修复某个问题
199
+
200
+ Args:
201
+ issue: 验证问题
202
+
203
+ Returns:
204
+ bool: 是否可以修复
205
+ """
206
+ return False
207
+
121
208
  def _get_plugin_name(self) -> str | None:
122
209
  """获取插件名称(从目录名)
123
210