import asyncio
import os
import sys
from pathlib import Path
# Ensure project root is on sys.path when running as a script
PROJECT_ROOT = str(Path(__file__).resolve().parents[1])
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from scenecraft_mcp.engine import script_parser, shot_planner
from scenecraft_mcp.models import Scene, Storyboard, StoryStylePreset
from scenecraft_mcp.storage.file_repository import FileStoryboardRepository
from scenecraft_mcp.utils.ids import generate_project_id
from scenecraft_mcp.config import LLM_PROVIDER
TEST_SCRIPT = """
INT. SMALL APARTMENT – NIGHT
A tired programmer sits in front of a glowing laptop.
Lines of code reflect in their glasses.
Their phone buzzes: "Deployment Failed".
They rub their eyes, sigh, and glance at the city lights through the window.
"""
async def main():
print(f"Using LLM provider: {LLM_PROVIDER.value}")
# 1) Parse script into a single scene (for now)
scenes_raw = script_parser.parse_script(TEST_SCRIPT)
scenes: list[Scene] = []
for idx, s in enumerate(scenes_raw, start=1):
print(f"\nPlanning shots for scene {idx}: {s['slugline']}")
shots = await shot_planner.plan_shots(
scene_text=s["raw_text"],
scene_number=idx,
style_preset=StoryStylePreset.YOUTUBE_SHORT,
)
scene = Scene(
scene_number=idx,
slugline=s["slugline"],
summary=s["summary"],
location=s["location"],
time_of_day=s["time_of_day"],
mood=s["mood"],
raw_text=s["raw_text"],
shots=shots,
)
scenes.append(scene)
# 2) Build storyboard and save (optional)
project_id = generate_project_id()
storyboard = Storyboard(project_id=project_id, scenes=scenes)
repo = FileStoryboardRepository()
repo.save_storyboard(storyboard)
# 3) Print results
print(f"\nCreated storyboard {project_id}")
print(f"Total scenes: {len(storyboard.scenes)}")
print(f"Total shots: {storyboard.total_shots}\n")
for scene in storyboard.scenes:
print(f"=== Scene {scene.scene_number}: {scene.slugline} ===")
for shot in scene.shots:
print(
f"- {shot.shot_id} | {shot.type.value} | "
f"{shot.duration_seconds or 'n/a'}s | "
f"hook={shot.is_hook_shot}"
)
print(f" desc: {shot.description}")
if shot.text_overlay_hint:
print(f" overlay: {shot.text_overlay_hint}")
print()
if __name__ == "__main__":
asyncio.run(main())