MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / validate_pattern

Function validate_pattern

scripts/python_ui/streamlit.py:915–939  ·  view source on GitHub ↗

Validate a pattern's structure and content.

(pattern_name)

Source from the content-addressed store, hash-verified

913
914
915def validate_pattern(pattern_name):
916 """Validate a pattern's structure and content."""
917 try:
918 pattern_path = os.path.join(pattern_dir, pattern_name)
919
920 if not os.path.exists(os.path.join(pattern_path, "system.md")):
921 return False, f"Missing required file: system.md."
922
923 with open(os.path.join(pattern_path, "system.md")) as f:
924 content = f.read()
925 required_sections = ["# IDENTITY", "# STEPS", "# OUTPUT"]
926 missing_sections = []
927 for section in required_sections:
928 if section.lower() not in content.lower():
929 missing_sections.append(section)
930
931 if missing_sections:
932 return (
933 True,
934 f"Warning: Missing sections in system.md: {', '.join(missing_sections)}",
935 )
936
937 return True, "Pattern is valid."
938 except Exception as e:
939 return False, f"Error validating pattern: {str(e)}"
940
941
942def pattern_editor(pattern_name):

Callers 2

create_patternFunction · 0.85
pattern_editorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected