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

Environment:0xNyk Council of high intelligence Python3

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

Overview

Python 3.9+ runtime with PyYAML for agent frontmatter conversion (opencode) and prose-vs-frontmatter roster validation.

Description

The Python3 environment provides the runtime for two validation/conversion scripts in the Council of High Intelligence. Both scripts parse YAML frontmatter from agent definition files (`agents/council-*.md`) and require the `PyYAML` package.

`convert-agents-opencode.py` reshapes Claude agent frontmatter to fit opencode's stricter schema: it removes the deprecated `tools: [...]` array (replaced by `permission`), strips free-form `color` names, and removes Claude's `opus`/`sonnet` model aliases while preserving the original routing metadata in a `council:` block (including `claude_tier`). The script writes converted files to the opencode agents directory and prints the count of converted agents.

`validate-roster.py` is a hard CI gate that verifies SKILL.md prose and agent frontmatter describe the same council. It checks frontmatter completeness (8 required keys), method diversity (no shared `reasoning_method`), polarity pair reciprocity and mirroring, profile size/tag consistency, triad references, and roster/disk agreement. Three real drifts motivated it: Aristotle carried a `profiles` tag for a panel without him, and two polarity pairs existed in frontmatter but not in the Polarity Pairs prose list.

Usage

Use this environment for:

  • opencode installation — `install.sh` invokes `python3 convert-agents-opencode.py` during `--opencode` install
  • Roster validation — `validate-roster.py` runs as a CI gate to prevent prose/frontmatter drift

It is the mandatory prerequisite for the convert_agents_opencode_py and validate_roster_py implementations.

System Requirements

Category Requirement Notes
OS Any (Python is cross-platform) Linux, macOS, WSL2
Hardware Any CPU Scripts are I/O-bound, not compute-intensive
Disk < 1 MB Scripts only
Runtime Python 3.9+ Uses `Path.stem.removeprefix()` (3.9+), f-strings, `pathlib`

Dependencies

System Packages

  • `python3` >= 3.9 — uses `pathlib.Path.stem.removeprefix()` (added in 3.9)

Python Packages

  • `PyYAML` (`yaml`) >= 5.1 — required by both scripts for YAML frontmatter parsing

Credentials

No credentials are required for the Python3 environment. Both scripts operate on local files only.

Quick Install

# Install PyYAML (required dependency)
pip3 install --user pyyaml

# Convert agents for opencode
python3 scripts/convert-agents-opencode.py agents/ ~/.config/opencode/agent/

# Validate roster (run from repo root)
python3 scripts/validate-roster.py

Code Evidence

PyYAML dependency with explicit error message. From `scripts/convert-agents-opencode.py:L18-23`:

try:
    import yaml
except ImportError:
    sys.exit(
        "Error: PyYAML is required. Install it with: pip3 install --user pyyaml"
    )

Same pattern in `scripts/validate-roster.py:L19-24`:

try:
    import yaml
except ImportError:
    sys.exit(
        "Error: PyYAML is required. Install it with: pip3 install --user pyyaml"
    )

Python 3.9+ feature — `Path.stem.removeprefix()` from `scripts/validate-roster.py:L75`:

agents[path.stem.removeprefix("council-")] = council

Frontmatter conversion logic from `scripts/convert-agents-opencode.py:L36-44`:

council = fm.get("council", {}) or {}
council["claude_tier"] = fm.get("model")

new_fm = {
    "description": fm["description"],
    "mode": "subagent",
    "permission": {"edit": "deny", "write": "deny"},
    "council": council,
}

Method diversity validation (DMAD) from `scripts/validate-roster.py:L101-105`:

methods = {}
for slug, council in agents.items():
    methods.setdefault(council.get("reasoning_method"), []).append(slug)
for method, owners in sorted(methods.items()):
    check(len(owners) == 1, f"reasoning_method '{method}' shared by {owners}")

Common Errors

Error Message Cause Solution
`Error: PyYAML is required. Install it with: pip3 install --user pyyaml` PyYAML not installed Run `pip3 install --user pyyaml`
`No agent definitions found under agents/council-*.md` Script run from wrong directory or `agents/` missing Run from repo root or pass repo root as argument: `python3 scripts/validate-roster.py /path/to/repo`
`no frontmatter in {file}` Agent file missing YAML frontmatter delimiters (`---`) Ensure agent file starts with `---\n…\n---\n`
`reasoning_method '{method}' shared by {owners}` Two agents share the same `reasoning_method` (violates DMAD) Assign a unique `reasoning_method` to each agent in frontmatter
`AttributeError: 'str' object has no attribute 'removeprefix'` Python < 3.9 Upgrade to Python 3.9+

Compatibility Notes

  • Python 3.9+: Required — uses `str.removeprefix()` (PEP 616, added in 3.9).
  • Python 3.8 and below: Not compatible — `Path.stem.removeprefix()` will raise `AttributeError`.
  • PyPy: Compatible if PyPy 3.9+ with PyYAML installed.
  • Virtual environments: Both scripts work in venvs; ensure `pyyaml` is installed in the active environment.
  • System Python (macOS): May need `pip3 install --user pyyaml` since system Python does not include PyYAML by default.

Related Pages

Page Connections

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