Skip to content

Commit 3b12625

Browse files
committed
fix(devins-language): update ToolHubVariable property names #100
Updating the property names of ToolHubVariable to better reflect their purpose and usage. Also, adjusting the lookup method to handle the new property names and provide more descriptive output in the AgentToolOverviewCompletion class.
1 parent 2796660 commit 3b12625

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/DevInsCompiler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DevInsCompiler(
114114
val variableId = id?.text
115115
val variable = ToolHubVariable.lookup(myProject, variableId)
116116
if (variable.isNotEmpty()) {
117-
output.append(variable.first())
117+
output.append(variable.map { it }.joinToString("\n"))
118118
return
119119
}
120120

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/dataprovider/ToolHubVariable.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.intellij.openapi.util.NlsSafe
1212
* $agent
1313
* ```
1414
*/
15-
enum class ToolHubVariable(val summaryName: String, val type: String, val description: String) {
15+
enum class ToolHubVariable(val hubName: String, val type: String, val description: String) {
1616
AGENTS("agents", CustomAgentConfig::class.simpleName.toString(), "DevIns all agent for AI Agent to call"),
1717
COMMANDS("commands", BuiltinCommand::class.simpleName.toString(), "DevIns all commands for AI Agent to call"),
1818

@@ -23,16 +23,19 @@ enum class ToolHubVariable(val summaryName: String, val type: String, val descri
2323
return values().toList()
2424
}
2525

26-
2726
/**
2827
* @param variableId should be one of the [ToolHubVariable] name
2928
*/
3029
fun lookup(myProject: Project, variableId: @NlsSafe String?): List<String> {
3130
return when (variableId) {
32-
AGENTS.name -> CustomAgentConfig.loadFromProject(myProject).map { it.name }
33-
COMMANDS.name -> BuiltinCommand.all().map { it.commandName }
31+
AGENTS.hubName -> CustomAgentConfig.loadFromProject(myProject).map {
32+
"- " + it.name + ". " + it.description
33+
}
34+
COMMANDS.hubName -> BuiltinCommand.all().map {
35+
"- " + it.commandName + ". " + it.description
36+
}
3437
else -> emptyList()
3538
}
3639
}
3740
}
38-
}
41+
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/provider/AgentToolOverviewCompletion.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ class AgentToolOverviewCompletion : CompletionProvider<CompletionParameters>() {
1616
result: CompletionResultSet
1717
) {
1818
ToolHubVariable.all().forEach { toolHub ->
19-
val elements = LookupElementBuilder.create(toolHub.summaryName)
19+
val elements = LookupElementBuilder.create(toolHub.hubName)
2020
.withIcon(DevInIcons.DEFAULT)
21-
.withTypeText(toolHub.type, true)
22-
.withPresentableText(toolHub.summaryName)
23-
.withTailText(toolHub.description, true)
21+
.withTypeText("(${toolHub.description})", true)
22+
.withPresentableText(toolHub.hubName)
23+
.withTailText(toolHub.type, true)
24+
2425
result.addElement(PrioritizedLookupElement.withPriority(elements, 0.0))
2526
}
2627
}

0 commit comments

Comments
 (0)