From 531a486f73b2b05c0e6cac551e2b86aed180bf81 Mon Sep 17 00:00:00 2001 From: Sergio Sisternes Date: Tue, 28 Apr 2026 15:34:13 +0100 Subject: [PATCH] fix: use POSIX paths in auto-discovery CLI output for Windows compat On Windows, Path.__str__() produces backslash separators, causing format_auto_discovery_message and the script_runner print statement to output paths like 'prompts\hello.md' instead of 'prompts/hello.md'. This broke two tests in test_script_formatters.py on the Windows CI job. Use Path.as_posix() in all three f-string interpolation sites in script_formatters.py and the direct print in script_runner.py to ensure consistent forward-slash output across all platforms. Fixes CI/CD Pipeline failure on windows-latest (run 25036652822). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/apm_cli/core/script_runner.py | 2 +- src/apm_cli/output/script_formatters.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apm_cli/core/script_runner.py b/src/apm_cli/core/script_runner.py index ec3d09a20..f8243c9b3 100644 --- a/src/apm_cli/core/script_runner.py +++ b/src/apm_cli/core/script_runner.py @@ -73,7 +73,7 @@ def run_script(self, script_name: str, params: Dict[str, str]) -> bool: if discovered_prompt: # Print discovery message early to allow E2E tests to validate # This message appears before runtime detection, which may fail in test environments - print(f"[i] Auto-discovered: {discovered_prompt}") + print(f"[i] Auto-discovered: {discovered_prompt.as_posix()}") # Detect runtime and generate command runtime = self._detect_installed_runtime() diff --git a/src/apm_cli/output/script_formatters.py b/src/apm_cli/output/script_formatters.py index 12f30b059..779606984 100644 --- a/src/apm_cli/output/script_formatters.py +++ b/src/apm_cli/output/script_formatters.py @@ -321,7 +321,7 @@ def format_auto_discovery_message(self, script_name: str, prompt_file: Path, run try: text = Text() text.append("[i] Auto-discovered: ", style="cyan") - text.append(str(prompt_file), style="bold white") + text.append(prompt_file.as_posix(), style="bold white") text.append(f" (runtime: {runtime})", style="dim") with self.console.capture() as capture: @@ -329,9 +329,9 @@ def format_auto_discovery_message(self, script_name: str, prompt_file: Path, run return capture.get().rstrip('\n') except Exception: # Fallback to simple formatting - return f"[i] Auto-discovered: {prompt_file} (runtime: {runtime})" + return f"[i] Auto-discovered: {prompt_file.as_posix()} (runtime: {runtime})" else: - return f"[i] Auto-discovered: {prompt_file} (runtime: {runtime})" + return f"[i] Auto-discovered: {prompt_file.as_posix()} (runtime: {runtime})" def _styled(self, text: str, style: str) -> str: """Apply styling to text with rich fallback."""