Initial scaffold: API service, K8s operator, and CRDs
Forgebot is a K8s operator + API service for dispatching AI agent jobs from git forge commands. Includes: - CRDs: AgentPool, AgentTask, ProviderQueue, RepositoryBinding - API server with webhook handler, task queue, and comment proxy - Operator controllers for task scheduling and job management - Gitea provider with webhook parsing and signature verification - PostgreSQL database with auto-migration - Woodpecker CI pipelines and multi-stage Dockerfiles
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package models
|
||||
|
||||
import "strings"
|
||||
|
||||
var ValidCommands = map[string]bool{
|
||||
"plan": true,
|
||||
"implement": true,
|
||||
"review": true,
|
||||
"test": true,
|
||||
"fix": true,
|
||||
"retry": true,
|
||||
"cancel": true,
|
||||
}
|
||||
|
||||
type ParsedCommand struct {
|
||||
Name string
|
||||
Args string
|
||||
}
|
||||
|
||||
func ParseCommands(body string) []ParsedCommand {
|
||||
var commands []ParsedCommand
|
||||
for _, line := range strings.Split(body, "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if !strings.HasPrefix(line, "/") {
|
||||
continue
|
||||
}
|
||||
parts := strings.SplitN(line[1:], " ", 2)
|
||||
name := strings.ToLower(parts[0])
|
||||
if !ValidCommands[name] {
|
||||
continue
|
||||
}
|
||||
cmd := ParsedCommand{Name: name}
|
||||
if len(parts) > 1 {
|
||||
cmd.Args = strings.TrimSpace(parts[1])
|
||||
}
|
||||
commands = append(commands, cmd)
|
||||
}
|
||||
return commands
|
||||
}
|
||||
Reference in New Issue
Block a user