CodeMode

Struct CodeMode 

Source
pub struct CodeMode { /* private fields */ }
Expand description

Code Mode for focused code generation and modification

Code Mode provides full capabilities for:

  • Code generation from specifications
  • File creation and modification
  • Test execution
  • Quality validation
  • Change summarization

Implementations§

Source§

impl CodeMode

Source

pub fn new() -> Self

Create a new Code Mode instance

Source

pub fn with_config(config: ModeConfig) -> Self

Create a Code Mode with custom configuration

Source

pub fn generate_code(&self, spec: &str) -> Result<String>

Generate code from a specification

This method generates code based on the provided specification. The generated code is tracked for later file operations.

Source

pub async fn create_file(&self, path: &Path, content: &str) -> Result<()>

Create a file with the given content

This method creates a new file at the specified path with the given content.

Source

pub async fn modify_file(&self, path: &Path, diff: &str) -> Result<()>

Modify a file with the given diff

This method applies a diff to an existing file.

Source

pub fn track_changes( &self, files_created: usize, files_modified: usize, ) -> ChangeSummary

Track file changes and return a summary

This method creates a summary of file operations performed.

Source

pub async fn run_tests( &self, paths: &[PathBuf], ) -> Result<(usize, usize, Vec<String>)>

Run tests for the given paths

This method executes tests and captures the results.

Source

pub fn capture_test_results( &self, summary: ChangeSummary, tests_run: usize, tests_passed: usize, failures: Vec<String>, ) -> ChangeSummary

Capture test results and update summary

This method updates a change summary with test results.

Source

pub fn report_test_failures(&self, failures: &[String]) -> String

Report test failures

This method formats test failures for reporting.

Source

pub async fn validate_quality(&self, paths: &[PathBuf]) -> Result<Vec<String>>

Validate code quality against workspace standards

This method checks code for quality issues.

Source

pub fn report_quality_issues(&self, issues: &[String]) -> String

Report quality issues

This method formats quality issues for reporting.

Source

pub fn suggest_improvements(&self, issues: &[String]) -> Vec<String>

Suggest improvements based on quality issues

This method generates suggestions for code improvement.

Source

pub fn generate_change_summary( &self, files_created: usize, files_modified: usize, tests_run: usize, tests_passed: usize, quality_issues: Vec<String>, ) -> ChangeSummary

Generate a summary of all changes made

This method creates a comprehensive summary including file counts, test results, and quality issues.

Source

pub fn format_change_summary(&self, summary: &ChangeSummary) -> String

Format a change summary for display

This method creates a human-readable summary of changes.

Source

pub fn provide_feedback(&self, summary: &ChangeSummary) -> Vec<String>

Provide actionable feedback based on summary

This method generates feedback and recommendations.

Trait Implementations§

Source§

impl Clone for CodeMode

Source§

fn clone(&self) -> CodeMode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CodeMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Mode for CodeMode

Source§

fn id(&self) -> &str

Mode identifier (e.g., “code”, “ask”, “vibe”)
Source§

fn name(&self) -> &str

Human-readable name
Source§

fn description(&self) -> &str

Mode description
Source§

fn system_prompt(&self) -> &str

Get system prompt for this mode
Source§

fn process<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, input: &'life1 str, context: &'life2 ModeContext, ) -> Pin<Box<dyn Future<Output = Result<ModeResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Process user input in this mode
Source§

fn capabilities(&self) -> Vec<Capability>

Get mode-specific capabilities
Source§

fn config(&self) -> &ModeConfig

Get mode configuration
Source§

fn can_execute(&self, operation: &Operation) -> bool

Validate if operation is allowed in this mode
Source§

fn constraints(&self) -> ModeConstraints

Get mode-specific constraints

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.