"""Read the SHARED vram state logic and CLI args."""
import paramiko

k = paramiko.Ed25519Key.from_private_key_file(r'C:\Users\fabia\.ssh\id_ed25519')
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('192.168.178.150', username='fabian', pkey=k, timeout=10)
sftp = c.open_sftp()

# Read model_management.py around line 440-470 (where SHARED is set)
with sftp.open('/home/fabian/ComfyUI/comfy/model_management.py', 'r') as f:
    mgmt = f.read().decode()
lines = mgmt.split('\n')

print("=== L430-475: VRAM state setting ===")
for i in range(429, min(475, len(lines))):
    print(f"  {i+1}: {lines[i]}")

print("\n=== L750-790: NO_VRAM model loading ===")
for i in range(749, min(790, len(lines))):
    print(f"  {i+1}: {lines[i]}")

print("\n=== L850-870: Smart memory / offload ===")
for i in range(849, min(870, len(lines))):
    print(f"  {i+1}: {lines[i]}")

# Check CLI args for shared memory
with sftp.open('/home/fabian/ComfyUI/comfy/cli_args.py', 'r') as f:
    cli = f.read().decode()

print("\n=== CLI args with 'shared' or 'SHARED' ===")
for i, line in enumerate(cli.split('\n')):
    if 'shared' in line.lower():
        print(f"  L{i+1}: {line.strip()}")

# Check what --gpu-only does
print("\n=== CLI args with 'gpu_only' ===")
for i, line in enumerate(cli.split('\n')):
    if 'gpu_only' in line.lower() or 'gpu-only' in line.lower():
        print(f"  L{i+1}: {line.strip()}")

sftp.close()
c.close()
