Skip to content

Commit be0e071

Browse files
committed
feat(sketch): add toolchain function support in DevIns #308
- Add support for toolchain function commands in DevIns transpilation. - Update UI messages for DevIns compilation in both English and Chinese. - Modify function name formatting in DatabaseFunction to include "database:" prefix.
1 parent b04ab80 commit be0e071

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

core/src/main/kotlin/cc/unitmesh/devti/bridge/provider/DatabaseFunction.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ enum class DatabaseFunction(val funName: String) {
1212
return entries.firstOrNull { it.funName == value }
1313
}
1414

15-
fun allFuncNames(): List<String> = entries.map { it.funName }
15+
fun allFuncNames(): List<String> = entries.map {
16+
"database:" + it.funName
17+
}
1618
}
1719
}

core/src/main/kotlin/cc/unitmesh/devti/sketch/AutoSketchMode.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cc.unitmesh.devti.sketch
22

33
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand
4+
import cc.unitmesh.devti.provider.toolchain.ToolchainFunctionProvider
45
import cc.unitmesh.devti.util.parser.CodeFence
56
import com.intellij.openapi.components.Service
67
import com.intellij.openapi.components.service
@@ -16,7 +17,7 @@ class AutoSketchMode() {
1617
val devinCodeFence = codeFenceList.filter { it.language.displayName == "DevIn" }
1718

1819
val allCode = devinCodeFence.filter {
19-
!it.text.contains("<DevinsError>") && (hasReadCommand(it))
20+
!it.text.contains("<DevinsError>") && (hasReadCommand(it) || hasToolchainFunctionCommand(it))
2021
}
2122

2223
if (allCode.isEmpty()) return
@@ -33,6 +34,12 @@ class AutoSketchMode() {
3334
fence.text.contains("/" + command.commandName + ":")
3435
}
3536

37+
private fun hasToolchainFunctionCommand(fence: CodeFence): Boolean {
38+
val toolchainCmds = ToolchainFunctionProvider.all().map { it.funcNames() }.flatten()
39+
return toolchainCmds.any {
40+
fence.text.contains("/$it:")
41+
}
42+
}
3643

3744
companion object {
3845
fun getInstance(project: Project): AutoSketchMode {

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchInputListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ open class SketchInputListener(
101101

102102
toolWindow.onFinish(suggestion.toString())
103103
}
104-
}, "Compile DevIns", false, project);
104+
}, AutoDevBundle.message("sketch.compile.devins"), false, project);
105105
}
106106

107107
override fun dispose() {

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,4 @@ sketch.dependencies.check=Check dependencies has Issues
223223
prompts.autodev.bridge=Bridge
224224
autodev.custom.llms.placeholder=Custom different LLM
225225
settings.autodev.coder.customLlms=Config LLMs: Plan/ACT/Completion/Embedding/FastApply
226+
sketch.compile.devins=Collect context (aka. transpile AutoDev DevIns)

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,5 @@ sketch.dependencies.check=Check dependencies has Issues
222222
prompts.autodev.bridge=Bridge
223223
autodev.custom.llms.placeholder=Custom diffrent LLM
224224
settings.autodev.coder.customLlms=自定义不同模型: Plan/ACT/Completion/Embedding/FastApply
225+
#sketch.compile.devins="Collect context (Transpile AutoDev DevIns)"
226+
sketch.compile.devins=收集上下文中(即转译 AutoDev DevIns 指令)

0 commit comments

Comments
 (0)