fix: replace sys.path.insert(0) with safe sys.path.append (issue #7)

- Append project root instead of inserting at position 0
- Prevents import shadowing of system packages
- Check for duplicates before adding to sys.path
- Add __init__.py to models package
This commit is contained in:
opencode 2026-07-05 07:02:43 +00:00
parent b25fb3c1c6
commit fde9ab9b39
2 changed files with 5 additions and 2 deletions

View File

@ -8,8 +8,11 @@ import argparse
import os
import sys
# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Ensure project root is in path for direct execution (python main.py)
# Use a set to avoid duplicates and don't insert at position 0 to avoid shadowing
_project_root = os.path.dirname(os.path.abspath(__file__))
if _project_root not in sys.path:
sys.path.append(_project_root)
from cli.commands import handle_command
from cli.parser import parse_args, print_help

0
models/__init__.py Normal file
View File