Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mini_agent/tools/skill_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ class Skill:

def to_prompt(self) -> str:
"""Convert skill to prompt format"""
# Inject skill root directory path for context
skill_root = str(self.skill_path.parent) if self.skill_path else "unknown"

return f"""
# Skill: {self.name}

{self.description}

**Skill Root Directory:** `{skill_root}`

All files and references in this skill are relative to this directory.

---

{self.content}
Expand Down
28 changes: 28 additions & 0 deletions tests/test_skill_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,31 @@ def test_script_path_processing():

# Check that script path is converted to absolute
assert str(skill_dir / "scripts" / "test_script.py") in skill.content


def test_skill_to_prompt_includes_root_directory():
"""Test that to_prompt includes skill root directory path"""
with tempfile.TemporaryDirectory() as tmpdir:
skill_dir = Path(tmpdir) / "test-skill"
skill_dir.mkdir()

skill_file = skill_dir / "SKILL.md"
skill_content = """---
name: test-skill
description: A test skill
---

Skill content here.
"""
skill_file.write_text(skill_content, encoding="utf-8")

loader = SkillLoader(tmpdir)
skill = loader.load_skill(skill_file)

assert skill is not None

# Test to_prompt includes root directory
prompt = skill.to_prompt()
assert "Skill Root Directory" in prompt
assert str(skill_dir) in prompt
assert "All files and references in this skill are relative to this directory" in prompt