Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xNyk Council of high intelligence convert agents opencode py

From Leeroopedia
Knowledge Sources
Domains Scripting, Agent_Configuration, opencode
Last Updated 2026-10-20 00:00 GMT

Overview

Concrete Python script for converting Claude-format agent persona files into opencode-compatible subagent files, provided by the Council of High Intelligence project.

Description

convert-agents-opencode.py reshapes the YAML frontmatter of each `agents/council-*.md` file to fit opencode's stricter subagent schema. opencode rejects the `tools: [...]` array (deprecated in opencode, replaced by `permission`), rejects free-form `color` names (must be hex or fixed theme keyword), and has no notion of Claude's `opus`/`sonnet` model aliases. This script strips those fields, adds `mode: subagent` and `permission: {edit: deny, write: deny}`, and preserves the `council:` routing metadata block (storing the Claude model tier as `claude_tier` for the coordinator to reference).

The script reads each agent file, extracts frontmatter via regex, reshapes it with PyYAML, and writes the converted file to the destination directory. It prints the count of converted agents to stdout (consumed by `install.sh`).

Usage

Run this script when:

  • Installing the council skill for opencode (`install.sh --opencode`)
  • The script is invoked by `install.sh` automatically during opencode installation
  • In dry-run mode, `install.sh` prints the command and sets the count to the total agent count

Code Reference

Source Location

Signature

def convert(src_path: Path) -> str:
    """Convert one agent file's frontmatter to opencode format.

    - Strips: tools, color, model (top-level)
    - Adds: mode="subagent", permission={"edit": "deny", "write": "deny"}
    - Preserves: description, council block (with model saved as council.claude_tier)
    - Returns: full file text with new frontmatter + original body
    """

def main() -> int:
    """CLI entry point.

    Usage: convert-agents-opencode.py <src_agents_dir> <dst_agents_dir>
    Converts all council-*.md files, prints count to stdout.
    """

Import

# Run directly:
python3 scripts/convert-agents-opencode.py agents/ ~/.config/opencode/agent/

# Or via install.sh (which calls this automatically):
# install.sh --opencode

I/O Contract

Inputs

Name Type Required Description
src_agents_dir Path Yes Directory containing council-*.md source files
dst_agents_dir Path Yes Destination directory for converted files
PyYAML dependency Yes yaml.safe_load / yaml.safe_dump

Outputs

Name Type Description
converted files filesystem One converted .md per council-*.md in dst_agents_dir
count int (stdout) Number of agents converted (printed to stdout)

Usage Examples

Direct Invocation

# Convert all agents for opencode:
python3 scripts/convert-agents-opencode.py agents/ ~/.config/opencode/agent/
# Output: 18

# Each agent file gets reshaped frontmatter:
# Original:
#   ---
#   name: council-socrates
#   description: "Council member..."
#   model: opus
#   color: blue
#   tools: ["Read", "Grep", "Glob", "Bash", "WebSearch", "WebFetch"]
#   council:
#     figure: Socrates
#     ...
#   ---
#
# Converted:
#   ---
#   description: "Council member..."
#   mode: subagent
#   permission:
#     edit: deny
#     write: deny
#   council:
#     figure: Socrates
#     claude_tier: opus    # model moved here for coordinator reference
#     ...
#   ---

Via install.sh

# install.sh handles the conversion automatically:
./install.sh --opencode
# Internally runs:
# python3 scripts/convert-agents-opencode.py agents/ ~/.config/opencode/agent/
# Then prints: "Installed 18 opencode council subagents to ~/.config/opencode/agent"

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment