feat: add --keep-workspace flag for debugging #123#217
Merged
Conversation
Add --keep-workspace flag to 'waza run' that preserves temp workspaces after execution, allowing users to inspect fixture files and agent modifications for debugging. Changes: - Add WorkspaceKeeper interface (optional, avoids breaking AgentEngine) - CopilotEngine/MockEngine: skip os.RemoveAll when keepWorkspace is set - Print 'Workspace preserved: <path>' to stderr on shutdown - Show workspace path in verbose progress output per-run - Add WorkspaceDir to RunResult model (omitempty for JSON compat) - Propagate workspace_dir in RunComplete progress event - Add 4 dedicated tests (preserve, cleanup, copilot, stderr message) - Update CLI reference docs and README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 3 integration tests in cmd_run_shutdown_test.go: - TestRunSingleModel_KeepWorkspaceFlag: verifies flag works and stderr shows preserved path - TestRunSingleModel_KeepWorkspaceVerbose: verifies --keep-workspace + --verbose combo - TestRunSingleModel_DefaultCleansWorkspace: verifies default behavior has no preservation message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a0622aa to
4c03466
Compare
- Fix gofmt alignment in CopilotEngine struct fields (copilot.go) - Handle w.Close() error returns in shutdown tests (errcheck) - Handle os.RemoveAll() error return in engine shutdown test (errcheck) - Wrap os.WriteFile() calls with error checking in spec_test.go (errcheck) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--keep-workspaceflag towaza runthat preserves temp workspaces after execution, allowing users to inspect fixture files and agent modifications for debugging.Closes #123
Working as Linus (Backend Developer)
Changes
Core
WorkspaceKeeperinterface (internal/execution/engine.go): Optional interface withSetKeepWorkspace(bool)— avoids breaking theAgentEngineinterface contractinternal/execution/copilot.go): Skipsos.RemoveAllwhenkeepWorkspaceis true; printsWorkspace preserved: <path>to stderrinternal/execution/mock.go): Same pattern for test engineModel & Orchestration
RunResult.WorkspaceDir(internal/models/outcome.go): New field (omitemptyfor JSON compat)internal/orchestration/runner.go): PropagatesWorkspaceDirfrom execution response; addsworkspace_dirtoRunCompleteprogress eventCLI
--keep-workspaceflag (cmd/waza/cmd_run.go): Registered as bool flag, wired to engine via type assertioncmd/waza/cmd_run_test.go): ResetkeepWorkspace = falseTests (4 new)
TestMockEngine_KeepWorkspace_PreservesDir— workspace survives shutdownTestMockEngine_DefaultBehavior_CleansUpDir— regression: default still cleans upTestCopilotEngine_KeepWorkspace_PreservesDir— copilot engine workspace survivesTestCopilotEngine_KeepWorkspace_PrintsPath— stderr message verificationWorkspaceKeeperDocs
README.md: Added flag to run command flags tablesite/src/content/docs/reference/cli.mdx: Added flag to table + exampleUsage
Testing
go test ./internal/...passesgo vetclean