Skip to content

Commit

Permalink
docs: update docs for instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 24, 2023
1 parent 2ce015b commit 069db5a
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions docs/instruction/instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Unit Eval with combined with CodeContextStrategy and CompletionBuilderType to bu

The instructions will be generated by the following steps:

| | CodeContextStrategy |
|-----------------------|---------------------|
| CompletionBuilderType | |
| TestCode (Todo) | |
| 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:

Expand All @@ -22,13 +22,14 @@ for example:
| InlineCompletion | afterCursor > 10 | |
| InBlockCompletion | | |
| AfterBlockCompletion | | |
| TestCode | | |

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

# Context Strategy

```kotlin
enum class CodeContextStrategy {
enum class BizCodeContextStrategy {
/**
* the AutoDev with pre-build context for un-support language
*/
Expand All @@ -52,18 +53,25 @@ enum class CodeContextStrategy {

```kotlin
enum class CompletionBuilderType {
// TODO: support in future for this
/**
* generate code after cursor, like text after `Blog blog = `, will be `new Blog();`
*/
INLINE_COMPLETION,

/**
* generate the rest of code of correct block, like function inner code
*/
IN_BLOCK_COMPLETION,
AFTER_BLOCK_COMPLETION;

fun builder(context: JobContext): CompletionBuilder {
return mapOf(
INLINE_COMPLETION to InlineCodeCompletionBuilder(context),
IN_BLOCK_COMPLETION to InBlockCodeCompletionBuilder(context),
AFTER_BLOCK_COMPLETION to AfterBlockCodeCompletionBuilder(context),
)[this] ?: throw SerializationException("Unknown message type: $this")
}
/**
* generate code after block, like multiple functions
*/
AFTER_BLOCK_COMPLETION,

/**
* generate full file code, like test code, class code, api code
*/
TEST_CODE_GEN,
}
```

0 comments on commit 069db5a

Please sign in to comment.