Add missing setup files and add a nice logger

This commit is contained in:
Alex Selimov 2025-06-09 21:22:50 -04:00
parent ed38373d1e
commit 645d329321
7 changed files with 132 additions and 6 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# ReviewLlama
Simple coding agent for double checking PRs before you submit them

19
pyproject.toml Normal file
View File

@ -0,0 +1,19 @@
[project]
name = "reviewllama"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
{ name = "Alex Selimov", email = "alex@alexselimov.com" }
]
requires-python = ">=3.13"
dependencies = [
"rich>=14.0.0",
]
[project.scripts]
reviewllama = "reviewllama:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View File

@ -1,8 +1,10 @@
import argparse import argparse
from typing import List, Optional
from pathlib import Path
import sys import sys
from pathlib import Path
from typing import List, Optional
from .configs import OllamaConfig, ReviewConfig, create_config_from_vars from .configs import OllamaConfig, ReviewConfig, create_config_from_vars
from .logger import log_paths, log_review_start
def normalize_server_url(url: str) -> str: def normalize_server_url(url: str) -> str:
@ -93,9 +95,8 @@ def cli() -> None:
try: try:
config = parse_arguments() config = parse_arguments()
# TODO: Pass config to review engine # TODO: Pass config to review engine
print(f"Reviewing {len(config.paths)} path(s) with model {config.ollama.model}") log_review_start(config)
for path in config.paths: log_paths(config.paths)
print(f" - {path}")
except SystemExit: except SystemExit:
# argparse calls sys.exit on error, let it propagate # argparse calls sys.exit on error, let it propagate
raise raise

View File

@ -1,6 +1,6 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import List
from pathlib import Path from pathlib import Path
from typing import List
@dataclass(frozen=True) @dataclass(frozen=True)

44
src/reviewllama/logger.py Normal file
View File

@ -0,0 +1,44 @@
import sys
from pathlib import Path
from typing import List
from rich.console import Console
from rich.text import Text
from .configs import ReviewConfig
def create_console() -> Console:
"""Create console instance for colored output."""
return Console()
def create_error_console() -> Console:
return Console(stderr=True, style="bold red")
def log_review_start(config: ReviewConfig) -> None:
console = create_console()
"""Log the start of review process with colored output."""
console.print(
f"[bold blue]ReviewLlama[/bold blue] - Starting review of {len(config.paths)} path(s)",
style="bold",
)
console.print(f"[dim]Model:[/dim] [cyan]{config.ollama.model}[/cyan]")
console.print(f"[dim]Server:[/dim] [cyan]{config.ollama.server_url}[/cyan]")
console.print()
def log_paths(paths: List[Path]) -> None:
"""Log the paths being reviewed with colored output."""
console = create_console()
console.print("[bold]Paths to review:[/bold]")
for path in paths:
console.print(f"{path}")
console.print()
def log_error(error: str) -> None:
"""Log error message with colored output."""
console = create_error_console()
console.print(f"Error: {error}")

49
uv.lock generated
View File

@ -2,7 +2,56 @@ version = 1
revision = 1 revision = 1
requires-python = ">=3.13" requires-python = ">=3.13"
[[package]]
name = "markdown-it-py"
version = "3.0.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "mdurl" },
]
sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528 },
]
[[package]]
name = "mdurl"
version = "0.1.2"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979 },
]
[[package]]
name = "pygments"
version = "2.19.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 },
]
[[package]] [[package]]
name = "reviewllama" name = "reviewllama"
version = "0.1.0" version = "0.1.0"
source = { editable = "." } source = { editable = "." }
dependencies = [
{ name = "rich" },
]
[package.metadata]
requires-dist = [{ name = "rich", specifier = ">=14.0.0" }]
[[package]]
name = "rich"
version = "14.0.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "markdown-it-py" },
{ name = "pygments" },
]
sdist = { url = "https://files.pythonhosted.org/packages/a1/53/830aa4c3066a8ab0ae9a9955976fb770fe9c6102117c8ec4ab3ea62d89e8/rich-14.0.0.tar.gz", hash = "sha256:82f1bc23a6a21ebca4ae0c45af9bdbc492ed20231dcb63f297d6d1021a9d5725", size = 224078 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0d/9b/63f4c7ebc259242c89b3acafdb37b41d1185c07ff0011164674e9076b491/rich-14.0.0-py3-none-any.whl", hash = "sha256:1c9491e1951aac09caffd42f448ee3d04e58923ffe14993f6e83068dc395d7e0", size = 243229 },
]