From a2244d9204a72e091b7cefa5abe236248ebc3161 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 4 Apr 2024 11:07:42 +0800 Subject: [PATCH] feat(terminal): add basic support for AI-generated shell scripts #135 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. --- build.gradle.kts | 12 ++++++++++++ .../cc/unitmesh/terminal/GenShellAction.kt | 13 +++++++++++++ .../main/resources/cc.unitmesh.terminal.xml | 18 ++++++++++++++++++ plugin/src/main/resources/META-INF/plugin.xml | 3 ++- settings.gradle.kts | 1 + .../main/resources/META-INF/autodev-core.xml | 1 - .../actions/quick/QuickAssistantAction.kt | 2 +- 7 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/GenShellAction.kt create mode 100644 exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml diff --git a/build.gradle.kts b/build.gradle.kts index 53f771bd89..1578c056bf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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")) } @@ -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") diff --git a/exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/GenShellAction.kt b/exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/GenShellAction.kt new file mode 100644 index 0000000000..40cbd685fe --- /dev/null +++ b/exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/GenShellAction.kt @@ -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 + + } +} \ No newline at end of file diff --git a/exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml b/exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml new file mode 100644 index 0000000000..d586bf0516 --- /dev/null +++ b/exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/plugin/src/main/resources/META-INF/plugin.xml b/plugin/src/main/resources/META-INF/plugin.xml index bf8a57e66b..1b7559f75a 100644 --- a/plugin/src/main/resources/META-INF/plugin.xml +++ b/plugin/src/main/resources/META-INF/plugin.xml @@ -29,13 +29,14 @@ - + + diff --git a/settings.gradle.kts b/settings.gradle.kts index 48f25c257a..557bf8ba29 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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" diff --git a/src/233/main/resources/META-INF/autodev-core.xml b/src/233/main/resources/META-INF/autodev-core.xml index 448f9953a3..ff16b3e8b7 100644 --- a/src/233/main/resources/META-INF/autodev-core.xml +++ b/src/233/main/resources/META-INF/autodev-core.xml @@ -272,7 +272,6 @@ description="Ask AI generate test data"> - diff --git a/src/main/kotlin/cc/unitmesh/devti/actions/quick/QuickAssistantAction.kt b/src/main/kotlin/cc/unitmesh/devti/actions/quick/QuickAssistantAction.kt index 273f342517..15d7ccfc90 100644 --- a/src/main/kotlin/cc/unitmesh/devti/actions/quick/QuickAssistantAction.kt +++ b/src/main/kotlin/cc/unitmesh/devti/actions/quick/QuickAssistantAction.kt @@ -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")