/** * MI Context-Aware Suggestions — client-side suggestion registry. * * Maps module IDs to suggested prompts. When the MI panel opens, * it reads the current module context and returns matching chips. * No server call needed for static suggestions. */ export interface MiSuggestion { label: string; icon: string; prompt: string; autoSend?: boolean; } const MODULE_SUGGESTIONS: Record = { rspace: [ { label: "Add a note", icon: "📝", prompt: "Add a markdown note to the canvas", autoSend: true }, { label: "Generate an image", icon: "🎨", prompt: "Generate an image", autoSend: false }, { label: "Arrange my shapes", icon: "📐", prompt: "Arrange all shapes on the canvas into a grid", autoSend: true }, { label: "What's on this canvas?", icon: "🔍", prompt: "Summarize what's on this canvas", autoSend: true }, ], rnotes: [ { label: "Create a notebook", icon: "📓", prompt: "Create a new notebook", autoSend: true }, { label: "Summarize my notes", icon: "📋", prompt: "Summarize my recent notes", autoSend: true }, { label: "Import from Obsidian", icon: "⬇", prompt: "How do I import notes from Obsidian?", autoSend: true }, ], rcal: [ { label: "Create an event", icon: "📅", prompt: "Create a calendar event", autoSend: false }, { label: "What's this week?", icon: "🗓", prompt: "What's on my calendar this week?", autoSend: true }, { label: "Import a calendar", icon: "⬇", prompt: "How do I import an ICS calendar?", autoSend: true }, ], rtasks: [ { label: "Create a task", icon: "✅", prompt: "Create a task", autoSend: false }, { label: "Show open tasks", icon: "📋", prompt: "Show my open tasks", autoSend: true }, { label: "Set up a project", icon: "🏗", prompt: "Help me set up a project board", autoSend: true }, ], rflows: [ { label: "Create a flow", icon: "💧", prompt: "Create a new funding flow", autoSend: false }, { label: "How do flows work?", icon: "❓", prompt: "How do community funding flows work?", autoSend: true }, ], rvote: [ { label: "Create a proposal", icon: "🗳", prompt: "Create a governance proposal", autoSend: false }, { label: "Start a vote", icon: "✋", prompt: "Start a governance vote", autoSend: false }, ], rchat: [ { label: "Start a discussion", icon: "💬", prompt: "Start a new discussion thread", autoSend: false }, { label: "Create a channel", icon: "📢", prompt: "Create a new chat channel", autoSend: false }, ], rcrm: [ { label: "Add a contact", icon: "👤", prompt: "Add a new contact", autoSend: false }, { label: "Show my pipeline", icon: "📊", prompt: "Show my CRM pipeline", autoSend: true }, ], rsocials: [ { label: "Create a campaign", icon: "📣", prompt: "Create a social media campaign", autoSend: false }, { label: "Draft a post", icon: "✏", prompt: "Draft a social media post", autoSend: false }, ], rwallet: [ { label: "Check my balance", icon: "💰", prompt: "Check my wallet balance", autoSend: true }, { label: "How do tokens work?", icon: "🪙", prompt: "How do CRDT tokens work?", autoSend: true }, ], rmaps: [ { label: "Share my location", icon: "📍", prompt: "How do I share my location?", autoSend: true }, { label: "Find nearby places", icon: "🔍", prompt: "Find interesting places nearby", autoSend: true }, ], rphotos: [ { label: "Upload photos", icon: "📷", prompt: "How do I upload photos?", autoSend: true }, { label: "Create an album", icon: "🖼", prompt: "Create a new photo album", autoSend: false }, ], rfiles: [ { label: "Upload a file", icon: "📁", prompt: "How do I upload files?", autoSend: true }, { label: "Browse files", icon: "🗂", prompt: "Show my recent files", autoSend: true }, ], }; const GENERIC_SUGGESTIONS: MiSuggestion[] = [ { label: "What can I do here?", icon: "✨", prompt: "What can I do in this space?", autoSend: true }, { label: "Set up this space", icon: "🏗", prompt: "Help me set up this space", autoSend: true }, { label: "Show me around", icon: "🧭", prompt: "Give me a tour of the available rApps", autoSend: true }, ]; const CANVAS_SUGGESTIONS: MiSuggestion[] = [ { label: "Summarize selected", icon: "📋", prompt: "Summarize the selected shapes", autoSend: true }, { label: "Connect these", icon: "🔗", prompt: "Connect the selected shapes", autoSend: true }, { label: "Arrange in grid", icon: "📐", prompt: "Arrange the selected shapes in a grid", autoSend: true }, ]; export function getContextSuggestions(ctx: { module: string; hasShapes: boolean; hasSelectedShapes: boolean; }): MiSuggestion[] { const suggestions: MiSuggestion[] = []; // Canvas selection suggestions take priority if (ctx.hasSelectedShapes) { suggestions.push(...CANVAS_SUGGESTIONS); } // Module-specific suggestions const moduleSuggestions = MODULE_SUGGESTIONS[ctx.module]; if (moduleSuggestions) { suggestions.push(...moduleSuggestions); } // Always add generic suggestions if we have room if (suggestions.length < 6) { const remaining = 6 - suggestions.length; suggestions.push(...GENERIC_SUGGESTIONS.slice(0, remaining)); } return suggestions; }