Extract daemon logic from cmd/daemon/ into internal/daemon/ package and create a new unified CLI entry point at cmd/multica/ using cobra. The CLI supports `daemon` as a long-running subcommand plus ctrl subcommands for agent/runtime management, config, status, and version. Server, migrate, and seed binaries remain unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package daemon
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizeServerBaseURL(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got, err := NormalizeServerBaseURL("ws://localhost:8080/ws")
|
|
if err != nil {
|
|
t.Fatalf("NormalizeServerBaseURL returned error: %v", err)
|
|
}
|
|
if got != "http://localhost:8080" {
|
|
t.Fatalf("expected http://localhost:8080, got %s", got)
|
|
}
|
|
}
|
|
|
|
func TestResolveTaskWorkdirUsesRepoPathWhenPresent(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
root := t.TempDir()
|
|
repoPath := filepath.Join(root, "repo")
|
|
if err := os.Mkdir(repoPath, 0o755); err != nil {
|
|
t.Fatalf("mkdir repo: %v", err)
|
|
}
|
|
|
|
got, err := ResolveTaskWorkdir(root, &RepoRef{Path: "repo"})
|
|
if err != nil {
|
|
t.Fatalf("ResolveTaskWorkdir returned error: %v", err)
|
|
}
|
|
if got != repoPath {
|
|
t.Fatalf("expected %s, got %s", repoPath, got)
|
|
}
|
|
}
|
|
|
|
func TestBuildPromptIncludesIssueAndSkills(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
prompt := BuildPrompt(Task{
|
|
Context: TaskContext{
|
|
Issue: IssueContext{
|
|
Title: "Fix failing test",
|
|
Description: "Investigate and fix the test failure.",
|
|
AcceptanceCriteria: []string{"tests pass"},
|
|
ContextRefs: []string{"log snippet"},
|
|
},
|
|
Agent: AgentContext{
|
|
Name: "Local Codex",
|
|
Skills: "Be concise.",
|
|
},
|
|
},
|
|
}, "/tmp/work")
|
|
|
|
for _, want := range []string{"Fix failing test", "Investigate and fix the test failure.", "tests pass", "log snippet", "Be concise."} {
|
|
if !strings.Contains(prompt, want) {
|
|
t.Fatalf("prompt missing %q", want)
|
|
}
|
|
}
|
|
}
|