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

Method _emit_agent

tools/adapters/opencode.py:224–246  ·  view source on GitHub ↗
(self, plugin: PluginSource, agent: AgentSource, result: EmitResult)

Source from the content-addressed store, hash-verified

222 result.written.append(self.mirror_file(src, skill_dir / rel))
223
224 def _emit_agent(self, plugin: PluginSource, agent: AgentSource, result: EmitResult) -> None:
225 agent_id = f"{plugin.name}__{agent.name}"
226 rel = Path(".opencode") / "agents" / f"{agent_id}.md"
227
228 model, warning = resolve_model("opencode", agent.model)
229 if warning:
230 result.warnings.append(f"agent `{agent_id}`: {warning}")
231
232 fm: dict = {
233 "name": agent_id,
234 "description": agent.description or f"{agent.name} (from {plugin.name})",
235 "mode": "subagent",
236 "model": model,
237 }
238
239 has_tools_field = "tools" in agent.frontmatter
240 permission = _build_permission_block(agent.tools, has_tools_field=has_tools_field)
241 if permission:
242 fm["permission"] = permission
243
244 body = _rewrite_body_lowercase_tools(agent.body).rstrip() + "\n"
245 content = _opencode_frontmatter(fm) + "\n\n" + body
246 result.written.append(self.write(rel, content))
247
248 def _emit_command(self, plugin: PluginSource, cmd: CommandSource, result: EmitResult) -> None:
249 cmd_id = f"{plugin.name}__{cmd.name}"

Callers 1

emit_pluginMethod · 0.95

Calls 5

resolve_modelFunction · 0.90
_build_permission_blockFunction · 0.85
_opencode_frontmatterFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected