@@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
13
13
import com.intellij.openapi.actionSystem.AnActionHolder
14
14
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
15
15
import com.intellij.openapi.project.Project
16
+ import com.intellij.openapi.project.guessProjectDir
16
17
import com.intellij.openapi.ui.popup.Balloon
17
18
import com.intellij.openapi.ui.popup.JBPopupFactory
18
19
import com.intellij.openapi.ui.popup.JBPopupListener
@@ -27,6 +28,7 @@ import com.intellij.util.ui.SwingHelper
27
28
import com.intellij.util.ui.UIUtil
28
29
import kotlinx.coroutines.flow.*
29
30
import kotlinx.coroutines.launch
31
+ import org.jetbrains.plugins.terminal.TerminalProjectOptionsProvider
30
32
import java.awt.Component
31
33
import java.awt.Font
32
34
import java.awt.Point
@@ -42,23 +44,24 @@ private const val ERROR_VALUE = "error"
42
44
class ShellCommandSuggestAction : AnAction () {
43
45
override fun actionPerformed (e : AnActionEvent ) {
44
46
val project = e.project ? : return
45
-
46
- val popupPoint = getPreferredPopupPoint(e)
47
-
48
47
val contextComponent = e.getData(PlatformCoreDataKeys .CONTEXT_COMPONENT ) ? : return
49
48
50
- showContentRenamePopup(contextComponent, popupPoint ) { data ->
49
+ showContentRenamePopup(contextComponent, getPreferredPopupPoint(e) ) { data ->
51
50
val widget = TerminalUtil .getCurrentTerminalWidget(project) ? : return @showContentRenamePopup
52
51
suggestCommand(widget, data, project)
53
52
}
54
53
}
55
54
56
- data class ShellSuggestions (val question : String )
57
-
58
55
private fun suggestCommand (widget : JBTerminalWidget , data : String , project : Project ) {
59
56
val templateRender = TemplateRender (GENIUS_PRACTISES )
60
57
val template = templateRender.getTemplate(" shell-suggest.vm" )
61
- templateRender.context = ShellSuggestions (data)
58
+
59
+ val options = TerminalProjectOptionsProvider .getInstance(project)
60
+
61
+ templateRender.context = ShellSuggestContext (
62
+ data, options.shellPath, options.startingDirectory
63
+ ? : project.guessProjectDir()?.path ? : System .getProperty(" user.home" )
64
+ )
62
65
val promptText = templateRender.renderTemplate(template)
63
66
64
67
val llm = LlmFactory .instance.create(project)
@@ -156,3 +159,4 @@ class ShellCommandSuggestAction : AnAction() {
156
159
}
157
160
}
158
161
162
+ data class ShellSuggestContext (val question : String , val shellPath : String , val cwd : String )
0 commit comments