diff --git a/CHANGELOG.md b/CHANGELOG.md index 98415cbf..78f36483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Show the opening turn in `list-cases` for multi-turn cases and keep multiline + prompt previews on a single row. A simulated opening turn is labelled. - `skill-up run --dry-run` now prints the planned case executions as cases times configurations times iterations. A benchmark over four cases with `--iteration 5` previously reported only `Would run 4 case(s)` for 40 diff --git a/internal/cli/command_integration_test.go b/internal/cli/command_integration_test.go index 38c78399..602350fe 100644 --- a/internal/cli/command_integration_test.go +++ b/internal/cli/command_integration_test.go @@ -459,6 +459,21 @@ func TestListCasesCommandRunEPrintsDefaultsAndTruncatesPrompt(t *testing.T) { } } +func TestListCasesShowsMultilineOpeningTurnOnOneRow(t *testing.T) { + root := t.TempDir() + writeAutoModeSkill(t, root) + writeAutoModeEvalYAML(t, root, "conversation") + writeSkillFile(t, root, "evals/cases/conversation.yaml", "id: conversation\ninput:\n turns:\n - role: user\n content: |\n Read this file.\n Summarize it.\n") + cmd := &cobra.Command{} + cmd.SetContext(t.Context()) + output, err := captureStdout(t, func() error { + return listCasesCmd.RunE(cmd, []string{filepath.Join(root, "evals", "eval.yaml")}) + }) + if err != nil || !strings.Contains(output, "Read this file. Summarize it.") || strings.Count(strings.TrimSpace(output), "\n") != 1 { + t.Fatalf("list-cases output = %q, err = %v", output, err) + } +} + func TestListCasesCommandRunEPreservesUnicodePrompt(t *testing.T) { root := t.TempDir() writeAutoModeSkill(t, root) diff --git a/internal/cli/listcases.go b/internal/cli/listcases.go index b904c1e6..486db4fa 100644 --- a/internal/cli/listcases.go +++ b/internal/cli/listcases.go @@ -3,6 +3,7 @@ package cli import ( "fmt" "os" + "strings" "text/tabwriter" "github.com/spf13/cobra" @@ -40,12 +41,7 @@ var listCasesCmd = &cobra.Command{ if tag == "" { tag = "functional_test" } - const promptPreviewLen = 50 - promptPreview := c.Input.Prompt - if previewRunes := []rune(promptPreview); len(previewRunes) > promptPreviewLen { - promptPreview = string(previewRunes[:promptPreviewLen-3]) + "..." - } - _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", c.ID, title, tag, promptPreview) + _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", c.ID, title, tag, promptPreview(c.Input)) } _ = w.Flush() @@ -53,3 +49,20 @@ var listCasesCmd = &cobra.Command{ return nil }, } + +func promptPreview(input config.Input) string { + const maxRunes = 50 + text := input.Prompt + if text == "" && len(input.Turns) > 0 { + first := input.Turns[0] + text = first.Content + if first.Respond != "" { + text = "[simulated] " + first.Respond + } + } + text = strings.Join(strings.Fields(text), " ") + if runes := []rune(text); len(runes) > maxRunes { + return string(runes[:maxRunes-3]) + "..." + } + return text +} diff --git a/internal/cli/listcases_test.go b/internal/cli/listcases_test.go index 0e634ad9..11a8f6dd 100644 --- a/internal/cli/listcases_test.go +++ b/internal/cli/listcases_test.go @@ -7,6 +7,13 @@ import ( "github.com/alibaba/skill-up/internal/config" ) +func TestPromptPreviewLabelsSimulatedOpeningTurn(t *testing.T) { + input := config.Input{Turns: []config.Turn{{Respond: "Ask about the result"}}} + if got := promptPreview(input); got != "[simulated] Ask about the result" { + t.Fatalf("promptPreview = %q", got) + } +} + func TestListCasesCommand_ValidConfig(t *testing.T) { if _, err := os.Stat(testEvalPath); os.IsNotExist(err) { t.Skip("examples/code-stats/evals/eval.yaml not found")