Use consistent terminology
Remove test folder from .gitignore for live simulation test to pass
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -165,4 +165,3 @@ test_simulation_files/.claude/
|
|||||||
|
|
||||||
# Temporary test directories
|
# Temporary test directories
|
||||||
test-setup/
|
test-setup/
|
||||||
/test_simulation_files/**
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Validates that:
|
|||||||
4. Docker logs show deduplication behavior
|
4. Docker logs show deduplication behavior
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .base_test import BaseSimulatorTest
|
from .base_test import BaseSimulatorTest
|
||||||
@@ -98,14 +99,17 @@ class PerToolDeduplicationTest(BaseSimulatorTest):
|
|||||||
# Setup test files
|
# Setup test files
|
||||||
self.setup_test_files()
|
self.setup_test_files()
|
||||||
|
|
||||||
# Create a short dummy file for quick testing
|
# Create a short dummy file for quick testing in the current repo
|
||||||
dummy_content = """def add(a, b):
|
dummy_content = """def add(a, b):
|
||||||
return a + b # Missing type hints
|
return a + b # Missing type hints
|
||||||
|
|
||||||
def divide(x, y):
|
def divide(x, y):
|
||||||
return x / y # No zero check
|
return x / y # No zero check
|
||||||
"""
|
"""
|
||||||
dummy_file_path = self.create_additional_test_file("dummy_code.py", dummy_content)
|
# Create the file in the current git repo directory to make it show up in git status
|
||||||
|
dummy_file_path = os.path.join(os.getcwd(), "dummy_code.py")
|
||||||
|
with open(dummy_file_path, "w") as f:
|
||||||
|
f.write(dummy_content)
|
||||||
|
|
||||||
# Get timestamp for log filtering
|
# Get timestamp for log filtering
|
||||||
import datetime
|
import datetime
|
||||||
@@ -162,7 +166,10 @@ def divide(x, y):
|
|||||||
def subtract(a, b):
|
def subtract(a, b):
|
||||||
return a - b
|
return a - b
|
||||||
"""
|
"""
|
||||||
new_file_path = self.create_additional_test_file("new_feature.py", new_file_content)
|
# Create another temp file in the current repo for git changes
|
||||||
|
new_file_path = os.path.join(os.getcwd(), "new_feature.py")
|
||||||
|
with open(new_file_path, "w") as f:
|
||||||
|
f.write(new_file_content)
|
||||||
|
|
||||||
# Continue precommit with both files
|
# Continue precommit with both files
|
||||||
continue_params = {
|
continue_params = {
|
||||||
@@ -249,4 +256,11 @@ def subtract(a, b):
|
|||||||
self.logger.error(f"File deduplication workflow test failed: {e}")
|
self.logger.error(f"File deduplication workflow test failed: {e}")
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
|
# Clean up temp files created in current repo
|
||||||
|
temp_files = ["dummy_code.py", "new_feature.py"]
|
||||||
|
for temp_file in temp_files:
|
||||||
|
temp_path = os.path.join(os.getcwd(), temp_file)
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
os.remove(temp_path)
|
||||||
|
self.logger.debug(f"Removed temp file: {temp_path}")
|
||||||
self.cleanup_test_files()
|
self.cleanup_test_files()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from unittest.mock import Mock
|
|||||||
from providers.base import ModelCapabilities, ProviderType, RangeTemperatureConstraint
|
from providers.base import ModelCapabilities, ProviderType, RangeTemperatureConstraint
|
||||||
|
|
||||||
|
|
||||||
def create_mock_provider(model_name="gemini-2.5-flash-preview-05-20", max_tokens=1_048_576):
|
def create_mock_provider(model_name="gemini-2.5-flash-preview-05-20", context_window=1_048_576):
|
||||||
"""Create a properly configured mock provider."""
|
"""Create a properly configured mock provider."""
|
||||||
mock_provider = Mock()
|
mock_provider = Mock()
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ def create_mock_provider(model_name="gemini-2.5-flash-preview-05-20", max_tokens
|
|||||||
provider=ProviderType.GOOGLE,
|
provider=ProviderType.GOOGLE,
|
||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
friendly_name="Gemini",
|
friendly_name="Gemini",
|
||||||
max_tokens=max_tokens,
|
context_window=context_window,
|
||||||
supports_extended_thinking=False,
|
supports_extended_thinking=False,
|
||||||
supports_system_prompts=True,
|
supports_system_prompts=True,
|
||||||
supports_streaming=True,
|
supports_streaming=True,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async def test_conversation_history_field_mapping():
|
|||||||
provider=ProviderType.GOOGLE,
|
provider=ProviderType.GOOGLE,
|
||||||
model_name="gemini-2.5-flash-preview-05-20",
|
model_name="gemini-2.5-flash-preview-05-20",
|
||||||
friendly_name="Gemini",
|
friendly_name="Gemini",
|
||||||
max_tokens=200000,
|
context_window=200000,
|
||||||
supports_extended_thinking=True,
|
supports_extended_thinking=True,
|
||||||
)
|
)
|
||||||
mock_get_provider.return_value = mock_provider
|
mock_get_provider.return_value = mock_provider
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class TestOpenRouterProvider:
|
|||||||
caps = provider.get_capabilities("unknown-model")
|
caps = provider.get_capabilities("unknown-model")
|
||||||
assert caps.provider == ProviderType.OPENROUTER
|
assert caps.provider == ProviderType.OPENROUTER
|
||||||
assert caps.model_name == "unknown-model"
|
assert caps.model_name == "unknown-model"
|
||||||
assert caps.max_tokens == 32_768 # Safe default
|
assert caps.context_window == 32_768 # Safe default
|
||||||
assert hasattr(caps, "_is_generic") and caps._is_generic is True
|
assert hasattr(caps, "_is_generic") and caps._is_generic is True
|
||||||
|
|
||||||
def test_model_alias_resolution(self):
|
def test_model_alias_resolution(self):
|
||||||
@@ -139,7 +139,7 @@ class TestOpenRouterRegistry:
|
|||||||
caps = registry.get_capabilities("opus")
|
caps = registry.get_capabilities("opus")
|
||||||
assert caps is not None
|
assert caps is not None
|
||||||
assert caps.model_name == "anthropic/claude-3-opus"
|
assert caps.model_name == "anthropic/claude-3-opus"
|
||||||
assert caps.max_tokens == 200000 # Claude's context window
|
assert caps.context_window == 200000 # Claude's context window
|
||||||
|
|
||||||
# Test using full model name
|
# Test using full model name
|
||||||
caps = registry.get_capabilities("anthropic/claude-3-opus")
|
caps = registry.get_capabilities("anthropic/claude-3-opus")
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class TestOpenRouterModelRegistry:
|
|||||||
assert caps.provider == ProviderType.OPENROUTER
|
assert caps.provider == ProviderType.OPENROUTER
|
||||||
assert caps.model_name == "anthropic/claude-3-opus"
|
assert caps.model_name == "anthropic/claude-3-opus"
|
||||||
assert caps.friendly_name == "OpenRouter"
|
assert caps.friendly_name == "OpenRouter"
|
||||||
assert caps.max_tokens == 200000
|
assert caps.context_window == 200000
|
||||||
assert not caps.supports_extended_thinking
|
assert not caps.supports_extended_thinking
|
||||||
|
|
||||||
def test_duplicate_alias_detection(self):
|
def test_duplicate_alias_detection(self):
|
||||||
@@ -147,13 +147,13 @@ class TestOpenRouterModelRegistry:
|
|||||||
os.unlink(temp_path)
|
os.unlink(temp_path)
|
||||||
|
|
||||||
def test_backwards_compatibility_max_tokens(self):
|
def test_backwards_compatibility_max_tokens(self):
|
||||||
"""Test backwards compatibility with old max_tokens field."""
|
"""Test that old max_tokens field is no longer supported (should result in empty registry)."""
|
||||||
config_data = {
|
config_data = {
|
||||||
"models": [
|
"models": [
|
||||||
{
|
{
|
||||||
"model_name": "test/old-model",
|
"model_name": "test/old-model",
|
||||||
"aliases": ["old"],
|
"aliases": ["old"],
|
||||||
"max_tokens": 16384, # Old field name
|
"max_tokens": 16384, # Old field name should cause error
|
||||||
"supports_extended_thinking": False,
|
"supports_extended_thinking": False,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -164,15 +164,12 @@ class TestOpenRouterModelRegistry:
|
|||||||
temp_path = f.name
|
temp_path = f.name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Should gracefully handle the error and result in empty registry
|
||||||
registry = OpenRouterModelRegistry(config_path=temp_path)
|
registry = OpenRouterModelRegistry(config_path=temp_path)
|
||||||
config = registry.resolve("old")
|
# Registry should be empty due to config error
|
||||||
|
assert len(registry.list_models()) == 0
|
||||||
assert config is not None
|
assert len(registry.list_aliases()) == 0
|
||||||
assert config.context_window == 16384 # Should be converted
|
assert registry.resolve("old") is None
|
||||||
|
|
||||||
# Check capabilities still work
|
|
||||||
caps = config.to_capabilities()
|
|
||||||
assert caps.max_tokens == 16384
|
|
||||||
finally:
|
finally:
|
||||||
os.unlink(temp_path)
|
os.unlink(temp_path)
|
||||||
|
|
||||||
@@ -215,7 +212,7 @@ class TestOpenRouterModelRegistry:
|
|||||||
)
|
)
|
||||||
|
|
||||||
caps = config.to_capabilities()
|
caps = config.to_capabilities()
|
||||||
assert caps.max_tokens == 128000
|
assert caps.context_window == 128000
|
||||||
assert caps.supports_extended_thinking
|
assert caps.supports_extended_thinking
|
||||||
assert caps.supports_system_prompts
|
assert caps.supports_system_prompts
|
||||||
assert caps.supports_streaming
|
assert caps.supports_streaming
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class TestGeminiProvider:
|
|||||||
|
|
||||||
assert capabilities.provider == ProviderType.GOOGLE
|
assert capabilities.provider == ProviderType.GOOGLE
|
||||||
assert capabilities.model_name == "gemini-2.5-flash-preview-05-20"
|
assert capabilities.model_name == "gemini-2.5-flash-preview-05-20"
|
||||||
assert capabilities.max_tokens == 1_048_576
|
assert capabilities.context_window == 1_048_576
|
||||||
assert capabilities.supports_extended_thinking
|
assert capabilities.supports_extended_thinking
|
||||||
|
|
||||||
def test_get_capabilities_pro_model(self):
|
def test_get_capabilities_pro_model(self):
|
||||||
@@ -165,7 +165,7 @@ class TestOpenAIProvider:
|
|||||||
|
|
||||||
assert capabilities.provider == ProviderType.OPENAI
|
assert capabilities.provider == ProviderType.OPENAI
|
||||||
assert capabilities.model_name == "o3-mini"
|
assert capabilities.model_name == "o3-mini"
|
||||||
assert capabilities.max_tokens == 200_000
|
assert capabilities.context_window == 200_000
|
||||||
assert not capabilities.supports_extended_thinking
|
assert not capabilities.supports_extended_thinking
|
||||||
|
|
||||||
def test_validate_model_names(self):
|
def test_validate_model_names(self):
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ from typing import Any, Literal, Optional
|
|||||||
from mcp.types import TextContent
|
from mcp.types import TextContent
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
# Conservative fallback for token limits
|
|
||||||
DEFAULT_CONTEXT_WINDOW = 200_000
|
|
||||||
from prompts.tool_prompts import PRECOMMIT_PROMPT
|
from prompts.tool_prompts import PRECOMMIT_PROMPT
|
||||||
from utils.file_utils import translate_file_paths, translate_path_for_environment
|
from utils.file_utils import translate_file_paths, translate_path_for_environment
|
||||||
from utils.git_utils import find_git_repositories, get_git_status, run_git_command
|
from utils.git_utils import find_git_repositories, get_git_status, run_git_command
|
||||||
@@ -24,6 +22,9 @@ from utils.token_utils import estimate_tokens
|
|||||||
from .base import BaseTool, ToolRequest
|
from .base import BaseTool, ToolRequest
|
||||||
from .models import ToolOutput
|
from .models import ToolOutput
|
||||||
|
|
||||||
|
# Conservative fallback for token limits
|
||||||
|
DEFAULT_CONTEXT_WINDOW = 200_000
|
||||||
|
|
||||||
|
|
||||||
class PrecommitRequest(ToolRequest):
|
class PrecommitRequest(ToolRequest):
|
||||||
"""Request model for precommit tool"""
|
"""Request model for precommit tool"""
|
||||||
|
|||||||
Reference in New Issue
Block a user