Skip to content

Commit

Permalink
fix(devins-language): update ToolHubVariable property names #100
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phodal committed Mar 21, 2024
1 parent 2796660 commit 3b12625
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Expand Up @@ -114,7 +114,7 @@ class DevInsCompiler(
val variableId = id?.text
val variable = ToolHubVariable.lookup(myProject, variableId)
if (variable.isNotEmpty()) {
output.append(variable.first())
output.append(variable.map { it }.joinToString("\n"))
return
}

Expand Down
Expand Up @@ -12,7 +12,7 @@ import com.intellij.openapi.util.NlsSafe
* $agent
* ```
*/
enum class ToolHubVariable(val summaryName: String, val type: String, val description: String) {
enum class ToolHubVariable(val hubName: String, val type: String, val description: String) {
AGENTS("agents", CustomAgentConfig::class.simpleName.toString(), "DevIns all agent for AI Agent to call"),
COMMANDS("commands", BuiltinCommand::class.simpleName.toString(), "DevIns all commands for AI Agent to call"),

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


/**
* @param variableId should be one of the [ToolHubVariable] name
*/
fun lookup(myProject: Project, variableId: @NlsSafe String?): List<String> {
return when (variableId) {
AGENTS.name -> CustomAgentConfig.loadFromProject(myProject).map { it.name }
COMMANDS.name -> BuiltinCommand.all().map { it.commandName }
AGENTS.hubName -> CustomAgentConfig.loadFromProject(myProject).map {
"- " + it.name + ". " + it.description
}
COMMANDS.hubName -> BuiltinCommand.all().map {
"- " + it.commandName + ". " + it.description
}
else -> emptyList()
}
}
}
}
}
Expand Up @@ -16,11 +16,12 @@ class AgentToolOverviewCompletion : CompletionProvider<CompletionParameters>() {
result: CompletionResultSet
) {
ToolHubVariable.all().forEach { toolHub ->
val elements = LookupElementBuilder.create(toolHub.summaryName)
val elements = LookupElementBuilder.create(toolHub.hubName)
.withIcon(DevInIcons.DEFAULT)
.withTypeText(toolHub.type, true)
.withPresentableText(toolHub.summaryName)
.withTailText(toolHub.description, true)
.withTypeText("(${toolHub.description})", true)
.withPresentableText(toolHub.hubName)
.withTailText(toolHub.type, true)

result.addElement(PrioritizedLookupElement.withPriority(elements, 0.0))
}
}
Expand Down

0 comments on commit 3b12625

Please sign in to comment.