prompt.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { feature } from 'bun:bundle'
  2. import type { Message } from '../types/message.js'
  3. import type { Attachment } from '../utils/attachments.js'
  4. import { getGlobalConfig } from '../utils/config.js'
  5. import { getCompanion } from './companion.js'
  6. export function companionIntroText(name: string, species: string): string {
  7. return `# Companion
  8. A small ${species} named ${name} sits beside the user's input box and occasionally comments in a speech bubble. You're not ${name} — it's a separate watcher.
  9. When the user addresses ${name} directly (by name), its bubble will answer. Your job in that moment is to stay out of the way: respond in ONE line or less, or just answer any part of the message meant for you. Don't explain that you're not ${name} — they know. Don't narrate what ${name} might say — the bubble handles that.`
  10. }
  11. export function getCompanionIntroAttachment(
  12. messages: Message[] | undefined,
  13. ): Attachment[] {
  14. if (!feature('BUDDY')) return []
  15. const companion = getCompanion()
  16. if (!companion || getGlobalConfig().companionMuted) return []
  17. // Skip if already announced for this companion.
  18. for (const msg of messages ?? []) {
  19. if (msg.type !== 'attachment') continue
  20. if (msg.attachment.type !== 'companion_intro') continue
  21. if (msg.attachment.name === companion.name) return []
  22. }
  23. return [
  24. {
  25. type: 'companion_intro',
  26. name: companion.name,
  27. species: companion.species,
  28. },
  29. ]
  30. }