🚀 Quick Start Multi-agent mode extension for Oh My Pi (OMP) ported from pi-mode. Defines mode-specific personas, tools, and constraints.

omp install @yuechou/omp-agent
omp -e @yuechou/omp-agent # Activate via env or CLI

🔧 Configuration Customize agent directories via OMP standard environment variables.

  • PI_CONFIG_DIR: Base configuration directory (default: .omp).
  • PI_CODING_AGENT_DIR: Agent configurations and skills directory (default: ~/.omp/agent).
  • Agent configurations are structured under ~/.omp/agent/modes/<mode_name>/ (e.g., coding/, research/, all/).

📦 Dependencies

  • Core: @oh-my-pi/pi-coding-agent (Extension API, Command Context).
  • Built-in: fs, path, os.

💡 Best Practices / Patterns

  • Lifecycle Hooking: Use pi.on("session_start", ...) for migrations and pi.on("before_agent_start", ...) for dynamic model/context switching.
  • Graceful Degradation: Wrap pi.setThinkingLevel() and ctx.setActiveTools() in try/catch to avoid crashing the main agent if a mode requests unsupported limits.
  • Event-Driven Sync: Emit agent_ready and agent_changed events (pi.events.emit) to broadcast state changes across other extensions.
  • Context Scoping (XML Protocol): Wrap extension logic with <extension_context mode="coding,research"> to ensure prompts inject only when target modes are active.
  • Tool Filtering: Dynamically limit accessible tools per mode using ctx.setActiveTools(config.tools).

🚨 Gotchas / Warnings (Anti-Patterns)

  • Silent Failures: The codebase makes heavy use of empty catch {} blocks (e.g., during file reads or migrations). This silently swallows errors, making debugging difficult.
  • Synchronous I/O Blocking: Heavy reliance on synchronous file reads (fs.readFileSync) during startup phases can bottleneck initialization on slow file systems.
  • Legacy Mode Overhead: Migrating from modes/ to agents/ is checked on every session_start, adding unnecessary startup overhead.
  • Tag Collision: mode="all" unconditionally injects context; overusing this defeats the purpose of isolated agent domains.

🔍 Research / References