gendesign/scripts/start-bot.ps1
lekss361 edc5823622 chore(bots): per-role launcher scripts + move bot pipeline to forgejo MCP
(a) Launcher scripts — больше не экспортировать токен руками:
- scripts/start-bot.ps1 <role> — выставляет per-bot identity + токены (FORGEJO_ACCESS_TOKEN
  для forgejo MCP + FORGEJO_TOKEN для curl-fallback), git-identity, forgejo-bot remote,
  verify, затем запускает claude.
- scripts/start-{analyst,backend,frontend,reviewer,qa}.ps1 — тонкие врапперы.

(b) Bots on forgejo MCP (goern) вместо curl:
- _autonomous_pickup.md: новая секция «Forgejo операции — mcp__forgejo__* (PRIMARY)» с полным
  curl→MCP mapping (list_repo_issues / create_pull_request / merge_pull_request /
  get_pull_request_diff / create_pull_review / add+remove_issue_labels / update_issue /
  issue_state_change / create_issue_comment). curl_forgejo помечен FALLBACK.
- 5 auto-*.md + 5 work-as-*.md: директива «Forgejo API → mcp__forgejo__* tools (mapping в
  _autonomous_pickup); curl только fallback» + указатель на start-bot.ps1.

Gotcha задокументирован: include_org_labels:false на user-репо (lekss361 не org).
Требует: рестарт Claude Code (forgejo MCP eager из .mcp.json) + FORGEJO_ACCESS_TOKEN per-window
(делает start-bot.ps1).
2026-05-30 10:38:10 +03:00

57 lines
2.4 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Launch a Claude Code window pre-configured as a GenDesign autonomous bot.
#
# Usage: .\scripts\start-bot.ps1 reviewer
# roles: analyst | backend | frontend | reviewer | qa
#
# Выставляет per-bot identity + токены (для forgejo MCP И curl-fallback), bot-remote,
# verify, затем запускает `claude`. Внутри окна: /work-as-<role> -> /loop.
#
# Требует: scripts/setup-bot-env.ps1 уже выполнен (FORGEJO_TOKEN_<ROLE>, *_BOTS в User env).
param(
[Parameter(Mandatory = $true)]
[ValidateSet('analyst', 'backend', 'frontend', 'reviewer', 'qa')]
[string]$Role
)
$ErrorActionPreference = 'Stop'
$roleUp = $Role.ToUpper()
$bot = "bot-$Role"
$token = [Environment]::GetEnvironmentVariable("FORGEJO_TOKEN_$roleUp", "User")
if (-not $token) {
Write-Error "FORGEJO_TOKEN_$roleUp не выставлен в User env. Запусти scripts/setup-bot-env.ps1 сначала."
return
}
$url = [Environment]::GetEnvironmentVariable("FORGEJO_URL_BOTS", "User")
$repo = [Environment]::GetEnvironmentVariable("FORGEJO_REPO_BOTS", "User")
# forgejo MCP (goern) читает FORGEJO_ACCESS_TOKEN — MCP-процесс наследует его при старте claude.
$env:FORGEJO_ACCESS_TOKEN = $token
# curl-fallback + in-session pre-flight
$env:FORGEJO_TOKEN = $token
$env:BOT_USERNAME = $bot
$env:FORGEJO_URL = $url
$env:FORGEJO_REPO = $repo
# git identity — иначе commit author = lekss361
$env:GIT_AUTHOR_NAME = $bot
$env:GIT_AUTHOR_EMAIL = "$bot@gendsgn.local"
$env:GIT_COMMITTER_NAME = $bot
$env:GIT_COMMITTER_EMAIL = "$bot@gendsgn.local"
# bot-remote для push audit-log (токен в URL — только локально)
git remote remove forgejo-bot 2>$null | Out-Null
git remote add forgejo-bot "https://$($bot):$token@git.gendsgn.ru/lekss361/gendesign.git"
# verify: PAT принадлежит ожидаемому боту
$me = (curl.exe -sS -H "Authorization: token $token" "$url/api/v1/user" | ConvertFrom-Json).login
if ($me -ne $bot) {
Write-Error "Identity mismatch: PAT принадлежит '$me', ожидался '$bot'. Проверь FORGEJO_TOKEN_$roleUp."
return
}
Write-Host "OK bot=$bot" -ForegroundColor Green
Write-Host "OK forgejo MCP token set (FORGEJO_ACCESS_TOKEN) + git identity + forgejo-bot remote" -ForegroundColor Green
Write-Host ""
Write-Host "В окне Claude (Opus 4.8 для reviewer): /work-as-$Role -> затем /loop" -ForegroundColor Cyan
claude