MCPcopy
hub / github.com/wshobson/agents / init_from_source

Method init_from_source

plugins/plugin-eval/src/plugin_eval/corpus.py:37–67  ·  view source on GitHub ↗

Index all skills from a plugins directory into a corpus.

(cls, plugins_dir: Path, corpus_dir: Path)

Source from the content-addressed store, hash-verified

35
36 @classmethod
37 def init_from_source(cls, plugins_dir: Path, corpus_dir: Path) -> Corpus:
38 """Index all skills from a plugins directory into a corpus."""
39 corpus_dir.mkdir(parents=True, exist_ok=True)
40
41 entries = []
42 for plugin_dir in sorted(plugins_dir.iterdir()):
43 if not plugin_dir.is_dir():
44 continue
45 skills_dir = plugin_dir / "skills"
46 if not skills_dir.exists():
47 continue
48 for skill_dir in sorted(skills_dir.iterdir()):
49 if skill_dir.is_dir() and (skill_dir / "SKILL.md").exists():
50 try:
51 skill = parse_skill(skill_dir)
52 entries.append(
53 CorpusEntry(
54 name=skill.name,
55 path=str(skill_dir),
56 category=plugin_dir.name,
57 line_count=skill.line_count,
58 )
59 )
60 except Exception:
61 continue
62
63 index = [e.to_dict() for e in entries]
64 (corpus_dir / "index.json").write_text(json.dumps(index, indent=2))
65
66 corpus = cls(corpus_dir)
67 return corpus
68
69 @property
70 def size(self) -> int:

Callers 4

initFunction · 0.80
test_list_skillsMethod · 0.80

Calls 3

parse_skillFunction · 0.90
CorpusEntryClass · 0.85
to_dictMethod · 0.80

Tested by 3

test_list_skillsMethod · 0.64