[Draft] feat: add workspace-local skills support#7508
Conversation
This commit adds support for workspace-local skills and automatic workspace initialization: 1. New init_workspace() function in util.py: - Creates workspace with EXTRA_PROMPT.md and skills/ subdirectory - Called automatically when using local runtime shell 2. SkillManager enhancements: - Added workspace_skills_root parameter for two-tier skill storage - list_skills() now scans both global and workspace skills - install_skill_from_zip() supports install_to_workspace parameter 3. Local mode system prompt updates: - Added EXTRA_PROMPT.md customization instructions - Added skill installation location preference hint Changes: - astrbot/core/tools/computer_tools/util.py: add init_workspace() - astrbot/core/tools/computer_tools/shell.py: use init_workspace() - astrbot/core/skills/skill_manager.py: workspace skills support - astrbot/core/astr_main_agent.py: update system prompt
There was a problem hiding this comment.
Code Review
This pull request introduces workspace-local skills and customizable system prompt instructions via an EXTRA_PROMPT.md file. The SkillManager has been updated to support a workspace_skills_root for isolated skill management, and a new init_workspace utility handles the creation of necessary workspace files and directories. Review feedback recommends joining system prompt instructions with newlines instead of spaces for improved clarity and suggests limiting workspace-local skill scanning to the local runtime to avoid path access issues within sandboxed environments.
| lines = [ | ||
| "You have access to the host local environment and can execute shell commands and Python code.", | ||
| f"Current operating system: {system_name}.", | ||
| shell_hint, | ||
| "", | ||
| "You can write and modify the EXTRA_PROMPT.md file in the current workspace", | ||
| "to customize your own system prompt instructions. This file will be automatically", | ||
| "loaded and applied to your system prompt in subsequent conversations.", | ||
| "", | ||
| "When installing skills, unless explicitly specified otherwise, prefer installing", | ||
| "them to the workspace/skills directory for better isolation and portability.", | ||
| ] | ||
| return " ".join(lines) |
There was a problem hiding this comment.
The system prompt instructions in _build_local_mode_prompt are joined using a single space. Since the list includes empty strings and distinct instructional sentences, joining with newlines (\n) would provide a much clearer structure for the LLM, making the instructions easier to follow and maintain.
| lines = [ | |
| "You have access to the host local environment and can execute shell commands and Python code.", | |
| f"Current operating system: {system_name}.", | |
| shell_hint, | |
| "", | |
| "You can write and modify the EXTRA_PROMPT.md file in the current workspace", | |
| "to customize your own system prompt instructions. This file will be automatically", | |
| "loaded and applied to your system prompt in subsequent conversations.", | |
| "", | |
| "When installing skills, unless explicitly specified otherwise, prefer installing", | |
| "them to the workspace/skills directory for better isolation and portability.", | |
| ] | |
| return " ".join(lines) | |
| lines = [ | |
| "You have access to the host local environment and can execute shell commands and Python code.", | |
| f"Current operating system: {system_name}.", | |
| shell_hint, | |
| "", | |
| "You can write and modify the EXTRA_PROMPT.md file in the current workspace", | |
| "to customize your own system prompt instructions. This file will be automatically", | |
| "loaded and applied to your system prompt in subsequent conversations.", | |
| "", | |
| "When installing skills, unless explicitly specified otherwise, prefer installing", | |
| "them to the workspace/skills directory for better isolation and portability.", | |
| ] | |
| return "\n".join(lines) |
| # Scan workspace-local skills (if workspace_skills_root is set) | ||
| if self.workspace_skills_root and os.path.isdir(self.workspace_skills_root): |
There was a problem hiding this comment.
Workspace-local skills are currently scanned and added to the prompt regardless of the runtime setting. However, the paths provided for these skills (line 454) are absolute host paths. If the runtime is set to "sandbox", the agent will not be able to access these host paths, which will lead to errors when the agent tries to read the skill files. Consider restricting workspace-local skills to the "local" runtime or ensuring they are correctly mapped for sandbox use.
| # Scan workspace-local skills (if workspace_skills_root is set) | |
| if self.workspace_skills_root and os.path.isdir(self.workspace_skills_root): | |
| # Scan workspace-local skills (if workspace_skills_root is set and runtime is local) | |
| if runtime == "local" and self.workspace_skills_root and os.path.isdir(self.workspace_skills_root): |
This PR introduces workspace-local skills support and automatic workspace initialization for local runtime mode. See full description in commit message.