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(runtime): simplify hasArg with slices.Contains (#362)
fx-kurumiab3e4a73f157
diff --git a/internal/runtime/has_arg_test.go b/internal/runtime/has_arg_test.gonew file mode 100644index 00000000..e6e974f5--- /dev/null+++ b/internal/runtime/has_arg_test.go@@ -0,0 +1,26 @@+package runtime++import "testing"++func TestHasArg(t *testing.T) {+ cases := []struct {+ name string+ values []string+ wanted string+ want bool+ }{+ {name: "nil slice", values: nil, wanted: "--model", want: false},+ {name: "empty slice", values: []string{}, wanted: "--model", want: false},+ {name: "exact match", values: []string{"-p", "--model", "x"}, wanted: "--model", want: true},+ {name: "case sensitive", values: []string{"--Model"}, wanted: "--model", want: false},+ {name: "no prefix match", values: []string{"--model=x"}, wanted: "--model", want: false},+ {name: "empty wanted", values: []string{"a", ""}, wanted: "", want: true},+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ if got := hasArg(tc.values, tc.wanted); got != tc.want {+ t.Fatalf("hasArg(%q, %q) = %v, want %v", tc.values, tc.wanted, got, tc.want)+ }+ })+ }+}diff --git a/internal/runtime/runner.go b/internal/runtime/runner.goindex e14ed10f..d81889ce 100644--- a/internal/runtime/runner.go+++ b/internal/runtime/runner.go@@ -315,12 +315,7 @@ func executorReportedError(adapterResult, raw string) error {}func hasArg(values []string, wanted string) bool {- for _, value := range values {- if value == wanted {- return true- }- }- return false+ return slices.Contains(values, wanted)}// dropArgWithValue removes every occurrence of the given flags together with