fix: default runtimeDir to workflow directory when not specified#196
fix: default runtimeDir to workflow directory when not specified#196kris-hansen merged 1 commit intomainfrom
Conversation
When --runtime-dir flag is not provided, Claude Code was running in whatever the current working directory happened to be (often a temp folder where the prompt file was written). This caused file write operations to fail or write to unexpected locations. Fix: Default runtimeDir to the workflow file's directory, ensuring Claude Code runs in the project context where allowed_paths are relative to.
PR Analysis
PR Feedback
How to useInstructions
|
| effectiveRuntimeDir = filepath.Dir(file) | ||
| if effectiveRuntimeDir == "." { | ||
| // Get absolute path for current directory | ||
| if cwd, err := os.Getwd(); err == nil { |
There was a problem hiding this comment.
Consider handling the error case when obtaining the current working directory or resolving the absolute path. Logging an error message or providing a fallback could improve robustness. [important]
| effectiveRuntimeDir = absPath | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Add a debug log message in the runWorkflowWithStreamLog function similar to the one in processCmd to maintain consistency in logging when the workflow directory is used as the runtime directory. [medium]
PR Type:
Bug fix
PR Description:
--runtime-dirflag is not provided, default theruntimeDirto the workflow file's directory.allowed_pathsrelative to the project directory.processCmdandrunWorkflowWithStreamLogfunctions.PR Main Files Walkthrough:
files:
cmd/process.go: - Introduced logic to seteffectiveRuntimeDirto the workflow file's directory ifruntimeDiris not specified.effectiveRuntimeDirinstead ofruntimeDir.User Description:
Problem
When
--runtime-dirflag is not provided,runtimeDirstays empty. This caused Claude Code to run in whatever the current working directory was — often a temp folder like/var/folders/jj/.../Twhere the prompt file was written.Debug output showed:
This breaks file operations because
allowed_paths: [., .comanda]are resolved relative to that temp folder, not the project.Solution
Default
runtimeDirto the workflow file's directory when not explicitly specified. This ensures:allowed_pathsresolve correctlyApplied to both process command paths (
processCmdandrunWorkflowWithStreamLog).