Skip to content

fix: default runtimeDir to workflow directory when not specified#196

Merged
kris-hansen merged 1 commit intomainfrom
fix/runtimedir-default
Mar 28, 2026
Merged

fix: default runtimeDir to workflow directory when not specified#196
kris-hansen merged 1 commit intomainfrom
fix/runtimedir-default

Conversation

@kris-hansen
Copy link
Copy Markdown
Owner

@kris-hansen kris-hansen commented Mar 28, 2026

PR Type:

Bug fix


PR Description:

  • When the --runtime-dir flag is not provided, default the runtimeDir to the workflow file's directory.
  • Ensures Claude Code runs in the project context rather than a temporary folder.
  • Corrects file operations by resolving allowed_paths relative to the project directory.
  • Applied changes to both processCmd and runWorkflowWithStreamLog functions.

PR Main Files Walkthrough:

files:
  • cmd/process.go: - Introduced logic to set effectiveRuntimeDir to the workflow file's directory if runtimeDir is not specified.
  • Added checks to resolve the directory to an absolute path and handle cases where the directory is the current directory.
  • Updated the processor initialization to use effectiveRuntimeDir instead of runtimeDir.
  • Added debug logging to inform when the workflow directory is used as the runtime directory.

User Description:

Problem

When --runtime-dir flag is not provided, runtimeDir stays empty. This caused Claude Code to run in whatever the current working directory was — often a temp folder like /var/folders/jj/.../T where the prompt file was written.

Debug output showed:

[DEBUG][ClaudeCode] Starting claude command in /var/folders/jj/0fmlymc157b1lwmwt70vb8hc0000gn/T

This breaks file operations because allowed_paths: [., .comanda] are resolved relative to that temp folder, not the project.

Solution

Default runtimeDir to the workflow file's directory when not explicitly specified. This ensures:

  • Claude Code runs in the project context
  • allowed_paths resolve correctly
  • File writes go to the expected location

Applied to both process command paths (processCmd and runWorkflowWithStreamLog).

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.
@preston-ai preston-ai bot added the Bug fix label Mar 28, 2026
@preston-ai
Copy link
Copy Markdown

preston-ai bot commented Mar 28, 2026

PR Analysis

  • 🎯 Main theme: Default the runtime directory to the workflow file's directory when the --runtime-dir flag is not specified.
  • 📝 PR summary: This PR addresses an issue where the runtime directory was not set when the --runtime-dir flag was omitted, causing operations to run in a temporary folder. The solution defaults the runtime directory to the workflow file's directory, ensuring operations occur in the correct project context.
  • 📌 Type of PR: Bug fix
  • 🧪 Relevant tests added: No
  • Focused PR: Yes, because the changes are all related to setting the default runtime directory when it is not specified.
  • ⏱️ Estimated effort to review [1-5]: 2, because the changes are straightforward and primarily involve setting a default directory path.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR effectively addresses the issue of the runtime directory defaulting to an unintended location. It would be beneficial to add tests to ensure this behavior is maintained in future updates.

How to use

Instructions

To invoke the Preston AI, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.

effectiveRuntimeDir = filepath.Dir(file)
if effectiveRuntimeDir == "." {
// Get absolute path for current directory
if cwd, err := os.Getwd(); err == nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@kris-hansen kris-hansen merged commit a001686 into main Mar 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant