π OMPYCORD β Ultimate Over-Powered Cheat Sheet
Decoupled, robust, and emojified single source of truth for the OMPβDiscord sidecar bridge.
1. β‘ Speedrun Setup
π§ Environment Config (/home/dv/.omp/plugins/ompycord/.env)
# π why: authenticate bot with Discord Gateway API
DISCORD_BOT_TOKEN=MTUxMTAx...
# π why: home channel where status reports and commands route
DISCORD_CHANNEL_ID=1514380270491402270
# ποΈ why: restrict interactions to this specific server
DISCORD_GUILD_ID=1496176276933972110
# π₯ why: limit bot administrative actions to allowed user snowflakes
DISCORD_ALLOWED_USERS=481482311288750080,1148596028556197939
# π why: emoji trigger to launch new subagent process threads
OMP_LAUNCH_EMOJI=π
# ποΈ why: channel IDs where reaction launches are active
OMP_LAUNCH_CHANNEL_IDS=1514380270491402270π Process Control
# π why: start the background daemon process
# π οΈ what: spawns FastAPI on port 8901 and connects the Discord Gateway client
# βοΈ how: nohup keeps it running after ssh/terminal session closes
nohup /bin/bash /home/dv/.omp/plugins/ompycord/start.sh >/home/dv/.omp/plugins/ompycord/bot.log 2>&1 &
# π why: cleanly terminate bot daemon and uvicorn backend
# π οΈ what: kills both the bash starter script and the python child process
# βοΈ how: pgrep searches command strings and pipes to SIGTERM
pgrep -f "python3 bot.py|start.sh" | xargs kill -92. ποΈ Command Hub
πΎ Hybrid Commands (/omp)
| Command | Trigger | Telemetry / Output |
|---|---|---|
/omp status | Manual | Renders StatusSnapshot embed showing uptime, latencies, and checklist. |
/omp health | Diagnostics | Validates STLink gateway ping and checks SQLite DB read/write connection. |
/omp new | Spawn | Creates new thread session Session: <topic> under text channel. |
/omp say | steering | Queues prompt into target thread, waking up the background subagent. |
/omp cancel | Emergency | Sends SIGTERM to the active OMP subprocess, stopping loops instantly. |
/omp stop | Archive | Clears DB mapping, archives thread channel, and cleans system memory. |
/omp queue | Telemetry | Renders depth of waiting prompts and list of next tasks. |
/omp version | Telemetry | Outputs process ID (PID), code build versions, and daemon uptime. |
3. πΎ DB Architecture
db.py handles database migrations and queries. bot.py is fully decoupled from SQL syntax.
# π path: /home/dv/.omp/plugins/ompycord/db.py
import aiosqlite
DB_PATH = "/home/dv/.omp/plugins/ompycord/sessions.db"
# ποΈ why: delete mapped thread session from SQLite database upon stop/archive command
# π οΈ what: removes row matching thread ID from active sessions table
# βοΈ how: db.execute("DELETE FROM agent_sessions WHERE discord_thread_id = ?", (thread_id,))
async def delete_session_by_thread(thread_id: int) -> None:
async with aiosqlite.connect(DB_PATH) as db:
await db.execute("DELETE FROM agent_sessions WHERE discord_thread_id = ?", (thread_id,))
await db.commit()
# π why: retrieve active dashboard message ID to edit or relocate panel
# π οΈ what: selects dashboard_message_id matching session key
# βοΈ how: returns row[0] if it exists, else None
async def get_dashboard_message_id(session_id: str) -> Optional[int]:
async with aiosqlite.connect(DB_PATH) as db:
async with db.execute(
"SELECT dashboard_message_id FROM agent_sessions WHERE session_id = ?",
(session_id,)
) as cursor:
row = await cursor.fetchone()
return row[0] if row else None4. π Launch Pipeline
Triggers automatic thread creation and agent bootstrapping from reaction clicks.
sequenceDiagram participant User as π₯ User participant Gateway as π‘ Discord Gateway participant Daemon as π Ompycord bot.py participant DB as πΎ db.py participant Subprocess as βοΈ Subprocess User->>Gateway: Reacts π to Message Gateway->>Daemon: on_raw_reaction_add() Daemon->>Daemon: Debounce check (active_launches) Daemon->>Gateway: create_thread() & fetch_message() Daemon->>DB: register_session(session_id, thread_id) Daemon->>Subprocess: run_omp_subprocess() Note over Daemon,Subprocess: Stream logs & update embeds Subprocess->>Daemon: Exit process (done / fail) Daemon->>Daemon: Discard message ID from active_launches
π Debounced Launcher Hook
# π path: /home/dv/.omp/plugins/ompycord/bot.py
@bot.event
async def on_raw_reaction_add(payload: discord.RawReactionActionEvent):
# π« why: prevent bot from triggering its own message reactions
if payload.user_id == bot.user.id: return
# π why: filter out any emoji other than the designated launch rocket
if str(payload.emoji) != os.getenv("OMP_LAUNCH_EMOJI", "π"): return
# π why: avoid double-click concurrent thread spawn bugs
if payload.message_id in active_launches: return
active_launches.add(payload.message_id)
try:
# π why: extract text content and spawn thread channel
channel = bot.get_channel(payload.channel_id) or await bot.fetch_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
# π€ why: security guard, verify reaction clicker matches message author
if message.author.id != payload.user_id:
active_launches.remove(payload.message_id)
return
thread = await message.create_thread(name=f"Run: {message.content[:20]}")
session_id = f"session_{uuid.uuid4().hex[:8]}"
await register_session(session_id, thread.id)
# βοΈ why: run agent command process asynchronously
asyncio.create_task(run_omp_subprocess(session_id, message.content, thread, message.id))
except Exception:
active_launches.discard(payload.message_id)
raise5. βοΈ Subprocess Loop
# π path: /home/dv/.omp/plugins/ompycord/bot.py
async def run_omp_subprocess(session_id: str, prompt: str, thread: discord.Thread, message_id: Optional[int] = None):
# ... setup command ...
try:
process = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT)
while True:
line = await process.stdout.readline()
if not line: break
# π why: prevents UnicodeDecodeError from crashing the loop if binary/malformed bytes are output
# π οΈ what: decodes stream bytes to string, ignoring decoding issues
# βοΈ how: line.decode("utf-8", errors="ignore")
log_line = line.decode("utf-8", errors="ignore").strip()
if log_line:
log_buffer.append(log_line)
if len(log_buffer) >= 10 or (time.time() - last_flush_time >= 1.5):
await flush_logs()
await flush_logs()
await process.wait()
finally:
# π why: guarantee release of launch lock even if subprocess fails
if message_id is not None:
active_launches.discard(message_id)
# ... unpin prompt & repaint dashboard state ...6. π¨ Dashboard States
Interactive dashboards visualize live agent metrics through colors.
| Status | Color | Emoji | Description |
|---|---|---|---|
| Idle | 0x2ECC71 | π’ | Daemon is online, ready for prompt inputs. |
| Busy | 0x5865F2 | π΅ | Subprocess execution loop is active. |
| Waiting | 0xF1C40F | π‘ | Interactive modal/select is awaiting user click. |
| Degraded | 0xE67E22 | π | Subprocess returned warnings or execution failed. |
| Failed | 0xE74C3C | π΄ | Core daemon process is unresponsive or offline. |
7. π Sidecar API
The sidecar daemon runs an asynchronous FastAPI router exposing endpoint handlers on port 8901:
# π’ why: receive real-time execution step telemetry from the active OMP agent
POST http://127.0.0.1:8901/api/webhook/event
Content-Type: application/json
{
"session_id": "session_a4b91f0",
"event_type": "tool_call",
"content": "Running search...",
"timestamp": "2026-06-13T22:00:00Z"
}
# π₯ why: allow OMP agent to poll for queued steering commands from thread
GET http://127.0.0.1:8901/api/commands/poll?session_id=session_a4b91f08. πΊοΈ Canvas Alignment
π Grid Alignment Rules
- Height: File nodes must have a standard height of
80px. - Gap: Space nodes vertically by a strict
20pxgap (100pxcoordinate spacing). - Group Height: Automatically adjust group wrapping boundaries to prevent overlaps.
πΊοΈ specs.canvas Coordinates Matrix
| Node ID | Target File | X | Y | Width | Height | Color |
|---|---|---|---|---|---|---|
f-cs2docs | skills/cs2docs.md | 40 | 100 | 480 | 80 | 6 |
f-docskurby | skills/docskurby.md | 40 | 200 | 480 | 80 | 6 |
f-llmwiki | skills/llm-wiki.md | 40 | 300 | 480 | 80 | 6 |
f-skills | skills/SKILLS.md | 40 | 400 | 480 | 80 | 6 |
f-skills-cheat | skills/SKILLS-CHEATSHEET.md | 40 | 500 | 480 | 80 | 6 |
f-omp | stack/omp.md | 1760 | 100 | 480 | 80 | 4 |
f-ompkeep | stack/ompkeep.md | 1760 | 200 | 480 | 80 | 4 |
f-quartz5 | stack/quartz5.md | 1760 | 300 | 480 | 80 | 4 |
f-planning | plans/planning-standard.md | 40 | 920 | 480 | 80 | 3 |
f-migration | plans/w-0rk-migration/index.md | 40 | 1020 | 480 | 80 | 3 |
f-ompycord | projects/ompcord/ompycord.md | 920 | 720 | 480 | 80 | 3 |
f-review | projects/ompcord/ompycord-review.md | 920 | 820 | 480 | 80 | 3 |
f-unidialog | projects/ompcord/unidialog.md | 920 | 920 | 480 | 80 | 3 |
f-ssotembed | projects/ompcord/ssotembed.md | 920 | 1020 | 480 | 80 | 3 |
f-redvsomp | projects/ompcord/red-vs-omp.md | 920 | 1120 | 480 | 80 | 3 |
f-cheatsheet | projects/ompcord/cheatsheet.md | 920 | 1220 | 480 | 80 | 3 |
f-llmstxt | knowledge/cognitive-fs/llms-txt.md | 1760 | 720 | 480 | 80 | 2 |
f-projects | knowledge/cheatsheets/projects.md | 1760 | 820 | 480 | 80 | 2 |
f-smokmod | knowledge/cheatsheets/novo-modding/index.md | 1760 | 920 | 480 | 80 | 2 |
f-bible | bible.md | 1760 | 1020 | 480 | 80 | 2 |