# Install or update the Grok side of the agent loop on Windows. # powershell -NoProfile -ExecutionPolicy Bypass -File install-grok.ps1 install / update + register task # powershell -NoProfile -ExecutionPolicy Bypass -File install-grok.ps1 -Uninstall remove the scheduled task # ... -RunOnce run one tick now in this window (for the first test) # Copies this folder to %USERPROFILE%\.jyotisha-agent\bin and runs from there, # because each tick checks out other branches in the loop worktree. # ASCII only (see grok-tick.ps1). param([switch]$Uninstall, [switch]$RunOnce) $ErrorActionPreference = 'Stop' $TaskName = 'JyotishaAgentGrokTick' $Src = Split-Path -Parent $MyInvocation.MyCommand.Path $Bin = Join-Path $HOME '.jyotisha-agent\bin' if ($Uninstall) { Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue Write-Host "removed scheduled task $TaskName" exit 0 } if ($Src -ne $Bin) { if (Test-Path $Bin) { Remove-Item -Recurse -Force $Bin } New-Item -ItemType Directory -Force (Split-Path $Bin) | Out-Null Copy-Item -Recurse $Src $Bin Write-Host "copied $Src -> $Bin" } $cfg = Get-Content -Raw -Encoding UTF8 (Join-Path $Bin 'grok-config.json') | ConvertFrom-Json $tokenFile = Join-Path $HOME '.config\jyotisha-agent\gitea-token' if (-not (Test-Path $tokenFile)) { throw "token file missing: $tokenFile" } $token = ([IO.File]::ReadAllText($tokenFile)).Trim() $login = (Invoke-RestMethod -UseBasicParsing -Uri "$($cfg.gitea_url)/api/v1/user" -Headers @{ Authorization = "token $token" }).login Write-Host "gitea user: $login" foreach ($p in @($cfg.repo, $cfg.worktree, $cfg.git_bash_dir, $cfg.grok_exe)) { if (-not (Test-Path $p)) { throw "path from grok-config.json not found: $p" } } if ($RunOnce) { & powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $Bin 'grok-tick.ps1') Get-Content (Join-Path $HOME '.jyotisha-agent\state\grok-tick.log') -Tail 5 exit 0 } $action = New-ScheduledTaskAction -Execute 'powershell.exe' ` -Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$(Join-Path $Bin 'grok-tick.ps1')`"" $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) ` -RepetitionInterval (New-TimeSpan -Minutes $cfg.tick_minutes) $settings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -StartWhenAvailable ` -ExecutionTimeLimit (New-TimeSpan -Hours 2) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger $trigger -Settings $settings ` -Description 'Jyotisha agent loop: Grok executes agent/todo issues' -Force | Out-Null Write-Host "registered ${TaskName}: every $($cfg.tick_minutes) min while you are logged on" Write-Host "pause: create $HOME\.config\jyotisha-agent\STOP log: $HOME\.jyotisha-agent\state\grok-tick.log"