Drop a SKILL.md under `` /skills/ /`` and return its path.
(
kb_dir: Path,
name: str,
*,
body: str = "Do the thing.",
od: dict | None = None,
description: str = "A test skill.",
)
| 41 | |
| 42 | |
| 43 | def _install_skill( |
| 44 | kb_dir: Path, |
| 45 | name: str, |
| 46 | *, |
| 47 | body: str = "Do the thing.", |
| 48 | od: dict | None = None, |
| 49 | description: str = "A test skill.", |
| 50 | ) -> Path: |
| 51 | """Drop a SKILL.md under ``<kb>/skills/<name>/`` and return its path.""" |
| 52 | sk_dir = kb_dir / "skills" / name |
| 53 | sk_dir.mkdir(parents=True) |
| 54 | frontmatter = {"name": name, "description": description} |
| 55 | if od is not None: |
| 56 | frontmatter["od"] = od |
| 57 | # Write YAML by hand to avoid a yaml.dump dependency on test side |
| 58 | fm_lines = ["---"] |
| 59 | for k, v in frontmatter.items(): |
| 60 | if isinstance(v, dict): |
| 61 | fm_lines.append(f"{k}:") |
| 62 | for kk, vv in v.items(): |
| 63 | if isinstance(vv, dict): |
| 64 | fm_lines.append(f" {kk}:") |
| 65 | for kkk, vvv in vv.items(): |
| 66 | fm_lines.append(f" {kkk}: {vvv!r}") |
| 67 | else: |
| 68 | fm_lines.append(f" {kk}: {vv!r}") |
| 69 | else: |
| 70 | fm_lines.append(f"{k}: {v!r}") |
| 71 | fm_lines.append("---") |
| 72 | (sk_dir / "SKILL.md").write_text("\n".join(fm_lines) + "\n" + body, encoding="utf-8") |
| 73 | return sk_dir |
| 74 | |
| 75 | |
| 76 | @pytest.mark.asyncio |
no outgoing calls
no test coverage detected