Architectural comparison and structural mapping between Red-DiscordBot (Python chatbot) and OMP (TypeScript terminal AI agent).


1. πŸš€ Quick Start Configuration

Red-DiscordBot (Cog Extension)

# ssot_cog.py
from redbot.core import commands
 
class SSOTExtension(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
 
    @commands.command()
    async def ping(self, ctx):
        await ctx.send("Pong!")

OMP (Oh My Pi Extension)

// index.ts
import { OmpExtensionAPI } from "./types"
 
export default function myExtension(pi: OmpExtensionAPI) {
  pi.registerTool({
    name: "ping",
    label: "Ping Tool",
    description: "Returns pong response",
    parameters: {},
    execute: async () => "Pong!",
  })
}

2. πŸ”§ Modular Mapping Matrix

Architectural LayerRed-DiscordBotOMP (Oh My Pi) / omp.sh
Core RuntimePython-based Discord client (discord.py).TypeScript/Rust terminal-first agent harness.
Extension UnitCog: Python class dynamically loaded/unloaded via Red’s command line.Extension: Host-side TS/JS module loaded via jiti utilizing the ExtensionAPI.
Package / PluginDownloader Repo: GitHub repository containing a bundle of cogs with info.json manifests.Plugin: Node-module packages managed in ~/.omp/plugins/ declared via package.json "pi" manifest.
Functional ToolCommands: Python methods decorated with @commands.command() or @commands.hybrid_command().Tools: TypeScript functions registered via pi.registerTool and exposed to the LLM agent.
System InstructionHandled via hardcoded python docstrings or embed responses.Skill: Declarative Markdown instructions (SKILL.md) dynamically injected into LLM prompt contexts.
ConstraintsPermissions/checks (@commands.admin_or_permissions).Rules: L2 Hard Rules (memory database) and file-based Domain Rules.
ConfigurationRed Config database (JSON-backed schema storage).Profiles: Agent Profiles (personas/vibe) and Project Profiles (CWD-scoped boundary maps).
Work UnitBackground tasks.loop or asyncio.create_task.Tasks: todo checklists and parallel subagent assignments via task tools.

3. πŸ“¦ Packaging and Discovery Standards

Red-DiscordBot info.json

To publish a Cog, define package metadata at the root of the cog folder:

{
  "author": ["Developer Name"],
  "install_msg": "Cog successfully installed. Run [p]slash sync to configure slash commands.",
  "short": "Embed generator with persistent session editor.",
  "min_bot_version": "3.5.0",
  "requirements": ["discord.py>=2.6"],
  "end_user_data_statement": "This cog stores session settings and author IDs locally in Red Config."
}

OMP / pi.dev package.json

To distribute an OMP extension, configure the "pi" manifest properties in npm packages:

{
  "name": "pi-extension",
  "version": "1.0.0",
  "keywords": ["pi-package"],
  "pi": {
    "extensions": ["./index.ts"],
    "skills": ["./skills"]
  }
}

4. πŸ’‘ Best Practices

  • Venv Isolation: Keep Red-DiscordBot and OMP runtimes in separate virtual environments or node modules. Dependency namespaces must never overlap.
  • State Restoring: Register persistent Views in Red’s cog_load() and register tools/lifecycle events in OMP’s session_start hooks. This ensures zero data loss on reboots.
  • Memory Partitions: In Red, partition config variables using Config.get_conf(self, identifier=<unique_int>). In OMP, partition memories using Project Profiles resolved from the active workspace directory.

5. 🚨 Gotchas / Traps

  • Dependency Clash: Installing other discord libraries in Red’s venv breaks the bot instantly.
  • Precedence Trap: In OMP, programmatic settings inside config.json override config values from config.yml.
  • Unloaded Tasks: Unhandled background loops in Red or hanging event listeners in OMP create zombie processes. Always run cleanup logic in cog_unload() or session_shutdown() hooks.

6. πŸ” Verification Checklist

  • Step 0: Verify Python version (Redbot min 3.11) and Node version (OMP min v22).
  • Step 1: Verify the active library version using pip show discord.py.
  • Step 2: Test local package load commands ([p]cog load for Red, pi -e ./path for OMP).
  • Step 3: Validate manifest files (info.json for Red, package.json for OMP).
  • Step 4: Run integration checks to ensure extensions auto-restore states on process restarts.