mofox-plugin-dev-toolkit 0.5.1__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.1/mofox_plugin_dev_toolkit.egg-info → mofox_plugin_dev_toolkit-0.6.0}/PKG-INFO +17 -66
  2. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/README.md +14 -64
  3. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0/mofox_plugin_dev_toolkit.egg-info}/PKG-INFO +17 -66
  4. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/SOURCES.txt +28 -18
  5. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mofox_plugin_dev_toolkit.egg-info/requires.txt +1 -0
  6. {mofox_plugin_dev_toolkit-0.5.1 → 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.1/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.1/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/__init__.py +3 -10
  18. {mofox_plugin_dev_toolkit-0.5.1/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/component_validator.py +217 -323
  19. {mofox_plugin_dev_toolkit-0.5.1/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.1/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/metadata_validator.py +51 -20
  22. {mofox_plugin_dev_toolkit-0.5.1/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/structure_validator.py +1 -1
  23. {mofox_plugin_dev_toolkit-0.5.1/mpdt → mofox_plugin_dev_toolkit-0.6.0/mpdt/checkers}/validators/style_validator.py +1 -1
  24. {mofox_plugin_dev_toolkit-0.5.1/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.1 → 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.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/dev.py +60 -58
  31. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/generate.py +39 -76
  32. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/init.py +59 -224
  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.1 → 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.1 → 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.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/plugin_parser.py +14 -1
  47. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/template_engine.py +2 -2
  48. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/pyproject.toml +4 -3
  49. mofox_plugin_dev_toolkit-0.5.1/mpdt/cli.py +0 -538
  50. mofox_plugin_dev_toolkit-0.5.1/mpdt/commands/build.py +0 -387
  51. mofox_plugin_dev_toolkit-0.5.1/mpdt/commands/market.py +0 -460
  52. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/__init__.py +0 -1
  53. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/client.py +0 -153
  54. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/config.py +0 -44
  55. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/git.py +0 -109
  56. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/github.py +0 -145
  57. mofox_plugin_dev_toolkit-0.5.1/mpdt/market/manifest.py +0 -102
  58. mofox_plugin_dev_toolkit-0.5.1/mpdt/utils/__init__.py +0 -10
  59. mofox_plugin_dev_toolkit-0.5.1/mpdt/utils/color_printer.py +0 -99
  60. mofox_plugin_dev_toolkit-0.5.1/mpdt/utils/config_loader.py +0 -171
  61. mofox_plugin_dev_toolkit-0.5.1/mpdt/utils/config_manager.py +0 -166
  62. mofox_plugin_dev_toolkit-0.5.1/mpdt/utils/manifest_metadata.py +0 -199
  63. mofox_plugin_dev_toolkit-0.5.1/mpdt/validators/auto_fix_validator.py +0 -1107
  64. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/LICENSE +0 -0
  65. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/MANIFEST.in +0 -0
  66. {mofox_plugin_dev_toolkit-0.5.1 → 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.1 → 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.1 → 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.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/__main__.py +0 -0
  70. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/commands/__init__.py +0 -0
  71. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/__init__.py +0 -0
  72. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/cleanup_handler.py +0 -0
  73. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/dev_config.py +0 -0
  74. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/file_watcher.py +0 -0
  75. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/manifest.json +0 -0
  76. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/dev/bridge_plugin/plugin.py +0 -0
  77. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/__init__.py +0 -0
  78. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/action_template.py +0 -0
  79. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/adapter_template.py +0 -0
  80. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/chatter_template.py +0 -0
  81. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/collection_template.py +0 -0
  82. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/config_template.py +0 -0
  83. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/event_template.py +0 -0
  84. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/plus_command_template.py +0 -0
  85. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/prompt_template.py +0 -0
  86. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/router_template.py +0 -0
  87. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/service_template.py +0 -0
  88. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/templates/tool_template.py +0 -0
  89. {mofox_plugin_dev_toolkit-0.5.1 → mofox_plugin_dev_toolkit-0.6.0}/mpdt/utils/license_generator.py +0 -0
  90. {mofox_plugin_dev_toolkit-0.5.1 → 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.1
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
@@ -34,6 +34,7 @@ Requires-Dist: uvicorn>=0.24.0
34
34
  Requires-Dist: fastapi>=0.104.0
35
35
  Requires-Dist: ruff>=0.1.6
36
36
  Requires-Dist: mypy>=1.7.0
37
+ Requires-Dist: packaging>=23.0
37
38
  Provides-Extra: dev
38
39
  Requires-Dist: pytest>=7.4.3; extra == "dev"
39
40
  Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
@@ -224,8 +225,8 @@ mpdt dev
224
225
  # 指定主程序路径
225
226
  mpdt dev --neo-mofox-path /path/to/neo-mofox
226
227
 
227
- # 指定插件路径
228
- mpdt dev --plugin-path /path/to/plugin
228
+ # 指定插件路径(作为参数)
229
+ mpdt dev /path/to/plugin
229
230
 
230
231
  # 首次运行会提示配置
231
232
  # 之后会自动:
@@ -305,62 +306,7 @@ mpdt build --with-docs --bump patch --output release
305
306
 
306
307
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
307
308
 
308
- ### 6. 发布到插件市场
309
-
310
- MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
311
-
312
- 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
313
-
314
- ```bash
315
- set GITHUB_TOKEN=ghp_xxx
316
- set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
317
- set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
318
- ```
319
-
320
- 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
321
-
322
- ```bash
323
- mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
324
- ```
325
-
326
- 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
327
-
328
- 在插件目录执行一键发布:
329
-
330
- ```bash
331
- mpdt market publish --owner your-github-user-or-org
332
- ```
333
-
334
- 该命令会依次执行:
335
-
336
- 1. 读取 `manifest.json`。
337
- 2. 构建 `.mfp` 包并计算 sha256。
338
- 3. 如果 GitHub 仓库不存在则自动创建。
339
- 4. 初始化或复用本地 git 仓库。
340
- 5. 提交当前插件代码。
341
- 6. 创建版本 tag,例如 `v1.0.0`。
342
- 7. 推送分支和 tag 到 GitHub。
343
- 8. 创建或复用 GitHub Release。
344
- 9. 上传 `.mfp` Release 资产。
345
- 10. 注册或更新中心服务器插件元数据。
346
- 11. 提交新版本;如果版本已存在则同步版本元数据。
347
-
348
- 常用参数:
349
-
350
- ```bash
351
- mpdt market publish \
352
- --owner MoFox-Studio \
353
- --repo my_plugin \
354
- --release-notes "First public release"
355
- ```
356
-
357
- 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
358
-
359
- ```bash
360
- mpdt market publish --owner MoFox-Studio --skip-push
361
- ```
362
-
363
- ### 7. 配置管理
309
+ ### 6. 配置管理
364
310
 
365
311
  ```bash
366
312
  # 交互式配置向导
@@ -390,7 +336,6 @@ mpdt config set-mofox /path/to/neo-mofox
390
336
  mpdt [OPTIONS] COMMAND [ARGS]...
391
337
 
392
338
  选项:
393
- -v, --verbose 详细输出模式
394
339
  --no-color 禁用彩色输出
395
340
  --version 显示版本信息
396
341
  --help 显示帮助信息
@@ -422,7 +367,7 @@ mpdt init [PLUGIN_NAME] [OPTIONS]
422
367
  生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
423
368
 
424
369
  ```bash
425
- mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
370
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [PATH] [OPTIONS]
426
371
 
427
372
  组件类型:
428
373
  action Action 组件 - 执行具体操作
@@ -436,16 +381,19 @@ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
436
381
  service Service 组件 - 服务类
437
382
  config Config 组件 - 配置类
438
383
 
384
+ 位置参数:
385
+ PATH 插件根目录路径(默认为当前目录)
386
+
439
387
  选项:
440
388
  -d, --description TEXT 组件描述信息
441
- -o, --output PATH 输出目录(默认自动选择对应组件目录)
442
389
  -f, --force 覆盖已存在的文件
390
+ --root 在插件根目录生成组件文件,而不是 components/ 文件夹
443
391
 
444
392
  示例:
445
393
  mpdt generate # 交互式生成
446
394
  mpdt generate action SendMsg -d "发送消息" # 命令行生成
447
395
  mpdt generate tool Formatter --force # 强制覆盖
448
- mpdt generate service DataService # 生成服务类
396
+ mpdt generate service DataService ./my_plugin # 在指定插件中生成服务类
449
397
  ```
450
398
 
451
399
  **注意**:不提供参数时将进入交互式问答模式,更易于使用。
@@ -516,11 +464,13 @@ mpdt build [PLUGIN_PATH] [OPTIONS]
516
464
  启动带热重载的开发模式,实时监控文件变化并自动重载插件。
517
465
 
518
466
  ```bash
519
- mpdt dev [OPTIONS]
467
+ mpdt dev [PATH] [OPTIONS]
468
+
469
+ 位置参数:
470
+ PATH 插件路径(默认当前目录)
520
471
 
521
472
  选项:
522
473
  --neo-mofox-path PATH Neo-MoFox 主程序路径
523
- --plugin-path PATH 插件路径(默认当前目录)
524
474
 
525
475
  功能特性:
526
476
  - 🔄 自动检测文件变化并热重载
@@ -543,6 +493,7 @@ mpdt dev [OPTIONS]
543
493
 
544
494
  示例:
545
495
  mpdt dev # 在插件目录中运行
496
+ mpdt dev /path/to/plugin # 指定插件路径
546
497
  mpdt dev --neo-mofox-path /path/to/neo-mofox # 指定主程序路径
547
498
  ```
548
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.1
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
@@ -34,6 +34,7 @@ Requires-Dist: uvicorn>=0.24.0
34
34
  Requires-Dist: fastapi>=0.104.0
35
35
  Requires-Dist: ruff>=0.1.6
36
36
  Requires-Dist: mypy>=1.7.0
37
+ Requires-Dist: packaging>=23.0
37
38
  Provides-Extra: dev
38
39
  Requires-Dist: pytest>=7.4.3; extra == "dev"
39
40
  Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
@@ -224,8 +225,8 @@ mpdt dev
224
225
  # 指定主程序路径
225
226
  mpdt dev --neo-mofox-path /path/to/neo-mofox
226
227
 
227
- # 指定插件路径
228
- mpdt dev --plugin-path /path/to/plugin
228
+ # 指定插件路径(作为参数)
229
+ mpdt dev /path/to/plugin
229
230
 
230
231
  # 首次运行会提示配置
231
232
  # 之后会自动:
@@ -305,62 +306,7 @@ mpdt build --with-docs --bump patch --output release
305
306
 
306
307
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
307
308
 
308
- ### 6. 发布到插件市场
309
-
310
- MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
311
-
312
- 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
313
-
314
- ```bash
315
- set GITHUB_TOKEN=ghp_xxx
316
- set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
317
- set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
318
- ```
319
-
320
- 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
321
-
322
- ```bash
323
- mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
324
- ```
325
-
326
- 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
327
-
328
- 在插件目录执行一键发布:
329
-
330
- ```bash
331
- mpdt market publish --owner your-github-user-or-org
332
- ```
333
-
334
- 该命令会依次执行:
335
-
336
- 1. 读取 `manifest.json`。
337
- 2. 构建 `.mfp` 包并计算 sha256。
338
- 3. 如果 GitHub 仓库不存在则自动创建。
339
- 4. 初始化或复用本地 git 仓库。
340
- 5. 提交当前插件代码。
341
- 6. 创建版本 tag,例如 `v1.0.0`。
342
- 7. 推送分支和 tag 到 GitHub。
343
- 8. 创建或复用 GitHub Release。
344
- 9. 上传 `.mfp` Release 资产。
345
- 10. 注册或更新中心服务器插件元数据。
346
- 11. 提交新版本;如果版本已存在则同步版本元数据。
347
-
348
- 常用参数:
349
-
350
- ```bash
351
- mpdt market publish \
352
- --owner MoFox-Studio \
353
- --repo my_plugin \
354
- --release-notes "First public release"
355
- ```
356
-
357
- 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
358
-
359
- ```bash
360
- mpdt market publish --owner MoFox-Studio --skip-push
361
- ```
362
-
363
- ### 7. 配置管理
309
+ ### 6. 配置管理
364
310
 
365
311
  ```bash
366
312
  # 交互式配置向导
@@ -390,7 +336,6 @@ mpdt config set-mofox /path/to/neo-mofox
390
336
  mpdt [OPTIONS] COMMAND [ARGS]...
391
337
 
392
338
  选项:
393
- -v, --verbose 详细输出模式
394
339
  --no-color 禁用彩色输出
395
340
  --version 显示版本信息
396
341
  --help 显示帮助信息
@@ -422,7 +367,7 @@ mpdt init [PLUGIN_NAME] [OPTIONS]
422
367
  生成插件组件代码,始终生成异步方法,支持交互式和命令行两种模式。
423
368
 
424
369
  ```bash
425
- mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
370
+ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [PATH] [OPTIONS]
426
371
 
427
372
  组件类型:
428
373
  action Action 组件 - 执行具体操作
@@ -436,16 +381,19 @@ mpdt generate [COMPONENT_TYPE] [COMPONENT_NAME] [OPTIONS]
436
381
  service Service 组件 - 服务类
437
382
  config Config 组件 - 配置类
438
383
 
384
+ 位置参数:
385
+ PATH 插件根目录路径(默认为当前目录)
386
+
439
387
  选项:
440
388
  -d, --description TEXT 组件描述信息
441
- -o, --output PATH 输出目录(默认自动选择对应组件目录)
442
389
  -f, --force 覆盖已存在的文件
390
+ --root 在插件根目录生成组件文件,而不是 components/ 文件夹
443
391
 
444
392
  示例:
445
393
  mpdt generate # 交互式生成
446
394
  mpdt generate action SendMsg -d "发送消息" # 命令行生成
447
395
  mpdt generate tool Formatter --force # 强制覆盖
448
- mpdt generate service DataService # 生成服务类
396
+ mpdt generate service DataService ./my_plugin # 在指定插件中生成服务类
449
397
  ```
450
398
 
451
399
  **注意**:不提供参数时将进入交互式问答模式,更易于使用。
@@ -516,11 +464,13 @@ mpdt build [PLUGIN_PATH] [OPTIONS]
516
464
  启动带热重载的开发模式,实时监控文件变化并自动重载插件。
517
465
 
518
466
  ```bash
519
- mpdt dev [OPTIONS]
467
+ mpdt dev [PATH] [OPTIONS]
468
+
469
+ 位置参数:
470
+ PATH 插件路径(默认当前目录)
520
471
 
521
472
  选项:
522
473
  --neo-mofox-path PATH Neo-MoFox 主程序路径
523
- --plugin-path PATH 插件路径(默认当前目录)
524
474
 
525
475
  功能特性:
526
476
  - 🔄 自动检测文件变化并热重载
@@ -543,6 +493,7 @@ mpdt dev [OPTIONS]
543
493
 
544
494
  示例:
545
495
  mpdt dev # 在插件目录中运行
496
+ mpdt dev /path/to/plugin # 指定插件路径
546
497
  mpdt dev --neo-mofox-path /path/to/neo-mofox # 指定主程序路径
547
498
  ```
548
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
@@ -14,6 +14,7 @@ uvicorn>=0.24.0
14
14
  fastapi>=0.104.0
15
15
  ruff>=0.1.6
16
16
  mypy>=1.7.0
17
+ packaging>=23.0
17
18
 
18
19
  [check]
19
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
 
@@ -0,0 +1,17 @@
1
+ """修复器模块"""
2
+
3
+ from .attribute_fixer import AttributeFixer
4
+ from .decorator_fixer import DecoratorFixer
5
+ from .import_fixer import ImportFixer
6
+ from .manifest_fixer import ManifestFixer
7
+ from .method_fixer import MethodFixer
8
+ from .style_fixer import StyleFixer
9
+
10
+ __all__ = [
11
+ "ManifestFixer",
12
+ "DecoratorFixer",
13
+ "AttributeFixer",
14
+ "MethodFixer",
15
+ "StyleFixer",
16
+ "ImportFixer",
17
+ ]