36 lines
920 B
Python
36 lines
920 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
class RulesLoader:
|
|
"""프로젝트 규칙 파일(RULES.md)을 로드합니다."""
|
|
|
|
@staticmethod
|
|
def load_rules(project_root: Path | None = None) -> str:
|
|
"""프로젝트 루트에서 RULES.md를 찾아 내용을 반환합니다.
|
|
|
|
탐색 순서:
|
|
1. {project_root}/RULES.md
|
|
2. {project_root}/.claude/RULES.md
|
|
|
|
Args:
|
|
project_root: 프로젝트 루트 디렉토리. None이면 빈 문자열 반환.
|
|
|
|
Returns:
|
|
RULES.md 내용 또는 빈 문자열.
|
|
"""
|
|
if project_root is None:
|
|
return ""
|
|
|
|
candidates = [
|
|
project_root / "RULES.md",
|
|
project_root / ".claude" / "RULES.md",
|
|
]
|
|
|
|
for path in candidates:
|
|
if path.is_file():
|
|
return path.read_text(encoding="utf-8")
|
|
|
|
return ""
|