From 645d329321bb086560cf08dbd6dae6b8fab06783 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Mon, 9 Jun 2025 21:22:50 -0400 Subject: [PATCH] Add missing setup files and add a nice logger --- .gitignore | 10 ++++++++ README.md | 3 +++ pyproject.toml | 19 +++++++++++++++ src/reviewllama/cli.py | 11 +++++---- src/reviewllama/configs.py | 2 +- src/reviewllama/logger.py | 44 ++++++++++++++++++++++++++++++++++ uv.lock | 49 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 src/reviewllama/logger.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..505a3b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9e7bcb --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# ReviewLlama + +Simple coding agent for double checking PRs before you submit them diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..18ef4bd --- /dev/null +++ b/pyproject.toml @@ -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" diff --git a/src/reviewllama/cli.py b/src/reviewllama/cli.py index 12afab5..5676e3d 100644 --- a/src/reviewllama/cli.py +++ b/src/reviewllama/cli.py @@ -1,8 +1,10 @@ import argparse -from typing import List, Optional -from pathlib import Path import sys +from pathlib import Path +from typing import List, Optional + from .configs import OllamaConfig, ReviewConfig, create_config_from_vars +from .logger import log_paths, log_review_start def normalize_server_url(url: str) -> str: @@ -93,9 +95,8 @@ def cli() -> None: try: config = parse_arguments() # TODO: Pass config to review engine - print(f"Reviewing {len(config.paths)} path(s) with model {config.ollama.model}") - for path in config.paths: - print(f" - {path}") + log_review_start(config) + log_paths(config.paths) except SystemExit: # argparse calls sys.exit on error, let it propagate raise diff --git a/src/reviewllama/configs.py b/src/reviewllama/configs.py index b4e882d..588be9a 100644 --- a/src/reviewllama/configs.py +++ b/src/reviewllama/configs.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from typing import List from pathlib import Path +from typing import List @dataclass(frozen=True) diff --git a/src/reviewllama/logger.py b/src/reviewllama/logger.py new file mode 100644 index 0000000..f4f188a --- /dev/null +++ b/src/reviewllama/logger.py @@ -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}") diff --git a/uv.lock b/uv.lock index bf575ff..2a77ae8 100644 --- a/uv.lock +++ b/uv.lock @@ -2,7 +2,56 @@ version = 1 revision = 1 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]] name = "reviewllama" version = "0.1.0" 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 }, +]