Skip to content

Commit

Permalink
feat(terminal): add basic support for AI-generated shell scripts #135
Browse files Browse the repository at this point in the history
This commit introduces a new extension module for terminal support, including a plugin and an action to generate shell scripts using AI. The `ext-terminal` module is added to the project and its dependencies are configured. The `plugin.xml` file is updated to include the `cc.unitmesh.terminal` module, and a new file `cc.unitmesh.terminal.xml` is created with the necessary plugin configuration.

Additionally, the `QuickAssistantAction` class is modified to include a new action for generating shell scripts, and the `autodev-core.xml` file is updated to add this action to the appropriate group. The `settings.gradle.kts` file is also updated to include the `ext-terminal` module in the project setup.
  • Loading branch information
phodal committed Apr 4, 2024
1 parent e511179 commit a2244d9
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 3 deletions.
12 changes: 12 additions & 0 deletions build.gradle.kts
Expand Up @@ -267,6 +267,7 @@ project(":plugin") {
implementation(project(":exts:database"))
implementation(project(":exts:ext-android"))
implementation(project(":exts:ext-harmonyos"))
implementation(project(":exts:ext-terminal"))
implementation(project(":exts:devins-lang"))
}

Expand Down Expand Up @@ -589,6 +590,17 @@ project(":exts:ext-harmonyos") {
}
}

project(":exts:ext-terminal") {
intellij {
version.set(ideaVersion)
plugins.set((ideaPlugins + "org.jetbrains.plugins.terminal"))
}

dependencies {
implementation(project(":"))
}
}

project(":exts:devins-lang") {
apply {
plugin("org.jetbrains.grammarkit")
Expand Down
@@ -0,0 +1,13 @@
package cc.unitmesh.terminal

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.editor.ex.EditorEx

class GenShellAction: AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val editor = e.getData(CommonDataKeys.EDITOR) as? EditorEx ?: return

}
}
18 changes: 18 additions & 0 deletions exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml
@@ -0,0 +1,18 @@
<idea-plugin package="cc.unitmesh.terminal">
<!--suppress PluginXmlValidity -->
<dependencies>
<plugin id="org.jetbrains.plugins.terminal"/>
</dependencies>

<actions>

<action id="genShell"
class="cc.unitmesh.terminal.GenShellAction"
description="Ask AI to generate shell"
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
>

<add-to-group group-id="TerminalToolwindowActionGroup" anchor="last"/>
</action>
</actions>
</idea-plugin>
3 changes: 2 additions & 1 deletion plugin/src/main/resources/META-INF/plugin.xml
Expand Up @@ -29,13 +29,14 @@
<module name="cc.unitmesh.go"/>
<module name="cc.unitmesh.rust"/>
<module name="cc.unitmesh.cpp"/>
<module name="cc.unitmesh.scala"/>
<!-- <module name="cc.unitmesh.scala"/>-->
<!-- <module name="cc.unitmesh.csharp"/>-->

<!-- extension modules -->
<module name="cc.unitmesh.database"/>
<module name="cc.unitmesh.android"/>
<module name="cc.unitmesh.harmonyos"/>
<!-- <module name="cc.unitmesh.terminal"/>-->
<module name="cc.unitmesh.devti.language"/>
</content>
</idea-plugin>
1 change: 1 addition & 0 deletions settings.gradle.kts
Expand Up @@ -23,6 +23,7 @@ include(
// since JetBrains also call `android.jar`, so we rename it to `ext-android`
"exts:ext-android",
"exts:ext-harmonyos",
"exts:ext-terminal",

// the Input Language support for AutoDev
"exts:devins-lang"
Expand Down
1 change: 0 additions & 1 deletion src/233/main/resources/META-INF/autodev-core.xml
Expand Up @@ -272,7 +272,6 @@
description="Ask AI generate test data">

<add-to-group group-id="GenerateGroup" anchor="last"/>
<!-- <add-to-group group-id="TerminalToolwindowActionGroup" anchor="last"/>-->
</action>

<add-to-group group-id="EditorPopupMenu" anchor="first"/>
Expand Down
Expand Up @@ -32,7 +32,7 @@ import javax.swing.AbstractAction
* A quick insight action is an action that can be triggered by a user,
* user can input custom text to call with LLM.
*/
class QuickAssistantAction : AnAction() {
open class QuickAssistantAction : AnAction() {
init{
val presentation = getTemplatePresentation()
presentation.text = AutoDevBundle.message("settings.autodev.others.quickAssistant")
Expand Down

0 comments on commit a2244d9

Please sign in to comment.