from __future__ import annotations
import json
from pathlib import Path

ROOT = Path(__file__).resolve().parent

required = [
    ROOT / 'suite-catalog.json',
    ROOT / 'portfolio-suite-standalone.ps1',
    ROOT / 'launch-portfolio-suite.bat',
    ROOT / 'VBNET_LAUNCHER_GUIDE.md',
    ROOT / 'launcher-portfolio-suite-vbnet' / 'PortfolioSuiteLauncher.vbproj',
    ROOT / 'launcher-portfolio-suite-vbnet' / 'Program.vb',
    ROOT / 'launcher-portfolio-suite-vbnet' / 'MainForm.vb',
    ROOT / 'launcher-portfolio-suite-vbnet' / 'ProjectItem.vb',
]

for path in required:
    if not path.exists():
        raise SystemExit(f'MISSING: {path}')

catalog = json.loads((ROOT / 'suite-catalog.json').read_text(encoding='utf-8'))
for item in catalog:
    folder = ROOT / item['folder']
    if not folder.exists():
        raise SystemExit(f"MISSING FOLDER: {folder}")
    for script_name in ('demo.ps1', 'open.ps1'):
        script = folder / script_name
        if not script.exists():
            raise SystemExit(f"MISSING SCRIPT: {script}")

print(json.dumps({
    'status': 'ok',
    'projects': len(catalog),
    'launcher': 'vbnet + powershell standalone'
}, indent=2))
