mofox-plugin-dev-toolkit 0.3.3__py3-none-any.whl
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.
- mofox_plugin_dev_toolkit-0.3.3.dist-info/METADATA +730 -0
- mofox_plugin_dev_toolkit-0.3.3.dist-info/RECORD +46 -0
- mofox_plugin_dev_toolkit-0.3.3.dist-info/WHEEL +5 -0
- mofox_plugin_dev_toolkit-0.3.3.dist-info/entry_points.txt +2 -0
- mofox_plugin_dev_toolkit-0.3.3.dist-info/licenses/LICENSE +674 -0
- mofox_plugin_dev_toolkit-0.3.3.dist-info/top_level.txt +1 -0
- mpdt/__init__.py +15 -0
- mpdt/__main__.py +8 -0
- mpdt/cli.py +316 -0
- mpdt/commands/__init__.py +9 -0
- mpdt/commands/check.py +498 -0
- mpdt/commands/dev.py +318 -0
- mpdt/commands/generate.py +448 -0
- mpdt/commands/init.py +686 -0
- mpdt/dev/bridge_plugin/__init__.py +17 -0
- mpdt/dev/bridge_plugin/cleanup_handler.py +65 -0
- mpdt/dev/bridge_plugin/dev_config.py +24 -0
- mpdt/dev/bridge_plugin/file_watcher.py +169 -0
- mpdt/dev/bridge_plugin/plugin.py +219 -0
- mpdt/templates/__init__.py +165 -0
- mpdt/templates/action_template.py +102 -0
- mpdt/templates/adapter_template.py +129 -0
- mpdt/templates/chatter_template.py +103 -0
- mpdt/templates/event_template.py +116 -0
- mpdt/templates/plus_command_template.py +150 -0
- mpdt/templates/prompt_template.py +92 -0
- mpdt/templates/router_template.py +175 -0
- mpdt/templates/tool_template.py +98 -0
- mpdt/utils/__init__.py +10 -0
- mpdt/utils/code_parser.py +401 -0
- mpdt/utils/color_printer.py +99 -0
- mpdt/utils/config_loader.py +171 -0
- mpdt/utils/config_manager.py +297 -0
- mpdt/utils/file_ops.py +207 -0
- mpdt/utils/license_generator.py +980 -0
- mpdt/utils/plugin_parser.py +195 -0
- mpdt/utils/template_engine.py +112 -0
- mpdt/validators/__init__.py +26 -0
- mpdt/validators/auto_fix_validator.py +990 -0
- mpdt/validators/base.py +129 -0
- mpdt/validators/component_validator.py +842 -0
- mpdt/validators/config_validator.py +119 -0
- mpdt/validators/metadata_validator.py +107 -0
- mpdt/validators/structure_validator.py +72 -0
- mpdt/validators/style_validator.py +117 -0
- mpdt/validators/type_validator.py +206 -0
mpdt/validators/base.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
验证器基类
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ValidationLevel(str, Enum):
|
|
12
|
+
"""验证级别"""
|
|
13
|
+
|
|
14
|
+
ERROR = "error"
|
|
15
|
+
WARNING = "warning"
|
|
16
|
+
INFO = "info"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class ValidationIssue:
|
|
21
|
+
"""验证问题"""
|
|
22
|
+
|
|
23
|
+
level: ValidationLevel
|
|
24
|
+
message: str
|
|
25
|
+
file_path: str | None = None
|
|
26
|
+
line_number: int | None = None
|
|
27
|
+
suggestion: str | None = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class ValidationResult:
|
|
32
|
+
"""验证结果"""
|
|
33
|
+
|
|
34
|
+
validator_name: str
|
|
35
|
+
issues: list[ValidationIssue] = field(default_factory=list)
|
|
36
|
+
success: bool = True
|
|
37
|
+
|
|
38
|
+
def add_error(self, message: str, file_path: str | None = None, line_number: int | None = None, suggestion: str | None = None) -> None:
|
|
39
|
+
"""添加错误"""
|
|
40
|
+
self.issues.append(
|
|
41
|
+
ValidationIssue(
|
|
42
|
+
level=ValidationLevel.ERROR,
|
|
43
|
+
message=message,
|
|
44
|
+
file_path=file_path,
|
|
45
|
+
line_number=line_number,
|
|
46
|
+
suggestion=suggestion,
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
self.success = False
|
|
50
|
+
|
|
51
|
+
def add_warning(self, message: str, file_path: str | None = None, line_number: int | None = None, suggestion: str | None = None) -> None:
|
|
52
|
+
"""添加警告"""
|
|
53
|
+
self.issues.append(
|
|
54
|
+
ValidationIssue(
|
|
55
|
+
level=ValidationLevel.WARNING,
|
|
56
|
+
message=message,
|
|
57
|
+
file_path=file_path,
|
|
58
|
+
line_number=line_number,
|
|
59
|
+
suggestion=suggestion,
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def add_info(self, message: str, file_path: str | None = None, line_number: int | None = None) -> None:
|
|
64
|
+
"""添加信息"""
|
|
65
|
+
self.issues.append(
|
|
66
|
+
ValidationIssue(
|
|
67
|
+
level=ValidationLevel.INFO,
|
|
68
|
+
message=message,
|
|
69
|
+
file_path=file_path,
|
|
70
|
+
line_number=line_number,
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def error_count(self) -> int:
|
|
76
|
+
"""错误数量"""
|
|
77
|
+
return sum(1 for issue in self.issues if issue.level == ValidationLevel.ERROR)
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def warning_count(self) -> int:
|
|
81
|
+
"""警告数量"""
|
|
82
|
+
return sum(1 for issue in self.issues if issue.level == ValidationLevel.WARNING)
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def info_count(self) -> int:
|
|
86
|
+
"""信息数量"""
|
|
87
|
+
return sum(1 for issue in self.issues if issue.level == ValidationLevel.INFO)
|
|
88
|
+
|
|
89
|
+
def _update_counts(self) -> None:
|
|
90
|
+
"""更新成功状态(根据错误数量)"""
|
|
91
|
+
if self.error_count > 0:
|
|
92
|
+
self.success = False
|
|
93
|
+
elif self.error_count == 0 and not self.success:
|
|
94
|
+
# 如果没有错误了,且之前是失败状态,更新为成功
|
|
95
|
+
self.success = True
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class BaseValidator(ABC):
|
|
99
|
+
"""验证器基类"""
|
|
100
|
+
|
|
101
|
+
def __init__(self, plugin_path: Path):
|
|
102
|
+
"""初始化验证器
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
plugin_path: 插件路径
|
|
106
|
+
"""
|
|
107
|
+
self.plugin_path = plugin_path
|
|
108
|
+
self.result = ValidationResult(validator_name=self.__class__.__name__)
|
|
109
|
+
|
|
110
|
+
@abstractmethod
|
|
111
|
+
def validate(self) -> ValidationResult:
|
|
112
|
+
"""执行验证
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
ValidationResult: 验证结果
|
|
116
|
+
"""
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
def _get_plugin_name(self) -> str | None:
|
|
120
|
+
"""获取插件名称(从目录名)
|
|
121
|
+
|
|
122
|
+
插件结构: my_plugin/plugin.py
|
|
123
|
+
"""
|
|
124
|
+
# 检查 plugin.py 是否在根目录
|
|
125
|
+
if (self.plugin_path / "plugin.py").exists():
|
|
126
|
+
# 返回插件路径的目录名
|
|
127
|
+
return self.plugin_path.name
|
|
128
|
+
|
|
129
|
+
return None
|