Skip to content

Commit 81766ff

Browse files
committed
feat(devin-compiler): add support for builtin commands and agents in DevInCompiler #101
The DevInCompiler now supports builtin commands and agents, enhancing the language's capabilities.
1 parent ed9378b commit 81766ff

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/DevInCompiler.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devti.language.compiler
22

3+
import cc.unitmesh.devti.language.completion.BuiltinCommand
34
import cc.unitmesh.devti.language.psi.DevInFile
45
import cc.unitmesh.devti.language.psi.DevInTypes
56
import cc.unitmesh.devti.language.psi.DevInUsed
@@ -36,6 +37,46 @@ class DevInCompiler(val project: Project, val file: DevInFile, val editor: Edito
3637
}
3738

3839
private fun processUsed(used: DevInUsed) {
40+
val firstChild = used.firstChild
41+
val id = used.children.getOrNull(1)
3942

43+
when (firstChild.elementType) {
44+
DevInTypes.COMMAND_START -> {
45+
/**
46+
*
47+
*/
48+
49+
val command = BuiltinCommand.fromString(id?.text ?: "")
50+
if (command == null) {
51+
output.append(used.text)
52+
logger.warn("Unknown command: ${id?.text}")
53+
return
54+
}
55+
56+
when (command) {
57+
BuiltinCommand.FILE -> TODO()
58+
BuiltinCommand.REV -> TODO()
59+
BuiltinCommand.SYMBOL -> TODO()
60+
BuiltinCommand.WRITE -> TODO()
61+
}
62+
}
63+
64+
DevInTypes.AGENT_START -> {
65+
/**
66+
* add for post action
67+
*/
68+
}
69+
70+
DevInTypes.VARIABLE_START -> {
71+
/**
72+
* Todo, call [cc.unitmesh.devti.custom.compile.VariableTemplateCompiler]
73+
*/
74+
}
75+
76+
else -> {
77+
output.append(used.text)
78+
logger.warn("Unknown used type: ${firstChild.elementType}")
79+
}
80+
}
4081
}
4182
}

exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/BuiltinCommandProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ enum class BuiltinCommand(val agentName: String, val description: String) {
1616
fun all(): List<BuiltinCommand> {
1717
return values().toList()
1818
}
19+
20+
fun fromString(agentName: String): BuiltinCommand? {
21+
return values().find { it.agentName == agentName }
22+
}
1923
}
2024
}
2125

0 commit comments

Comments
 (0)