Skip to content

Conversation

PierrunoYT
Copy link

@PierrunoYT PierrunoYT commented Sep 25, 2025

Summary

This PR fixes PowerShell command syntax issues in the runTerminalCommand tool that were causing AI-generated commands to fail in Windows PowerShell environments.

Problem

  • AI was generating bash-style commands that failed in PowerShell (using && instead of ;)
  • Directory navigation and creation commands were using incorrect syntax
  • Path resolution issues with relative paths
  • Missing platform-specific guidance for command generation

Solution

  • Added getPlatformCommandGuidance() function with comprehensive PowerShell syntax guidance
  • Distinguished between PowerShell (;) vs bash (&&) command chaining
  • Provided both PowerShell aliases (mkdir, ls) and native cmdlets (New-Item, Get-ChildItem)
  • Clarified path navigation support including ./ usage
  • Added platform-specific examples in tool configuration
  • Fixed code formatting inconsistencies (indentation)

Changes Made

  • Platform detection: Added proper PowerShell syntax guidance for Windows
  • Command chaining: Use semicolons (;) instead of && for PowerShell
  • Directory operations: Support both mkdir dir1, dir2 and New-Item -ItemType Directory
  • Path handling: Clarified that both relative and ./ paths work in PowerShell
  • Examples: Added PowerShell-specific examples like Get-ChildItem -Recurse *.js
  • Code quality: Fixed inconsistent indentation in parameters and security evaluation

Testing

Resolves command execution failures in PowerShell environments where bash-style syntax was being generated by AI agents.

🤖 Generated with Claude Code

- Add platform-specific command syntax guidance
- Provide PowerShell-specific examples and instructions
- Distinguish between && (bash) vs ; (PowerShell) for command chaining
- Include proper directory creation syntax for PowerShell
- Update parameter descriptions to be platform-aware
- Add comprehensive PowerShell syntax warnings for AI

Resolves issues where AI generated bash-style commands that failed in PowerShell environment, causing directory navigation and command execution problems.
@PierrunoYT PierrunoYT requested a review from a team as a code owner September 25, 2025 13:21
@PierrunoYT PierrunoYT requested review from Patrick-Erichsen and removed request for a team September 25, 2025 13:21
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 25, 2025
@chezsmithy
Copy link
Contributor

Nice! Curious if you have run this prompt for powershell as a rule and it's working as expected for you?

@PierrunoYT
Copy link
Author

Hello

I could not test it yet. It should rather be marked as WIP. So people
can try and contribute.

@PierrunoYT PierrunoYT changed the title Fix PowerShell command syntax issues in run_terminal_command tool WIP: Fix PowerShell command syntax issues in run_terminal_command tool Sep 25, 2025
…tool

- Fix inconsistent indentation in parameters and evaluateToolCallPolicy
- Clarify that PowerShell redirection operators (> >> < |) do work
- Add native PowerShell cmdlet examples (Get-ChildItem, New-Item, etc.)
- Correct path navigation guidance to include ./ support
- Add PowerShell-specific example with Get-ChildItem -Recurse
- Distinguish between PowerShell aliases vs native cmdlets

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@PierrunoYT
Copy link
Author

@chezsmithy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants