From cc53685267ffaafeca460f802c6d092b02c14de9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:51:54 +0000 Subject: [PATCH 1/2] Initial plan From 3d00895a2be92b4b6bb684a09cf3f990fbfc019e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:57:52 +0000 Subject: [PATCH 2/2] Fix TestRunWithExplainTrue assertion and build failure Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com> --- cmd/root.go | 1 + internal/config/config.go | 1 + internal/executor/executor.go | 2 +- internal/executor/executor_test.go | 7 ++++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d82a0b6..20c2ab0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -165,6 +165,7 @@ func runRoot(_ *cobra.Command, args []string) error { return nil }, } + cfg.Explain = explainFlag return interactiveRun(Version, cmds, cfg, client, shellInfo) } diff --git a/internal/config/config.go b/internal/config/config.go index 31613ee..619d4eb 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -22,6 +22,7 @@ type Config struct { Provider ProviderConfig `toml:"provider"` Safety SafetyConfig `toml:"safety"` Debug string `toml:"debug"` // "none", "screen", or "file" + Explain bool `toml:"-"` // runtime-only; set from CLI flag, not persisted } type ProviderConfig struct { diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 514f026..a7722fb 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -44,7 +44,7 @@ func Run(commands []llm.Command, cfg *config.Config, shellInfo shell.Info, expla dimColor.Printf(" %d%% certainty\n", cmd.Certainty) if explain && cmd.Explanation != "" { - dimColor.Printf(" 💡 %s\n", cmd.Explanation) + dimColor.Fprintf(os.Stdout, " 💡 %s\n", cmd.Explanation) } if ShouldConfirm(cmd, cfg) { diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index adeba5c..ae8b60d 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -131,12 +131,13 @@ func TestRunExecutesSafeCommandWithoutConfirmation(t *testing.T) { func TestRunWithExplainTrue(t *testing.T) { cfg := defaultSafetyCfg() + const explanationText = "Unique explanation string that only appears in the explanation output." cmds := []llm.Command{{ - Command: "echo explain-test", + Command: "echo hello", Description: "echo with explanation", Risk: "safe", Certainty: 100, - Explanation: "Prints the text 'explain-test' to stdout.", + Explanation: explanationText, }} // Capture stdout to verify explanation is printed @@ -160,7 +161,7 @@ func TestRunWithExplainTrue(t *testing.T) { t.Fatalf("Run() error = %v, want nil", runErr) } output := buf.String() - if !strings.Contains(output, "explain-test") { + if !strings.Contains(output, explanationText) { t.Errorf("output missing explanation text:\n%s", output) } }