-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbase_generator.py
More file actions
35 lines (26 loc) · 1.12 KB
/
base_generator.py
File metadata and controls
35 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
from abc import abstractmethod
from typing import List
from sync_ai_rules.core.generator_interface import OutputGenerator
from sync_ai_rules.core.rule_metadata import RuleMetadata
class BaseGenerator(OutputGenerator):
"""Base class for all generators with shared functionality."""
@property
def default_filenames(self) -> List[str]:
"""Default target files for all generators."""
return [
"AGENTS.md",
".github/copilot-instructions.md",
]
@property
def gitattributes_patterns(self) -> List[str]:
return self.default_filenames
def _format_heading(self, category: str) -> str:
"""Format category as heading."""
return category.replace("-", " ").replace("_", " ").title()
def _sort_rules_by_title(self, rules: List[RuleMetadata]) -> List[RuleMetadata]:
"""Sort rules alphabetically by title."""
return sorted(rules, key=lambda r: r.title)
@abstractmethod
def _format_rule(self, rule: RuleMetadata) -> List[str]:
"""Format individual rule as markdown. Must be implemented by subclasses."""