Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion crates/chat-cli/src/cli/chat/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ use tracing::{
warn,
};

use crate::util::system_info::{
in_wsl,
os_version,
};

use super::consts::{
MAX_CURRENT_WORKING_DIRECTORY_LEN,
MAX_USER_MESSAGE_SIZE,
Expand Down Expand Up @@ -540,8 +545,21 @@ impl From<ToolUse> for AssistantToolUse {
}

pub fn build_env_state() -> EnvState {
// Build a detailed OS description using system_info
let os_description = match os_version() {
Some(version) => {
let base = version.to_string();
if in_wsl() {
format!("{} (WSL - Windows Subsystem for Linux)", base)
} else {
base
}
},
None => env::consts::OS.into(),
};

let mut env_state = EnvState {
operating_system: Some(env::consts::OS.into()),
operating_system: Some(os_description),
..Default::default()
};

Expand Down
4 changes: 2 additions & 2 deletions crates/chat-cli/src/cli/chat/tools/tool_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
},
"execute_bash": {
"name": "execute_bash",
"description": "Execute the specified bash command.",
"description": "Execute the specified shell command.\n\nIMPORTANT: Always check the 'operating_system' field in the user's environment context before generating commands.\n\nOS-specific guidance:\n- Windows: Use PowerShell syntax (Get-ChildItem instead of ls, Get-Content instead of cat, New-Item instead of touch, Remove-Item instead of rm, Copy-Item instead of cp, Move-Item instead of mv). Use backslashes for paths or forward slashes. Use $env:VAR for environment variables.\n- Linux/macOS: Use bash/POSIX syntax (ls, cat, touch, rm, cp, mv). Use forward slashes for paths. Use $VAR for environment variables.\n- WSL: The environment is Linux but may interact with Windows paths via /mnt/c/.\n\nNever assume Linux commands will work on Windows or vice versa. When the OS is unclear, ask the user to confirm.",
"input_schema": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Bash command to execute"
"description": "Shell command to execute. Must use syntax appropriate for the user's operating system."
},
"summary": {
"type": "string",
Expand Down