tools(agent-loop): copse onboarding, PR/merge/runs commands, trusted claude-agent/grok-agent accounts
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Ad9rqAB8pXXvyzh7f4X8v
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
358a41fe52
commit
05f8800531
@@ -4,18 +4,25 @@
|
||||
# BOM-less scripts as ANSI); Chinese label names arrive as arguments.
|
||||
# gitea.ps1 whoami
|
||||
# gitea.ps1 issues <label1,label2> open issues carrying ALL labels, oldest first (JSON)
|
||||
# gitea.ps1 issue <N> number, title, body (body only if written by the owner)
|
||||
# gitea.ps1 issue <N> number, title, body (body only if written by a trusted account)
|
||||
# gitea.ps1 labels <N> label names, one per line
|
||||
# gitea.ps1 add-label <N> <name>
|
||||
# gitea.ps1 remove-label <N> <name>
|
||||
# gitea.ps1 comments <N> owner's comments only (JSON: created_at, body)
|
||||
# gitea.ps1 comments <N> trusted accounts' comments only (JSON: author, created_at, body)
|
||||
# gitea.ps1 comment <N> <file> post a UTF-8 file as a comment
|
||||
param([Parameter(Mandatory = $true)][string]$Cmd, [string]$A1, [string]$A2)
|
||||
# gitea.ps1 create-pr <branch> <title> <bodyfile> open a PR from <branch> into the repo's default branch; prints its number
|
||||
# gitea.ps1 pr-for-branch <branch> open PR number for <branch> (empty if none)
|
||||
# -Repo selects the repository (default root/Jyotisha), e.g. -Repo root/copse.
|
||||
param([Parameter(Mandatory = $true)][string]$Cmd, [string]$A1, [string]$A2, [string]$A3, [string]$Repo = 'root/Jyotisha')
|
||||
$ErrorActionPreference = 'Stop'
|
||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||
$Utf8 = New-Object Text.UTF8Encoding $false
|
||||
$Base = 'https://git.copse.top/api/v1'
|
||||
$Api = "$Base/repos/root/Jyotisha"
|
||||
if ($Repo -notmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$') { throw "bad -Repo: $Repo" }
|
||||
$Api = "$Base/repos/$Repo"
|
||||
# Accounts whose issue text and comments are trusted: the product owner and the two agents.
|
||||
$Trusted = @('jesse', 'claude-agent', 'grok-agent')
|
||||
if ($env:GITEA_TRUSTED_USERS) { $Trusted = $env:GITEA_TRUSTED_USERS -split ',' }
|
||||
$Token = ([IO.File]::ReadAllText((Join-Path $HOME '.config\jyotisha-agent\gitea-token'))).Trim()
|
||||
|
||||
function Call([string]$Method, [string]$Url, $Body = $null) {
|
||||
@@ -35,12 +42,16 @@ switch ($Cmd) {
|
||||
'whoami' { Owner }
|
||||
'issues' { Json @(@(Call GET "$Api/issues?state=open&type=issues&limit=50&labels=$([uri]::EscapeDataString($A1))") |
|
||||
Sort-Object created_at | ForEach-Object { [ordered]@{ number = $_.number; title = $_.title; labels = @($_.labels | ForEach-Object { $_.name }) } }) }
|
||||
'issue' { $o = Owner; $i = Call GET "$Api/issues/$A1"
|
||||
Json ([ordered]@{ number = $i.number; title = $i.title; body = $(if ($i.user.login -eq $o) { $i.body } else { '' }) }) }
|
||||
'issue' { $i = Call GET "$Api/issues/$A1"
|
||||
Json ([ordered]@{ number = $i.number; title = $i.title; body = $(if ($Trusted -contains $i.user.login) { $i.body } else { '' }) }) }
|
||||
'labels' { @(Call GET "$Api/issues/$A1/labels") | ForEach-Object { $_.name } }
|
||||
'add-label' { Call POST "$Api/issues/$A1/labels" @{ labels = @($A2) } | Out-Null; "added $A2" }
|
||||
'remove-label' { $id = LabelId $A2; if ($id -and (@(Call GET "$Api/issues/$A1/labels") | Where-Object { $_.id -eq $id })) { Call DELETE "$Api/issues/$A1/labels/$id" | Out-Null }; "removed $A2" }
|
||||
'comments' { $o = Owner; Json @(@(Call GET "$Api/issues/$A1/comments") | Where-Object { $_.user.login -eq $o } | ForEach-Object { [ordered]@{ created_at = $_.created_at; body = $_.body } }) }
|
||||
'comments' { Json @(@(Call GET "$Api/issues/$A1/comments") | Where-Object { $Trusted -contains $_.user.login } | ForEach-Object { [ordered]@{ author = $_.user.login; created_at = $_.created_at; body = $_.body } }) }
|
||||
'comment' { Call POST "$Api/issues/$A1/comments" @{ body = [IO.File]::ReadAllText($A2, [Text.Encoding]::UTF8) } | Out-Null; "commented on #$A1" }
|
||||
'create-pr' { if ($A1 -notmatch '^codex/') { throw 'PR head must be a codex/* branch' }
|
||||
$base = (Call GET $Api).default_branch
|
||||
(Call POST "$Api/pulls" @{ head = $A1; base = $base; title = $A2; body = [IO.File]::ReadAllText($A3, [Text.Encoding]::UTF8) }).number }
|
||||
'pr-for-branch' { (@(Call GET "$Api/pulls?state=open&limit=50") | Where-Object { $_.head.ref -eq $A1 } | Select-Object -First 1).number }
|
||||
default { throw "unknown command: $Cmd" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user