diff --git a/docs/instruction/instruction.md b/docs/instruction/instruction.md index 25623969..badbbc1b 100644 --- a/docs/instruction/instruction.md +++ b/docs/instruction/instruction.md @@ -23,6 +23,7 @@ for example: | InBlockCompletion | | | | AfterBlockCompletion | | | | TestCode | | | +| Documentation | lines >= 5 | | If you want to add a new instruction, you need to add a new CodeContextStrategy and CompletionBuilderType. diff --git a/docs/instruction/similar-code-completion.md b/docs/instruction/similar-code-completion.md index bb52d75e..6f908ed9 100644 --- a/docs/instruction/similar-code-completion.md +++ b/docs/instruction/similar-code-completion.md @@ -1,13 +1,13 @@ --- layout: default -title: Similar Code Completion +title: SimilarChunks Strategy parent: Instruction Builder nav_order: 2 --- -# Similar Code Completion +# SimilarChunks Strategy -Implement class: SimilarChunksCompletionBuilder +Implement class: SimilarChunks Strategy ## Core Logic diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/SingleProjectCodePicker.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/SingleProjectCodePicker.kt index 27214cb6..8958fb4a 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/SingleProjectCodePicker.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/SingleProjectCodePicker.kt @@ -75,7 +75,7 @@ class SingleProjectCodePicker(private val config: InsPickerOption) { val workerManager = WorkerManager( WorkerContext( - config.buildPlan, + config.codeStrategyTypes, config.codeQualityTypes, config.insOutputConfig, pureDataFileName = config.pureDataFileName(), diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/option/InsPickerOption.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/option/InsPickerOption.kt index 3f0bb5ec..007171c0 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/option/InsPickerOption.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/option/InsPickerOption.kt @@ -1,6 +1,6 @@ package cc.unitmesh.pick.option -import cc.unitmesh.pick.strategy.BuildPlanType +import cc.unitmesh.pick.strategy.CodeStrategyType import cc.unitmesh.core.completion.CompletionBuilderType import cc.unitmesh.pick.threshold.InsQualityThreshold import cc.unitmesh.quality.CodeQualityType @@ -25,7 +25,7 @@ const val MAX_COMPLETION_EACH_FILE = 10 * @property branch The branch of the repository. Default value is "master". * @property language The programming language of the code in the repository. Default value is "java". * @property baseDir The base directory where the datasets are stored. Default value is "datasets". - * @property buildPlan The strategies to determine the code context. Default value is [BuildPlanType.RELATED_CODE]. + * @property codeStrategyTypes The strategies to determine the code context. Default value is [CodeStrategyType.RELATED_CODE]. * Possible values are: * - [CodeContextStrategy.SIMILAR_CHUNKS]: Determines the code context based on similar code chunks. * - [CodeContextStrategy.RELATED_CODE]: Determines the code context based on related code. @@ -53,15 +53,15 @@ data class InsPickerOption( val language: String = "java", val baseDir: String = "datasets", /** - * The [BuildPlanType], suggest to be one of:. + * The [CodeStrategyType], suggest to be one of:. * - * - [BuildPlanType.SIMILAR_CHUNKS] - * - [BuildPlanType.RELATED_CODE] + * - [CodeStrategyType.SIMILAR_CHUNKS] + * - [CodeStrategyType.RELATED_CODE] * */ - val buildPlan: List = listOf( - BuildPlanType.RELATED_CODE, -// BuildPlanType.SIMILAR_CHUNKS, + val codeStrategyTypes: List = listOf( + CodeStrategyType.RELATED_CODE, + CodeStrategyType.SIMILAR_CHUNKS, ), /** * The [CompletionBuilderType], which will according you IDE strategy to generate the type. diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/BuildPlanType.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/CodeStrategyType.kt similarity index 84% rename from unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/BuildPlanType.kt rename to unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/CodeStrategyType.kt index ee202689..cbe8216a 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/BuildPlanType.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/strategy/CodeStrategyType.kt @@ -10,16 +10,16 @@ import kotlinx.serialization.SerializationException * The `BuildPlanType` enum class represents different strategies for generating code context in AutoDev. * * There are two available strategies: - * 1. [BuildPlanType.SIMILAR_CHUNKS]: This prompt is used with pre-built context for unsupported languages. + * 1. [CodeStrategyType.SIMILAR_CHUNKS]: This prompt is used with pre-built context for unsupported languages. * It allows AutoDev to generate code context with similar code chunks builder. - * 2. [BuildPlanType.RELATED_CODE]: This prompt is used with pre-built context. It allows AutoDev to + * 2. [CodeStrategyType.RELATED_CODE]: This prompt is used with pre-built context. It allows AutoDev to * generate code context with similar code builder. * * The strategies are used through the `builder` function, which takes an `InstructionContext` parameter and returns an `InstructionBuilder` object. * * Note that the `builder` function throws a `SerializationException` if the prompt is unknown. */ -enum class BuildPlanType { +enum class CodeStrategyType { /** * the AutoDev with pre-build context for un-support language */ diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerContext.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerContext.kt index 9737f82b..5a058d5d 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerContext.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerContext.kt @@ -1,7 +1,7 @@ package cc.unitmesh.pick.worker import cc.unitmesh.pick.option.InsOutputConfig -import cc.unitmesh.pick.strategy.BuildPlanType +import cc.unitmesh.pick.strategy.CodeStrategyType import cc.unitmesh.core.completion.CompletionBuilderType import cc.unitmesh.pick.project.ProjectContext import cc.unitmesh.pick.threshold.InsQualityThreshold @@ -12,7 +12,7 @@ import org.jetbrains.annotations.TestOnly @Serializable data class WorkerContext( - val codeContextStrategies: List, + val codeContextStrategies: List, val qualityTypes: List, val insOutputConfig: InsOutputConfig, val pureDataFileName: String, diff --git a/unit-picker/src/test/kotlin/cc/unitmesh/pick/SingleProjectCodePickerTest.kt b/unit-picker/src/test/kotlin/cc/unitmesh/pick/SingleProjectCodePickerTest.kt index fb1c417c..67367b5c 100644 --- a/unit-picker/src/test/kotlin/cc/unitmesh/pick/SingleProjectCodePickerTest.kt +++ b/unit-picker/src/test/kotlin/cc/unitmesh/pick/SingleProjectCodePickerTest.kt @@ -3,7 +3,7 @@ package cc.unitmesh.pick import cc.unitmesh.core.Instruction import cc.unitmesh.core.completion.CompletionBuilderType import cc.unitmesh.pick.option.InsPickerOption -import cc.unitmesh.pick.strategy.BuildPlanType +import cc.unitmesh.pick.strategy.CodeStrategyType import kotlinx.coroutines.runBlocking import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -39,7 +39,7 @@ class SingleProjectCodePickerTest { language = "kotlin", url = root, maxTokenLength = 8192, - buildPlan = listOf(BuildPlanType.RELATED_CODE), + codeStrategyTypes = listOf(CodeStrategyType.RELATED_CODE), completionTypes = listOf( CompletionBuilderType.DOCUMENTATION, CompletionBuilderType.TEST_CODE_GEN ),