@echo off
REM Agile Together - powered by AI. Double-click it. Nothing to install: Python
REM travels inside this folder (python\), portable. The first time, it asks for your
REM ProjectAdm token, creates your project and your board, and opens the MENU.
cd /d "%~dp0"
title Agile Together - powered by AI

REM Files that come out of a downloaded .zip carry the Mark of the Web. Windows
REM (SmartScreen / Smart App Control) blocks marked files with "this file may not be
REM safe". Clearing the mark on the folder settles it - and needs no administrator.
REM If the student already unblocked the .zip before extracting, this does nothing.
powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -LiteralPath '%~dp0' -Recurse -Force | Unblock-File" >nul 2>&1

REM 1) The portable Python that came in the package (the normal path).
if exist "python\python.exe" (
  "python\python.exe" bootstrap.py
  goto :saiu
)

REM 2) Package with no python\ folder (an old version, or a .zip that was never
REM    extracted): fall back to the Python on the computer.
where py >nul 2>nul && ( py bootstrap.py & goto :saiu )
where python >nul 2>nul && ( python bootstrap.py & goto :saiu )

echo.
echo  [!] The "python" folder did not come along with these files.
echo.
echo      That usually means the .zip was opened without being extracted. Do this:
echo        1) right-click the .zip file
echo        2) choose "Extract all..."
echo        3) open the extracted folder and click start.bat again
echo.
pause
goto :fim

:saiu
REM DID THE COURSE STOP WITH AN ERROR? THE WINDOW MUST NOT VANISH WITH THE MESSAGE.
REM
REM Until 2026-08-20 there was nothing here: any stop in the bootstrap (a half-filled
REM .env, ProjectAdm down, a refused token) showed the student a black window that
REM OPENED AND CLOSED - no menu, and no chance to read the sentence telling them what
REM to do. That is how the EN package reached Eduardo. That day's bug is fixed; this
REM pause is so the NEXT error, whatever it turns out to be, gets read.
if errorlevel 1 (
  echo.
  echo  ------------------------------------------------------------------
  echo   The course stopped. What happened is written just above.
  echo   Read it, do what it asks and click start.bat again.
  echo   If that does not settle it, screenshot this window and send it to us.
  echo  ------------------------------------------------------------------
  echo.
  pause
)

:fim
