The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): resolve native Git Bash for Windows inline shell
funky-xamarin1a24b851e523
diff --git a/agent/skill_preprocessing.py b/agent/skill_preprocessing.pyindex efa153c3ea7..18d90e9e76c 100644--- a/agent/skill_preprocessing.py+++ b/agent/skill_preprocessing.py@@ -49,8 +49,14 @@ def run_inline_shell(command: str, cwd: Path | None, timeout: int) -> str:_popen_kwargs = {"creationflags": windows_hide_flags()} if IS_WINDOWS else {}from agent.delegation_context import delegated_child_subprocess_envtry:+ bash = "bash"+ if IS_WINDOWS:+ # CreateProcess searches System32 before PATH and may pick WSL's+ # launcher. Reuse the terminal's native Git Bash resolution.+ from tools.environments.local import _find_bash+ bash = _find_bash()completed = subprocess.run(- ["bash", "-c", command],+ [bash, "-c", command],cwd=str(cwd) if cwd else None,capture_output=True,text=True, encoding='utf-8', errors='replace',diff --git a/tests/agent/test_skill_inline_bash_windows.py b/tests/agent/test_skill_inline_bash_windows.pynew file mode 100644index 00000000000..7d8736d57fa--- /dev/null+++ b/tests/agent/test_skill_inline_bash_windows.py@@ -0,0 +1,48 @@+"""Native Windows execution contract for opt-in skill snippets."""+import pytest++from agent.skill_preprocessing import preprocess_skill_content, run_inline_shell++[email protected]_only[email protected](('command', 'expected'), [+ ('printf "hello"', 'hello'),+ (':', ''),+ ('printf "diagnostic" >&2; exit 3', 'diagnostic'),+ ('printf "preferred"; printf "ignored" >&2', 'preferred'),+])+def test_inline_shell_keeps_output_contract(tmp_path, command, expected):+ assert run_inline_shell(command, tmp_path, 5) == expected++[email protected]_only+def test_inline_shell_resolver_failure_is_a_marker(tmp_path, monkeypatch):+ from tools.environments import local++ def unavailable():+ raise RuntimeError('Git Bash unavailable')++ monkeypatch.setattr(local, '_find_bash', unavailable)+ assert run_inline_shell(':', tmp_path, 5) == '[inline-shell error: Git Bash unavailable]'++[email protected]_only+def test_disabled_inline_shell_does_not_resolve_bash(tmp_path, monkeypatch):+ from tools.environments import local++ def unexpected():+ pytest.fail('disabled inline shell must not resolve an interpreter')++ monkeypatch.setattr(local, '_find_bash', unexpected)+ assert preprocess_skill_content('!`printf hello`', tmp_path, skills_cfg={}) == '!`printf hello`'++[email protected]_only+def test_inline_shell_executes_in_native_skill_directory(tmp_path):+ (tmp_path / 'marker.txt').write_text('native-skill', encoding='utf-8')+ result = preprocess_skill_content(+ 'value=!`read -r value < marker.txt; printf "%s" "$value"`',+ tmp_path,+ skills_cfg={'inline_shell': True, 'inline_shell_timeout': 5},+ )+ assert result == 'value=native-skill'