Files
magpie/internal/cli/slot_help_cli_test.go
T
yetone 55792628ac cli: magpie <agent> --help names the form that gives a tier its own model (KoiLx0 on X)
KoiLx0 could not find how to give Claude Code's opus tier a group of its
own. The CLI already does: `magpie claude opus <model>` (also sonnet,
haiku, fable; Claude Desktop the same; omp's roles as `magpie omp small
<model>`), and `<tier> default` puts it back on the main model. Only the
field list hinted at it, and a bare `magpie claude opus` sets the main
model. agentHelp now prints the form with the tiers or roles it takes.

Run (mote-run, sandbox HOME): a probe wired claude on group/opus, then
opus group/fast, sonnet b/gpt-5.5, haiku a/only-a wrote the three
ANTHROPIC_DEFAULT_*_MODEL lines; `opus nope/zzz` is refused ("not a model
magpie serves"); `--haiku x` is refused as an unknown flag. New
TestAgentHelpNamesTheTierForm, red with the help line switched off.
go test ./internal/cli ./internal/agent; vet darwin, linux nogui, windows.
Not tried: a real Claude Code session on the written tiers.
2026-11-12 21:16:10 +08:00

38 lines
1.2 KiB
Go

package cli
import (
"strings"
"testing"
"github.com/yetone/magpie/internal/agent"
)
// `magpie claude --help` names the form that gives a tier a model of its
// own, which only the field list hinted at (KoiLx0 on X: "magpie claude
// opus xxxx" was tried as if it did not exist). A tier takes a model, a
// flag is refused, and so is a model magpie does not serve.
func TestAgentHelpNamesTheTierForm(t *testing.T) {
groupsHome(t)
t.Setenv("CLAUDE_CONFIG_DIR", "")
a, err := agent.Find("claude")
if err != nil {
t.Fatal(err)
}
h := agentHelp(a)
if !strings.Contains(h, "magpie claude opus <model>") || !strings.Contains(h, "opus, sonnet, haiku, fable") {
t.Fatalf("help lacks the tier form:\n%s", h)
}
if err := run([]string{"claude", "a/m"}); err != nil {
t.Fatal(err)
}
if err := run([]string{"claude", "haiku", "a/only-a"}); err != nil {
t.Fatal(err)
}
if err := run([]string{"claude", "--haiku", "a/only-a"}); err == nil || !strings.Contains(err.Error(), "unknown flag") {
t.Fatalf("a flag: %v", err)
}
if err := run([]string{"claude", "haiku", "nope/zzz"}); err == nil || !strings.Contains(err.Error(), "not a model magpie serves") {
t.Fatalf("an unknown model: %v", err)
}
}