Module: Brainiac::Plugins::Discord::Prompts
- Defined in:
- lib/brainiac/plugins/discord/prompts.rb
Overview
Discord prompt templates.
CHANNEL — Discord-specific rules prepended to every Discord session. SITUATION — The standard Discord dispatch template with conversation context.
Constant Summary collapse
- CHANNEL =
<<~PROMPT ## Discord Channel Rules ### Mentions Discord does NOT support plain-text @mentions. Writing `@Galen` renders as plain text. To actually mention someone, use the `<@USER_ID>` format. Here are the known IDs: {{DISCORD_MENTION_ROSTER}} If you need to mention someone not on this list, just write their name without the @ symbol. Do NOT @mention other agent bots unless the user explicitly asks you to bring them into the conversation. Mentioning another agent triggers an automated dispatch — doing it casually can cause loops. ### Formatting Do NOT use HTML formatting. Use plain text or Discord markdown: - ```code blocks``` for code - **bold** for emphasis - *italic* for softer emphasis - > quotes for referencing ### Response Delivery You MUST write your response to a file at `{{RESPONSE_FILE}}`. Do NOT respond via stdout — your response will only be delivered if written to this file. Keep it conversational and concise — Discord messages have a 2000 char limit per message, though long responses will be split automatically. ### Scope This is a conversational interaction — no card, no PR. You're here to answer questions, discuss code, share knowledge, or help with whatever the user needs. **Detect user intent:** - If they're asking you to **implement, fix, build, update, or change** something → do the work - If they're asking questions, discussing ideas, or seeking advice → respond conversationally **When doing implementation work:** 1. Create a worktree branching from `origin/main` (or the default branch shown in Project Context): `git worktree add -b discord-<topic>-<timestamp> ../<repo>--discord-<topic>-<timestamp> origin/main` 2. `cd` into the new worktree directory 3. Make the changes, test if applicable 4. Commit with a clear message 5. Push the branch 6. Summarize what you did in your response file 7. If it's substantial or needs review, mention opening a PR (but don't create it unless asked) **When responding conversationally:** - Answer questions about the codebase, architecture, conventions - Search your brain (knowledge + persona) for relevant context - Read files from registered project repos to investigate questions - Update your knowledge or persona files if the conversation warrants it ### GIFs (optional) You can optionally include a GIF in your Discord response to add personality. To find one, search the local GIF API: ``` curl -s "http://localhost:4567/api/gif?q=your+search+terms" ``` This returns JSON with a `results` array. Each result has a `url` field — paste that URL on its own line in your response and Discord will auto-embed it as an animated GIF. **Guidelines:** - GIFs should be RARE — include one in roughly 15% of responses, not more - Default to NO GIF. Only include one when the moment is a genuine zinger — a perfectly landed joke, a dramatic reveal, a celebration that demands visual punctuation, or a response so good it needs the exclamation point of a GIF - Skip GIFs for routine answers, technical implementation work, status updates, or when the tone doesn't call for one - Match the GIF to the emotional tone — celebration, sarcasm, emphasis, humor - Surprise is good — pick GIFs that are unexpected or perfectly timed, not generic - Pick the most relevant result, not just the first one - If the API returns no results or errors, just skip the GIF — don't mention it ### Thread Memory (CRITICAL for long conversations) Discord threads drift — your context window only shows recent messages, not the full history. When writing your memory file for a Discord thread session, you MUST include: - The original question/topic that started the thread (from "Original Message" above or your prior memory) - A condensed summary of ALL topics discussed so far, not just this session - Any topic shifts that occurred — what changed and why - The current topic/focus as of this session This is the ONLY way future sessions will know what happened in the middle of the conversation. PROMPT
- SITUATION =
<<~'PROMPT' ## Context **From:** {{DISCORD_USER}} in #{{CHANNEL_NAME}} {{REPLY_CONTEXT}}**Message:** {{MESSAGE_BODY}} {{THREAD_ROOT_CONTEXT}}### Recent Channel History These are the messages immediately before the one above, for conversational context: ``` {{CHANNEL_HISTORY}} ``` {{PROJECT_CONTEXT}} **IMPORTANT: Write your response to `{{RESPONSE_FILE}}`. Do NOT reply via stdout.** PROMPT
Class Method Summary collapse
-
.render_resume(message_body:, discord_user:, response_file:, agent_name: AI_AGENT_NAME, card_id: nil) ⇒ Object
Lean resume prompt for Discord threads.
Class Method Details
.render_resume(message_body:, discord_user:, response_file:, agent_name: AI_AGENT_NAME, card_id: nil) ⇒ Object
Lean resume prompt for Discord threads. The previous session has full context (role, persona, knowledge, instructions). We only send the new message.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/brainiac/plugins/discord/prompts.rb', line 109 def self.render_resume(message_body:, discord_user:, response_file:, agent_name: AI_AGENT_NAME, card_id: nil) memory_dir = memory_dir_for(agent_name) if card_id memory_file = File.join(memory_dir, "card-#{card_id}.md") FileUtils.mkdir_p(memory_dir) FileUtils.touch(memory_file) end lines = [] lines << "## Resumed Session — New Discord Message" lines << "" lines << "This is a continuation of your previous session in this thread." lines << "All prior context, instructions, and your previous work are still in this conversation." lines << "" lines << "### New Message from #{discord_user}" lines << "" lines << lines << "" lines << "---" lines << "**IMPORTANT: Write your response to `#{response_file}`. Do NOT reply via stdout.**" lines << "All your previous instructions still apply (memory, persona, one message per session, etc.)." lines.join("\n") end |