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
impl CodeMode
Sourcepub fn with_config(config: ModeConfig) -> Self
pub fn with_config(config: ModeConfig) -> Self
Create a Code Mode with custom configuration
Sourcepub fn generate_code(&self, spec: &str) -> Result<String>
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.
Sourcepub async fn create_file(&self, path: &Path, content: &str) -> Result<()>
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.
Sourcepub async fn modify_file(&self, path: &Path, diff: &str) -> Result<()>
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.
Sourcepub fn track_changes(
&self,
files_created: usize,
files_modified: usize,
) -> ChangeSummary
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.
Sourcepub async fn run_tests(
&self,
paths: &[PathBuf],
) -> Result<(usize, usize, Vec<String>)>
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.
Sourcepub fn capture_test_results(
&self,
summary: ChangeSummary,
tests_run: usize,
tests_passed: usize,
failures: Vec<String>,
) -> ChangeSummary
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.
Sourcepub fn report_test_failures(&self, failures: &[String]) -> String
pub fn report_test_failures(&self, failures: &[String]) -> String
Report test failures
This method formats test failures for reporting.
Sourcepub async fn validate_quality(&self, paths: &[PathBuf]) -> Result<Vec<String>>
pub async fn validate_quality(&self, paths: &[PathBuf]) -> Result<Vec<String>>
Validate code quality against workspace standards
This method checks code for quality issues.
Sourcepub fn report_quality_issues(&self, issues: &[String]) -> String
pub fn report_quality_issues(&self, issues: &[String]) -> String
Report quality issues
This method formats quality issues for reporting.
Sourcepub fn suggest_improvements(&self, issues: &[String]) -> Vec<String>
pub fn suggest_improvements(&self, issues: &[String]) -> Vec<String>
Suggest improvements based on quality issues
This method generates suggestions for code improvement.
Sourcepub fn generate_change_summary(
&self,
files_created: usize,
files_modified: usize,
tests_run: usize,
tests_passed: usize,
quality_issues: Vec<String>,
) -> ChangeSummary
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.
Sourcepub fn format_change_summary(&self, summary: &ChangeSummary) -> String
pub fn format_change_summary(&self, summary: &ChangeSummary) -> String
Format a change summary for display
This method creates a human-readable summary of changes.
Sourcepub fn provide_feedback(&self, summary: &ChangeSummary) -> Vec<String>
pub fn provide_feedback(&self, summary: &ChangeSummary) -> Vec<String>
Provide actionable feedback based on summary
This method generates feedback and recommendations.