Skip to content

Commit 3f1b3d0

Browse files
RichardAtCTclaude
andauthored
Clean up test files in main directory (#17)
* refactor: reorganize repository structure into src/, tests/, and docs/ - Move all Python source files to src/ directory - Move all test files to tests/ directory - Move documentation files (MIGRATION_STATUS.md, UPGRADE_PLAN.md) to docs/ - Update all imports to use src. prefix for proper package structure - Update pyproject.toml to reference src package and src.main:run_server - Update Dockerfile to reference src.main:app - Add src/__init__.py for proper package initialization This cleanup improves code organization and follows Python best practices for project structure. * fix: update import in claude_cli.py to use src.auth * fix: correct model support and test validation - Remove Claude 3.x models from CLAUDE_MODELS (not supported by Claude Agent SDK) - Update parameter_validator to use CLAUDE_MODELS constant (single source of truth) - Fix test_basic.py to use supported model (claude-sonnet-4-5-20250929) - Add error detection in tests to properly fail when API returns errors The Claude Agent SDK only supports Claude 4+ models. The tests were incorrectly reporting success when getting error responses because the OpenAI SDK returns errors in the content rather than raising exceptions. * fix: update import path in test_working_directory.py Update import statement to use src.claude_cli path to match the reorganized repository structure. * fix: update imports in test files to use src. prefix - Update test_docker_workspace.sh to import from src.claude_cli - Update test_working_directory.py to import from src.claude_cli - Update test_sdk_migration.py to import from src.constants, src.models, and src.message_adapter - Fix sys.path adjustment in test_working_directory.py to point to parent directory All test files now use the new src/ package structure. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3c08b13 commit 3f1b3d0

26 files changed

Lines changed: 62 additions & 54 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ RUN poetry install --no-root
2929
EXPOSE 8000
3030

3131
# Run the app with Uvicorn (development mode with reload; switch to --no-reload for prod)
32-
CMD ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
32+
CMD ["poetry", "run", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
File renamed without changes.
File renamed without changes.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "OpenAI API-compatible wrapper for Claude Code"
55
authors = ["Richard Atkinson <richardatk01@gmail.com>"]
66
readme = "README.md"
77
license = "MIT"
8-
packages = [{include = "*.py"}]
8+
packages = [{include = "src"}]
99

1010
[tool.poetry.dependencies]
1111
python = "^3.10"
@@ -35,4 +35,4 @@ line-length = 100
3535
target-version = ['py310']
3636

3737
[tool.poetry.scripts]
38-
claude-wrapper = "main:run_server"
38+
claude-wrapper = "src.main:run_server"

src/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Claude Code OpenAI Wrapper - A FastAPI-based OpenAI-compatible API for Claude Code."""
2+
3+
__version__ = "1.0.0"

auth.py renamed to src/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_api_key(self):
2121
"""Get the active API key (environment or runtime-generated)."""
2222
# Try to import runtime_api_key from main module
2323
try:
24-
import main
24+
from src import main
2525
if hasattr(main, 'runtime_api_key') and main.runtime_api_key:
2626
return main.runtime_api_key
2727
except ImportError:

claude_cli.py renamed to src/claude_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, timeout: int = 600000, cwd: Optional[str] = None):
3939
atexit.register(self._cleanup_temp_dir)
4040

4141
# Import auth manager
42-
from auth import auth_manager, validate_claude_code_auth
42+
from src.auth import auth_manager, validate_claude_code_auth
4343

4444
# Validate authentication
4545
is_valid, auth_info = validate_claude_code_auth()

constants.py renamed to src/constants.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
]
4444

4545
# Claude Models
46-
# All currently supported Claude models (as of November 2025)
46+
# Models supported by Claude Agent SDK (as of November 2025)
47+
# NOTE: Claude Agent SDK only supports Claude 4+ models, not Claude 3.x
4748
CLAUDE_MODELS = [
48-
# Claude 4.5 Family (Latest - Fall 2025)
49+
# Claude 4.5 Family (Latest - Fall 2025) - RECOMMENDED
4950
"claude-sonnet-4-5-20250929", # Recommended - best coding model
5051
"claude-haiku-4-5-20251001", # Fast & cheap
5152

@@ -56,10 +57,12 @@
5657
"claude-opus-4-20250514",
5758
"claude-sonnet-4-20250514",
5859

59-
# Claude 3.x Family
60-
"claude-3-7-sonnet-20250219",
61-
"claude-3-5-sonnet-20241022",
62-
"claude-3-5-haiku-20241022",
60+
# Claude 3.x Family - NOT SUPPORTED by Claude Agent SDK
61+
# These models work with Anthropic API but NOT with Claude Code
62+
# Uncomment only if using direct Anthropic API (not Claude Agent SDK)
63+
# "claude-3-7-sonnet-20250219",
64+
# "claude-3-5-sonnet-20241022",
65+
# "claude-3-5-haiku-20241022",
6366
]
6467

6568
# Default model (recommended for most use cases)

main.py renamed to src/main.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
from pydantic import ValidationError
1616
from dotenv import load_dotenv
1717

18-
from models import (
19-
ChatCompletionRequest,
20-
ChatCompletionResponse,
18+
from src.models import (
19+
ChatCompletionRequest,
20+
ChatCompletionResponse,
2121
ChatCompletionStreamResponse,
22-
Choice,
23-
Message,
22+
Choice,
23+
Message,
2424
Usage,
2525
StreamChoice,
2626
ErrorResponse,
2727
ErrorDetail,
2828
SessionInfo,
2929
SessionListResponse
3030
)
31-
from claude_cli import ClaudeCodeCLI
32-
from message_adapter import MessageAdapter
33-
from auth import verify_api_key, security, validate_claude_code_auth, get_claude_code_auth_info
34-
from parameter_validator import ParameterValidator, CompatibilityReporter
35-
from session_manager import session_manager
36-
from rate_limiter import limiter, rate_limit_exceeded_handler, get_rate_limit_for_endpoint, rate_limit_endpoint
37-
from constants import CLAUDE_MODELS, DEFAULT_MODEL, FAST_MODEL, CLAUDE_TOOLS
31+
from src.claude_cli import ClaudeCodeCLI
32+
from src.message_adapter import MessageAdapter
33+
from src.auth import verify_api_key, security, validate_claude_code_auth, get_claude_code_auth_info
34+
from src.parameter_validator import ParameterValidator, CompatibilityReporter
35+
from src.session_manager import session_manager
36+
from src.rate_limiter import limiter, rate_limit_exceeded_handler, get_rate_limit_for_endpoint, rate_limit_endpoint
37+
from src.constants import CLAUDE_MODELS, DEFAULT_MODEL, FAST_MODEL, CLAUDE_TOOLS
3838

3939
# Load environment variables
4040
load_dotenv()
@@ -778,7 +778,7 @@ async def debug_request_validation(request: Request):
778778
@rate_limit_endpoint("auth")
779779
async def get_auth_status(request: Request):
780780
"""Get Claude Code authentication status."""
781-
from auth import auth_manager
781+
from src.auth import auth_manager
782782

783783
auth_info = get_claude_code_auth_info()
784784
active_api_key = auth_manager.get_api_key()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List, Optional, Dict, Any
2-
from models import Message
2+
from src.models import Message
33
import re
44

55

0 commit comments

Comments
 (0)