Codex Handbook
core/src/context/collaboration_mode_instructions.rs 40 lines
use super::ContextualUserFragment;use codex_protocol::config_types::CollaborationMode;use codex_protocol::protocol::COLLABORATION_MODE_CLOSE_TAG;use codex_protocol::protocol::COLLABORATION_MODE_OPEN_TAG;#[derive(Debug, Clone, PartialEq)]pub(crate) struct CollaborationModeInstructions {    instructions: String,}impl CollaborationModeInstructions {    pub(crate) fn from_collaboration_mode(collaboration_mode: &CollaborationMode) -> Option<Self> {        collaboration_mode            .settings            .developer_instructions            .as_ref()            .filter(|instructions| !instructions.is_empty())            .map(|instructions| Self {                instructions: instructions.clone(),            })    }}impl ContextualUserFragment for CollaborationModeInstructions {    fn role(&self) -> &'static str {        "developer"    }    fn markers(&self) -> (&'static str, &'static str) {        Self::type_markers()    }    fn type_markers() -> (&'static str, &'static str) {        (COLLABORATION_MODE_OPEN_TAG, COLLABORATION_MODE_CLOSE_TAG)    }    fn body(&self) -> String {        self.instructions.clone()    }}