| from pathlib import Path | |
| from backend.database.schemas import Chunk | |
| def chunk_generic_file(path: Path, repo_root: Path, repo_id: str) -> list[Chunk]: | |
| text = path.read_text(encoding="utf-8", errors="ignore") | |
| lines = text.splitlines() | |
| rel = path.relative_to(repo_root).as_posix() | |
| return [ | |
| Chunk( | |
| id=f"{repo_id}:{rel}:1", | |
| repo_id=repo_id, | |
| path=rel, | |
| language=path.suffix.lower().lstrip(".") or "text", | |
| start_line=1, | |
| end_line=max(1, len(lines)), | |
| content=text, | |
| ) | |
| ] | |