[PR #3588] core: add cwd parameter to bash tool for better directory control #10703

Closed
opened 2026-02-16 18:15:26 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3588

State: closed
Merged: No


Summary

  • Add optional cwd parameter to bash tool allowing users to specify working directory for commands
  • Enables running commands in specific subdirectories without needing cd commands
  • Maintains security by restricting access to within project directory
  • Includes comprehensive test coverage and updated documentation

Why this change

Users previously had to use cd commands or absolute paths to run commands in specific directories, which was cumbersome and could lead to working directory confusion. The new cwd parameter provides precise control over command execution location while maintaining the existing security model.

Changes

  • Added cwd parameter to bash tool schema with validation
  • Updated spawn execution to use validated working directory
  • Enhanced documentation with usage examples
  • Added comprehensive test coverage for all scenarios

Summary by CodeRabbit

Release Notes

  • New Features

    • Added working directory parameter for bash commands, enabling execution in specific project directories with validation to ensure commands stay within the project scope.
  • Improvements

    • Enhanced markdown file parsing with centralized error handling and clearer error messages.
  • Documentation

    • Updated command execution guides with examples demonstrating the new working directory functionality.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3588 **State:** closed **Merged:** No --- ## Summary - Add optional `cwd` parameter to bash tool allowing users to specify working directory for commands - Enables running commands in specific subdirectories without needing `cd` commands - Maintains security by restricting access to within project directory - Includes comprehensive test coverage and updated documentation ## Why this change Users previously had to use `cd` commands or absolute paths to run commands in specific directories, which was cumbersome and could lead to working directory confusion. The new `cwd` parameter provides precise control over command execution location while maintaining the existing security model. ## Changes - Added `cwd` parameter to bash tool schema with validation - Updated spawn execution to use validated working directory - Enhanced documentation with usage examples - Added comprehensive test coverage for all scenarios <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added working directory parameter for bash commands, enabling execution in specific project directories with validation to ensure commands stay within the project scope. * **Improvements** * Enhanced markdown file parsing with centralized error handling and clearer error messages. * **Documentation** * Updated command execution guides with examples demonstrating the new working directory functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
yindo added the pull-request label 2026-02-16 18:15:26 -05:00
yindo closed this issue 2026-02-16 18:15:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10703