From c1917ebf4f87cb89ac8e35afc4cd576f5eb63b88 Mon Sep 17 00:00:00 2001 From: zenfun Date: Sat, 21 Feb 2026 01:03:45 +0800 Subject: [PATCH] fix(computer): resolve absolute skill paths at runtime in scan command - Resolve skills root via Path.resolve() so LLM prompts always reference absolute paths regardless of sandbox cwd - Use resolved path in skill metadata for reliable cat/head commands - Add DRY cross-reference comment for frontmatter parser - Remove dead skills_root_abs field from JSON output (no consumer) - Remove unnecessary os import and fake resolve/abspath branch --- astrbot/core/computer/computer_client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/astrbot/core/computer/computer_client.py b/astrbot/core/computer/computer_client.py index 39dd66ce0..1853abf75 100644 --- a/astrbot/core/computer/computer_client.py +++ b/astrbot/core/computer/computer_client.py @@ -183,6 +183,10 @@ def _build_scan_command() -> str: This stage is read-oriented: it scans SKILL.md metadata and returns the historical payload shape consumed by cache update logic. + + The scan resolves the absolute path of the skills root at runtime so + that the LLM can reliably ``cat`` skill files regardless of cwd. + Only the ``description`` field is extracted from frontmatter. """ script = f""" import json @@ -191,7 +195,12 @@ from pathlib import Path root = Path({SANDBOX_SKILLS_ROOT!r}) managed_file = root / {_MANAGED_SKILLS_FILE!r} +# Resolve absolute path at runtime so prompts always have a reliable path +root_abs = str(root.resolve()) + +# NOTE: This parser mirrors skill_manager._parse_frontmatter_description. +# Keep the two implementations in sync when changing parsing logic. def parse_description(text: str) -> str: if not text.startswith("---"): return "" @@ -253,7 +262,7 @@ def collect_skills() -> list[dict[str, str]]: {{ "name": skill_dir.name, "description": description, - "path": f"{SANDBOX_SKILLS_ROOT}/{{skill_dir.name}}/SKILL.md", + "path": f"{{root_abs}}/{{skill_dir.name}}/SKILL.md", }} ) return skills