vent_skills.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. """
  3. Skills 发现与辅助模块
  4. Skills 的实际定义现在位于各子目录的 SKILL.md 文件中:
  5. - src/skills/click-interpret-tun/SKILL.md 点选数据解读
  6. - src/skills/dialog-interpret/SKILL.md 对话式数据解读
  7. DeepAgents 的 create_deep_agent(skills=[...]) 参数直接加载这些目录,
  8. 读取 SKILL.md 的 YAML frontmatter 实现渐进式披露。
  9. 添加新 Skill 的步骤:
  10. 1. 在 src/skills/ 下创建新目录
  11. 2. 在该目录中创建 SKILL.md(含 YAML frontmatter)
  12. 3. 在 vent_agent.py 中添加对应的路径常量
  13. 4. 在 create_deep_agent() 的 skills= 参数中引用
  14. """
  15. from pathlib import Path
  16. # Skills 根目录
  17. SKILLS_ROOT = Path(__file__).parent
  18. def list_skills():
  19. """发现所有可用的 Skill 目录(包含 SKILL.md 的目录)。"""
  20. skills = []
  21. for d in sorted(SKILLS_ROOT.iterdir()):
  22. if d.is_dir() and (d / "SKILL.md").exists():
  23. skills.append(str(d))
  24. return skills
  25. def get_skill_path(name: str):
  26. """获取指定 Skill 的路径。"""
  27. path = SKILLS_ROOT / name
  28. if path.is_dir() and (path / "SKILL.md").exists():
  29. return str(path)
  30. return None
  31. if __name__ == "__main__":
  32. print("Available skills:")
  33. for s in list_skills():
  34. print(f" {s}")