MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _install_skill

Function _install_skill

tests/test_skill_runner.py:43–73  ·  view source on GitHub ↗

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.",
)

Source from the content-addressed store, hash-verified

41
42
43def _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

Calls

no outgoing calls

Tested by

no test coverage detected