Propagate --explain flag into interactive mode#30
Conversation
Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes interactive mode ignoring the --explain flag by threading the flag through the interactive REPL entrypoint and down into system-prompt construction and command execution, matching single-shot behavior.
Changes:
- Add an
explain boolparameter tointeractive.Run,replBuildSystemPrompt, andhandleResponse, and pass it through tollm.BuildSystemPromptandexecutor.Run. - Update the interactive branch in
cmd/root.goto passexplainFlagintointeractiveRun. - Update impacted tests/stubs to match the new function signatures.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/interactive/repl.go | Threads explain through the interactive REPL prompt builder and response handling into executor.Run. |
| cmd/root.go | Forwards the Cobra --explain flag into interactive mode via interactiveRun(..., explainFlag). |
| internal/interactive/repl_test.go | Updates handleResponse callsites to include the new explain argument. |
| internal/interactive/repl_run_test.go | Updates REPL hook stubs to match new signatures (prompt builder / response handler). |
| cmd/root_test.go | Updates interactive-mode stubs for interactiveRun to accept the new explain argument. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var capturedCmds interactive.BuiltinCommands | ||
| interactiveRun = func(_ string, cmds interactive.BuiltinCommands, _ *config.Config, _ llm.Client, _ shell.Info) error { | ||
| interactiveRun = func(_ string, cmds interactive.BuiltinCommands, _ *config.Config, _ llm.Client, _ shell.Info, _ bool) error { | ||
| capturedCmds = cmds | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Interactive mode tests stub interactiveRun but never assert that the new explain flag is forwarded. Add/extend a test to set explainFlag=true before runRoot and verify the stub receives explain=true (and similarly verify false by default) so this regression can’t reappear.
There was a problem hiding this comment.
Added TestRunRoot_InteractiveMode_ExplainFlag in commit 8818e5a. It calls runRoot with explainFlag=false and verifies the stub receives false, then again with explainFlag=true and verifies it receives true.
| var promptArgs []string | ||
| replBuildSystemPrompt = func(osName, shellName, shellVersion, cwd string) string { | ||
| replBuildSystemPrompt = func(osName, shellName, shellVersion, cwd string, explain bool) string { | ||
| promptArgs = []string{osName, shellName, shellVersion, cwd} | ||
| return "system-prompt" | ||
| } |
There was a problem hiding this comment.
This test updates the replBuildSystemPrompt signature to accept explain, but it still always calls Run(..., false) and doesn’t assert what explain value was passed into the prompt builder/response handler. Add a case that runs with explain=true and asserts the captured explain argument(s) so interactive mode explain propagation is covered.
There was a problem hiding this comment.
Added TestRun_ExplainFlagPropagated in commit 8818e5a. It calls Run(..., true) and asserts that both replBuildSystemPrompt and replHandleResponse receive explain=true.
- Implement ValidatePath function to ensure paths are within the current working directory and do not match blocked patterns. - Create tests for ValidatePath covering valid paths, paths outside CWD, blocked patterns, and allowed files. - Introduce tools for listing directories, reading files, and checking commands with safety checks. - Add tests for tool execution, including handling of blocked files and large files. - Implement environment variable filtering to redact sensitive information. - Enhance command help functionality with fallbacks for Unix systems. - Add comprehensive tests for all new functionalities to ensure reliability and security.
|
@copilot fix the tests for this biuld. |
Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com>
…uncation handling
--explainwas wired up for single-shot mode but silently ignored in interactive mode:interactive.Runhad no explain parameter,replBuildSystemPrompthardcodedfalse, andhandleResponsepassedfalsetoexecutor.Run.Changes
internal/interactive/repl.go: Addexplain booltoRun,replBuildSystemPrompt, andhandleResponse; thread it through tollm.BuildSystemPromptandexecutor.Runcmd/root.go: PassexplainFlagtointeractiveRunin the interactive branchTestRunRoot_InteractiveMode_ExplainFlagto verifyexplainFlagis forwarded correctly (bothtrueandfalse) tointeractiveRun; addTestRun_ExplainFlagPropagatedto verifyexplain=truereaches bothreplBuildSystemPromptandreplHandleResponseinside the REPL loop💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.