Skip to content

Commit 4b9f2e9

Browse files
committed
feat(devti): add domain dictionary service and magic icon #358
- Implement DomainDictService for loading and parsing domain-specific dictionaries - Add MAGIC icon to AutoDevIcons - Include new magic.svg icon file - Update build.gradle.kts to include csv parsing dependency
1 parent a70687e commit 4b9f2e9

File tree

6 files changed

+88
-15
lines changed

6 files changed

+88
-15
lines changed

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ project(":core") {
440440

441441
// implementation("com.nfeld.jsonpathkt:jsonpathkt:2.0.1")
442442
implementation("com.jayway.jsonpath:json-path:2.9.0")
443+
implementation("com.jsoizo:kotlin-csv-jvm:1.10.0") {
444+
excludeKotlinDeps()
445+
}
443446

444447
// chocolate factorys
445448
// follow: https://onnxruntime.ai/docs/get-started/with-java.html
@@ -696,7 +699,8 @@ project(":exts:ext-endpoints") {
696699
intellijIde(prop("ideaVersion"))
697700
intellijPlugins(ideaPlugins + prop("endpointsPlugin") + prop("swaggerPlugin"))
698701
intellijPlugins(
699-
listOf("com.intellij.spring", "com.intellij.spring.mvc",
702+
listOf(
703+
"com.intellij.spring", "com.intellij.spring.mvc",
700704
// "com.intellij.micronaut"
701705
)
702706
)

core/src/main/kotlin/cc/unitmesh/devti/AutoDevIcons.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object AutoDevIcons {
2121
val InProgress = AnimatedIcon.Default()
2222

2323
@JvmField
24-
val Send: Icon = IconLoader.getIcon("/icons/send.svg", AutoDevIcons::class.java)
24+
val SEND: Icon = IconLoader.getIcon("/icons/send.svg", AutoDevIcons::class.java)
2525

2626
@JvmField
2727
val InsertCode: Icon = IconLoader.getIcon("/icons/insert-code.svg", AutoDevIcons::class.java)
@@ -100,4 +100,7 @@ object AutoDevIcons {
100100

101101
@JvmField
102102
val RERUN: Icon = IconLoader.getIcon("/icons/rerun.svg", AutoDevIcons::class.java)
103+
104+
@JvmField
105+
val MAGIC: Icon = IconLoader.getIcon("/icons/magic.svg", AutoDevIcons::class.java)
103106
}

core/src/main/kotlin/cc/unitmesh/devti/gui/chat/ui/AutoDevInputSection.kt

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cc.unitmesh.devti.gui.chat.ui
22

33
import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.AutoDevIcons
5+
import cc.unitmesh.devti.AutoDevNotifications
56
import cc.unitmesh.devti.agent.custom.model.CustomAgentConfig
67
import cc.unitmesh.devti.agent.custom.model.CustomAgentState
78
import cc.unitmesh.devti.completion.AutoDevInputLookupManagerListener
@@ -21,7 +22,6 @@ import com.intellij.openapi.Disposable
2122
import com.intellij.openapi.actionSystem.Presentation
2223
import com.intellij.openapi.actionSystem.impl.ActionButton
2324
import com.intellij.openapi.application.ApplicationManager
24-
import com.intellij.openapi.application.invokeLater
2525
import com.intellij.openapi.application.runInEdt
2626
import com.intellij.openapi.diagnostic.logger
2727
import com.intellij.openapi.editor.event.DocumentEvent
@@ -67,15 +67,17 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
6767
private val documentListener: DocumentListener
6868
private val sendButtonPresentation: Presentation
6969
private val stopButtonPresentation: Presentation
70+
private val enhanceButtonPresentation: Presentation
7071
private val sendButton: ActionButton
7172
private val stopButton: ActionButton
72-
private val buttonPanel = JPanel(CardLayout())
73+
private val enhanceButton: ActionButton
74+
private var buttonPanel: JPanel = JPanel(CardLayout())
7375
private val inputPanel = BorderLayoutPanel()
7476
val focusableComponent: JComponent get() = input
7577

7678
private val relatedFileListViewModel = RelatedFileListViewModel(project)
7779
private val elementsList = JBList(relatedFileListViewModel.getListModel())
78-
80+
7981
private val workspaceFilePanel: WorkspaceFilePanel
8082

8183
private val defaultRag: CustomAgentConfig = CustomAgentConfig("<Select Custom Agent>", "Normal")
@@ -114,12 +116,15 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
114116

115117
setupElementsList()
116118
val sendButtonPresentation = Presentation(AutoDevBundle.message("chat.panel.send"))
117-
sendButtonPresentation.icon = AutoDevIcons.Send
119+
sendButtonPresentation.icon = AutoDevIcons.SEND
118120
this.sendButtonPresentation = sendButtonPresentation
119121

120-
val stopButtonPresentation = Presentation("Stop")
121-
stopButtonPresentation.icon = AutoDevIcons.STOP
122-
this.stopButtonPresentation = stopButtonPresentation
122+
this.stopButtonPresentation = Presentation("Stop").apply {
123+
icon = AutoDevIcons.STOP
124+
}
125+
this.enhanceButtonPresentation = Presentation("Enhance").apply {
126+
icon = AutoDevIcons.MAGIC
127+
}
123128

124129
sendButton = ActionButton(
125130
DumbAwareAction.create {
@@ -135,6 +140,13 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
135140
this.stopButtonPresentation, "", Dimension(20, 20)
136141
)
137142

143+
enhanceButton = ActionButton(
144+
DumbAwareAction.create {
145+
AutoDevNotifications.notify(project, "Enhancing input text...")
146+
},
147+
this.enhanceButtonPresentation, "", Dimension(20, 20)
148+
)
149+
138150
documentListener = object : DocumentListener {
139151
override fun documentChanged(event: DocumentEvent) {
140152
val i = input.preferredSize?.height
@@ -171,16 +183,14 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
171183
layoutPanel.addToLeft(customAgent)
172184
}
173185

174-
175-
buttonPanel.add(sendButton, "Send")
176-
buttonPanel.add(stopButton, "Stop")
186+
buttonPanel = createButtonPanel()
177187

178188
layoutPanel.addToCenter(horizontalGlue)
179189
layoutPanel.addToRight(buttonPanel)
180190

181191
inputPanel.add(input, BorderLayout.CENTER)
182192
inputPanel.addToBottom(layoutPanel)
183-
193+
184194
inputPanel.addToTop(workspaceFilePanel)
185195

186196
val scrollPane = JBScrollPane(elementsList)
@@ -217,6 +227,21 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
217227
}
218228
}
219229

230+
private fun createButtonPanel(): JPanel {
231+
val panel = JPanel(CardLayout())
232+
233+
// Create a panel for the "Send" state that contains both enhance and send buttons
234+
val sendPanel = JPanel(FlowLayout(FlowLayout.RIGHT, JBUI.scale(8), 0))
235+
sendPanel.isOpaque = false
236+
sendPanel.add(enhanceButton)
237+
sendPanel.add(sendButton)
238+
239+
panel.add(sendPanel, "Send")
240+
panel.add(stopButton, "Stop")
241+
242+
return panel
243+
}
244+
220245
private fun setupEditorListener() {
221246
project.messageBus.connect(disposable!!).subscribe(
222247
FileEditorManagerListener.FILE_EDITOR_MANAGER,
@@ -262,7 +287,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
262287

263288
val wrapper = relatedFileListViewModel.getListModel().getElementAt(index)
264289
val cellBounds = list.getCellBounds(index, index)
265-
290+
266291
val actionType = relatedFileListViewModel.determineFileAction(wrapper, e.point, cellBounds)
267292
val actionPerformed = relatedFileListViewModel.handleFileAction(wrapper, actionType) { vfile, relativePath ->
268293
if (relativePath != null) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cc.unitmesh.devti.indexer
2+
3+
import cc.unitmesh.devti.mcp.host.readText
4+
import cc.unitmesh.devti.settings.coder.coderSetting
5+
import com.github.doyaaaaaken.kotlincsv.dsl.csvReader
6+
import com.intellij.openapi.application.runReadAction
7+
import com.intellij.openapi.components.Service
8+
import com.intellij.openapi.project.Project
9+
import com.intellij.openapi.project.guessProjectDir
10+
11+
@Service(Service.Level.PROJECT)
12+
class DomainDictService(val project: Project) {
13+
private val baseDir get() = project.coderSetting.state.teamPromptsDir
14+
private val basePromptDir get() = project.guessProjectDir()?.findChild(baseDir)
15+
16+
fun domainDict(): List<List<String>> {
17+
val content = loadContent() ?: return emptyList()
18+
return csvReader().readAll(content)
19+
}
20+
21+
fun loadContent(): String? {
22+
val promptsDir = basePromptDir ?: return null
23+
val dictFile = promptsDir.findChild("domain.csv") ?: return null
24+
val content = runReadAction { dictFile.readText() }
25+
return content
26+
}
27+
}
Lines changed: 14 additions & 0 deletions
Loading

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/sketch/TerminalSketchProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class TerminalLangSketch(val project: Project, var content: String) : ExtensionL
211211
}
212212

213213
val sendText = AutoDevBundle.message("sketch.terminal.send.chat")
214-
val sendAction = object : AnAction(sendText, sendText, AutoDevIcons.Send) {
214+
val sendAction = object : AnAction(sendText, sendText, AutoDevIcons.SEND) {
215215
override fun actionPerformed(e: AnActionEvent) {
216216
try {
217217
val output = if (hasExecutionResults) {

0 commit comments

Comments
 (0)