Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
refactor(domain): split command partition and git gate construction out of SplitVerificationGates (#590)
fx-kurumie5cf42e52431
diff --git a/internal/domain/verification.go b/internal/domain/verification.goindex 0d397c52..d7e3e4ac 100644--- a/internal/domain/verification.go+++ b/internal/domain/verification.go@@ -124,17 +124,7 @@ func SplitVerificationGates(gates []VerificationGate) []VerificationGate {out = append(out, gate)continue}- var runCmds, repoCmds []string- for _, command := range gate.Commands {- if strings.TrimSpace(command) == "" {- continue- }- if CommandNeedsRepository(command) {- repoCmds = append(repoCmds, rewriteRepositoryWorkspaceRefs(command))- continue- }- runCmds = append(runCmds, command)- }+ runCmds, repoCmds := partitionGateCommands(gate.Commands)if len(runCmds) == 0 && len(repoCmds) == 0 {out = append(out, gate)continue@@ -154,21 +144,45 @@ func SplitVerificationGates(gates []VerificationGate) []VerificationGate {runGate := gaterunGate.Commands = runCmdsrunGate.ExecutionScope = ExecutionScopeRun- repoGate := gate- baseID := strings.TrimSpace(gate.ID)- if baseID == "" {- baseID = "gate"- }- repoGate.ID = uniqueGateID(baseID+"-git", used)- used[repoGate.ID] = true- if name := strings.TrimSpace(gate.Name); name != "" {- repoGate.Name = name + " · Git 检查"- } else {- repoGate.Name = "Git 检查"- }- repoGate.Commands = repoCmds- repoGate.ExecutionScope = ExecutionScopeRepositories+ repoGate := repositoryGitGate(gate, repoCmds, used)out = append(out, runGate, repoGate)}return out}++// partitionGateCommands drops blank commands and splits the rest into+// run-scoped deliverable checks and repository-scoped git checks. Repository+// commands are rewritten so run-root paths keep resolving from each repo.+func partitionGateCommands(commands []string) (runCmds, repoCmds []string) {+ for _, command := range commands {+ if strings.TrimSpace(command) == "" {+ continue+ }+ if CommandNeedsRepository(command) {+ repoCmds = append(repoCmds, rewriteRepositoryWorkspaceRefs(command))+ continue+ }+ runCmds = append(runCmds, command)+ }+ return runCmds, repoCmds+}++// repositoryGitGate derives the repositories-scoped companion of gate that+// runs repoCmds, reserving its unique "-git" ID in used.+func repositoryGitGate(gate VerificationGate, repoCmds []string, used map[string]bool) VerificationGate {+ repoGate := gate+ baseID := strings.TrimSpace(gate.ID)+ if baseID == "" {+ baseID = "gate"+ }+ repoGate.ID = uniqueGateID(baseID+"-git", used)+ used[repoGate.ID] = true+ if name := strings.TrimSpace(gate.Name); name != "" {+ repoGate.Name = name + " · Git 检查"+ } else {+ repoGate.Name = "Git 检查"+ }+ repoGate.Commands = repoCmds+ repoGate.ExecutionScope = ExecutionScopeRepositories+ return repoGate+}diff --git a/internal/domain/verification_test.go b/internal/domain/verification_test.goindex fc07c9c0..914126aa 100644--- a/internal/domain/verification_test.go+++ b/internal/domain/verification_test.go@@ -78,3 +78,31 @@ func TestCommandNeedsRepository(t *testing.T) {t.Fatal("negated git commands must be repository-scoped")}}++func TestPartitionGateCommandsSkipsBlankAndRewritesRepoCommands(t *testing.T) {+ runCmds, repoCmds := partitionGateCommands([]string{"", " ", "test -f report.md", `git log -1 && test -s fix-report.md`})+ if len(runCmds) != 1 || runCmds[0] != "test -f report.md" {+ t.Fatalf("run commands = %#v", runCmds)+ }+ if len(repoCmds) != 1 || repoCmds[0] != "git log -1 && test -s $AGENTFLOW_WORKSPACE/fix-report.md" {+ t.Fatalf("repo commands = %#v", repoCmds)+ }+ if runCmds, repoCmds := partitionGateCommands(nil); runCmds != nil || repoCmds != nil {+ t.Fatalf("empty input = %#v %#v", runCmds, repoCmds)+ }+}++func TestRepositoryGitGateReservesUniqueIDAndFallsBack(t *testing.T) {+ used := map[string]bool{"fix-git": true}+ gate := repositoryGitGate(VerificationGate{ID: " fix ", Name: " 修复 ", Required: true, ExecutionScope: ""}, []string{"git status"}, used)+ if gate.ID != "fix-git-2" || !used["fix-git-2"] || gate.Name != "修复 · Git 检查" || !gate.Required {+ t.Fatalf("gate = %#v used = %#v", gate, used)+ }+ if gate.ExecutionScope != ExecutionScopeRepositories || len(gate.Commands) != 1 || gate.Commands[0] != "git status" {+ t.Fatalf("gate scope/commands = %#v", gate)+ }+ blank := repositoryGitGate(VerificationGate{}, []string{"git status"}, used)+ if blank.ID != "gate-git" || blank.Name != "Git 检查" || !used["gate-git"] {+ t.Fatalf("blank gate = %#v", blank)+ }+}