From bb3cc0d48afc29e04001bd45cf1bfffee8ce2d06 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Fri, 30 Oct 2026 13:08:12 +0100 Subject: [PATCH] Add time to review prompt and fix highlights Inject the current date and time into code review prompts to give the model reference context for evaluating commit dates, timestamps, and other time- sensitive data. Additionally, update UI highlight configuration to only mark colors as custom when their value differs from the default, preventing default colors from overriding existing highlights. Assisted-by: Gemini 3.8 Flash Signed-off-by: Jakub Jelen --- python3/vimini/agent/review.py | 15 +++++++++++++++ python3/vimini/util.py | 19 +++++++++++++------ tests/test_review_agent.py | 19 +++++++++++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/python3/vimini/agent/review.py b/python3/vimini/agent/review.py index c1196fb..1092014 100644 --- a/python3/vimini/agent/review.py +++ b/python3/vimini/agent/review.py @@ -1,4 +1,5 @@ import os +from datetime import datetime import logging import re import json @@ -142,10 +143,23 @@ def _construct_review_prompt( content_source_description, security_focus, max_turns=DEFAULT_MAX_TURNS, + current_time=None, ): """ Constructs the prompt for the review. """ + if current_time is None: + current_time_str = datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S %z") + elif isinstance(current_time, datetime): + current_time_str = current_time.astimezone().strftime("%Y-%m-%d %H:%M:%S %z") + else: + current_time_str = str(current_time) + + time_instruction = ( + f"The current date and time is {current_time_str}. " + "Use this as the reference for the current time when evaluating timestamps, commit dates, or other time-sensitive context." + ) + if security_focus: review_instructions = ( f"Please review {content_source_description} exclusively for potential security issues or hazards. " @@ -168,6 +182,7 @@ def _construct_review_prompt( ) prompt_text = ( + f"{time_instruction}\n\n" f"{review_instructions}\n\n" f"{tools_guideline}\n\n" "--- CONTENT TO REVIEW ---\n" diff --git a/python3/vimini/util.py b/python3/vimini/util.py index 86fb234..5591fef 100644 --- a/python3/vimini/util.py +++ b/python3/vimini/util.py @@ -287,25 +287,32 @@ def _build_highlight_command(group, color_val, is_custom, extra=""): attrs = f"ctermfg={color_val} guifg={color_val} {extra}".strip() return f"highlight {default_clause}{group} {attrs}" + def _is_custom(field): + return ( + field in ui_cfg + and bool(ui_cfg[field]) + and ui_cfg[field] != DEFAULT_UI_CONFIG.get(field) + ) + thinking_color = ui_cfg.get("thinking_color") or DEFAULT_UI_CONFIG["thinking_color"] - is_custom_thinking = "thinking_color" in ui_cfg and bool(ui_cfg["thinking_color"]) + is_custom_thinking = _is_custom("thinking_color") prompt_color = ui_cfg.get("prompt_color") or DEFAULT_UI_CONFIG["prompt_color"] - is_custom_prompt = "prompt_color" in ui_cfg and bool(ui_cfg["prompt_color"]) + is_custom_prompt = _is_custom("prompt_color") waiting_color = ui_cfg.get("waiting_color") or DEFAULT_UI_CONFIG["waiting_color"] - is_custom_waiting = "waiting_color" in ui_cfg and bool(ui_cfg["waiting_color"]) + is_custom_waiting = _is_custom("waiting_color") service_color = ui_cfg.get("service_color") or DEFAULT_UI_CONFIG["service_color"] - is_custom_service = "service_color" in ui_cfg and bool(ui_cfg["service_color"]) + is_custom_service = _is_custom("service_color") error_color = ui_cfg.get("error_color") or DEFAULT_UI_CONFIG["error_color"] - is_custom_error = "error_color" in ui_cfg and bool(ui_cfg["error_color"]) + is_custom_error = _is_custom("error_color") prompt_hint_color = ( ui_cfg.get("prompt_hint_color") or DEFAULT_UI_CONFIG["prompt_hint_color"] ) - is_custom_hint = "prompt_hint_color" in ui_cfg and bool(ui_cfg["prompt_hint_color"]) + is_custom_hint = _is_custom("prompt_hint_color") cmds = [ _build_highlight_command("ViminiWaiting", waiting_color, is_custom_waiting), diff --git a/tests/test_review_agent.py b/tests/test_review_agent.py index 609628e..fbe507b 100644 --- a/tests/test_review_agent.py +++ b/tests/test_review_agent.py @@ -1,4 +1,5 @@ import sys +from datetime import datetime import os import pytest from unittest.mock import MagicMock, patch, call @@ -263,6 +264,24 @@ def test_construct_review_prompt_max_turns(): assert "maximum limit of 50 tool iterations" in prompt_custom +def test_construct_review_prompt_includes_current_time(): + prompt_custom = _construct_review_prompt( + "Prompt", + "diff", + "buffer", + security_focus=False, + current_time="2026-10-29 14:30:00 +0000", + ) + assert "The current date and time is 2026-10-29 14:30:00 +0000." in prompt_custom + assert "Use this as the reference for the current time" in prompt_custom + + prompt_default = _construct_review_prompt( + "Prompt", "diff", "buffer", security_focus=False + ) + assert "The current date and time is" in prompt_default + assert str(datetime.now().year) in prompt_default + + def test_execute_review_stream_reaches_max_turns(): mock_session = MagicMock() mock_session._check_running.return_value = True