Refactor: Clean up obsolete files and organize codebase structure
This commit removes deprecated modules and reorganizes code into logical directories: Deleted files (superseded by newer systems): - claude_code_server.py (replaced by agent-sdk direct integration) - heartbeat.py (superseded by scheduled_tasks.py) - pulse_brain.py (unused in production) - config/pulse_brain_config.py (obsolete config) Created directory structure: - examples/ (7 example files: example_*.py, demo_*.py) - tests/ (5 test files: test_*.py) Updated imports: - agent.py: Removed heartbeat module and all enable_heartbeat logic - bot_runner.py: Removed heartbeat parameter from Agent initialization - llm_interface.py: Updated deprecated claude_code_server message Preserved essential files: - hooks.py (for future use) - adapters/skill_integration.py (for future use) - All Google integration tools (Gmail, Calendar, Contacts) - GLM provider code (backward compatibility) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
209
tests/test_installation.py
Normal file
209
tests/test_installation.py
Normal file
@@ -0,0 +1,209 @@
|
||||
"""
|
||||
Installation verification script for Windows 11.
|
||||
Tests all core components without making API calls.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_python_version() -> bool:
|
||||
"""Check Python version is 3.8+."""
|
||||
version = sys.version_info
|
||||
if version.major >= 3 and version.minor >= 8:
|
||||
print(f" Python {version.major}.{version.minor}.{version.micro}")
|
||||
return True
|
||||
print(f" [FAIL] Python {version.major}.{version.minor} is too old")
|
||||
print(" Please install Python 3.8 or higher")
|
||||
return False
|
||||
|
||||
|
||||
def test_imports() -> bool:
|
||||
"""Test all required imports."""
|
||||
required_modules = [
|
||||
("anthropic", "Anthropic SDK"),
|
||||
("requests", "Requests"),
|
||||
("watchdog", "Watchdog"),
|
||||
]
|
||||
|
||||
optional_modules = [
|
||||
("slack_bolt", "Slack Bolt (for Slack adapter)"),
|
||||
("telegram", "python-telegram-bot (for Telegram adapter)"),
|
||||
("yaml", "PyYAML"),
|
||||
]
|
||||
|
||||
all_ok = True
|
||||
|
||||
print("\nRequired modules:")
|
||||
for module_name, display_name in required_modules:
|
||||
try:
|
||||
__import__(module_name)
|
||||
print(f" {display_name}")
|
||||
except ImportError:
|
||||
print(f" [FAIL] {display_name} not installed")
|
||||
all_ok = False
|
||||
|
||||
print("\nOptional modules:")
|
||||
for module_name, display_name in optional_modules:
|
||||
try:
|
||||
__import__(module_name)
|
||||
print(f" {display_name}")
|
||||
except ImportError:
|
||||
print(f" [SKIP] {display_name} (optional)")
|
||||
|
||||
return all_ok
|
||||
|
||||
|
||||
def test_core_modules() -> bool:
|
||||
"""Test core ajarbot modules can be imported."""
|
||||
core_modules = [
|
||||
"agent",
|
||||
"memory_system",
|
||||
"llm_interface",
|
||||
"pulse_brain",
|
||||
"scheduled_tasks",
|
||||
"heartbeat",
|
||||
"hooks",
|
||||
]
|
||||
|
||||
all_ok = True
|
||||
print("\nCore modules:")
|
||||
for module_name in core_modules:
|
||||
try:
|
||||
__import__(module_name)
|
||||
print(f" {module_name}.py")
|
||||
except Exception as e:
|
||||
print(f" [FAIL] {module_name}.py: {e}")
|
||||
all_ok = False
|
||||
|
||||
return all_ok
|
||||
|
||||
|
||||
def test_file_structure() -> bool:
|
||||
"""Check required files and directories exist."""
|
||||
required_paths = [
|
||||
("agent.py", "file"),
|
||||
("memory_system.py", "file"),
|
||||
("llm_interface.py", "file"),
|
||||
("pulse_brain.py", "file"),
|
||||
("bot_runner.py", "file"),
|
||||
("requirements.txt", "file"),
|
||||
("adapters", "dir"),
|
||||
("config", "dir"),
|
||||
("docs", "dir"),
|
||||
]
|
||||
|
||||
all_ok = True
|
||||
print("\nProject structure:")
|
||||
for path_str, path_type in required_paths:
|
||||
path = Path(path_str)
|
||||
if path_type == "file":
|
||||
exists = path.is_file()
|
||||
else:
|
||||
exists = path.is_dir()
|
||||
|
||||
if exists:
|
||||
print(f" {path_str}")
|
||||
else:
|
||||
print(f" [FAIL] {path_str} not found")
|
||||
all_ok = False
|
||||
|
||||
return all_ok
|
||||
|
||||
|
||||
def test_environment() -> bool:
|
||||
"""Check environment variables."""
|
||||
import os
|
||||
|
||||
print("\nEnvironment variables:")
|
||||
|
||||
api_key = os.getenv("ANTHROPIC_API_KEY")
|
||||
if api_key:
|
||||
masked = api_key[:10] + "..." + api_key[-4:]
|
||||
print(f" ANTHROPIC_API_KEY: {masked}")
|
||||
else:
|
||||
print(" [WARN] ANTHROPIC_API_KEY not set")
|
||||
print(" You'll need to set this before running examples")
|
||||
|
||||
glm_key = os.getenv("GLM_API_KEY")
|
||||
if glm_key:
|
||||
print(" GLM_API_KEY: set (optional)")
|
||||
else:
|
||||
print(" [INFO] GLM_API_KEY not set (optional)")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def test_memory_workspace() -> bool:
|
||||
"""Check or create memory workspace."""
|
||||
workspace = Path("memory_workspace")
|
||||
|
||||
print("\nMemory workspace:")
|
||||
if workspace.exists():
|
||||
print(f" memory_workspace/ exists")
|
||||
|
||||
db_file = workspace / "memory.db"
|
||||
if db_file.exists():
|
||||
size_mb = db_file.stat().st_size / 1024 / 1024
|
||||
print(f" Database size: {size_mb:.2f} MB")
|
||||
else:
|
||||
print(" [INFO] memory_workspace/ will be created on first run")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Run all tests."""
|
||||
print("=" * 60)
|
||||
print("Ajarbot Installation Verification")
|
||||
print("=" * 60)
|
||||
|
||||
tests = [
|
||||
("Python version", test_python_version),
|
||||
("Dependencies", test_imports),
|
||||
("Core modules", test_core_modules),
|
||||
("File structure", test_file_structure),
|
||||
("Environment", test_environment),
|
||||
("Memory workspace", test_memory_workspace),
|
||||
]
|
||||
|
||||
results = {}
|
||||
for test_name, test_func in tests:
|
||||
print(f"\n[TEST] {test_name}")
|
||||
try:
|
||||
results[test_name] = test_func()
|
||||
except Exception as e:
|
||||
print(f" [ERROR] {e}")
|
||||
results[test_name] = False
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("Summary")
|
||||
print("=" * 60)
|
||||
|
||||
passed = sum(1 for result in results.values() if result)
|
||||
total = len(results)
|
||||
|
||||
for test_name, result in results.items():
|
||||
status = "PASS" if result else "FAIL"
|
||||
print(f" [{status}] {test_name}")
|
||||
|
||||
print(f"\nPassed: {passed}/{total}")
|
||||
|
||||
if passed == total:
|
||||
print("\nAll tests passed!")
|
||||
print("\nNext steps:")
|
||||
print(" 1. Set ANTHROPIC_API_KEY if not already set")
|
||||
print(" 2. Run: python example_usage.py")
|
||||
print(" 3. See docs/WINDOWS_DEPLOYMENT.md for more options")
|
||||
else:
|
||||
print("\nSome tests failed. Please:")
|
||||
print(" 1. Ensure Python 3.8+ is installed")
|
||||
print(" 2. Run: pip install -r requirements.txt")
|
||||
print(" 3. Check you're in the correct directory")
|
||||
print(" 4. See docs/WINDOWS_DEPLOYMENT.md for help")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user