Validate a pattern's structure and content.
(pattern_name)
| 913 | |
| 914 | |
| 915 | def 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 | |
| 942 | def pattern_editor(pattern_name): |
no outgoing calls
no test coverage detected