ricecoder_modes/mode.rs
1//! Mode trait definition
2
3use crate::error::Result;
4use crate::models::{
5 Capability, ModeConfig, ModeConstraints, ModeContext, ModeResponse, Operation,
6};
7use async_trait::async_trait;
8
9/// Trait that all modes must implement
10///
11/// This trait defines the interface for all modes in the RiceCoder system.
12/// Each mode must provide its own implementation of these methods.
13#[async_trait]
14pub trait Mode: Send + Sync {
15 /// Mode identifier (e.g., "code", "ask", "vibe")
16 fn id(&self) -> &str;
17
18 /// Human-readable name
19 fn name(&self) -> &str;
20
21 /// Mode description
22 fn description(&self) -> &str;
23
24 /// Get system prompt for this mode
25 fn system_prompt(&self) -> &str;
26
27 /// Process user input in this mode
28 async fn process(&self, input: &str, context: &ModeContext) -> Result<ModeResponse>;
29
30 /// Get mode-specific capabilities
31 fn capabilities(&self) -> Vec<Capability>;
32
33 /// Get mode configuration
34 fn config(&self) -> &ModeConfig;
35
36 /// Validate if operation is allowed in this mode
37 fn can_execute(&self, operation: &Operation) -> bool;
38
39 /// Get mode-specific constraints
40 fn constraints(&self) -> ModeConstraints;
41}