com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.kt Maven / Gradle / Ivy
package com.simiacryptus.skyenet.apps.plan.file
import com.simiacryptus.jopenai.describe.Description
import com.simiacryptus.skyenet.apps.plan.PlanSettings
import com.simiacryptus.skyenet.apps.plan.TaskType
import com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.CodeOptimizationTaskData
import org.slf4j.LoggerFactory
class CodeOptimizationTask(
planSettings: PlanSettings,
planTask: CodeOptimizationTaskData?
) : AbstractAnalysisTask(planSettings, planTask) {
class CodeOptimizationTaskData(
@Description("Files to be optimized")
val filesToOptimize: List? = null,
@Description("Specific areas of focus for the optimization")
val optimizationFocus: List? = null,
task_description: String? = null,
task_dependencies: List? = null,
input_files: List? = null,
output_files: List? = null,
state: TaskState? = null
) : FileTaskBase(
task_type = TaskType.Optimization.name,
task_description = task_description,
task_dependencies = task_dependencies,
input_files = input_files,
output_files = output_files,
state = state
)
override val actorName = "CodeOptimization"
override val actorPrompt = """
Analyze the provided code and suggest optimizations to improve code quality. Focus exclusively on:
|1. Code structure and organization
|2. Readability improvements
|3. Maintainability enhancements
|4. Proper use of language-specific features and best practices
|5. Design pattern applications
|
|Provide detailed explanations for each suggested optimization, including:
|- The reason for the optimization
|- The expected benefits
|- Any potential trade-offs or considerations
|
|Format the response as a markdown document with appropriate headings and code snippets.
|Use diff format to show the proposed changes clearly.
""".trimMargin()
override fun promptSegment(): String {
return """
|CodeOptimization - Analyze and optimize existing code for better readability, maintainability, and adherence to best practices
| * Specify the files to be optimized
| * Optionally provide specific areas of focus for the optimization (e.g., code structure, readability, design patterns)
""".trimMargin()
}
override fun getAnalysisInstruction(): String {
return "Optimize the following code for better readability and maintainability"
}
companion object {
private val log = LoggerFactory.getLogger(CodeOptimizationTask::class.java)
}
}