Skip to content

fix: correct metadata previousDirectory in set_current_directory tool#81

Merged
s2005 merged 2 commits intomainfrom
fix/change_cwd
Feb 24, 2026
Merged

fix: correct metadata previousDirectory in set_current_directory tool#81
s2005 merged 2 commits intomainfrom
fix/change_cwd

Conversation

@s2005
Copy link
Copy Markdown
Owner

@s2005 s2005 commented Feb 24, 2026

Summary

  • Fixed bug where previousDirectory metadata was set to the requested path instead of the actual previous working directory
  • Added comprehensive test coverage (20 tests) for set_current_directory tool

Bug Fix

Before: The previousDirectory field in the response metadata was incorrectly set to args.path (the requested path).

After: The previousDirectory now correctly contains serverActiveCwd (the actual previous directory before the change).

Test Coverage

Added 20 comprehensive tests covering:

  • Path validation (exact match, subdirectory, rejection, similar prefix, multiple paths, trailing slash, case sensitivity)
  • restrictWorkingDirectory = false scenarios
  • Empty allowedPaths scenarios
  • process.chdir() failure handling (state consistency, permission denied)
  • Path normalization (Git Bash, WSL, forward slashes)
  • State management (sequential changes)
  • Metadata structure verification

Test Results

All 796 tests pass (806 total, 10 skipped)

🤖 Generated with Claude Code

s2005 and others added 2 commits February 24, 2026 18:52
- Fixed bug where previousDirectory metadata was set to requested path
  instead of the actual previous working directory
- Added comprehensive test coverage (20 tests) for set_current_directory
  including path validation, normalization, state management, and metadata
- Tests cover edge cases: chdir failures, empty allowedPaths,
  restrictWorkingDirectory=false, Git Bash/WSL paths, and more

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Fixed set_current_directory metadata bug (previousDirectory now returns actual previous directory)
- Added comprehensive test coverage (20 tests)
- Updated changelog with version 1.2.3 entry

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@s2005 s2005 merged commit 3acd5ac into main Feb 24, 2026
3 checks passed
@s2005 s2005 deleted the fix/change_cwd branch February 24, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant