|
1 | 1 | # sync-ai-rules |
2 | 2 |
|
3 | | -- Synchronize AI coding rules from .cursor/rules/\*.mdc files to other AI assistant configuration files (CLAUDE.md, AGENTS.md, etc.) |
4 | | -- Built with a plugin architecture that can easily support new input/output formats as the ecosystem evolves |
| 3 | +Synchronizes AI coding rules to configuration files for Claude, GitHub Copilot, and other AI assistants. Parses rules from source directories and generates documentation sections automatically. |
5 | 4 |
|
6 | | -## Extending to new formats |
| 5 | +## Supported Formats |
7 | 6 |
|
8 | | -### Adding New Input Parsers |
| 7 | +- **Development Rules** - `.cursor/rules/*.mdc` files (YAML frontmatter) → Development Rules section |
| 8 | +- **Review Guidelines** - `.code_review/*.md` files (HTML comment frontmatter) → Review Guidelines section |
9 | 9 |
|
10 | | -Create a parser class implementing `InputParser` in `sync_ai_rules/parsers/`: |
| 10 | +Target files: `CLAUDE.md`, `AGENTS.md`, `.github/copilot-instructions.md` |
| 11 | + |
| 12 | +## Extending the System |
| 13 | + |
| 14 | +### Create a New Pipeline |
| 15 | + |
| 16 | +1. **Create a parser** in `sync_ai_rules/parsers/`: |
11 | 17 |
|
12 | 18 | ```python |
13 | | -from sync_ai_rules.core.interfaces import InputParser, RuleMetadata |
| 19 | +from sync_ai_rules.core.parser_interface import InputParser |
| 20 | +from sync_ai_rules.core.rule_metadata import RuleMetadata |
14 | 21 |
|
15 | 22 | class YourParser(InputParser): |
16 | 23 | @property |
17 | 24 | def name(self) -> str: |
18 | 25 | return "your-format" |
19 | 26 |
|
20 | | - # Implement required methods... |
21 | | -``` |
| 27 | + @property |
| 28 | + def source_directories(self) -> list[str]: |
| 29 | + return [".your-rules"] # Where to scan |
22 | 30 |
|
23 | | -### Adding New Output Generators |
| 31 | + # Implement can_parse() and parse()... |
| 32 | +``` |
24 | 33 |
|
25 | | -Create a generator class implementing `OutputGenerator` in `sync_ai_rules/generators/`: |
| 34 | +2. **Create a generator** in `sync_ai_rules/generators/`: |
26 | 35 |
|
27 | 36 | ```python |
28 | | -from sync_ai_rules.core.interfaces import OutputGenerator |
| 37 | +from sync_ai_rules.generators.base_generator import BaseGenerator |
29 | 38 |
|
30 | | -class YourGenerator(OutputGenerator): |
| 39 | +class YourGenerator(BaseGenerator): |
31 | 40 | @property |
32 | 41 | def name(self) -> str: |
33 | 42 | return "your-output" |
34 | 43 |
|
35 | | - # Implement required methods... |
36 | | -``` |
| 44 | + def get_section_markers(self) -> tuple[str, str]: |
| 45 | + return ("<your-section>", "</your-section>") |
37 | 46 |
|
38 | | -### Register Your Extensions |
| 47 | + # Implement generate() and _format_rule()... |
| 48 | +``` |
39 | 49 |
|
40 | | -Add them to `sync_ai_rules/plugins.yaml`: |
| 50 | +3. **Register the pipeline** in `sync_ai_rules/plugins.yaml`: |
41 | 51 |
|
42 | 52 | ```yaml |
43 | | -parsers: |
44 | | - - name: your-format |
45 | | - module: your_parser |
46 | | - class: YourParser |
47 | | - |
48 | | -generators: |
49 | | - - name: your-output |
50 | | - module: your_generator |
51 | | - class: YourGenerator |
| 53 | +pipelines: |
| 54 | + - name: your-pipeline |
| 55 | + description: Your pipeline description |
| 56 | + parser: |
| 57 | + module: your_parser |
| 58 | + class: YourParser |
| 59 | + generator: |
| 60 | + module: your_generator |
| 61 | + class: YourGenerator |
52 | 62 | ``` |
| 63 | +
|
| 64 | +Parsers and generators can be reused across multiple pipelines. |
0 commit comments