MCPcopy Create free account
hub / github.com/DSGWJQ/Feagent / main

Function main

scripts/validate_node_definitions.py:102–168  ·  view source on GitHub ↗

主函数

()

Source from the content-addressed store, hash-verified

100
101
102def main():
103 """主函数"""
104 parser = argparse.ArgumentParser(
105 description="Validate node definition YAML files",
106 formatter_class=argparse.RawDescriptionHelpFormatter,
107 epilog="""
108Examples:
109 python scripts/validate_node_definitions.py
110 python scripts/validate_node_definitions.py definitions/nodes/llm.yaml
111 python scripts/validate_node_definitions.py --strict
112 python scripts/validate_node_definitions.py --dir definitions/tools
113 """,
114 )
115 parser.add_argument(
116 "file",
117 nargs="?",
118 help="YAML file to validate (optional, defaults to all in definitions/nodes/)",
119 )
120 parser.add_argument(
121 "--dir",
122 type=str,
123 default="definitions/nodes",
124 help="Directory to validate (default: definitions/nodes)",
125 )
126 parser.add_argument(
127 "--strict", action="store_true", help="Strict mode: treat warnings as errors"
128 )
129 parser.add_argument("--schema", type=str, help="Path to JSON Schema file (optional)")
130
131 args = parser.parse_args()
132
133 # 创建校验器
134 schema_path = Path(args.schema) if args.schema else None
135 validator = NodeYamlValidator(schema_path=schema_path)
136
137 print("=" * 60)
138 print("Feagent Node Definition Validator")
139 print("=" * 60)
140
141 if args.file:
142 # 校验单个文件
143 file_path = Path(args.file)
144 if not file_path.exists():
145 print(f"[ERROR] File not found: {file_path}")
146 sys.exit(1)
147
148 print(f"\nValidating: {file_path}\n")
149 success = validate_file(validator, file_path, args.strict)
150 sys.exit(0 if success else 1)
151 else:
152 # 校验目录
153 dir_path = Path(args.dir)
154 if not dir_path.exists():
155 print(f"[ERROR] Directory not found: {dir_path}")
156 sys.exit(1)
157
158 passed, failed = validate_directory(validator, dir_path, args.strict)
159

Callers 1

Calls 4

NodeYamlValidatorClass · 0.90
validate_fileFunction · 0.85
validate_directoryFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected