UnitGen with combined with CodeContextStrategy and CompletionBuilderType to build the instruction.

The instructions will be generated by the following steps:

CodeContextStrategy Description
SimilarChunks tokenize path to find similar path, then calculate similar chunk by path
RelatedCode use static analysis by imports to calculate related code

for example:

  SimilarChunks RelatedCode
InlineCompletion afterCursor > 10  
InBlockCompletion    
AfterBlockCompletion    
TestCode    
Documentation lines >= 5  

If you want to add a new instruction, you need to add a new CodeContextStrategy and CompletionBuilderType.

Code Context Strategy

enum class BizCodeContextStrategy {
    /**
     * the AutoDev with pre-build context for un-support language
     */
    SIMILAR_CHUNKS,

    /**
     * the AutoDev with pre-build context
     */
    RELATED_CODE;

    fun builder(context: JobContext): CodeContextBuilder<out Any> {
        return mapOf(
            SIMILAR_CHUNKS to SimilarChunksCompletionBuilder(context),
            RELATED_CODE to RelatedCodeCompletionBuilder(context),
        )[this] ?: throw SerializationException("Unknown message type: $this")
    }
}

Completion Type

enum class CompletionBuilderType {
    INLINE_COMPLETION,
    IN_BLOCK_COMPLETION,
    AFTER_BLOCK_COMPLETION,
    TEST_CODE_GEN,
    DOCUMENTATION
}

Table of contents