@@ -6,6 +6,8 @@ import type { OpenCodeMessageContext, OpenCodeOptions, PromptPart, SlackContext
66import { getSlackActionApiUrl } from "@/config" ;
77
88export function buildSystemPrompt ( slack ?: SlackContext ) : string {
9+ const platform = slack ?. platform === "discord" ? "discord" : "slack" ;
10+ const platformLabel = platform === "discord" ? "Discord" : "Slack" ;
911 const lines = [
1012 "COMMUNICATION STYLE:" ,
1113 "- Be concise and conversational - this is chat, not documentation" ,
@@ -29,7 +31,7 @@ export function buildSystemPrompt(slack?: SlackContext): string {
2931 ] ;
3032
3133 if ( slack ) {
32- lines . push ( "SLACK CONTEXT:" ) ;
34+ lines . push ( ` ${ platformLabel . toUpperCase ( ) } CONTEXT:` ) ;
3335 lines . push ( `- Channel: ${ slack . channelId } ` ) ;
3436 lines . push ( `- Thread: ${ slack . threadId } ` ) ;
3537 lines . push ( `- User: <@${ slack . userId } >` ) ;
@@ -38,26 +40,44 @@ export function buildSystemPrompt(slack?: SlackContext): string {
3840 }
3941
4042 lines . push ( "" ) ;
41- lines . push ( "SLACK ACTIONS:" ) ;
42- if ( slack . hasCustomSlackTool ) {
43+ lines . push ( `${ platformLabel . toUpperCase ( ) } ACTIONS:` ) ;
44+ const baseUrl = slack . odeSlackApiUrl ?? getSlackActionApiUrl ( ) ;
45+ if ( platform === "slack" && slack . hasCustomSlackTool ) {
4346 lines . push ( "- Use `ode_action` tool for Slack actions (messages, reactions, thread history, questions, uploads)." ) ;
4447 } else {
45- const baseUrl = slack . odeSlackApiUrl ?? getSlackActionApiUrl ( ) ;
46- lines . push ( "- Use bash + curl to call the Ode Slack API." ) ;
48+ lines . push ( "- Use bash + curl to call the Ode action API." ) ;
4749 lines . push ( `- Endpoint: ${ baseUrl } /action` ) ;
48- lines . push ( "- Payload: {\"action\":\"post_message\",\"channelId\":\"...\",\"threadId\":\"...\",\"messageId\":\"...\",\"text\":\"...\"}" ) ;
50+ lines . push (
51+ platform === "discord"
52+ ? "- Payload: {\"platform\":\"discord\",\"action\":\"post_message\",\"channelId\":\"...\",\"messageId\":\"...\",\"text\":\"...\"}"
53+ : "- Payload: {\"action\":\"post_message\",\"channelId\":\"...\",\"threadId\":\"...\",\"messageId\":\"...\",\"text\":\"...\"}"
54+ ) ;
55+ }
56+ if ( platform === "discord" ) {
57+ lines . push ( "- Supported actions: get_guilds, get_channels, post_message, update_message, create_thread_from_message, get_thread_messages, ask_user, add_reaction, get_user_info, upload_file." ) ;
58+ lines . push ( "- Required fields: channelId for message/reaction/question/upload actions; threadId for get_thread_messages; messageId + emoji for reactions; userId (or \"@me\") for get_user_info; filePath for upload_file." ) ;
59+ lines . push ( "- add_reaction schema: { platform: \"discord\", action: \"add_reaction\", channelId: string, messageId: string, emoji: \"thumbsup\" | \"eyes\" | \"ok_hand\" }" ) ;
60+ } else {
61+ lines . push ( "- Supported actions: post_message, add_reaction, get_thread_messages, ask_user, get_user_info, upload_file." ) ;
62+ lines . push ( "- Required fields: channelId; threadId for thread actions; messageId + emoji for reactions; userId for get_user_info." ) ;
63+ lines . push ( "- add_reaction schema: { action: \"add_reaction\", channelId: string, messageId: string, emoji: \"thumbsup\" | \"eyes\" | \"ok_hand\" }" ) ;
4964 }
50- lines . push ( "- Supported actions: post_message, add_reaction, get_thread_messages, ask_user, get_user_info, upload_file." ) ;
51- lines . push ( "- Required fields: channelId; threadId for thread actions; messageId + emoji for reactions; userId for get_user_info." ) ;
52- lines . push ( "- add_reaction schema: { action: \"add_reaction\", channelId: string, messageId: string, emoji: \"thumbsup\" | \"eyes\" | \"ok_hand\" }" ) ;
5365 lines . push ( "- You can use any tool available via bash, curl" ) ;
5466 lines . push ( "" ) ;
55- lines . push ( "IMPORTANT: Your text output is automatically posted to Slack." ) ;
56- lines . push ( "- When asking the user to choose options, you can send an ask_user Slack action, do NOT also output text - the buttons are enough." ) ;
67+ lines . push ( `IMPORTANT: Your text output is automatically posted to ${ platformLabel } .` ) ;
68+ lines . push (
69+ platform === "discord"
70+ ? "- When asking the user to choose options, use ask_user action and do NOT also output text - the posted question is enough."
71+ : "- When asking the user to choose options, you can send an ask_user Slack action, do NOT also output text - the buttons are enough."
72+ ) ;
5773 lines . push ( "- Only output text OR use a messaging tool, never both." ) ;
5874 lines . push ( "" ) ;
5975 lines . push ( "FORMATTING:" ) ;
60- lines . push ( "- Slack uses *bold* and _italic_ (not **bold** or *italic*)" ) ;
76+ lines . push (
77+ platform === "discord"
78+ ? "- Discord supports markdown like **bold**, _italic_, and code fences."
79+ : "- Slack uses *bold* and _italic_ (not **bold** or *italic*)"
80+ ) ;
6181 lines . push ( "- Use ` for inline code and ``` for code blocks" ) ;
6282 lines . push ( "- Keep responses readable on mobile screens" ) ;
6383 lines . push ( "" ) ;
0 commit comments