#!/usr/bin/env python
"""Find and modify return statement in _cmd_build_pro_session"""

import sys

def main():
    filepath = r'C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\__init__.py'
    
    with open(filepath, 'r', encoding='utf-8') as f:
        content = f.read()
    
    # Find the function
    func_start = content.find('def _cmd_build_pro_session')
    print(f"Function starts at position: {func_start}")
    
    # Find the pattern for the return statement after samples loaded
    pattern = '"samples loaded: %d across %d scenes"'
    idx = content.find(pattern, func_start)
    print(f"Pattern found at position: {idx}")
    
    if idx > 0:
        # Find the next return statement after this
        ret_idx = content.find('return {', idx)
        print(f"Return statement at position: {ret_idx}")
        
        # Print context
        print("\nContext around return:")
        print(content[ret_idx-200:ret_idx+400])
    
    return 0

if __name__ == '__main__':
    sys.exit(main())
