From 49cc2de9d41b123be0f5c5b2bf665bb5461ca23d Mon Sep 17 00:00:00 2001 From: ccsang Date: Wed, 18 Mar 2026 05:56:37 +0000 Subject: [PATCH 1/2] fix(skills): support Windows paths in Linux containers Fixes #6477 Problem: _is_windows_prompt_path() checks os.name before examining the path, which fails when AstrBot runs in Linux Docker containers but has Windows paths mounted from the host. Solution: Remove os.name check and directly test if the path matches Windows drive or UNC patterns. This allows proper handling of Windows paths (C:\, \server\share\) regardless of the host OS. --- astrbot/core/skills/skill_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/skills/skill_manager.py b/astrbot/core/skills/skill_manager.py index b02ffc5e93..c466a1509c 100644 --- a/astrbot/core/skills/skill_manager.py +++ b/astrbot/core/skills/skill_manager.py @@ -92,8 +92,8 @@ def _parse_frontmatter(text: str) -> dict: def _is_windows_prompt_path(path: str) -> bool: - if os.name != "nt": - return False + # 检查路径本身是否是 Windows 路径(不依赖当前系统) + # 修复 #6477:支持 Linux 容器中映射的 Windows 路径 return bool(_WINDOWS_DRIVE_PATH_RE.match(path) or _WINDOWS_UNC_PATH_RE.match(path)) From b689b42f0bc5504080b13d8a80ff812b3d295578 Mon Sep 17 00:00:00 2001 From: ccsang Date: Wed, 18 Mar 2026 07:08:35 +0000 Subject: [PATCH 2/2] fix(skills): keep command selection tied to runtime shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review feedback from chatgpt-codex-connector The previous fix made Linux/bash sessions emit 'type' command for Windows-like paths, which breaks file reading in bash (type only shows command type information). New approach: - Command selection based on os.name (runtime shell), not just path format - On Windows: use 'type' for Windows paths - On Linux/Mac: use 'cat' for all paths, converting backslashes to forward slashes for Windows-formatted paths (e.g., C:\path → C:/path) This maintains compatibility with existing tests while fixing the original issue #6477 (Windows paths in Linux containers). --- astrbot/core/skills/skill_manager.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/astrbot/core/skills/skill_manager.py b/astrbot/core/skills/skill_manager.py index c466a1509c..d3cac1978a 100644 --- a/astrbot/core/skills/skill_manager.py +++ b/astrbot/core/skills/skill_manager.py @@ -131,12 +131,24 @@ def _sanitize_skill_display_name(name: str) -> str: def _build_skill_read_command_example(path: str) -> str: if path == "//SKILL.md": return f"cat {path}" - if _is_windows_prompt_path(path): + + # 命令选择基于运行时 shell,而不是路径格式 + # 修复 #6477:在 Linux 容器中,即使路径是 Windows 格式(挂载路径), + # 也应该使用 cat 命令,但需要转换路径格式(\ → /) + if os.name == "nt" and _is_windows_prompt_path(path): + # Windows 系统上的 Windows 路径:使用 type 命令 command = "type" path_arg = f'"{os.path.normpath(path)}"' else: + # 非Windows 系统:使用 cat 命令 + # 如果路径是 Windows 格式,转换反斜杠为正斜杠 command = "cat" - path_arg = shlex.quote(path) + if _is_windows_prompt_path(path): + # 转换 Windows 路径格式:C:\path\to\file → C:/path/to/file + path_arg = shlex.quote(path.replace("\\", "/")) + else: + path_arg = shlex.quote(path) + return f"{command} {path_arg}"