=
15 | ExtensionPointName.create("cc.unitmesh.shireTerminalExecutor")
16 |
17 | fun provide(project: Project): TerminalLocationExecutor? {
18 | return EP_NAME.extensionList.firstOrNull()
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/complex/ComplexityPoint.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * https://github.com/nikolaikopernik/code-complexity-plugin
5 | *
6 | */
7 | package cc.unitmesh.devti.devins.provider.complex
8 |
9 | data class ComplexityPoint(
10 | val complexity: Int,
11 | val nesting: Int,
12 | val type: PointType) {
13 |
14 | override fun toString(): String = ". ".repeat(nesting) + "$type + $complexity"
15 | }
16 |
17 | enum class PointType {
18 | LOOP_WHILE,
19 | LOOP_FOR,
20 | IF,
21 | ELSE,
22 | SWITCH,
23 | CATCH,
24 | BREAK,
25 | CONTINUE,
26 | LOGICAL_AND,
27 | LOGICAL_OR,
28 | RECURSION,
29 | METHOD,
30 | UNKNOWN
31 | }
32 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/http/HttpHandler.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.provider.http
2 |
3 | import com.intellij.openapi.extensions.ExtensionPointName
4 | import com.intellij.openapi.project.Project
5 |
6 | interface HttpHandler {
7 | fun isApplicable(type: HttpHandlerType): Boolean
8 |
9 | fun execute(project: Project, content: String, variablesName: Array, variableTable: MutableMap) : String?
10 |
11 | companion object {
12 | private val EP_NAME: ExtensionPointName =
13 | ExtensionPointName("cc.unitmesh.shireHttpHandler")
14 |
15 | fun provide(type: HttpHandlerType): HttpHandler? {
16 | return EP_NAME.extensionList.find { it.isApplicable(type) }
17 | }
18 | }
19 | }
20 |
21 | enum class HttpHandlerType(val id: String) {
22 | CURL("cURL"),
23 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/terminal/TerminalHandler.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.provider.terminal
2 |
3 | import com.intellij.openapi.project.Project
4 |
5 | class TerminalHandler(
6 | val userInput: String,
7 | val project: Project,
8 | val onChunk: (str: String) -> Any?,
9 | val onFinish: ((str: String?) -> Any?)?,
10 | )
11 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/vcs/ShireFileBranch.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.provider.vcs
2 |
3 | data class ShireFileBranch(
4 | val name: String,
5 | override val count: Int,
6 | override val commits: List
7 | ) : CommitModel(count, commits)
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/vcs/ShireFileCommit.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.provider.vcs
2 |
3 | data class ShireFileCommit(
4 | val filename: String,
5 | val path: String,
6 | val status: String,
7 | override val count: Int,
8 | override val commits: List
9 | ) : CommitModel(count, commits)
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/provider/vcs/ShireGitCommit.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.provider.vcs
2 |
3 | sealed class GitEntity
4 |
5 | // Base class for models containing commits
6 | sealed class CommitModel(
7 | open val count: Int,
8 | open val commits: List
9 | ) : GitEntity()
10 |
11 | data class ShireGitCommit(
12 | val hash: String,
13 | val authorName: String,
14 | val authorEmail: String,
15 | val authorDate: Long,
16 | val committerName: String,
17 | val committerEmail: String,
18 | val committerDate: Long,
19 | val message: String,
20 | val fullMessage: String
21 | ) : GitEntity()
22 |
23 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/shireql/JvmShireQLFuncType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.shireql
2 |
3 | enum class JvmShireQLFuncType(val methodName: String, val description: String) {
4 | GET_NAME("getName", "Get class name"),
5 | NAME("name", "Get class name"),
6 | EXTENDS("extends", "Get class extends"),
7 | IMPLEMENTS("implements", "Get class implements"),
8 | METHOD_CODE_BY_NAME("methodCodeByName", "Get method code by name"),
9 | FIELD_CODE_BY_NAME("fieldCodeByName", "Get field code by name"),
10 |
11 | SUBCLASSES_OF("subclassesOf", "Get subclasses of class"),
12 | ANNOTATED_OF("annotatedOf", "Get annotated classes"),
13 | SUPERCLASS_OF("superclassOf", "Get superclass of class"),
14 | IMPLEMENTS_OF("implementsOf", "Get implemented interfaces of class"),
15 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/variable/ConditionPsiVariable.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.variable
2 |
3 | enum class ConditionPsiVariable(
4 | override val variableName: String,
5 | override val description: String,
6 | override var value: Any? = null,
7 | ) : Variable {
8 | FILE_PATH("filePath", "The path of the file"),
9 | FILE_NAME("fileName", "The name of the file"),
10 | FILE_EXTENSION("fileExtension", "The extension of the file"),
11 | FILE_CONTENT("fileContent", "The content of the file")
12 | ;
13 |
14 | companion object {
15 | fun from(variableName: String): ConditionPsiVariable? {
16 | return values().find { it.variableName == variableName }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/variable/Variable.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.variable
2 |
3 | interface Variable {
4 | val variableName: String
5 | val description: String
6 | var value: Any?
7 | }
8 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/devins/variable/VariableProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.devins.variable
2 |
3 | import com.intellij.openapi.editor.Editor
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.psi.PsiElement
6 |
7 | interface VariableProvider {
8 | fun resolve(variable: T, project: Project, editor: Editor, psiElement: PsiElement?,): Any
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/envior/PsiJsonUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.envior
2 |
3 | import com.intellij.json.JsonUtil
4 | import com.intellij.json.psi.*
5 |
6 | fun JsonProperty.valueAsString(obj: JsonObject): String? {
7 | val value = JsonUtil.getPropertyValueOfType(obj, name, JsonLiteral::class.java)
8 | return when (value) {
9 | is JsonStringLiteral -> value.value
10 | is JsonBooleanLiteral -> value.value.toString()
11 | else -> value?.text
12 | }
13 | }
14 |
15 | fun JsonObject.findString(name: String): String? {
16 | val property = findProperty(name) ?: return null
17 | return property.valueAsString(this)
18 | }
19 |
20 | fun JsonObject.findNumber(name: String): Number? {
21 | val property = findProperty(name) ?: return null
22 | return JsonUtil.getPropertyValueOfType(this, name, JsonNumberLiteral::class.java)?.value
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/envior/ShireEnvironmentInputFilter.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.envior
2 |
3 | import com.intellij.json.JsonFileType
4 | import com.intellij.openapi.fileTypes.FileType
5 | import com.intellij.openapi.vfs.VirtualFile
6 | import com.intellij.util.indexing.DefaultFileTypeSpecificInputFilter
7 |
8 | class ShireEnvironmentInputFilter : DefaultFileTypeSpecificInputFilter(*arrayOf(JsonFileType.INSTANCE)) {
9 | override fun acceptInput(file: VirtualFile): Boolean {
10 | return super.acceptInput(file) && isShireEnvFile(file)
11 | }
12 |
13 | private fun isShireEnvFile(file: VirtualFile?): Boolean {
14 | return file?.name?.endsWith(".autodevEnv.json") ?: false
15 | }
16 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/envior/ShireStringsExternalizer.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.envior
2 |
3 | import com.intellij.util.io.DataExternalizer
4 | import java.io.DataInput
5 | import java.io.DataOutput
6 |
7 | class ShireStringsExternalizer : DataExternalizer> {
8 | override fun save(out: DataOutput, value: Set) {
9 | out.writeInt(value.size)
10 | for (s in value) {
11 | out.writeUTF(s)
12 | }
13 | }
14 |
15 | override fun read(input: DataInput): Set {
16 | val size = input.readInt()
17 | val result: MutableSet = HashSet(size)
18 | for (i in 0 until size) {
19 | result.add(input.readUTF())
20 | }
21 |
22 | return result
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/flow/kanban/Kanban.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.flow.kanban
2 |
3 | import cc.unitmesh.devti.flow.model.SimpleStory
4 |
5 | interface Kanban {
6 | /**
7 | * Retrieves a user story by its ID.
8 | *
9 | * @param storyId The ID of the user story to retrieve.
10 | * @return The user story with the specified ID.
11 | */
12 | fun getStoryById(storyId: String): SimpleStory
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/flow/model/SimpleStory.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.flow.model
2 |
3 | /**
4 | * A simple story
5 | */
6 | class SimpleStory(
7 | val id: String,
8 | val title: String,
9 | val description: String
10 | ) {
11 |
12 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevChatPanel.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat
2 |
3 | import cc.unitmesh.devti.agent.custom.model.CustomAgentConfig
4 | import com.intellij.openapi.project.Project
5 | import javax.swing.JProgressBar
6 |
7 | interface AutoDevChatPanel {
8 | val progressBar: JProgressBar get() = JProgressBar()
9 | fun resetChatSession()
10 |
11 | /**
12 | * Custom Agent Event
13 | */
14 | fun resetAgent()
15 | fun hasSelectedCustomAgent(): Boolean
16 | fun getSelectedCustomAgent(): CustomAgentConfig
17 | fun selectAgent(config: CustomAgentConfig)
18 |
19 | /**
20 | * Progress Bar
21 | */
22 | fun hiddenProgressBar()
23 | fun showProgressBar()
24 |
25 | /**
26 | * append custom view
27 | */
28 | fun appendWebView(content: String, project: Project)
29 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/message/ChatContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat.message
2 |
3 | data class ChatContext(
4 | val postAction: ((response: String) -> Unit)? = null,
5 | val prefixText: String = "",
6 | val suffixText: String = ""
7 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/message/ChatRole.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat.message
2 |
3 | enum class ChatRole {
4 | System,
5 | Assistant,
6 | User;
7 |
8 | fun roleName(): String {
9 | return this.name.lowercase()
10 | }
11 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/ui/AutoDevInputListener.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat.ui
2 |
3 | import com.intellij.openapi.editor.ex.EditorEx
4 | import java.util.*
5 |
6 | enum class AutoDevInputTrigger {
7 | Button,
8 | Key
9 | }
10 |
11 | interface AutoDevInputListener : EventListener {
12 | fun editorAdded(editor: EditorEx) {}
13 | fun onSubmit(component: AutoDevInputSection, trigger: AutoDevInputTrigger) {}
14 | fun onStop(component: AutoDevInputSection) {}
15 | fun manualSend(userInput: String) {}
16 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/ui/AutoInputService.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat.ui
2 |
3 | import com.intellij.openapi.components.Service
4 | import com.intellij.openapi.project.Project
5 |
6 | @Service(Service.Level.PROJECT)
7 | class AutoInputService(val project: Project) {
8 | private var autoDevInput: AutoDevInput? = null
9 |
10 | fun registerAutoDevInput(input: AutoDevInput) {
11 | autoDevInput = input
12 | }
13 |
14 | fun putText(text: String) {
15 | autoDevInput?.appendText(text)
16 | }
17 |
18 | fun deregisterAutoDevInput(input: AutoDevInput) {
19 | autoDevInput = null
20 | }
21 |
22 | companion object {
23 | fun getInstance(project: Project): AutoInputService {
24 | return project.getService(AutoInputService::class.java)
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/chat/variable/AutoDevVariableListItemComponent.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.chat.variable
2 |
3 | import cc.unitmesh.devti.custom.compile.CustomVariable
4 | import com.intellij.ui.Gray
5 | import com.intellij.ui.JBColor
6 | import java.awt.BorderLayout
7 | import javax.swing.BorderFactory
8 | import javax.swing.JLabel
9 | import javax.swing.JPanel
10 |
11 | class AutoDevVariableListItemComponent(val customVariable: CustomVariable) : JPanel(BorderLayout()) {
12 | init {
13 | add(JLabel("$${customVariable.variable}"), BorderLayout.WEST)
14 | val label = JLabel(customVariable.description)
15 | label.border = BorderFactory.createEmptyBorder(0, 8, 0, 0)
16 | label.foreground = JBColor.namedColor("Component.infoForeground", JBColor(Gray.x99, Gray.x78))
17 | add(label, BorderLayout.EAST)
18 | }
19 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/snippet/error/CodeBlockHighlightErrorFilter.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 | package cc.unitmesh.devti.gui.snippet.error
3 |
4 | import cc.unitmesh.devti.AutoDevSnippetFile
5 | import com.intellij.codeInsight.highlighting.HighlightErrorFilter
6 | import com.intellij.psi.PsiErrorElement
7 |
8 | class CodeBlockHighlightErrorFilter : HighlightErrorFilter() {
9 | override fun shouldHighlightErrorElement(element: PsiErrorElement): Boolean {
10 | val highlightedFile = element.containingFile?.virtualFile ?: return true
11 | return !AutoDevSnippetFile.isSnippet(highlightedFile)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/snippet/error/CodeBlockHighlightingSettingsProvider.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 | package cc.unitmesh.devti.gui.snippet.error
3 |
4 | import cc.unitmesh.devti.AutoDevSnippetFile.isSnippet
5 | import com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightingSettingProvider
6 | import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting
7 | import com.intellij.openapi.project.Project
8 | import com.intellij.openapi.vfs.VirtualFile
9 |
10 | class CodeBlockHighlightingSettingsProvider : DefaultHighlightingSettingProvider() {
11 | override fun getDefaultSetting(project: Project, file: VirtualFile): FileHighlightingSetting? {
12 | return if (isSnippet(file)) FileHighlightingSetting.SKIP_HIGHLIGHTING else null
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/snippet/error/CodeBlockIntentionActionFilter.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 | package cc.unitmesh.devti.gui.snippet.error
3 |
4 | import cc.unitmesh.devti.AutoDevSnippetFile.isSnippet
5 | import com.intellij.codeInsight.daemon.impl.IntentionActionFilter
6 | import com.intellij.codeInsight.intention.IntentionAction
7 | import com.intellij.psi.PsiFile
8 |
9 | class CodeBlockIntentionActionFilter : IntentionActionFilter {
10 | override fun accept(intentionAction: IntentionAction, file: PsiFile?): Boolean {
11 | val virtualFile = file?.virtualFile ?: return true
12 | return !isSnippet(virtualFile)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/gui/toolbar/TimeFormat.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.gui.toolbar
2 |
3 | fun
4 | formatRelativeTime(timestamp: Long): String {
5 | val now = System.currentTimeMillis()
6 | val diff = now - timestamp
7 |
8 | val seconds = diff / 1000
9 | val minutes = seconds / 60
10 | val hours = minutes / 60
11 | val days = hours / 24
12 | val weeks = days / 7
13 | val months = days / 30
14 | val years = days / 365
15 |
16 | return when {
17 | years > 0 -> "${years}年前"
18 | months > 0 -> "${months}个月前"
19 | weeks > 0 -> "${weeks}周前"
20 | days > 0 -> "${days}天前"
21 | hours > 0 -> "${hours}小时前"
22 | minutes > 0 -> "${minutes}分钟前"
23 | else -> "刚刚"
24 | }
25 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/history/ChatSessionHistory.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.history
2 |
3 | import cc.unitmesh.devti.llms.custom.Message
4 | import kotlinx.serialization.Serializable
5 |
6 | @Serializable
7 | data class ChatSessionHistory(
8 | val id: String,
9 | val name: String,
10 | val messages: List,
11 | val createdAt: Long
12 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/indexer/DomainDictService.kt:
--------------------------------------------------------------------------------
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.intellij.openapi.application.runReadAction
6 | import com.intellij.openapi.components.Service
7 | import com.intellij.openapi.project.Project
8 | import com.intellij.openapi.project.guessProjectDir
9 |
10 | @Service(Service.Level.PROJECT)
11 | class DomainDictService(val project: Project) {
12 | private val baseDir get() = project.coderSetting.state.teamPromptsDir
13 | private val basePromptDir get() = project.guessProjectDir()?.findChild(baseDir)
14 |
15 | fun loadContent(): String? {
16 | val promptsDir = basePromptDir ?: return null
17 | val dictFile = promptsDir.findChild("domain.csv") ?: return null
18 | return runReadAction { dictFile.readText() }
19 | }
20 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/indexer/provider/LangDictProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.indexer.provider
2 |
3 | import com.intellij.openapi.extensions.ExtensionPointName
4 | import com.intellij.openapi.project.Project
5 |
6 | interface LangDictProvider {
7 | suspend fun collectFileNames(project: Project): List
8 |
9 | companion object {
10 | private val EP_NAME: ExtensionPointName =
11 | ExtensionPointName("cc.unitmesh.langDictProvider")
12 |
13 |
14 | suspend fun all(project: Project): List {
15 | return EP_NAME.extensions.flatMap { provider ->
16 | provider.collectFileNames(project)
17 | }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/inlay/codecomplete/InlayDisposeContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.inlay.codecomplete
2 |
3 | enum class InlayDisposeContext {
4 | UserAction,
5 | IdeCompletion,
6 | CaretChange,
7 | SelectionChange,
8 | SettingsChange,
9 | Cycling,
10 | TypingAsSuggested,
11 | Typing,
12 | Applied,
13 | ;
14 |
15 | val isResetLastRequest: Boolean
16 | get() = this == SettingsChange || this == Applied
17 | val isSendRejectedTelemetry: Boolean
18 | get() = this == UserAction
19 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/inline/AutoDevInlineChatProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.inline
2 |
3 | import com.intellij.openapi.project.Project
4 |
5 | object AutoDevInlineChatProvider {
6 | var isAdded = false
7 |
8 | fun addListener(project: Project) {
9 | if (isAdded) return
10 | AutoDevGutterHandler.getInstance(project).listen()
11 | }
12 |
13 | fun removeListener(project: Project) {
14 | AutoDevGutterHandler.getInstance(project).dispose()
15 | }
16 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/intentions/action/test/TestCodeGenRequest.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.intentions.action.test
2 |
3 | import com.intellij.openapi.editor.Editor
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.psi.PsiElement
6 | import com.intellij.psi.PsiFile
7 |
8 | class TestCodeGenRequest(
9 | val file: PsiFile,
10 | val element: PsiElement,
11 | val project: Project,
12 | val editor: Editor?
13 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/LLMProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms
2 |
3 | import cc.unitmesh.devti.gui.chat.message.ChatRole
4 | import cc.unitmesh.devti.llms.custom.Message
5 | import kotlinx.coroutines.ExperimentalCoroutinesApi
6 | import kotlinx.coroutines.flow.Flow
7 |
8 | interface LLMProvider {
9 | val defaultTimeout: Long get() = 600
10 |
11 | @OptIn(ExperimentalCoroutinesApi::class)
12 | fun stream(promptText: String, systemPrompt: String, keepHistory: Boolean = true, usePlanForFirst: Boolean = false): Flow
13 |
14 | /**
15 | * Clear all messages
16 | */
17 | fun clearMessage() {}
18 |
19 | fun getAllMessages() = emptyList()
20 |
21 | fun appendLocalMessage(msg: String, role: ChatRole) {}
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/custom/SSE.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.custom
2 |
3 | class SSE(val data: String) {
4 | fun toBytes(): ByteArray {
5 | return String.format("data: %s\n\n", this.data).toByteArray()
6 | }
7 |
8 | val isDone: Boolean
9 | get() = DONE_DATA.equals(this.data, ignoreCase = true)
10 |
11 | companion object {
12 | private const val DONE_DATA = "[DONE]"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/recording/EmptyRecording.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.recording
2 |
3 | class EmptyRecording: Recording {
4 | override fun write(instruction: RecordingInstruction) {
5 | // do nothing
6 | }
7 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/recording/JsonlRecording.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.recording
2 |
3 | import com.intellij.openapi.components.Service
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.project.guessProjectDir
6 | import kotlinx.serialization.encodeToString
7 | import kotlinx.serialization.json.Json
8 | import java.nio.file.Path
9 |
10 | @Service(Service.Level.PROJECT)
11 | class JsonlRecording(val project: Project) : Recording {
12 | private val recordingPath: Path = Path.of(project.guessProjectDir()!!.path, "recording.jsonl")
13 | override fun write(instruction: RecordingInstruction) {
14 | if (!recordingPath.toFile().exists()) {
15 | recordingPath.toFile().createNewFile()
16 | }
17 |
18 | recordingPath.toFile().appendText(Json.encodeToString(instruction) + "\n")
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/recording/Recording.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.recording
2 |
3 | interface Recording {
4 | fun write(instruction: RecordingInstruction)
5 | }
6 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/recording/RecordingInstruction.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.recording
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | @Serializable
6 | data class RecordingInstruction(
7 | val instruction: String,
8 | val output: String,
9 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/llms/tokenizer/Tokenizer.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.llms.tokenizer
2 |
3 | import com.knuddels.jtokkit.api.IntArrayList
4 |
5 | interface Tokenizer {
6 | fun getMaxLength(): Int
7 | fun count(string: String): Int
8 | fun tokenize(chunk: String): IntArrayList?
9 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/mcp/ui/model/McpMessage.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.mcp.ui.model
2 |
3 | import java.time.LocalDateTime
4 |
5 | enum class MessageType {
6 | REQUEST,
7 | RESPONSE
8 | }
9 |
10 | data class McpMessage(
11 | val type: MessageType,
12 | val method: String,
13 | val timestamp: LocalDateTime,
14 | val duration: Long? = null,
15 | val content: String,
16 | val toolName: String? = null,
17 | val parameters: String? = null
18 | )
19 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/observer/agent/AgentProcessor.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.observer.agent
2 |
3 | interface AgentProcessor {
4 | fun process()
5 | }
6 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/observer/plan/CreateIssueAction.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.observer.plan
2 |
3 | import cc.unitmesh.devti.AutoDevBundle
4 | import cc.unitmesh.devti.gui.planner.AutoDevPlannerToolWindow
5 | import com.intellij.openapi.actionSystem.ActionUpdateThread
6 | import com.intellij.openapi.actionSystem.AnAction
7 | import com.intellij.openapi.actionSystem.AnActionEvent
8 |
9 | class CreateIssueAction : AnAction(AutoDevBundle.message("sketch.plan.create")) {
10 | override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
11 |
12 | override fun actionPerformed(event: AnActionEvent) {
13 | val project = event.project ?: return
14 | AutoDevPlannerToolWindow.showIssueInput(project)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/observer/plan/PlanUpdateListener.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.observer.plan
2 |
3 | import com.intellij.openapi.vcs.changes.Change
4 | import com.intellij.util.messages.Topic
5 | import java.util.*
6 |
7 | @FunctionalInterface
8 | interface PlanUpdateListener: EventListener {
9 | fun onPlanUpdate(items: MutableList)
10 | fun onUpdateChange(changes: MutableList)
11 |
12 | companion object {
13 | @Topic.AppLevel
14 | val TOPIC: Topic = Topic(
15 | PlanUpdateListener::class.java, Topic.BroadcastDirection.TO_DIRECT_CHILDREN
16 | )
17 | }
18 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/prompting/code/TechStack.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.prompting.code
2 |
3 | data class TechStack(
4 | val coreFrameworks: MutableMap = mutableMapOf(),
5 | val testFrameworks: MutableMap = mutableMapOf(),
6 | val deps: MutableMap = mutableMapOf(),
7 | val devDeps: MutableMap = mutableMapOf()
8 | ) {
9 | fun coreFrameworks(): String {
10 | return coreFrameworks.keys.joinToString(", ")
11 | }
12 |
13 | fun testFrameworks(): String {
14 | return testFrameworks.keys.joinToString(", ")
15 | }
16 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/DevInsAgentToolCollector.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider
2 |
3 | import cc.unitmesh.devti.agent.tool.AgentTool
4 | import com.intellij.openapi.extensions.ExtensionPointName
5 | import com.intellij.openapi.project.Project
6 |
7 | interface DevInsAgentToolCollector {
8 | fun collect(project: Project): List
9 |
10 | suspend fun execute(project: Project, agentName: String, input: String): String?
11 |
12 | companion object {
13 | private val EP_NAME: ExtensionPointName =
14 | ExtensionPointName("cc.unitmesh.devInsAgentTool")
15 |
16 | fun all(project: Project): List {
17 | return EP_NAME.extensionList.flatMap { it.collect(project) }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/FrameworkConfigProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider
2 |
3 | import cc.unitmesh.devti.util.relativePath
4 | import com.intellij.openapi.extensions.ExtensionPointName
5 | import com.intellij.openapi.project.Project
6 | import com.intellij.openapi.vfs.VirtualFile
7 |
8 | interface FrameworkConfigProvider {
9 | suspend fun collect(project: Project): List
10 |
11 | companion object {
12 | private val EP_NAME: ExtensionPointName =
13 | ExtensionPointName("cc.unitmesh.frameworkConfigProvider")
14 |
15 | suspend fun collectAll(project: Project): List {
16 | return EP_NAME.extensionList.flatMap { it.collect(project) }.map {
17 | it.relativePath(project)
18 | }
19 | }
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/context/ChatContextItem.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider.context
2 |
3 | import kotlin.reflect.KClass
4 |
5 | class ChatContextItem(
6 | val clazz: KClass<*>,
7 | var text: String
8 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/context/ChatCreationContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider.context
2 |
3 | import cc.unitmesh.devti.gui.chat.message.ChatActionType
4 | import com.intellij.psi.PsiElement
5 | import com.intellij.psi.PsiFile
6 |
7 | data class ChatCreationContext(
8 | val origin: ChatOrigin,
9 | val action: ChatActionType,
10 | val sourceFile: PsiFile?,
11 | val extraItems: List = emptyList(),
12 | val element: PsiElement?
13 | )
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/context/ChatOrigin.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider.context
2 |
3 | enum class ChatOrigin {
4 | ChatAction,
5 | Intention
6 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/http/HttpClientProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider.http
2 |
3 | import com.intellij.openapi.extensions.ExtensionPointName
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.vfs.VirtualFile
6 |
7 | interface HttpClientProvider {
8 | fun execute(project: Project, virtualFile: VirtualFile, text: String)
9 |
10 | companion object {
11 | private val EP_NAME: ExtensionPointName =
12 | ExtensionPointName("cc.unitmesh.httpClientExecutor")
13 |
14 | fun all(): List {
15 | return EP_NAME.extensionList
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/runner/RunContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.provider.runner
2 |
3 | import com.intellij.execution.ExecutionListener
4 | import com.intellij.execution.Executor
5 | import com.intellij.execution.process.ProcessListener
6 | import com.intellij.execution.runners.ExecutionEnvironment
7 | import com.intellij.execution.runners.ProgramRunner
8 | import com.intellij.openapi.Disposable
9 | import java.util.concurrent.CountDownLatch
10 |
11 | class RunContext(
12 | val processListener: ProcessListener?,
13 | val executionListener: ExecutionListener?,
14 | val latch: CountDownLatch,
15 | val executor: Executor? = null,
16 | val runner: ProgramRunner<*>? = null,
17 | ) : Disposable {
18 | val environments: MutableList = mutableListOf()
19 | override fun dispose() {}
20 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/runner/RunnerResultSeverity.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 | package cc.unitmesh.devti.provider.runner
3 |
4 | enum class RunnerResultSeverity {
5 | Info, Warning, Error;
6 |
7 | fun isWaring() = this == Warning
8 | fun isInfo() = this == Info
9 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/provider/runner/RunnerStatus.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 | package cc.unitmesh.devti.provider.runner
3 |
4 | enum class RunnerStatus(val rawStatus: String) {
5 | Unchecked("UNCHECKED"),
6 | Solved("CORRECT"),
7 | Failed("WRONG");
8 |
9 | companion object {
10 | fun String.toCheckStatus(): RunnerStatus = when (this) {
11 | "CORRECT" -> Solved
12 | "WRONG" -> Failed
13 | else -> Unchecked
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderConfigurableProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.coder
2 |
3 | import com.intellij.openapi.options.Configurable
4 | import com.intellij.openapi.options.ConfigurableProvider
5 | import com.intellij.openapi.project.Project
6 |
7 | class AutoDevCoderConfigurableProvider (private val project: Project) : ConfigurableProvider() {
8 | override fun createConfigurable(): Configurable {
9 | return AutoDevCoderConfigurable(project)
10 | }
11 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/customize/CustomizeConfigurableProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.customize
2 |
3 | import com.intellij.openapi.options.Configurable
4 | import com.intellij.openapi.options.ConfigurableProvider
5 | import com.intellij.openapi.project.Project
6 |
7 | class CustomizeConfigurableProvider (private val project: Project) : ConfigurableProvider() {
8 | override fun createConfigurable(): Configurable {
9 | return CustomizeConfigurable(project)
10 | }
11 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/locale/LocaleLanguages.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.locale
2 |
3 | @Suppress("unused")
4 | enum class HUMAN_LANGUAGES(val abbr: String, val display: String) {
5 | ENGLISH("en", "English"),
6 | CHINESE("zh", "中文");
7 |
8 | companion object {
9 | private val map: Map = values().map { it.display to it }.toMap()
10 |
11 | fun getAbbrByDispay(display: String): String {
12 | return map.getOrDefault(display, ENGLISH).abbr
13 | }
14 | }
15 | }
16 | val DEFAULT_HUMAN_LANGUAGE = HUMAN_LANGUAGES.ENGLISH.display
17 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/miscs/ResponseType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.miscs
2 |
3 | enum class ResponseType {
4 | SSE, JSON;
5 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/miscs/TokenLength.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.miscs
2 |
3 | val MAX_TOKEN_LENGTH = 128000
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/settings/ui/ModelItem.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.settings.ui
2 |
3 | /**
4 | * Data class to store both display name and model ID for dropdown items
5 | */
6 | data class ModelItem(val displayName: String, val modelId: String, val isCustom: Boolean = false) {
7 | override fun toString(): String = displayName
8 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/AutoSketchModeListener.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch
2 |
3 | import com.intellij.util.messages.Topic
4 | import java.util.EventListener
5 |
6 | @FunctionalInterface
7 | interface AutoSketchModeListener : EventListener {
8 | fun start()
9 |
10 | fun done()
11 |
12 | companion object {
13 | @Topic.AppLevel
14 | val TOPIC: Topic =
15 | Topic(AutoSketchModeListener::class.java, Topic.BroadcastDirection.TO_DIRECT_CHILDREN)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchToolchainProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch
2 |
3 | import cc.unitmesh.devti.agent.tool.AgentTool
4 | import com.intellij.openapi.extensions.ExtensionPointName
5 | import com.intellij.openapi.project.Project
6 |
7 | interface SketchToolchainProvider {
8 | fun collect(): List
9 |
10 | companion object {
11 | private val EP_NAME: ExtensionPointName =
12 | ExtensionPointName.create("cc.unitmesh.sketchToolchainProvider")
13 |
14 | fun collect(project: Project): List {
15 | return EP_NAME.extensionList.flatMap {
16 | it.collect()
17 | }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/MarkdownPreviewSketchProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch.ui
2 |
3 | import com.intellij.openapi.project.Project
4 |
5 | class MarkdownPreviewSketchProvider : LanguageSketchProvider {
6 | /**
7 | * Since Webview had a bad performance, we disable it by default.
8 | */
9 | override fun isSupported(lang: String): Boolean {
10 | return lang.lowercase() == "markdown"
11 | }
12 |
13 | override fun create(project: Project, content: String): ExtensionLangSketch = MarkdownPreviewHighlightSketch(project, content)
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/HtmlHighlightSketch.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch.ui.code
2 |
3 | import cc.unitmesh.devti.sketch.ui.ExtensionLangSketch
4 | import com.intellij.lang.html.HTMLLanguage
5 | import com.intellij.openapi.project.Project
6 |
7 | /**
8 | * Before WebView rendering, we use this class to highlight the HTML code.
9 | */
10 | class HtmlHighlightSketch(override val project: Project, override val text: String) :
11 | CodeHighlightSketch(project, text, HTMLLanguage.INSTANCE), ExtensionLangSketch {
12 | override fun getExtensionName(): String = "HTML"
13 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/DiffLangSketchProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch.ui.patch
2 |
3 | import cc.unitmesh.devti.sketch.ui.ExtensionLangSketch
4 | import cc.unitmesh.devti.sketch.ui.LanguageSketchProvider
5 | import com.intellij.openapi.project.Project
6 |
7 | class DiffLangSketchProvider : LanguageSketchProvider {
8 | override fun isSupported(lang: String): Boolean = lang == "diff" || lang == "patch"
9 | override fun create(project: Project, content: String): ExtensionLangSketch {
10 | val contentWithoutEnding = if (content.endsWith("\n+```")) {
11 | content.substring(0, content.length - 4)
12 | } else {
13 | content
14 | }
15 |
16 | return DiffLangSketch(project, contentWithoutEnding)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/webview/WebpageSketchProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.sketch.ui.webview
2 |
3 | import cc.unitmesh.devti.sketch.ui.ExtensionLangSketch
4 | import cc.unitmesh.devti.sketch.ui.LanguageSketchProvider
5 | import cc.unitmesh.devti.sketch.ui.code.HtmlHighlightSketch
6 | import com.intellij.openapi.project.Project
7 |
8 | class WebpageSketchProvider : LanguageSketchProvider {
9 | override fun isSupported(lang: String): Boolean {
10 | return lang.lowercase() == "html" || lang.lowercase() == "htm"
11 | }
12 |
13 | override fun create(project: Project, content: String): ExtensionLangSketch {
14 | if (content.startsWith("") || content.startsWith("")) {
15 | return WebpageLangSketch(project, content)
16 | }
17 |
18 | return HtmlHighlightSketch(project, content)
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/statusbar/AutoDevStatus.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.statusbar
2 |
3 | import cc.unitmesh.devti.AutoDevIcons
4 | import javax.swing.Icon
5 |
6 | enum class AutoDevStatus {
7 | WAITING,
8 | Ready,
9 | InProgress,
10 | Error,
11 | Done;
12 |
13 | val icon: Icon
14 | get() {
15 | return when (this) {
16 | WAITING -> AutoDevIcons.DARK
17 | Ready -> AutoDevIcons.AI_COPILOT
18 | InProgress -> AutoDevIcons.LOADING
19 | Error -> AutoDevIcons.AUTODEV_ERROR
20 | Done -> AutoDevIcons.AI_COPILOT
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/statusbar/AutoDevStatusListener.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.statusbar
2 |
3 | import com.intellij.util.messages.Topic
4 |
5 | interface AutoDevStatusListener {
6 | fun onCopilotStatus(status: AutoDevStatus, icon: String?)
7 |
8 | companion object {
9 | val TOPIC = Topic.create("autodev.status", AutoDevStatusListener::class.java)
10 | }
11 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/template/context/TemplateContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.template.context
2 |
3 | /**
4 | * `TemplateContext` is an interface used to provide data to the template rendering process in the `cc.unitmesh.devti.template.TemplateRender` class. It serves as a container for the data that should be made available within the template for use in the rendering process.
5 | *
6 | * This interface defines the contract for objects that will be passed to the template engine. Implementations of `TemplateContext` should provide the necessary data members or methods that will be used to populate the template with dynamic content.
7 | *
8 | * TODO: spike the common data element for the template context
9 | */
10 | interface TemplateContext {
11 | }
12 |
13 | class EmptyContext : TemplateContext {
14 | }
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/util/DirUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.util
2 |
3 | import com.intellij.openapi.application.runWriteAction
4 | import com.intellij.openapi.vfs.VirtualFile
5 |
6 | object DirUtil {
7 | private val pathSeparator = "/"
8 | fun getOrCreateDirectory(baseDir: VirtualFile, path: String): VirtualFile {
9 | var currentDir = baseDir
10 | val pathSegments = path.split(pathSeparator).filter { it.isNotEmpty() }
11 |
12 | for (segment in pathSegments) {
13 | val childDir = currentDir.findChild(segment)
14 | currentDir = childDir ?: runWriteAction { currentDir.createChildDirectory(DirUtil.javaClass, segment) }
15 | }
16 |
17 | return currentDir
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/main/kotlin/cc/unitmesh/devti/util/DispoableUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.util
2 |
3 | import com.intellij.openapi.Disposable
4 | import com.intellij.openapi.util.Disposer
5 | import java.util.concurrent.atomic.AtomicBoolean
6 |
7 | fun Disposable.whenDisposed(listener: () -> Unit) {
8 | Disposer.register(this) { listener() }
9 | }
10 |
11 | fun Disposable.whenDisposed(
12 | parentDisposable: Disposable,
13 | listener: () -> Unit
14 | ) {
15 | val isDisposed = AtomicBoolean(false)
16 |
17 | val disposable = Disposable {
18 | if (isDisposed.compareAndSet(false, true)) {
19 | listener()
20 | }
21 | }
22 |
23 | Disposer.register(this, disposable)
24 |
25 | Disposer.register(parentDisposable, Disposable {
26 | if (isDisposed.compareAndSet(false, true)) {
27 | Disposer.dispose(disposable)
28 | }
29 | })
30 | }
--------------------------------------------------------------------------------
/core/src/main/resources/fileTemplates/code/Java Controller.java.ft:
--------------------------------------------------------------------------------
1 | package ${packageName};
2 |
3 | ${code}
4 |
--------------------------------------------------------------------------------
/core/src/main/resources/fileTemplates/internal/Custom Prompt Action.vm.ft:
--------------------------------------------------------------------------------
1 | ---
2 | interaction: AppendCursorStream
3 | ---
4 |
5 | ## For more options, see [the docs](https://ide.unitmesh.cc/custom/team-prompts)
6 |
7 | You are an experienced software development engineer skilled in using Test-Driven Development (TDD) to develop software.
8 | You need to help users write test code based on their requirements.
9 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/cicd/generate-github-action.vm:
--------------------------------------------------------------------------------
1 | Create build.yml YAML file for GitHub Action for build project and runs tests
2 |
3 | - ${context.buildContext}
4 | - OS: latest ubuntu version
5 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/api-test-gen.vm:
--------------------------------------------------------------------------------
1 | Generate API test request (with `http request` code block) based on given code and request/response info.
2 | So that we can use it to test for APIs.
3 |
4 | // base URL route: ${context.baseUri}
5 | // compare this request body relate info:
6 | // ${context.requestBody}
7 | // compare this related class maybe you can use
8 | // ${context.relatedClasses}
9 |
10 | You should use the following format to output API, which use Intellij platform `http request` language:
11 |
12 | ```http request
13 | ### GET request to example server
14 | GET https://examples.http-client.intellij.net/get
15 |
16 | ### POST request to example server
17 | POST http://localhost:80/api/item
18 | Content-Type: application/json
19 | {
20 | "name": "item1"
21 | }
22 | ```
23 |
24 | Given code:
25 | ```${context.language}
26 | ${context.code}
27 | ```
28 |
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/code-complete.vm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unit-mesh/auto-dev/78b9d8c1c7fcf91643cc9753c47ecf3c97e19e54/core/src/main/resources/genius/en/code/code-complete.vm
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/enhance.vm:
--------------------------------------------------------------------------------
1 | 你是一个专业的 AI 提示词优化专家。请帮我优化以下 prompt,并按照格式返回。
2 |
3 | 以下是用户提供的可参考的词汇表,请只考虑用户问题相关的部分。
4 |
5 | ```csv
6 | $context.dict
7 | ```
8 |
9 | #if( $context.readme.length() > 0 )
10 | 以下是项目的 README 信息
11 | ==========
12 | $context.readme
13 | ==========
14 | #end
15 |
16 | 输出格式要求:
17 |
18 | - 使用 markdown 代码块返回结果,方便我解析
19 | - 改进后的完整示例要和用户提供的 prompt 语言一致
20 | - 改进后的完整示例要和用户提供的 prompt 描述的信息一致
21 | - 输出的内容只包含改进后的完整示例,不要添加任何其他内容
22 | - 只包含改进后的完整示例,不要添加任何其他内容,不要返回过于丰富的内容
23 | - 请不要做大量的联想,只针对用户的问题丰富词汇就行了
24 |
25 | 问答示例:
26 |
27 | Question: 购买朝朝宝产品的流程
28 | Anwswer: 购买朝朝宝(zzb)理财(LiCai)产品的流程
29 |
30 | Question:创建聚益生金金融产品的代码示例
31 | Anwswer: 创建聚益生金(JYSJ)金融产品(FinancialProduct)代码示例
32 |
33 | 现在,用户的 Question 是:$context.userInput
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/indexer.vm:
--------------------------------------------------------------------------------
1 | 你是一个 DDD(领域驱动设计)专家,正在从代码库中构建一个业务上的中英字典作为索引。你需要从给定的代码片段中提取出重要的概念,以便于其它人理解和使用。
2 |
3 | - 它不是公共的库 API(如 Spring 等标准库或者平台的 API)、三方库 API(如 OkHttp、Retrofit 等),也不是常用的类名(如 List、Map 等)
4 | - 它是关键业务概念、无法理解的单词或者拼音缩写
5 | - 代码翻译中,不包含任何技术词汇,比如:Controller、Exception、Request、Response、Code、Service、Repository、Mapper、DTO、VO、PO 等
6 |
7 | 项目的 README 文件信息如下:
8 |
9 | $context.readme
10 |
11 | 你的返回格式:
12 |
13 | | 中文 | 代码翻译 | 描述 |
14 |
15 | 请根据以下文件名片段,提取出重要的概念:
16 |
17 | $context.code
18 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/inline-chat.devin:
--------------------------------------------------------------------------------
1 | According user's selection code and question to answer user's question.
2 |
3 | Project context:
4 |
5 | $frameworkContext
6 |
7 | User's selection code:
8 |
9 | ```${language}
10 | ${selection}
11 | ```
12 |
13 | User's question:
14 |
15 | $input
16 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/repair-diff.vm:
--------------------------------------------------------------------------------
1 | Please according the diff to repair the code, and return the repaired final code. Follow these instructions carefully:
2 |
3 | - Add all necessary import statements, dependencies, and endpoints required to run the code.
4 | - NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.
5 | - Unless you are appending some small easy to apply edit to a file, or creating a new file, you MUST read the the contents or section of what you're editing before editing it.
6 |
7 | User origin intention: ${context.intention}
8 |
9 | Here is the original code: ${context.oldCode}
10 |
11 | Here is the failed patched context:
12 |
13 | ${context.patchedCode}
14 |
15 | Just return code which based original code and the diff, do not add any other content.
16 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/code/test-gen.vm:
--------------------------------------------------------------------------------
1 | Write unit test for following ${context.lang} code.
2 |
3 | ${context.frameworkContext}
4 |
5 | #if( $context.relatedClasses.length() > 0 )
6 | Here is the relate code maybe you can use
7 | ${context.relatedClasses}
8 | #end
9 |
10 | #if( $context.currentClass.length() > 0 )
11 | This is the class where the source code resides:
12 | ${context.currentClass}
13 | #end
14 | ${context.extContext}
15 | Here is the source code to be tested:
16 |
17 | ```$context.lang
18 | ${context.imports}
19 | ${context.sourceCode}
20 | ```
21 |
22 | ## if newFile
23 | #if( $context.isNewFile )
24 | Should include package and imports. Start method test code with Markdown code block here:
25 | #else
26 | Should include package and imports. Start ${context.testClassName} test code with Markdown code block here:
27 | #end
28 |
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/page/page-gen-clarify.vm:
--------------------------------------------------------------------------------
1 | You are a professional Frontend developer.
2 | According to the user's requirements, you should choose the best components for the user in List.
3 |
4 | - Framework: ${context.frameworks}
5 | - Language: ${context.language}
6 | - User component: ${context.componentNames}, ${context.pageNames}
7 |
8 | For example:
9 |
10 | - Question(requirements): Build a form for user to fill in their information.
11 | - You should anwser: [Input, Select, Radio, Checkbox, Button, Form]
12 |
13 | ----
14 |
15 | Here are the User requirements:
16 |
17 | ```markdown
18 | ${context.requirement}
19 | ```
20 |
21 | Please choose the best Components for the user, just return the components names in a list, no explain.
22 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/practises/release-note.vm:
--------------------------------------------------------------------------------
1 | Generate release note based on follow info:
2 |
3 | $context.commitMsgs
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/practises/shell-suggest.vm:
--------------------------------------------------------------------------------
1 | Return only the command to be executed as a raw string, no string delimiters
2 | wrapping it, no yapping, no markdown, no fenced code blocks, what you return
3 | will be passed to subprocess.check_output() directly.
4 |
5 | - Today is: ${context.today}, user system is: ${context.os},
6 | - User current directory is: ${context.cwd}, user use is: ${context.shellPath}, according the tool to create the command.
7 |
8 | For example, if the user asks: undo last git commit
9 |
10 | You return only line command: git reset --soft HEAD~1
11 |
12 | User asks: ${context.question}
13 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/quick/quick-action.vm:
--------------------------------------------------------------------------------
1 | Generate a concise code snippet with no extra text, description, or comments.
2 |
3 | The code should achieve the following task:
4 |
5 | ${context.task}
6 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/sql/sql-gen-clarify.vm:
--------------------------------------------------------------------------------
1 | You are a professional Database Administrator.
2 | According to the user's requirements, you should choose the best Tables for the user in List.
3 |
4 | — User use database: ${context.databaseVersion}
5 | - User schema name: ${context.schemaName}
6 | - User tables: ${context.tableNames}
7 |
8 | For example:
9 |
10 | - Question(requirements): calculate the average trip length by subscriber type.// User tables: trips, users, subscriber_type
11 | - You should anwser: [trips, subscriber_type]
12 |
13 | ----
14 |
15 | Here are the User requirements:
16 |
17 | ```markdown
18 | ${context.requirement}
19 | ```
20 |
21 | Please choose the best Tables for the user, just return the table names in a list, no explain.
22 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/sql/sql-gen-design.vm:
--------------------------------------------------------------------------------
1 | You are a professional Database Administrator.
2 | According to the user's requirements, and Tables info, write SQL for the user.
3 |
4 | — User use database: ${context.databaseVersion}
5 | - User schema name: ${context.schemaName}
6 | - User tableInfos: ${context.tableInfos}
7 |
8 | For example:
9 |
10 | - Question(requirements): calculate the average trip length by subscriber type.
11 | // table `subscriber_type`: average_trip_length: int, subscriber_type: string
12 | - Answer:
13 | ```sql
14 | select average_trip_length from subscriber_type where subscriber_type = 'subscriber'
15 | ```
16 |
17 | ----
18 |
19 | Here are the requirements:
20 |
21 | ```markdown
22 | ${context.requirement}
23 | ```
24 |
25 | Please write your SQL with Markdown syntax, no explanation is needed. :
26 |
27 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/en/sre/generate-dockerfile.vm:
--------------------------------------------------------------------------------
1 | Please write a Dockerfile with minimal steps.
2 |
3 | ${context.buildContext}
4 | - I need the building to be done in separate base image than running the build
5 | - I need the application port to be 3000
6 |
7 | Output only the Dockerfile content without any explanation.
8 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/cicd/generate-github-action.vm:
--------------------------------------------------------------------------------
1 | 创建 build.yml 文件,用于 GitHub Action 构建项目并运行测试。
2 |
3 | - ${context.buildContext}
4 | - OS: 最新版本的ubuntu
5 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/api-test-gen.vm:
--------------------------------------------------------------------------------
1 | Generate API test request (with `http request` code block) based on given code and request/response info.
2 | So that we can use it to test for APIs.
3 |
4 | // base URL route: ${context.baseUri}
5 | // compare this request body relate info:
6 | // ${context.requestBody}
7 | // compare this related class maybe you can use
8 | // ${context.relatedClasses}
9 |
10 | You should use the following format to output API, which use Intellij platform `http request` language:
11 |
12 | ```http request
13 | ### GET request to example server
14 | GET https://examples.http-client.intellij.net/get
15 |
16 | ### POST request to example server
17 | POST http://localhost:80/api/item
18 | Content-Type: application/json
19 | {
20 | "name": "item1"
21 | }
22 | ```
23 |
24 | Given code:
25 | ```${context.language}
26 | ${context.code}
27 | ```
28 |
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/code-complete.vm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unit-mesh/auto-dev/78b9d8c1c7fcf91643cc9753c47ecf3c97e19e54/core/src/main/resources/genius/zh/code/code-complete.vm
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/enhance.vm:
--------------------------------------------------------------------------------
1 | 你是一个专业的 AI 提示词优化专家。请帮我优化以下 prompt,并按照格式返回。
2 |
3 | 以下是用户提供的可参考的词汇表,请只考虑用户问题相关的部分。
4 |
5 | ```csv
6 | $context.dict
7 | ```
8 |
9 | #if( $context.readme.length() > 0 )
10 | 以下是项目的 README 信息
11 | ==========
12 | $context.readme
13 | ==========
14 | #end
15 |
16 | 输出格式要求:
17 |
18 | - 使用 markdown 代码块返回结果,方便我解析
19 | - 改进后的完整示例要和用户提供的 prompt 语言一致
20 | - 改进后的完整示例要和用户提供的 prompt 描述的信息一致
21 | - 输出的内容只包含改进后的完整示例,不要添加任何其他内容
22 | - 只包含改进后的完整示例,不要添加任何其他内容,不要返回过于丰富的内容
23 | - 请不要做大量的联想,只针对用户的问题丰富词汇就行了
24 |
25 | 问答示例:
26 |
27 | Question: 购买朝朝宝产品的流程
28 | Anwswer: 购买朝朝宝(zzb)理财(LiCai)产品的流程
29 |
30 | Question:创建聚益生金金融产品的代码示例
31 | Anwswer: 创建聚益生金(JYSJ)金融产品(FinancialProduct)代码示例
32 |
33 | 现在,用户的 Question 是:$context.userInput
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/indexer.vm:
--------------------------------------------------------------------------------
1 | 你是一个 DDD(领域驱动设计)专家,正在从代码库中构建一个业务上的中英字典作为索引。你需要从给定的代码片段中提取出重要的概念,以便于其它人理解和使用。
2 |
3 | - 它不是公共的库 API(如 Spring 等标准库或者平台的 API)、三方库 API(如 OkHttp、Retrofit 等),也不是常用的类名(如 List、Map 等)
4 | - 它是关键业务概念、无法理解的单词或者拼音缩写
5 | - 代码翻译中,不包含任何技术词汇,比如:Controller、Exception、Request、Response、Code、Service、Repository、Mapper、DTO、VO、PO 等
6 |
7 | 项目的 README 文件信息如下:
8 |
9 | $context.readme
10 |
11 | 你的返回格式:
12 |
13 | | 中文 | 代码翻译 | 描述 |
14 |
15 | 请根据以下文件名片段,提取出重要的概念:
16 |
17 | $context.code
18 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/inline-chat.devin:
--------------------------------------------------------------------------------
1 | 你是个代码专家,请根据用户的选择代码来回答他的问题。
2 |
3 | 项目相关的上下文:
4 |
5 | $frameworkContext
6 |
7 | 用户的选择代码:
8 |
9 | ```${language}
10 | ${selection}
11 | ```
12 |
13 | 用户的问题是:
14 |
15 | $input
16 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/repair-diff.vm:
--------------------------------------------------------------------------------
1 | Please according the diff to repair the code, and return the repaired final code. Follow these instructions carefully:
2 |
3 | - Add all necessary import statements, dependencies, and endpoints required to run the code.
4 | - NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.
5 | - Unless you are appending some small easy to apply edit to a file, or creating a new file, you MUST read the the contents or section of what you're editing before editing it.
6 |
7 | User origin intention: ${context.intention}
8 |
9 | Here is the original code: ${context.oldCode}
10 |
11 | Here is the failed patched context:
12 |
13 | ${context.patchedCode}
14 |
15 | Just return code which based original code and the diff, do not add any other content.
16 |
17 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/code/test-gen.vm:
--------------------------------------------------------------------------------
1 | 为以下代码编写单元测试。
2 |
3 | ${context.frameworkContext}
4 |
5 | #if( $context.relatedClasses.length() > 0 )
6 | ${context.relatedClasses}
7 | #end
8 | #if( $context.currentClass.length() > 0 )
9 | 以下是当前类的信息:
10 | ${context.currentClass}
11 | #end
12 | ${context.extContext}
13 | 以下是待测试的源代码:
14 |
15 | ```$context.lang
16 | ${context.imports}
17 | ${context.sourceCode}
18 | ```
19 |
20 | 如果是新文件
21 | #if( $context.isNewFile )
22 | 请包含package和import,在此处使用 Markdown 代码块编写方法测试代码:
23 | #else
24 | 请包含package和import, 在此处使用 Markdown 代码块编写 ${context.testClassName} 测试代码:
25 | #end
26 |
27 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/error/fix-error.vm:
--------------------------------------------------------------------------------
1 | 作为具有代码调试专业知识的有益助手,您的目标是通过分析控制台日志并提供一般解决方案来识别运行时问题的根源。在协助用户时,请遵循以下规则:
2 |
3 | 1. 始终友善和专业。
4 | 2. 利用您在代码调试方面的精通,通过查看控制台日志确定运行时问题的原因。
5 | 3. 在给定代码的情况下,提供修复导致运行时问题的错误的解决方案。
6 | 4. 确保您的解决方案不是临时的"临时性补丁",而是提供长期的解决方案。
7 | 5. 如果用户发送给您一个单文件程序,请在您的回复末尾以markdown格式附上修复后的代码。此代码将使用re.findall(r"{{3}}(\w*)\n([\S\s]+?)\n{{3}}",model_response)提取,因此严格遵循此格式。
8 | 6. 如果可以通过修改代码严格地修复问题,请这样做。例如,如果缺少库,则最好重新编写代码而不建议安装该库。
9 | 7. 始终遵循这些规则,以确保为用户提供最佳的帮助。
10 |
11 | 现在,考虑这个用户请求:
12 |
13 | "请帮助我理解问题所在,并尝试修复代码。这是控制台输出和程序文本:
14 |
15 | 控制台输出:
16 | %s
17 | 程序文本:
18 | %s
19 | 提供一个有益的回复,解决用户的问题,遵循规则,并为运行时问题提供解决方案。
20 |
21 | ```
22 | ${context.errorText}
23 | ```
24 |
25 | ```
26 | ${context.soureCode}
27 | ```
28 |
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/page/page-gen-clarify.vm:
--------------------------------------------------------------------------------
1 | 你是一位专业的前端开发者。根据用户的需求,在列表中为用户选择最佳组件。
2 |
3 | 框架:${context.frameworks}
4 | 语言:${context.language}
5 | 用户组件:${context.componentNames},${context.pageNames}
6 | 例如:
7 |
8 | 问题(需求):为用户构建一个填写个人信息的表单。
9 | 你应该回答:[Input, Select, Radio, Checkbox, Button, Form]
10 |
11 | ----
12 |
13 | 以下是用户需求:
14 |
15 | ```markdown
16 | ${context.requirement}
17 | ```
18 |
19 | 请为用户选择最佳组件,只返回组件名称列表,不解释。
20 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/page/page-gen-design.vm:
--------------------------------------------------------------------------------
1 | 你是一位专业的前端开发者。
2 | 根据用户的需求和组件信息,为用户编写组件。
3 |
4 | - 用户组件信息:${context.components}
5 |
6 | 例如:
7 |
8 | - 问题(需求):为用户构建一个填写个人信息的表单。
9 | // 组件名称: Form, props: { fields: [{name: 'name', type: 'text'}, {name: 'age', type: 'number'}] }
10 | // 组件名称: Input, props: { name: 'name', type: 'text' }
11 | // : Input, props: { name: 'age', type: 'number' }
12 | - 回答:
13 | ```react
14 |
18 | ```
19 |
20 | ----
21 |
22 | 以下是需求:
23 |
24 | ```markdown
25 | ${context.requirement}
26 | ```
27 |
28 | 请使用 Markdown 语法编写您的代码,无需解释。
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/practises/code-review.vm:
--------------------------------------------------------------------------------
1 | 你是一位经验丰富的软件开发者,我寻求您的专业知识来审查以下代码:
2 |
3 | - 专注于代码中的关键算法、逻辑流程和设计决策。讨论这些变化如何影响核心功能和代码的整体结构。
4 | - 确定并突出显示这些代码变化可能引入的任何潜在问题或风险。这将帮助审阅人员特别关注可能需要改进或进一步分析的领域。
5 | - 强调与现有代码库的兼容性和一致性的重要性。确保代码符合已建立的标准和实践,以确保代码的统一性和长期可维护性。
6 |
7 | ${context.frameworkContext}
8 |
9 | #if($context.stories.isNotEmpty())
10 | 以下用户故事与这些变化相关:
11 | ${context.stories.joinToString("\n")}
12 | #end
13 |
14 | ${context.diffContext}
15 |
16 | 作为您的技术负责人,我只关注关键的代码审查问题。请在此提供关键总结。
17 | 在此处以不超过 5 句话提交您的关键见解:
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/practises/gen-commit-msg.vm:
--------------------------------------------------------------------------------
1 | 根据针对如下的代码变更(Diff)编写提交信息。
2 |
3 | - 确保包含修改了什么以及为什么。
4 | - 以不超过 50 个字符的祈使句形式开头。
5 | - 然后留下一个空行,如有必要,继续详细说明。
6 | - 说明应该少于 200 个字符。
7 |
8 | 遵循常规提交规范,例如:
9 |
10 | - fix(authentication): 修复密码正则表达式模式问题
11 | - feat(storage): 添加对 S3 存储的支持
12 | - test(java): 修复用户控制器的测试用例
13 | - docs(architecture): 在主页添加架构图
14 |
15 | #if( $context.historyExamples.length() > 0 )
16 | 以下是用户的历史提交习惯:
17 |
18 | $context.historyExamples
19 |
20 | #end
21 |
22 | #if( $context.originText.length() > 0 )
23 | 用户先前的意图是: $context.originText
24 | #end
25 |
26 | #if( $context.issueId.length() > 0 )
27 | 相关 GitHub Issue: #$context.issueId
28 | $context.issueDetail
29 | #end
30 |
31 | 代码变更(Diff):
32 |
33 | ```diff
34 | ${context.diffContent}
35 | ```
36 |
37 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/practises/refactoring.vm:
--------------------------------------------------------------------------------
1 | 请你这段代码建议适当的重构。
2 | - 提高代码的可读性、质量,使代码更加有组织和易懂。
3 | - 如果代码太长,你需要考虑用更好的方式(诸如概念化)来组织代码。
4 | - 答案应包含重构描述和一个代码片段,展示重构后的结果。
5 | 使用一些众所周知的重构技巧,比如以下列表中的一个:
6 | - 重命名
7 | - 修改签名、声明
8 | - 提取或引入变量、函数、常量、参数、类型参数
9 | - 提取类、接口、超类
10 | - 内联类、函数、变量等
11 | - 移动字段、函数、语句等
12 | - 上移构造函数、字段、方法
13 | - 下移字段、方法
14 |
15 | 请勿生成多个代码片段,尝试将所有更改都整合到一个代码片段中。
16 | 请勿生成包含虚构周围类、方法的代码。不要模拟缺失的依赖项。
17 | 提供的代码已经整合到正确且可编译的代码中,不要在其周围添加额外的类。
18 |
19 | 重构以下代码:
20 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/practises/release-note.vm:
--------------------------------------------------------------------------------
1 | 根据如下的提交信息,生成本次发布的 Release Note::
2 |
3 | $context.commitMsgs
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/practises/shell-suggest.vm:
--------------------------------------------------------------------------------
1 | Return only the command to be executed as a raw string, no string delimiters
2 | wrapping it, no yapping, no markdown, no fenced code blocks, what you return
3 | will be passed to subprocess.check_output() directly.
4 |
5 | - Today is: ${context.today}, user system is: ${context.os},
6 | - User current directory is: ${context.cwd}, user use is: ${context.shellPath}, according the tool to create the command.
7 |
8 | For example, if the user asks: undo last git commit
9 |
10 | You return only line command: git reset --soft HEAD~1
11 |
12 | User asks: ${context.question}
13 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/quick/quick-action.vm:
--------------------------------------------------------------------------------
1 | 生成一个简洁的代码片段,不包含额外的文本、描述或注释。该代码应实现以下任务:
2 |
3 | ${context.task}
4 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/sql/sql-gen-clarify.vm:
--------------------------------------------------------------------------------
1 | 你是一名专业的数据库管理员。根据用户的要求,在列表中为用户选择最佳的表。
2 |
3 | - 用户使用的数据库版本:${context.databaseVersion}
4 | - 用户 schema 名称:${context.schemaName}
5 | - 用户表信息:${context.tableNames}
6 |
7 | 例如:
8 |
9 | - 问题(要求):计算按订阅者类型划分的平均行程长度。// 用户表:trips、users、subscriber_type
10 | - 你应该回答:[trips, subscriber_type]
11 |
12 | ----
13 |
14 | 以下是用户的需求:
15 |
16 | ```markdown
17 | ${context.requirement}
18 | ```
19 |
20 | 请为用户选择最佳的表,只需返回表名的列表,无需解释。
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/sql/sql-gen-design.vm:
--------------------------------------------------------------------------------
1 | 你是一名专业的数据库管理员。
2 | 根据用户的需求和表信息,为用户编写 SQL。
3 |
4 | - 用户使用的数据库版本:${context.databaseVersion}
5 | - 用户架构名称:${context.schemaName}
6 | - 用户表信息:${context.tableInfos}
7 |
8 | 例如:
9 |
10 | - 问题(需求):按订阅者类型计算平均行程长度。
11 | // table `subscriber_type`: average_trip_length: int, subscriber_type: string
12 | - 回答:
13 | ```sql
14 | select average_trip_length from subscriber_type where subscriber_type = 'subscriber'
15 | ```
16 |
17 | ----
18 |
19 | 以下是需求:
20 |
21 | ```markdown
22 | ${context.requirement}
23 | ```
24 | 请使用 Markdown 语法编写您的 SQL,无需解释。
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/core/src/main/resources/genius/zh/sre/generate-dockerfile.vm:
--------------------------------------------------------------------------------
1 | 请编写一个最小步骤的 Dockerfile。
2 |
3 | ${context.buildContext}
4 |
5 | - 我需要在与运行构建不同的基础镜像中进行构建
6 | - 我需要应用程序端口为 3000
7 |
8 | 仅输出 Dockerfile 内容,不要附带任何解释。
--------------------------------------------------------------------------------
/core/src/main/resources/icons/check.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/icons/stop.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntention/after.txt.template:
--------------------------------------------------------------------------------
1 | String url = "https://ide.unitmesh.cc/";
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntention/before.txt.template:
--------------------------------------------------------------------------------
1 | String s =
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntention/description.html:
--------------------------------------------------------------------------------
1 | InvokeAutoDev AI Intention Action on here. he AI-powered coding wizard with multilingual support 🌐,
2 | auto code generation 🏗️, and a helpful bug-slaying assistant 🐞! Customizable prompts 🎨 and a magic
3 | Auto Dev/Testing/Document feature 🧪 included! 🚀
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntentionHelper/after.txt.template:
--------------------------------------------------------------------------------
1 | String url = "https://ide.unitmesh.cc/";
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntentionHelper/before.txt.template:
--------------------------------------------------------------------------------
1 | String s =
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoDevIntentionHelper/description.html:
--------------------------------------------------------------------------------
1 | Invoke AutoDev Action on here.
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoSqlAction/after.txt.template:
--------------------------------------------------------------------------------
1 | // query recently blog
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoSqlAction/before.txt.template:
--------------------------------------------------------------------------------
1 | SELECT title, content, author, published_at
2 | FROM blogs
3 | ORDER BY published_at DESC
4 | LIMIT 10;
5 |
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/AutoSqlAction/description.html:
--------------------------------------------------------------------------------
1 | Invoke AutoDev Generate Action on here.
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/CodeCompletionIntention/after.txt.template:
--------------------------------------------------------------------------------
1 | String url = "https://www.phodal.com";
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/CodeCompletionIntention/before.txt.template:
--------------------------------------------------------------------------------
1 | String s = "https://www.phodal.com";
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/CodeCompletionIntention/description.html:
--------------------------------------------------------------------------------
1 | Invoke Code completion on here.
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/DefaultDocumentationIntention/description.html:
--------------------------------------------------------------------------------
1 | Auto generate documentation for the current class or method.
--------------------------------------------------------------------------------
/core/src/main/resources/intentionDescriptions/RefactorThisIntention/description.html:
--------------------------------------------------------------------------------
1 | Auto refactor code
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/create_controller.vm:
--------------------------------------------------------------------------------
1 | 你是一个资深的后端 CRUD 工程师,请根据下面的用户故事以及 {controllerName} 的相关信息,编写 Controller 部分的 Java 代码。要求如下:
2 | {spec}
3 | - 只返回修改完的函数代码,不做解释。
4 | - 请确保 service 类的名称与 {controllerName} 相关的 service 类的名称一致。
5 | - 请参考标准的 RESTful API 设计规范,尽量使用标准的 HTTP 方法和状态码。
6 |
7 | ###
8 | // {controllerName} 相关信息如下:
9 | {controllers}
10 | ###
11 |
12 | ###
13 | // 相关 DTO 和 entity 类如下:
14 | {models}
15 |
16 | // 所有 service 类如下,{如果不存在需要的 service 类,请自行创建}
17 | {services}
18 | ###
19 |
20 | 用户故事如下:
21 |
22 | ###
23 | {storyDetail}
24 | ###
25 |
26 |
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/create_service_and_repository.vm:
--------------------------------------------------------------------------------
1 | 你是一个资深的后端 CRUD 工程师,请根据下面的 Controller 代码,实现对应的 Service 代码和 Repository 代码。要求如下:
2 | {spec}
3 | - 你返回的代码需要能够编译通过,不做解释。
4 | - 你返回的代码示例如下:
5 | ###
6 | ```java
7 | import org.springframework.stereotype.Service;
8 |
9 | @Service
10 | public class {serviceName} {
11 | xxxRepository xxxRepository;
12 |
13 | constructor({xxxRepository} {xxxRepository}) {
14 | this.{xxxRepository} = {xxxRepository};
15 | }
16 |
17 | // {the logic to support on the controller}
18 | }
19 | ```
20 |
21 | ```java
22 | import org.springframework.data.repository.CrudRepository;
23 | import org.springframework.stereotype.Repository;
24 |
25 | @Repository
26 | public interface {xxxRepository} extends JpaRepository<{xxx}, Long> {
27 |
28 | }
29 | ```
30 | ###
31 |
32 | // Controller 代码
33 | ```java
34 | {controllerCode}
35 | ```
36 |
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/create_story_detail.vm:
--------------------------------------------------------------------------------
1 | 你是一个敏捷项目的 BA,请根据如下的信息,编写用户故事。
2 |
3 | - 你的项目是:### {project} ###
4 | - 你的需求是: ### {story} ###。
5 | - 必须要考虑、尽可能考虑各种异常场景,添加更多的 AC(至少 3 个)。
6 | - 你的返回模板如下所示:
7 |
8 | ###
9 | 用户故事:可以选择宝贝出行服务
10 | 作为 xxx
11 | 我想 在xx出行的手机客户端里选择宝贝出行服务
12 | 以便于 我能够带宝宝打车出行的时候打到有儿童座椅的车
13 |
14 | AC 1: xxx
15 | 假设 xxx
16 | 当 xxx
17 | 于是 xxx
18 | ###
19 |
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/lookup_or_create_endpoint.vm:
--------------------------------------------------------------------------------
1 | 你是一个资深的后端 CRUD 工程师,请根据下面的用户故事 和 Controller 列表。要求:
2 |
3 | - 请在下面的 Controller 列表中,寻找并返回最合适的 Controller 名字
4 | - 如果无法在给定列表中找到合适的 Controller 名字,请你自行设计一个合适的 Controller 名字。
5 |
6 | Controller 列表:
7 |
8 | ###
9 | {controllers}
10 | ###
11 |
12 | ###
13 | {storyDetail}
14 | ###
15 |
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/update_controller_method.vm:
--------------------------------------------------------------------------------
1 | 你是一个资深的后端 CRUD 工程师,请根据下面的用户故事以及 {controllerName} 的相关信息,编写 Controller 部分的 Java 代码。要求如下:
2 | {spec}
3 |
4 | - 只返回 Controller 对应接口的关键函数。
5 | - 不做解释,只返回对应的关键函数。
6 | - 你最后返回的代码示例如下:
7 | // {you should return CRUD method in here}
8 | ```java
9 | @{http method}Mapping("{xxxx}")
10 | @ApiOperation(value = "xxxx", notes = "xxxx")
11 | public {methodReturnType} {methodName}({methodParams}) {
12 | {methodBody}
13 | }
14 | ```
15 |
16 | ###
17 | // {controllerName} 相关信息如下:
18 | {controllers}
19 | ###
20 |
21 | ###
22 | // 相关 DTO 和 entity 类如下:
23 | {models}
24 |
25 | // 所有 service 类如下,{如果不存在需要的 service 类,请自行创建}
26 | {services}
27 | ###
28 |
29 | ###
30 | // 用户故事如下:
31 | {storyDetail}
32 | ###
33 |
34 | 你的代码:
35 |
36 | // {you should return CRUD method in here}
37 |
--------------------------------------------------------------------------------
/core/src/main/resources/prompts/default/update_service_method.vm:
--------------------------------------------------------------------------------
1 | 你是一个资深的后端 CRUD 工程师,根据下面的信息编写 Service 层新方法的代码。要求:
2 |
3 | - 实现 // TODO 声明部分的方法。
4 | - 保证 Service 层的代码简洁易读,不要有冗余代码。
5 | - 你最后返回的代码示例如下:
6 | // TODO: implementation follows methods: {{some method}}
7 | ```java
8 | public {methodReturnType} {methodName}({methodParams}) {
9 | {methodBody}
10 | }
11 | ```
12 |
13 | // current service code
14 | {prefixCode}
15 | // TODO: implementation follows methods: {suffixCode}
16 |
17 |
--------------------------------------------------------------------------------
/core/src/test/kotlin/cc/unitmesh/devti/custom/variable/CustomVariableTest.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.custom.variable
2 |
3 | import cc.unitmesh.devti.custom.compile.CustomVariable
4 | import junit.framework.TestCase.assertFalse
5 | import junit.framework.TestCase.assertTrue
6 | import org.junit.Test
7 |
8 |
9 | class CustomVariableTest {
10 | @Test
11 | fun should_parse_variable_from_content() {
12 | assertTrue(CustomVariable.hasVariable("解释一下代码:\$selection"))
13 | assertFalse(CustomVariable.hasVariable("解释一下代码:\$selectio"))
14 | }
15 | }
--------------------------------------------------------------------------------
/core/src/test/kotlin/cc/unitmesh/devti/prompting/CustomActionIntentionConfigConfigTest.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.prompting
2 |
3 | import cc.unitmesh.devti.custom.action.CustomPromptConfig
4 | import cc.unitmesh.devti.util.parser.MarkdownCodeHelper
5 | import junit.framework.TestCase.assertNotNull
6 | import org.junit.Test
7 | import java.io.File
8 |
9 | class CustomActionIntentionConfigConfigTest {
10 | @Test
11 | fun should_serial_from_readme_string() {
12 | val readmeFile = File("../README.md").readText()
13 | val codeBlocks = MarkdownCodeHelper.parseCodeFromString(readmeFile)
14 | val configExample = codeBlocks.last()
15 | val config = CustomPromptConfig.tryParse(configExample)
16 |
17 | assertNotNull(config)
18 | }
19 | }
--------------------------------------------------------------------------------
/core/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/core/src/test/resources/java/endpoint/HelloController.java:
--------------------------------------------------------------------------------
1 | import org.springframework.web.bind.annotation.RestController;
2 | import org.springframework.web.bind.annotation.RequestMapping;
3 |
4 | @RestController
5 | public class HelloController {
6 |
7 | @RequestMapping("/hello")
8 | public String hello() {
9 | return "Greetings from Spring Boot!";
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/example/custom_agent/README.md:
--------------------------------------------------------------------------------
1 | # Custom Agent Server example
2 |
3 | code:[server.py](server.py)
4 |
5 | 1. Create virtual environment
6 |
7 | ```bash
8 | python -m venv venv
9 | source venv/bin/activate
10 | ```
11 |
12 | 2. Install the required packages
13 |
14 | ```bash
15 | pip install -r requirements.txt
16 | ```
17 |
18 | 3. Run
19 |
20 | ```bash
21 | python server.py
22 | ```
23 |
24 |
--------------------------------------------------------------------------------
/example/custom_agent/requirements.txt:
--------------------------------------------------------------------------------
1 | fastapi==0.110.0
2 | uvicorn~=0.27.1
3 | pydantic~=2.6.3
4 | starlette~=0.36.3
--------------------------------------------------------------------------------
/example/custom_llm_server/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unit-mesh/auto-dev/78b9d8c1c7fcf91643cc9753c47ecf3c97e19e54/example/custom_llm_server/README.md
--------------------------------------------------------------------------------
/example/custom_llm_server/requirements.txt:
--------------------------------------------------------------------------------
1 | fastapi==0.109.1
2 | requests==2.31.0
3 | uvicorn
4 | sseclient-py
--------------------------------------------------------------------------------
/example/mcp/issues.mcp.json:
--------------------------------------------------------------------------------
1 | {
2 | "mcpServers": {
3 | "autodev.commitMenu": {
4 | "command": "/Users/phodal/test/github-mcp-server/cmd/github-mcp-server/github-mcp-server",
5 | "args": ["stdio"],
6 | "env": {
7 | "GITHUB_PERSONAL_ACCESS_TOKEN": "xxx"
8 | }
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/example/prompt/autodev/controller-output.md:
--------------------------------------------------------------------------------
1 | # Output
2 |
3 |
4 | ```
5 | @PostMapping("/blog")
6 | public ResponseEntity> createBlog(@RequestBody Blog blog) {
7 | try {
8 | // 验证博客信息是否完整
9 | if (StringUtils.isBlank(blog.getTitle())) {
10 | return ResponseEntity.badRequest().body("请输入博客标题");
11 | }
12 |
13 | // 调用 BlogService 创建博客
14 | Long blogId = blogService.createBlog(blog);
15 |
16 | // 返回博客 id
17 | return ResponseEntity.ok(blogId);
18 | } catch (Exception e) {
19 | // 返回错误信息
20 | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
21 | .body("创建博客失败,请稍后重试");
22 | }
23 | }
24 | ```
25 |
26 |
--------------------------------------------------------------------------------
/example/prompt/autodev/custom-prompt-dsl.md:
--------------------------------------------------------------------------------
1 | ## Custom Prompt DSL
2 |
3 | ```json
4 | [
5 | {
6 | "title": "转译",
7 | "autoInvoke": true,
8 | "matchRegex": ".*",
9 | "template": "帮我重构下面的代码为 Kotlin 语言,方便于我理解: \n ${SPEC_XXX} ${SELECTION}"
10 | }
11 | ]
12 | ```
13 |
14 | ### IDE Variable
15 |
16 | ```
17 | $SELECTION
18 | ```
19 |
20 | ### SPEC Variable
21 |
22 | ```
23 | $SPEC.xxx
24 | ```
25 |
26 | example: `$SPEC_CONTROLLER`
27 |
28 | ### CODE Context Variable
29 |
30 | `METHOD_INPUT_OUTPUT`
31 |
32 |
--------------------------------------------------------------------------------
/example/prompt/autodev/tasking.md:
--------------------------------------------------------------------------------
1 | controller:
2 |
3 | 接收用户请求,获取博客信息。
4 | 调用博客创建服务,并传入博客信息。
5 | 根据服务返回结果,构造响应数据。
6 |
7 | service:
8 |
9 | 验证博客信息是否完整。
10 | 生成博客 id,并保存博客信息。
11 | 返回博客 id 或者对应的错误信息。
12 |
13 | dao:
14 |
15 | 保存博客信息到数据库中。
16 |
--------------------------------------------------------------------------------
/example/prompt/bloop/code_search_hyde_doc.md:
--------------------------------------------------------------------------------
1 | Write a code snippet that could hypothetically be returned by a code search engine as the answer to the query: {query}
2 |
3 | - Write the snippets in a programming or markup language that is likely given the query
4 | - The snippet should be between 5 and 10 lines long
5 | - Surround the snippet in triple backticks
6 |
7 | For example:
8 |
9 | What's the Qdrant threshold?
10 |
11 | ```rust
12 | SearchPoints {{
13 | limit,
14 | vector: vectors.get(idx).unwrap().clone(),
15 | collection_name: COLLECTION_NAME.to_string(),
16 | offset: Some(offset),
17 | score_threshold: Some(0.3),
18 | with_payload: Some(WithPayloadSelector {{
19 | selector_options: Some(with_payload_selector::SelectorOptions::Enable(true)),
20 | }}),
21 | ```
22 |
--------------------------------------------------------------------------------
/example/prompt/bloop/file_explanation.md:
--------------------------------------------------------------------------------
1 | Below are some lines from the file /{path}. Each line is numbered.
2 |
3 | #####
4 |
5 | {code}
6 |
7 | #####
8 |
9 | Your job is to perform the following tasks:
10 | 1. Find all the relevant line ranges of code.
11 | 2. DO NOT cite line ranges that you are not given above
12 | 3. You MUST answer with only line ranges. DO NOT answer the question
13 |
14 | Q: find Kafka auth keys
15 | A: [[12,15]]
16 |
17 | Q: find where we submit payment requests
18 | A: [[37,50]]
19 |
20 | Q: auth code expiration
21 | A: [[486,501],[520,560],[590,631]]
22 |
23 | Q: library matrix multiplication
24 | A: [[68,74],[82,85],[103,107],[187,193]]
25 |
26 | Q: how combine result streams
27 | A: []
28 |
29 | Q: {question}
30 | A:
--------------------------------------------------------------------------------
/example/prompt/copilot/completion/java-code.md:
--------------------------------------------------------------------------------
1 | Q:
2 | ```java
3 | public void foo() {
4 | int x = 42 + 42;
5 | System.out.println(x);
6 | // TODO: write me gcd algorithm here
7 | // end of the code completion
8 | return x + x;
9 | }
10 | ```
11 | A:
12 | ```java
13 | public void foo() {
14 | int x = 42 + 42;
15 | System.out.println(x);
16 | // TODO: write me gcd algorithm here
17 | int a = 42;
18 | int b = 42;
19 |
20 | while (b != 0) {
21 | int temp = b;
22 | b = a % b;
23 | a = temp;
24 | }
25 |
26 | int gcd = a;
27 | System.out.println("The GCD is: " + gcd);
28 | // end of the code completion
29 | return x + x;
30 | }
31 | ```
32 | Q:
--------------------------------------------------------------------------------
/example/prompt/copilot/completion/python-code.md:
--------------------------------------------------------------------------------
1 | Q:
2 | ```python
3 | def foo():
4 | x = 42 + 42
5 | print(x)
6 | # TODO: write me gcd algorithm here
7 | # end of the code completion
8 | return x + x
9 | ```
10 | A:
11 | ```python
12 | def foo():
13 | x = 42 + 42
14 | print(x)
15 | # TODO: write me gcd algorithm here
16 | def gcd(a,b):
17 | while(b):
18 | a,b = b,a%b
19 | return a
20 | # end of the code completion
21 | return x + x
22 | ```
23 | Q:
--------------------------------------------------------------------------------
/exts/.gitignore:
--------------------------------------------------------------------------------
1 | exts/devin-lang
2 |
--------------------------------------------------------------------------------
/exts/README.md:
--------------------------------------------------------------------------------
1 | # AutoDev advanced Extension
2 |
3 | In this folder, you can find some advanced extensions for AutoDev.
4 |
5 | - Database. Build an SQL, Oracle or MySQL database with GenAI ability.
6 | - Android. This extension allows you to build Android with GenAI ability.
7 | - HarmonyOS. This extension allows you to build HarmonyOS with GenAI ability.
8 | - Terminal. Integration with terminal with GenAI ability.
9 | - HttpClient. Provider http API test ability.
10 |
11 | Others:
12 |
13 | - DevIns. This extension allows you to build DevIns language with GenAI ability.
14 |
15 | ## How to add new extensions
16 |
17 | follow [https://ide.unitmesh.cc/development/dev-new-language.html](https://ide.unitmesh.cc/development/dev-new-language.html)
18 |
--------------------------------------------------------------------------------
/exts/devins-lang/.gitignore:
--------------------------------------------------------------------------------
1 | src/gen
--------------------------------------------------------------------------------
/exts/devins-lang/src/223/main/kotlin/cc/unitmesh/devti/language/git/GitUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.git
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.openapi.vcs.changes.CommitContext
5 | import com.intellij.openapi.vcs.changes.LocalChangeList
6 | import com.intellij.vcs.commit.ChangeListCommitState
7 | import com.intellij.vcs.commit.SingleChangeListCommitter
8 |
9 | object GitUtil {
10 | fun doCommit(myProject: Project, list: LocalChangeList, commitMsg: String) {
11 | val commitState = ChangeListCommitState(list, list.changes.toList(), commitMsg)
12 | val committer = SingleChangeListCommitter(myProject, commitState, CommitContext(), commitMsg, false)
13 | committer.runCommit("Commit", false)
14 | }
15 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInAstFactory.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.lang.ASTFactory
4 |
5 | class DevInAstFactory : ASTFactory()
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInBundle.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.DynamicBundle
4 | import org.jetbrains.annotations.NonNls
5 | import org.jetbrains.annotations.PropertyKey
6 |
7 |
8 | @NonNls
9 | private const val DevInBUNDLE: String = "messages.DevInBundle"
10 |
11 | object DevInBundle : DynamicBundle(DevInBUNDLE) {
12 | @Suppress("SpreadOperator")
13 | @JvmStatic
14 | fun message(@PropertyKey(resourceBundle = DevInBUNDLE) key: String, vararg params: Any) = getMessage(key, *params)
15 |
16 | @Suppress("SpreadOperator", "unused")
17 | @JvmStatic
18 | fun messagePointer(@PropertyKey(resourceBundle = DevInBUNDLE) key: String, vararg params: Any) =
19 | getLazyMessage(key, *params)
20 | }
21 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInFileType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.openapi.fileTypes.FileType
4 | import com.intellij.openapi.fileTypes.LanguageFileType
5 | import com.intellij.openapi.vfs.VirtualFile
6 | import javax.swing.Icon
7 |
8 | class DevInFileType : LanguageFileType(DevInLanguage) {
9 | override fun getName(): String = "DevInFile"
10 |
11 | override fun getIcon(): Icon = DevInIcons.DEFAULT
12 |
13 | override fun getDefaultExtension(): String = "devin"
14 |
15 | override fun getCharset(file: VirtualFile, content: ByteArray): String = "UTF-8"
16 |
17 | override fun getDescription(): String = "DevIn file"
18 |
19 | companion object {
20 | val INSTANCE: FileType = DevInFileType()
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInIcons.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.openapi.util.IconLoader
4 | import javax.swing.Icon
5 |
6 | object DevInIcons {
7 | @JvmField
8 | val DEFAULT: Icon = IconLoader.getIcon("/icons/devin.svg", DevInIcons::class.java)
9 | @JvmField
10 | val COMMAND: Icon = IconLoader.getIcon("/icons/devins-command.svg", DevInIcons::class.java)
11 | @JvmField
12 | val Terminal: Icon = IconLoader.getIcon("/icons/terminal.svg", DevInIcons::class.java)
13 | }
14 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInLanguage.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.lang.Language
4 |
5 | object DevInLanguage : Language("DevIn", "text/devin", "text/x-devin", "application/x-devin") {
6 | val INSTANCE: Language = DevInLanguage
7 | override fun isCaseSensitive() = true
8 | override fun getDisplayName() = "DevIn"
9 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInsConstants.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.openapi.project.guessProjectDir
5 | import com.intellij.openapi.vfs.VirtualFile
6 |
7 | public const val SHIRE_TEMP_OUTPUT = ".autodev-output"
8 | public const val LLM_LOGGING_JSONL = "logging.jsonl"
9 | public const val LLM_LOGGING = "logging.log"
10 |
11 | object ShireConstants {
12 | fun outputDir(project: Project): VirtualFile? {
13 | val baseDir = project.guessProjectDir() ?: throw IllegalStateException("Project directory not found")
14 | val virtualFile = baseDir.findFileByRelativePath(SHIRE_TEMP_OUTPUT)
15 | if (virtualFile == null) {
16 | baseDir.createChildDirectory(this, SHIRE_TEMP_OUTPUT)
17 | }
18 |
19 | return virtualFile
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/action/PatternProcessor.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.action
2 |
3 | interface PatternProcessor {
4 | val type: PatternActionFuncDef
5 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/action/RuleBasedPatternAction.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.action
2 |
3 | class RuleBasedPatternAction(val pattern: String, override val processors: List) :
4 | DirectAction(processors)
5 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/shireql/ShireQLFromType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.shireql
2 |
3 | enum class ShireQLFromType(val typeName: String) {
4 | // PSI Query
5 | PsiFile("PsiFile"),
6 | PsiPackage("PsiPackage"),
7 | PsiClass("PsiClass"),
8 | PsiMethod("PsiMethod"),
9 | PsiField("PsiField"),
10 |
11 | // GitQuery
12 | GitCommit("GitCommit"),
13 | GitBranch("GitBranch"),
14 |
15 | // Others
16 | Date("Date"),
17 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/shireql/ShireQLSchema.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.shireql
2 |
3 | interface ShireQLSchema {
4 |
5 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/shireql/variable/frontend/Component.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.shireql.variable.frontend
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | /**
6 | * the Design System Component
7 | */
8 | @Serializable
9 | data class Component(
10 | val name: String,
11 | val path: String,
12 | val signature: String = "",
13 | val props: List = emptyList(),
14 | ) {
15 | fun format(): String {
16 | return """
17 | |component name: $name
18 | |component path: $path
19 | |input signature: $signature
20 | |component props: $props
21 | """.trimMargin()
22 | }
23 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/shireql/variable/frontend/ComponentProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.shirecore.variable.frontend
2 |
3 | import cc.unitmesh.devti.language.ast.shireql.variable.frontend.Component
4 |
5 | interface ComponentProvider {
6 | fun getPages(): List
7 | fun getComponents(): List
8 | fun getRoutes(): Map
9 | }
10 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/variable/resolver/SystemInfoVariableResolver.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.variable.resolver
2 |
3 | import cc.unitmesh.devti.devins.variable.SystemInfoVariable
4 | import cc.unitmesh.devti.language.ast.variable.resolver.base.VariableResolver
5 | import cc.unitmesh.devti.language.ast.variable.resolver.base.VariableResolverContext
6 |
7 | /**
8 | * SystemInfoVariableResolver is a class that provides a way to resolve system information variables.
9 | */
10 | class SystemInfoVariableResolver(
11 | private val context: VariableResolverContext,
12 | ) : VariableResolver {
13 | override suspend fun resolve(initVariables: Map): Map {
14 | return SystemInfoVariable.all().associate {
15 | it.variableName to it.value!!
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/variable/resolver/base/VariableResolver.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.variable.resolver.base
2 |
3 | /**
4 | * The `VariableResolver` interface is designed to provide a mechanism for resolving variables.
5 | */
6 | interface VariableResolver {
7 | suspend fun resolve(initVariables: Map): Map
8 | }
9 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/variable/resolver/base/VariableResolverContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.ast.variable.resolver.base
2 |
3 | import cc.unitmesh.devti.language.ast.HobbitHole
4 | import com.intellij.openapi.editor.Editor
5 | import com.intellij.openapi.project.Project
6 | import com.intellij.psi.PsiElement
7 | import cc.unitmesh.devti.language.ast.variable.VariableTable
8 |
9 | data class VariableResolverContext(
10 | val myProject: Project,
11 | val editor: Editor,
12 | val hole: HobbitHole?,
13 | val variableTable: VariableTable,
14 | var element: PsiElement?
15 | )
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/DevInsSketchToolchainProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler
2 |
3 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
4 | import cc.unitmesh.devti.sketch.SketchToolchainProvider
5 | import cc.unitmesh.devti.agent.tool.AgentTool
6 |
7 | class DevInsSketchToolchainProvider : SketchToolchainProvider {
8 | override fun collect(): List {
9 | /// we need to ignore some bad case for llm
10 | return BuiltinCommand.all()
11 | .filter {
12 | it.enableInSketch
13 | }
14 | .map {
15 | val example = BuiltinCommand.example(it)
16 | AgentTool(it.commandName, it.description, example)
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/error/DevInError.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.error
2 |
3 | val DEVINS_ERROR = ""
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/BrowseInsCommand.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.exec
2 |
3 | import cc.unitmesh.devti.agent.tool.browse.Browse
4 | import cc.unitmesh.devti.command.InsCommand
5 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
6 | import com.intellij.openapi.project.Project
7 |
8 | class BrowseInsCommand(val myProject: Project, private val prop: String) : InsCommand {
9 | override val commandName: BuiltinCommand = BuiltinCommand.BROWSE
10 |
11 | override suspend fun execute(): String? {
12 | val parse = Browse.parse(prop)
13 | return parse.body
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/OpenInsCommand.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.exec
2 |
3 | import cc.unitmesh.devti.command.InsCommand
4 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
5 | import cc.unitmesh.devti.language.utils.lookupFile
6 | import com.intellij.openapi.fileEditor.FileEditorManager
7 | import com.intellij.openapi.project.Project
8 |
9 | class OpenInsCommand(val myProject: Project, private val filename: String) : InsCommand {
10 | override val commandName: BuiltinCommand = BuiltinCommand.OPEN
11 |
12 | override suspend fun execute(): String? {
13 | val file = myProject.lookupFile(filename)
14 | if (file != null) {
15 | FileEditorManager.getInstance(myProject).openFile(file, true)
16 | }
17 |
18 | return "Opening $filename..."
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/PrintInsCommand.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.exec
2 |
3 | import cc.unitmesh.devti.command.InsCommand
4 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
5 |
6 | class PrintInsCommand(private val value: String) : InsCommand {
7 | override val commandName: BuiltinCommand = BuiltinCommand.OPEN
8 |
9 | override suspend fun execute(): String {
10 | return value
11 | }
12 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/RuleInsCommand.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.exec
2 |
3 | import cc.unitmesh.devti.command.InsCommand
4 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
5 | import cc.unitmesh.devti.language.compiler.error.DEVINS_ERROR
6 | import cc.unitmesh.devti.sketch.rule.ProjectRule
7 | import com.intellij.openapi.project.Project
8 |
9 | class RuleInsCommand(val myProject: Project, private val filename: String) : InsCommand {
10 | override val commandName: BuiltinCommand = BuiltinCommand.OPEN
11 |
12 | override suspend fun execute(): String? {
13 | val projectRule = ProjectRule(myProject)
14 | return projectRule.getRuleContent(filename) ?: "$DEVINS_ERROR rule file not found: $filename"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/debugger/ShireSuspendContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.debugger
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.xdebugger.frame.XExecutionStack
5 | import com.intellij.xdebugger.frame.XSuspendContext
6 |
7 | class ShireSuspendContext(val process: ShireDebugProcess, project: Project) : XSuspendContext() {
8 | private val shireExecutionStacks: Array = arrayOf(
9 | ShireExecutionStack(process, project)
10 | )
11 |
12 | override fun getActiveExecutionStack(): XExecutionStack? = shireExecutionStacks.firstOrNull()
13 | override fun getExecutionStacks(): Array = shireExecutionStacks
14 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/highlight/DevInSyntaxHighlighterFactory.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.highlight
2 |
3 | import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.vfs.VirtualFile
6 |
7 | class DevInSyntaxHighlighterFactory : SyntaxHighlighterFactory() {
8 | override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = DevInSyntaxHighlighter()
9 | }
10 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/lexer/DevInLexerAdapter.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.lexer
2 |
3 | import com.intellij.lexer.FlexAdapter
4 |
5 | class DevInLexerAdapter : FlexAdapter(_DevInLexer()) {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/lexer/DevInTokenType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.lexer
2 |
3 | import cc.unitmesh.devti.language.DevInLanguage
4 | import com.intellij.psi.tree.IElementType
5 | import org.jetbrains.annotations.NonNls
6 |
7 | class DevInTokenType(debugName: @NonNls String) : IElementType(debugName, DevInLanguage) {
8 | override fun toString(): String = "DevInTokenType." + super.toString()
9 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/middleware/select/PsiElementStrategy.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.middleware.select
2 |
3 | import com.intellij.openapi.editor.Editor
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.util.TextRange
6 | import com.intellij.psi.PsiElement
7 | import com.intellij.psi.PsiFile
8 |
9 | interface PsiElementStrategy {
10 | fun getElementToAction(project: Project?, editor: Editor?): PsiElement?
11 | fun getElementToAction(project: Project?, psiFile: PsiFile, range: TextRange): PsiElement?
12 | }
13 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/parser/ShireTokenTypeSets.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.parser
2 |
3 | import cc.unitmesh.devti.language.psi.DevInTypes
4 | import com.intellij.psi.TokenType
5 | import com.intellij.psi.tree.TokenSet
6 |
7 | object ShireTokenTypeSets {
8 | // DevInTypes.NEWLINE
9 | val WHITESPACES: TokenSet = TokenSet.create(TokenType.WHITE_SPACE)
10 |
11 | val SHIRE_COMMENTS = TokenSet.create(DevInTypes.CONTENT_COMMENTS, DevInTypes.COMMENTS, DevInTypes.BLOCK_COMMENT)
12 | }
13 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/psi/DevInElementType.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.psi
2 |
3 | import cc.unitmesh.devti.language.DevInLanguage
4 | import com.intellij.psi.tree.IElementType
5 |
6 | class DevInElementType(debugName: String): IElementType(debugName, DevInLanguage.INSTANCE)
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInsProcessHandler.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.run
2 |
3 | import com.intellij.build.process.BuildProcessHandler
4 | import java.io.OutputStream
5 |
6 | class DevInsProcessHandler(private val myExecutionName: String) : BuildProcessHandler() {
7 | override fun detachIsDefault(): Boolean = false
8 | override fun destroyProcessImpl() = Unit
9 | override fun detachProcessImpl() = notifyProcessTerminated(0)
10 | fun exitWithError() = notifyProcessTerminated(-1)
11 |
12 | override fun getProcessInput(): OutputStream? = null
13 | override fun getExecutionName(): String = myExecutionName
14 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/flow/DevInsProcessContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.run.flow
2 |
3 | import cc.unitmesh.devti.language.compiler.DevInsCompiledResult
4 |
5 | data class DevInsProcessContext(
6 | val scriptPath: String,
7 | val compiledResult: DevInsCompiledResult,
8 | val llmResponse: String,
9 | val ideOutput: String,
10 | val messages: MutableList = mutableListOf(),
11 | var hadReRun: Boolean = false
12 | ) {
13 | // update messages when has Error or Warning
14 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/runner/ShireRunnerContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.run.runner
2 |
3 | import cc.unitmesh.devti.language.ast.HobbitHole
4 | import cc.unitmesh.devti.language.compiler.DevInsCompiledResult
5 | import com.intellij.openapi.editor.Editor
6 |
7 | class ShireRunnerContext(
8 | val hole: HobbitHole?,
9 | val editor: Editor?,
10 | val compileResult: DevInsCompiledResult,
11 | val finalPrompt: String = "",
12 | val hasError: Boolean,
13 | val compiledVariables: Map,
14 | )
15 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/startup/DynamicDevInsActionConfig.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.startup
2 |
3 | import cc.unitmesh.devti.language.ast.HobbitHole
4 | import cc.unitmesh.devti.language.compiler.HobbitHoleParser
5 | import cc.unitmesh.devti.language.psi.DevInFile
6 | import com.intellij.openapi.editor.Editor
7 |
8 | data class DynamicDevInsActionConfig(
9 | val name: String,
10 | val hole: HobbitHole? = null,
11 | val devinFile: DevInFile,
12 | val editor: Editor? = null,
13 | ) {
14 | companion object {
15 | fun from(file: DevInFile): DynamicDevInsActionConfig {
16 | val hole = HobbitHoleParser.parse(file)
17 | return DynamicDevInsActionConfig(file.name, hole, file)
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/status/DevInsRunListener.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.status
2 |
3 | import cc.unitmesh.devti.language.run.runner.ShireConsoleView
4 | import com.intellij.execution.process.ProcessEvent
5 | import com.intellij.util.messages.Topic
6 | import java.util.*
7 |
8 | @FunctionalInterface
9 | interface DevInsRunListener : EventListener {
10 | fun runFinish(string: String, llmOutput: String, event: ProcessEvent, scriptPath: String, consoleView: ShireConsoleView?)
11 |
12 | companion object {
13 | @Topic.AppLevel
14 | val TOPIC: Topic = Topic(
15 | DevInsRunListener::class.java, Topic.BroadcastDirection.TO_DIRECT_CHILDREN
16 | )
17 | }
18 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/browse.devin:
--------------------------------------------------------------------------------
1 | /browse:https://ide.unitmesh.cc
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/commit.devin:
--------------------------------------------------------------------------------
1 | Execute git commit with commit message
2 | /commit
3 | ```markdown
4 | follow Conventional Commits, like feat: add 'graphiteWidth' option
5 | ```
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/componentView.devin:
--------------------------------------------------------------------------------
1 | List all UI Component List of current project, like React Vue components
2 | /componentView
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/containerView.devin:
--------------------------------------------------------------------------------
1 | List all modules of current project
2 | /containerView
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/database.devin:
--------------------------------------------------------------------------------
1 | 列出数据库的数据结构
2 | /database:schema
3 | 列出数据库中的所有表
4 | /database:table
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/dependencies.devin:
--------------------------------------------------------------------------------
1 | Get all dependencies (Gradle, Maven, package.json) of current project
2 | /dependencies
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/dir.devin:
--------------------------------------------------------------------------------
1 | 列出目录内容,默认深度为2,支持智能深度处理(单路径结构自动深入遍历,适合Java等层级深的结构,自动排除二进制文件、.idea目录和被版本控制系统忽略的文件)。
2 | /dir:.
3 | 列出特定目录:
4 | /dir:src/components
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/edit_file.devin:
--------------------------------------------------------------------------------
1 | /edit_file
2 | ```
3 | target_file: "src/main/kotlin/MyClass.kt"
4 | instructions: "Add a new method to calculate the sum of two numbers"
5 | code_edit: |
6 | class MyClass {
7 | // ... existing code ...
8 |
9 | fun calculateSum(a: Int, b: Int): Int {
10 | return a + b
11 | }
12 |
13 | // ... existing code ...
14 | }
15 | ```
16 |
17 | Use this command for precise file edits with clear context markers. The code_edit should contain the exact changes with // ... existing code ... markers to represent unchanged sections.
18 |
19 | YAML Format Benefits:
20 | - Uses YAML block scalar (|) for multiline code content
21 | - Automatically handles quotes, special characters, and escaping
22 | - More robust parsing compared to regex-based approach
23 | - Supports complex code with various quote types and nested strings
24 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/file-func.devin:
--------------------------------------------------------------------------------
1 | /file-func:regex(".*\.txt")
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/file.devin:
--------------------------------------------------------------------------------
1 | 找到指定文件(需要知道正确的文件路径,否则无法找到)
2 | /file:.github/dependabot.yml#L1C1-L2C12
3 | 根据文件名全局搜索(大小写敏感,不带路径)
4 | /file:PythonFrameworkContextProvider.kt
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/history.devin:
--------------------------------------------------------------------------------
1 | Get history commit message of current file
2 | /history:package.json
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/knowledge.devin:
--------------------------------------------------------------------------------
1 | 从 API 调用链来进行分析,默认 depth = 2(不可修改),即 Controller 到 Repository 的调用链
2 | /knowledge:GET#/api/blog/* [注:这里 * 代表 blog slug,等同于 SpringMVC 的 @PathVariable]
3 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/localSearch.devin:
--------------------------------------------------------------------------------
1 | 在项目中搜索关键字搜索时,不能有空格,而且至少是 4 个字符:
2 | /localSearch:photo
3 | 当你需要带空格时,语法如下:
4 | /localSearch:project
5 | ```
6 | select * from blog
7 | ```
8 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/open.devin:
--------------------------------------------------------------------------------
1 | /open:.github/dependabot.yml
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/patch.devin:
--------------------------------------------------------------------------------
1 | /patch
2 | ```patch
3 | Index: src/main/route.py
4 | --- src/main/route.py (revision 1)
5 | +++ src/main/route.py (revision 2)
6 | // GNU unified diff format structure
7 | ```
8 |
9 | If patch failured, please use write command
10 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/refactor.devin:
--------------------------------------------------------------------------------
1 | /refactor:rename cc.unitmesh.devti.language.run.DevInsProgramRunner to cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/related.devin:
--------------------------------------------------------------------------------
1 | /related:cc.unitmesh.devti.language.psi
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/rev.devin:
--------------------------------------------------------------------------------
1 | 只支持获取某个 sha hash 的代码变更
2 | /rev:38d23de2
3 | 如果想进行更多的操作,请使用 bash + git 来获取
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/ripgrepSearch.devin:
--------------------------------------------------------------------------------
1 | 支持 Regex 的全局搜索
2 | /ripgrepSearch:.*AutoDev.*
3 | 优化使用 Regex 方式,诸如使用 /s 替换空格
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/rule.devin:
--------------------------------------------------------------------------------
1 | 用户可以通过 rule 来自定义编程规范,以生成更符合自己需要的代码。
2 | 获取 service 相关的规则(将读取 promtps/rule/service.md 文件,请确保文件存在)
3 | /rule:service
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/run.devin:
--------------------------------------------------------------------------------
1 | 启动 Spring 应用运行测试
2 | /run::bootRun
3 | 运行测试
4 | /run:src/main/cc/unitmesh/PythonPromptStrategyTest.kt
5 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/scc.devin:
--------------------------------------------------------------------------------
1 | Scc is a very fast accurate code counter with complexity calculations and COCOMO estimates
2 | /scc
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/shell.devin:
--------------------------------------------------------------------------------
1 | 执行 shell 脚本,要考虑生成的脚本是非阻塞的,即可以读取标准输入
2 | /shell:execute
3 | ```bash
4 | echo "Hello, World!"
5 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/structure.devin:
--------------------------------------------------------------------------------
1 | /structure:cc.unitmesh.devti.language.psi
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/stylingView.devin:
--------------------------------------------------------------------------------
1 | List all CSS, SCSS classes of current project
2 | /stylingView
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/symbol.devin:
--------------------------------------------------------------------------------
1 | /symbol:cc.unitmesh.devti.language.psi
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/usage.devin:
--------------------------------------------------------------------------------
1 | Query usage of some method, should use following format: ..
2 | /usage:cc.unitmesh.untitled.demo.service.BlogService.createBlog
3 | the return include file path, usage's method (caller) text.
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/webApiView.devin:
--------------------------------------------------------------------------------
1 | List all web apis of current project
2 | /webApiView
3 | If return no endpoints, we need to check Endpoint plugin installed.
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/write.devin:
--------------------------------------------------------------------------------
1 | 注意:如果原先的文件已经存在,请优先考虑使用 file 读取文件信息,再通过 edit_file
2 | /write:src/main/kotlin/cc/unitmesh/context/CppFileContextBuilder.kt
3 | ```kotlin
4 | // the kotlin code
5 | ```
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/agent/toolExamples/x.devin:
--------------------------------------------------------------------------------
1 | /dependencies [list all dependencies]
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/fileTemplates/internal/AutoDevAction.devin.ft:
--------------------------------------------------------------------------------
1 | ---
2 | name: "{{name}}"
3 | description: "Here is a description of the action."
4 | interaction: AppendCursor
5 | actionLocation: ContextMenu
6 | ---
7 |
8 | [notes]: For more options, see [the docs](https://ide.unitmesh.cc/local-agent/)
9 |
10 | You are an experienced software development engineer skilled in using Test-Driven Development (TDD) to develop software.
11 | You need to help users write test code based on their requirements.
12 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/inspectionDescriptions/DevInsDuplicateAgent.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects multiple @[AGENT_ID] annotations. Multiple @[AGENT_ID] are not allowed.
4 |
5 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntention/after.txt.template:
--------------------------------------------------------------------------------
1 | 生成一个 Java hello, world:
2 |
3 | ```java
4 | public class HelloWorld {
5 | public static void main(String[] args) {
6 | System.out.println("Hello, World!");
7 | }
8 | }
9 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntention/before.txt.template:
--------------------------------------------------------------------------------
1 | 生成一个 Java hello, world:
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntention/description.html:
--------------------------------------------------------------------------------
1 | Invoke Shire Hobbit Action on here with AI ability.
2 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntentionHelper/after.txt.template:
--------------------------------------------------------------------------------
1 | 生成一个 Java hello, world:
2 |
3 | ```java
4 | public class HelloWorld {
5 | public static void main(String[] args) {
6 | System.out.println("Hello, World!");
7 | }
8 | }
9 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntentionHelper/before.txt.template:
--------------------------------------------------------------------------------
1 | 生成一个 Java hello, world:
--------------------------------------------------------------------------------
/exts/devins-lang/src/main/resources/intentionDescriptions/ShireIntentionHelper/description.html:
--------------------------------------------------------------------------------
1 | Invoke Shire Hobbit Action on here with AI ability.
2 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/kotlin/cc/unitmesh/devti/language/compiler/execute/CrawlProcessorTest.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.compiler.execute
2 |
3 | import cc.unitmesh.devti.language.processor.CrawlProcessor
4 | import com.intellij.testFramework.fixtures.BasePlatformTestCase
5 |
6 | class CrawlProcessorTest : BasePlatformTestCase() {
7 | fun testShouldParseLink() {
8 | val urls = arrayOf("https://ide.unitmesh.cc/local-agent")
9 | val results = CrawlProcessor.execute(urls)
10 | assertEquals(results.size, 1)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/kotlin/cc/unitmesh/devti/language/completion/dataprovider/BuiltinCommandTest.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti.language.completion.dataprovider
2 |
3 | import cc.unitmesh.devti.command.dataprovider.BuiltinCommand
4 | import junit.framework.TestCase.assertEquals
5 | import org.junit.Test
6 |
7 | class BuiltinCommandTest {
8 | @Test
9 | fun shouldEnableGetBuiltinExamples() {
10 | val commandList = BuiltinCommand.all()
11 | val map = commandList.map {
12 | BuiltinCommand.example(it)
13 | }
14 |
15 | assertEquals(commandList.size, map.size)
16 | }
17 | }
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/AfterStream.devin:
--------------------------------------------------------------------------------
1 | ---
2 | afterStreaming: {
3 | condition {
4 | "variable-success" { $selection.length > 1 }
5 | "jsonpath-success" { jsonpath("/bookstore/book[price>35]") }
6 | }
7 | case condition {
8 | "variable-sucesss" { done }
9 | "jsonpath-success" { task() }
10 | default { task() }
11 | }
12 | }
13 | ---
14 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/AutoCommand.devin:
--------------------------------------------------------------------------------
1 | /write:Sample.file#L1-L12
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/AutoCommand.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | DevInUsedImpl(USED)
3 | DevInCommandStartImpl(COMMAND_START)
4 | PsiElement(COMMAND_START)('/')
5 | DevInCommandIdImpl(COMMAND_ID)
6 | PsiElement(DevInTokenType.IDENTIFIER)('write')
7 | PsiElement(DevInTokenType.COLON)(':')
8 | PsiElement(DevInTokenType.COMMAND_PROP)('Sample.file#L1-L12')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/AutoRefactor.devin:
--------------------------------------------------------------------------------
1 | /refactor:rename com.phodal.shirelang.run.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunnerImpl
2 | /refactor:safeDelete com.phodal.shirelang.run.ShireProgramRunnerImpl
3 | /refactor:delete com.phodal.shirelang.run.ShireProgramRunnerImpl
4 | /refactor:move com.phodal.shirelang.ShireProgramRunner to com.phodal.shirelang.run.ShireProgramRunner
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/BasicTest.devin:
--------------------------------------------------------------------------------
1 | 你好 @hello-world sm
2 | 解释一下代码
3 | $selection 表示选择的内容
4 | @agent-name 调用特定的 agent
5 | /file:Sample.file 从文件中读取内容
6 | /rev:632372da 从版本库中读取内容
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/BlockStartOnly.devin:
--------------------------------------------------------------------------------
1 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/BlockStartOnly.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | CodeBlockElement(CODE)
3 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
4 | ASTWrapperPsiElement(CODE_CONTENTS)
5 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/BrowseWeb.devin:
--------------------------------------------------------------------------------
1 | /browse:https://ide.unitmesh.cc
2 | /browse:https://www.example.com/page?param1=value1¶m2=value2
3 | /browse:https://www.example.com/page#section1
4 | /browse:http://localhost:3000/page
5 | /browse:https://username:password@www.example.com/page
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/CommandAndSymbol.devin:
--------------------------------------------------------------------------------
1 | /explain /symbol:cc.unitmesh.devti#RevProvider.constructor
2 |
3 | /refactor /symbol:cc.unitmesh.devti#RevProvider.completions
4 |
5 | /write:presentation/VirtualFilePresentation.java#L1-L12
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/ComplexLangId.devin:
--------------------------------------------------------------------------------
1 | ```typescript jsx
2 | import { Button } from '@unitmesh-ui/core';
3 | ```
4 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/ComplexLangId.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | CodeBlockElement(CODE)
3 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
4 | PsiElement(DevInTokenType.LANGUAGE_ID)('typescript jsx')
5 | PsiElement(DevInTokenType.NEWLINE)('\n')
6 | ASTWrapperPsiElement(CODE_CONTENTS)
7 | PsiElement(DevInTokenType.CODE_CONTENT)('import { Button } from '@unitmesh-ui/core';')
8 | PsiElement(DevInTokenType.NEWLINE)('\n')
9 | PsiElement(DevInTokenType.CODE_BLOCK_END)('```')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/CustomFunctions.devin:
--------------------------------------------------------------------------------
1 | ---
2 | functions:
3 | aFunc: "defaultMain.py"(string)
4 | aFunc: "multipleOutput.py"(string, number) -> content
5 | cFunc: "accessFunctionIfSupport.py"::resize(string, number, number) -> image
6 | ---
7 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/EmptyCodeFence.devin:
--------------------------------------------------------------------------------
1 | 解释如下的代码:
2 |
3 | ```
4 | print("Hello, world!")
5 | ```
6 |
7 | 请使用 Markdown 语法返回。
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/EmptyCodeFence.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | PsiElement(DevInTokenType.TEXT_SEGMENT)('解释如下的代码:')
3 | PsiElement(DevInTokenType.NEWLINE)('\n')
4 | PsiElement(DevInTokenType.NEWLINE)('\n')
5 | CodeBlockElement(CODE)
6 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
7 | PsiElement(DevInTokenType.NEWLINE)('\n')
8 | ASTWrapperPsiElement(CODE_CONTENTS)
9 | PsiElement(DevInTokenType.CODE_CONTENT)('print("Hello, world!")')
10 | PsiElement(DevInTokenType.NEWLINE)('\n')
11 | PsiElement(DevInTokenType.CODE_BLOCK_END)('```')
12 | PsiElement(DevInTokenType.NEWLINE)('\n')
13 | PsiElement(DevInTokenType.NEWLINE)('\n')
14 | PsiElement(DevInTokenType.TEXT_SEGMENT)('请使用 Markdown 语法返回。')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/FrontMatter.devin:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Sample Title"
3 | date: 2022-01-01
4 | author: "John Doe"
5 | tags: [markdown, frontmatter]
6 | ---
7 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/JavaAnnotation.devin:
--------------------------------------------------------------------------------
1 | ```java
2 | @Target({ElementType.TYPE})
3 | @Retention(RetentionPolicy.RUNTIME)
4 | public @interface ExampleAnnotation {
5 | String value() default "";
6 | }
7 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/JavaHelloWorld.devin:
--------------------------------------------------------------------------------
1 | 解释如下的代码:
2 |
3 | ```java
4 | public class Main {
5 | public static void main(String[] args) {
6 | System.out.println("Hello, world!");
7 | }
8 | }
9 | ```
10 |
11 | 请使用 Markdown 语法返回。
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/MarkdownCompatible.devin:
--------------------------------------------------------------------------------
1 | ## Hello
2 |
3 | ```shire
4 | ---
5 | name: "自动 patch"
6 | variables:
7 | "codepath": /BlogController\.java/ { print }
8 | "controllerCode": /BlogController\.java/ { cat }
9 | "domainLanguage": /domain-language\.csv/ { cat }
10 | onStreamingEnd: { parseCode | patch($codepath, $output) }
11 | ---
12 | ```
13 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/MultipleFMVariable.devin:
--------------------------------------------------------------------------------
1 | ---
2 | variables:
3 | "extContext": /build\.gradle\.kts/ { cat | grep("org.springframework.boot:spring-boot-starter-jdbc") | print("This project use Spring Framework")}
4 | "testTemplate": /\(.*\).java/ {
5 | case "$1" {
6 | "Controller" { cat(".shire/templates/ControllerTest.java") }
7 | "Service" { cat(".shire/templates/ServiceTest.java") }
8 | default { cat(".shire/templates/DefaultTest.java") }
9 | }
10 | }
11 | "allController": {
12 | from {
13 | PsiClass clazz /* sample */
14 | }
15 | where {
16 | clazz.getAnAnnotation() == "org.springframework.web.bind.annotation.RequestMapping"
17 | }
18 | select {
19 | clazz.id, clazz.name, "code"
20 | }
21 | }
22 | ---
23 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/PatternAction.devin:
--------------------------------------------------------------------------------
1 | ---
2 | variables:
3 | "var1": "value2"
4 | "var2": /.*.java/ { grep("error.log") | sort | xargs("rm")}
5 | ---
6 |
7 | $var1
8 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/PatternCaseAction.devin:
--------------------------------------------------------------------------------
1 | ---
2 | variables:
3 | "var1": "demo"
4 | "var2": /.*.java/ { grep("error.log") | sort | xargs("rm")}
5 | "var3": /.*.log/ {
6 | case "$0" {
7 | "error" { grep("ERROR") | sort | xargs("notify_admin") }
8 | "warn" { grep("WARN") | sort | xargs("notify_admin") }
9 | "info" { grep("INFO") | sort | xargs("notify_user") }
10 | default { grep("ERROR") | sort | xargs("notify_admin") }
11 | }
12 | }
13 | "var4": 42
14 | ---
15 |
16 | $var1
17 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/ShireFmObject.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Java to Kotlin"
3 | description: "Convert Java to Kotlin file"
4 | interaction: AppendCursor
5 | actionLocation: ContextMenu
6 | enabled: false
7 | model: "codegeex-4"
8 | onStreamingEnd: { verifyCode | runCode }
9 | ---
10 |
11 | Convert follow $language code to Kotlin
12 |
13 | $all
14 |
15 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/ShirePsiQueryExpression.devin:
--------------------------------------------------------------------------------
1 | ---
2 | variables:
3 | "allController": {
4 | from {
5 | PsiClass clazz // the class
6 | }
7 | where {
8 | clazz.extends("org.springframework.web.bind.annotation.RestController") and clazz.getAnAnnotation() == "org.springframework.web.bind.annotation.RequestMapping"
9 | }
10 |
11 | select {
12 | clazz.id, clazz.name, "code"
13 | }
14 | }
15 | ---
16 |
17 | $allController
18 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/SingleComment.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Gandalf" // comment 2
3 | variables:
4 | "codepath": /BlogController\.java/ { print } // comments 3
5 | ---
6 |
7 | [flow]:flowable.devin
8 | [flow](result)
9 |
10 | [] is a symbol of comment, follow markdown syntax, and the content in [] is the comment content.
11 | The comment content is not displayed in the final result. So we can use it to add some notes to the flow.
12 |
13 | [ Normal start
14 | ]
15 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/VariableAccess.devin:
--------------------------------------------------------------------------------
1 | ---
2 | when: $selection.length == 1 && $selection.first() == 'file'
3 | ---
4 |
5 | Write unit test for following ${context.lang} code.
6 |
7 | ${context.frameworkContext}
8 |
9 | #if($context.relatedClasses.length() > 0 )
10 | Here is the relate code maybe you can use
11 | ${context.relatedClasses}
12 | #end
13 |
14 | ```$context.lang
15 | ${context.imports}
16 | ${context.sourceCode}
17 | ```
18 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/normal/WhenCondition.devin:
--------------------------------------------------------------------------------
1 | ---
2 | when: { $selection.length == 1 && $selection.first() == 'file' }
3 | ---
4 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/AutoCommand.devin:
--------------------------------------------------------------------------------
1 | /write:Sample.file#L1-L12
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/AutoCommand.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | DevInUsedImpl(USED)
3 | DevInCommandStartImpl(COMMAND_START)
4 | PsiElement(COMMAND_START)('/')
5 | DevInCommandIdImpl(COMMAND_ID)
6 | PsiElement(DevInTokenType.IDENTIFIER)('write')
7 | PsiElement(DevInTokenType.COLON)(':')
8 | PsiElement(DevInTokenType.COMMAND_PROP)('Sample.file#L1-L12')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/AutoRefactor.devin:
--------------------------------------------------------------------------------
1 | /refactor:rename cc.unitmesh.devti.language.run.DevInsProgramRunner to cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl
2 | /refactor:safeDelete cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl
3 | /refactor:delete cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl
4 | /refactor:move cc.unitmesh.devti.language.DevInsProgramRunner to cc.unitmesh.devti.language.run.DevInsProgramRunner
5 | /refactor:extractMethod cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl.run#L20-L30
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/BasicTest.devin:
--------------------------------------------------------------------------------
1 | 你好 @hello-world sm
2 | 解释一下代码
3 | $selection 表示选择的内容
4 | @agent-name 调用特定的 agent
5 | /file:Sample.file 从文件中读取内容
6 | /rev:632372da 从版本库中读取内容
7 | #system_id:51 传递参数到 story_id
8 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/BlockStartOnly.devin:
--------------------------------------------------------------------------------
1 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/BlockStartOnly.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | CodeBlockElement(CODE)
3 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
4 | ASTWrapperPsiElement(CODE_CONTENTS)
5 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/BrowseWeb.devin:
--------------------------------------------------------------------------------
1 | /browse:https://ide.unitmesh.cc
2 | /browse:https://www.example.com/page?param1=value1¶m2=value2
3 | /browse:https://www.example.com/page#section1
4 | /browse:http://localhost:3000/page
5 | /browse:https://username:password@www.example.com/page
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/CommandAndSymbol.devin:
--------------------------------------------------------------------------------
1 | /explain /symbol:cc.unitmesh.devti#RevProvider.constructor
2 |
3 | /refactor /symbol:cc.unitmesh.devti#RevProvider.completions
4 |
5 | /write:presentation/VirtualFilePresentation.java#L1-L12
6 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/ComplexLangId.devin:
--------------------------------------------------------------------------------
1 | ```typescript jsx
2 | ```
3 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/ComplexLangId.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | CodeBlockElement(CODE)
3 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
4 | PsiElement(DevInTokenType.LANGUAGE_ID)('typescript jsx')
5 | PsiElement(DevInTokenType.NEWLINE)('\n')
6 | ASTWrapperPsiElement(CODE_CONTENTS)
7 |
8 | PsiElement(DevInTokenType.CODE_BLOCK_END)('```')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/EmptyCodeFence.devin:
--------------------------------------------------------------------------------
1 | 解释如下的代码:
2 |
3 | ```
4 | print("Hello, world!")
5 | ```
6 |
7 | 请使用 Markdown 语法返回。
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/EmptyCodeFence.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | PsiElement(DevInTokenType.TEXT_SEGMENT)('解释如下的代码:')
3 | PsiElement(DevInTokenType.NEWLINE)('\n')
4 | PsiElement(DevInTokenType.NEWLINE)('\n')
5 | CodeBlockElement(CODE)
6 | PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
7 | PsiElement(DevInTokenType.NEWLINE)('\n')
8 | ASTWrapperPsiElement(CODE_CONTENTS)
9 | PsiElement(DevInTokenType.CODE_CONTENT)('print("Hello, world!")')
10 | PsiElement(DevInTokenType.NEWLINE)('\n')
11 | PsiElement(DevInTokenType.CODE_BLOCK_END)('```')
12 | PsiElement(DevInTokenType.NEWLINE)('\n')
13 | PsiElement(DevInTokenType.NEWLINE)('\n')
14 | PsiElement(DevInTokenType.TEXT_SEGMENT)('请使用 Markdown 语法返回。')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/JavaAnnotation.devin:
--------------------------------------------------------------------------------
1 | ```java
2 | @Target({ElementType.TYPE})
3 | @Retention(RetentionPolicy.RUNTIME)
4 | public @interface ExampleAnnotation {
5 | String value() default "";
6 | }
7 | ```
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/JavaHelloWorld.devin:
--------------------------------------------------------------------------------
1 | 解释如下的代码:
2 |
3 | ```java
4 | public class Main {
5 | public static void main(String[] args) {
6 | System.out.println("Hello, world!");
7 | }
8 | }
9 | ```
10 |
11 | 请使用 Markdown 语法返回。
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/SingleComment.devin:
--------------------------------------------------------------------------------
1 | [flow]:flowable.devin
2 | [flow](result)
3 |
4 | [] is a symbol of comment, follow markdown syntax, and the content in [] is the comment content.
5 | The comment content is not displayed in the final result. So we can use it to add some notes to the flow.
6 |
7 | [ Normal start
8 | ]
9 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/SingleComment.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | PsiElement(DevInTokenType.COMMENTS)('[flow]:flowable.devin')
3 | PsiElement(DevInTokenType.NEWLINE)('\n')
4 | PsiElement(DevInTokenType.COMMENTS)('[flow](result)')
5 | PsiElement(DevInTokenType.NEWLINE)('\n')
6 | PsiElement(DevInTokenType.NEWLINE)('\n')
7 | PsiElement(DevInTokenType.COMMENTS)('[] is a symbol of comment, follow markdown syntax, and the content in [] is the comment content.')
8 | PsiElement(DevInTokenType.NEWLINE)('\n')
9 | PsiElement(DevInTokenType.TEXT_SEGMENT)(' The comment content is not displayed in the final result. So we can use it to add some notes to the flow.')
10 | PsiElement(DevInTokenType.NEWLINE)('\n')
11 | PsiElement(DevInTokenType.NEWLINE)('\n')
12 | PsiElement(DevInTokenType.TEXT_SEGMENT)('[ Normal start')
13 | PsiElement(DevInTokenType.NEWLINE)('\n')
14 | PsiElement(DevInTokenType.TEXT_SEGMENT)(']')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/SystemCalling.devin:
--------------------------------------------------------------------------------
1 | #kanban:1
2 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/parser/SystemCalling.txt:
--------------------------------------------------------------------------------
1 | DevInFile
2 | DevInUsedImpl(USED)
3 | PsiElement(DevInTokenType.SYSTEM_START)('#')
4 | PsiElement(DevInTokenType.SYSTEM_ID)('kanban')
5 | PsiElement(DevInTokenType.COLON)(':')
6 | PsiElement(DevInTokenType.NUMBER)('1')
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/AfterStreamingOnly.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Search"
3 | variables:
4 | "testTemplate": /.*.kt/ { caching("disk") | splitting | embedding }
5 | afterStreaming: { searching($output) | execute("search.shire") }
6 | ---
7 |
8 | You are a coding assistant who helps the user answer questions about code in their workspace by providing a list of
9 | relevant keywords they can search for to answer the question.
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/ContentTee.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Context Variable"
3 | description: "Here is a description of the action."
4 | interaction: RunPanel
5 | variables:
6 | "currentCode": /HobbitHole\.kt/ { cat }
7 | "testCode": /ShireCompileTest\.kt/ { cat }
8 | "actionLocation": /ShireActionLocation\.kt/ { cat }
9 | onStreamingEnd: { append($actionLocation) | saveFile("docs/shire/shire-hobbit-hole.md") }
10 | ---
11 |
12 | 我有一份用户手册写得不好,需要你从用户容易阅读的角度,重新写一份。
13 |
14 | 根据如下的代码用例、文档,编写对应的 HobbitHole 相关信息的 markdown 文档。
15 |
16 | 现有代码:
17 |
18 | $currentCode
19 |
20 | 代码用例如下:
21 |
22 | $testCode
23 |
24 | 要求:
25 |
26 | 1. 尽详细介绍 HobbitHole 的相关信息和示例。
27 | 2. 请按现有的文档 Heading 方式编写,并去除非必要的代码。
28 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/LoginCommit.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Commit message"
3 | enabled: false
4 | description: "生成提交信息"
5 | interaction: AppendCursor
6 | actionLocation: CommitMenu
7 | variables:
8 | "story": /any/ { thread(".shire/fetch-jira.sh") | jsonpath("$.data[*].Story") }
9 | ---
10 |
11 | 请遵循常规提交规范,例如:
12 |
13 | - fix(authentication): 修复密码正则表达式模式问题 #$story
14 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/OnPaste.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "PasteMaster"
3 | actionLocation: ContextMenu
4 | enabled: false
5 | ---
6 |
7 | [interaction: OnPaste]
8 |
9 | 代码生成。根据当前的代码上下文(光标前后),对用户粘贴的代码,生成新的代码。
10 |
11 | 光标前的代码:
12 |
13 | $beforeCursor
14 |
15 | 光标后的代码:
16 |
17 | $afterCursor
18 |
19 | 用户粘贴的代码:
20 |
21 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/OutputInVariable.devin:
--------------------------------------------------------------------------------
1 | ---
2 | name: "代码修改"
3 | variables:
4 | "controllerCode": /any/ { cat($output) }
5 | onStreamingEnd: { parseCode | saveFile($output) }
6 | ---
7 |
8 | $output
9 |
--------------------------------------------------------------------------------
/exts/devins-lang/src/test/testData/realworld/WhenAfterStreaming.devin:
--------------------------------------------------------------------------------
1 | ---
2 | interaction: AppendCursor
3 | onStreamingEnd: { parseCode("json") | verifyCode("json") | runCode("json") }
4 | when: "$selection.length == 1 && $selection.first() == 'file'"
5 | ---
6 |
7 | hi
8 |
9 | Hello! How can I assist you today?
10 |
11 |
--------------------------------------------------------------------------------
/exts/ext-container/src/223/main/resources/cc.unitmesh.container.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/exts/ext-container/src/233/main/resources/cc.unitmesh.container.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/exts/ext-container/src/241/main/resources/cc.unitmesh.container.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exts/ext-database/README.md:
--------------------------------------------------------------------------------
1 | # Database Extensions
2 |
3 | Doc: [https://plugins.jetbrains.com/docs/intellij/data-grip-extension-point-list.html](https://plugins.jetbrains.com/docs/intellij/data-grip-extension-point-list.html)
4 |
5 | This directory contains extensions that are specific to a database.
6 |
7 | - Generate SQL DDL for a database from a schema
8 |
9 | Or others?
10 |
11 | ## 自然语言 SQL 生成
12 |
13 | 根据数据库表生成 JPA 、 MyBatis 、 Spring Data JDBC 等代码。
14 |
15 | ## Usecases: PL/SQL to Java
16 |
17 | 1. Generate Repository from PL/SQL code
18 | 2. Generate Entity from PL/SQL code
19 | 3. Generate Service from PL/SQL code
20 | - Create test cases for the service
21 | 4. Generate Java code from PL/SQL code
22 |
--------------------------------------------------------------------------------
/exts/ext-database/src/223/main/kotlin/cc/unitmesh/database/util/SqlUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.util
2 |
3 | import com.intellij.database.model.basic.BasicTableOrViewColumn
4 |
5 | fun columnType(it: BasicTableOrViewColumn) = it.dataType
--------------------------------------------------------------------------------
/exts/ext-database/src/233/main/kotlin/cc/unitmesh/database/util/SqlUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.util
2 |
3 | import com.intellij.database.model.basic.BasicTableOrViewColumn
4 |
5 | fun columnType(it: BasicTableOrViewColumn) = it.dasType.specification
--------------------------------------------------------------------------------
/exts/ext-database/src/241/main/kotlin/cc/unitmesh/database/util/SqlUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.util
2 |
3 | import com.intellij.database.model.basic.BasicTableOrViewColumn
4 |
5 | fun columnType(it: BasicTableOrViewColumn) = it.dasType.specification
--------------------------------------------------------------------------------
/exts/ext-database/src/243/main/kotlin/cc/unitmesh/database/util/SqlUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.util
2 |
3 | import com.intellij.database.model.basic.BasicTableOrViewColumn
4 |
5 | fun columnType(it: BasicTableOrViewColumn) = it.dasType.specification
--------------------------------------------------------------------------------
/exts/ext-database/src/main/kotlin/cc/unitmesh/database/actions/base/SqlMigrationContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.actions.base
2 |
3 | import cc.unitmesh.devti.template.context.TemplateContext
4 |
5 | data class SqlMigrationContext(
6 | val lang: String = "",
7 | var sql: String = "",
8 | ) : TemplateContext
--------------------------------------------------------------------------------
/exts/ext-database/src/main/kotlin/cc/unitmesh/database/flow/AutoSqlContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.flow
2 |
3 | import cc.unitmesh.devti.template.context.TemplateContext
4 |
5 | data class AutoSqlContext(
6 | val requirement: String,
7 | val databaseVersion: String,
8 | val schemaName: String,
9 | val tableNames: List,
10 | /**
11 | * Step 2.
12 | * A list of table names to retrieve the columns from.
13 | */
14 | var tableInfos: List = emptyList(),
15 | ) : TemplateContext
--------------------------------------------------------------------------------
/exts/ext-database/src/main/kotlin/cc/unitmesh/database/provider/DatabaseMcpToolProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.database.provider
2 |
3 | import cc.unitmesh.database.util.DatabaseSchemaAssistant
4 | import cc.unitmesh.devti.mcp.host.AbstractMcpTool
5 | import cc.unitmesh.devti.mcp.host.NoArgs
6 | import cc.unitmesh.devti.mcp.host.Response
7 | import com.intellij.openapi.project.Project
8 |
9 | class DatabaseMcpToolProvider : AbstractMcpTool() {
10 | override val name: String = "get_current_database_schema"
11 |
12 | override val description: String = """
13 | Get the current database schema which connect in IntelliJ IDEA.
14 | """.trimIndent()
15 |
16 | override fun handle(project: Project, args: NoArgs): Response {
17 | val listSchemas = DatabaseSchemaAssistant.listSchemas(project)
18 | return Response(listSchemas)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/en/migration/gen-entity.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer. Based on following Oracle PL/SQL code to Java entity,
2 | just need to convert the code to Java entity, no need to write any code logic.
3 |
4 | ```${context.lang}
5 | ${context.sql}
6 | ```
7 |
8 |
9 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/en/migration/gen-function.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer.
2 | Based on the following Oracle PL/SQL code to Java function,
3 |
4 | — When some function is missing in Java, just skip it.
5 | - If you find some function is not correct, please fix it.
6 | - Follow the Java coding style.
7 |
8 |
9 | ```${context.lang}
10 | ${context.sql}
11 | ```
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/en/migration/gen-unittest.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer.
2 | Write java unit test code to test the following Oracle PL/SQL code.
3 |
4 | — When some function is missing in Java, just skip it.
5 | - If you find some function is not correct, please fix it.
6 | - Follow the Java coding style.
7 |
8 | ```${context.lang}
9 | ${context.sql}
10 | ```
11 |
12 |
13 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/zh/migration/gen-entity.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer. Based on following Oracle PL/SQL code to Java entity,
2 | just need to convert the code to Java entity, no need to write any code logic.
3 |
4 | ```${context.lang}
5 | ${context.sql}
6 | ```
7 |
8 |
9 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/zh/migration/gen-function.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer.
2 | Based on the following Oracle PL/SQL code to Java function,
3 |
4 | — When some function is missing in Java, just skip it.
5 | - If you find some function is not correct, please fix it.
6 | - Follow the Java coding style.
7 |
8 |
9 | ```${context.lang}
10 | ${context.sql}
11 | ```
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exts/ext-database/src/main/resources/genius/zh/migration/gen-unittest.vm:
--------------------------------------------------------------------------------
1 | You are a professional application migration programmer.
2 | Write java unit test code to test the following Oracle PL/SQL code.
3 |
4 | — When some function is missing in Java, just skip it.
5 | - If you find some function is not correct, please fix it.
6 | - Follow the Java coding style.
7 |
8 | ```${context.lang}
9 | ${context.sql}
10 | ```
11 |
12 |
13 |
--------------------------------------------------------------------------------
/exts/ext-database/src/test/resources/blog.pl.sql:
--------------------------------------------------------------------------------
1 | CREATE OR REPLACE PROCEDURE find_blog_by_id(
2 | p_blog_id IN NUMBER,
3 | p_blog_content OUT VARCHAR2
4 | ) AS
5 | BEGIN
6 | SELECT blog_content
7 | INTO p_blog_content
8 | FROM blogs
9 | WHERE blog_id = p_blog_id;
10 |
11 | EXCEPTION
12 | WHEN NO_DATA_FOUND THEN
13 | p_blog_content := NULL; -- 或者你可以选择处理其他错误
14 | END find_blog_by_id;
15 | /
16 |
--------------------------------------------------------------------------------
/exts/ext-database/src/test/resources/create_blog.sql:
--------------------------------------------------------------------------------
1 | -- sample for create blog
2 | CREATE TABLE `blog`
3 | (
4 | `id` int(11) NOT NULL AUTO_INCREMENT,
5 | `title` varchar(255) DEFAULT NULL,
6 | `content` varchar(255) DEFAULT NULL,
7 | `create_time` datetime DEFAULT NULL,
8 | `update_time` datetime DEFAULT NULL,
9 | PRIMARY KEY (`id`)
10 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
11 |
--------------------------------------------------------------------------------
/exts/ext-dependencies/src/223/main/resources/cc.unitmesh.dependencies.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/exts/ext-endpoints/src/223/main/kotlin/cc/unitmesh/endpoints/provider/EndpointsContextProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.endpoints.provider
2 |
3 | import cc.unitmesh.devti.provider.context.ChatContextItem
4 | import cc.unitmesh.devti.provider.context.ChatContextProvider
5 | import cc.unitmesh.devti.provider.context.ChatCreationContext
6 | import com.intellij.openapi.project.Project
7 |
8 | class EndpointsContextProvider : ChatContextProvider {
9 | override fun isApplicable(project: Project, creationContext: ChatCreationContext): Boolean {
10 | return false
11 | }
12 |
13 | override suspend fun collect(
14 | project: Project,
15 | creationContext: ChatCreationContext
16 | ): List {
17 | return emptyList()
18 | }
19 | }
--------------------------------------------------------------------------------
/exts/ext-endpoints/src/223/main/resources/cc.unitmesh.endpoints.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/exts/ext-endpoints/src/233/main/resources/cc.unitmesh.endpoints.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/exts/ext-http-client/src/223/main/resources/cc.unitmesh.httpclient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/exts/ext-http-client/src/233/main/resources/cc.unitmesh.httpclient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exts/ext-mermaid/src/main/resources/cc.unitmesh.mermaid.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/exts/ext-openrewrite/src/main/resources/cc.unitmesh.openrewrite.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/exts/ext-plantuml/src/main/resources/cc.unitmesh.plantuml.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/exts/ext-terminal/src/223/main/resources/cc.unitmesh.terminal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/ShellSuggestContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.terminal
2 |
3 | import cc.unitmesh.devti.template.context.TemplateContext
4 | import java.text.SimpleDateFormat
5 | import java.util.*
6 |
7 | data class ShellSuggestContext(
8 | val question: String,
9 | val shellPath: String,
10 | val cwd: String,
11 | // today's date like 20240322
12 | val today: String = SimpleDateFormat("yyyyMMdd").format(Date()),
13 | // operating system name
14 | val os: String = System.getProperty("os.name")
15 | ) : TemplateContext
--------------------------------------------------------------------------------
/exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/sketch/TerminalExecutionState.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.terminal.sketch
2 |
3 | /**
4 | * 终端执行命令的状态枚举
5 | */
6 | enum class TerminalExecutionState {
7 | /**
8 | * 准备执行(初始状态)
9 | */
10 | READY,
11 |
12 | /**
13 | * 正在执行中
14 | */
15 | EXECUTING,
16 |
17 | /**
18 | * 执行成功
19 | */
20 | SUCCESS,
21 |
22 | /**
23 | * 执行失败
24 | */
25 | FAILED,
26 |
27 | /**
28 | * 执行被手动终止
29 | */
30 | TERMINATED
31 | }
32 |
--------------------------------------------------------------------------------
/exts/ext-vue/src/223/main/resources/cc.unitmesh.vue.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/exts/ext-vue/src/233/main/resources/cc.unitmesh.vue.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/exts/ext-vue/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/exts/ext-wechat/src/243/main/kotlin/cc/unitmesh/wechat/PlaceHolder.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.wechat
2 |
3 | class PlaceHolder {
4 | }
--------------------------------------------------------------------------------
/exts/ext-wechat/src/243/main/resources/cc.unitmesh.wechat.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/goland/src/main/kotlin/cc/unitmesh/go/context/GoVariableContextBuilder.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.go.context
2 |
3 | import cc.unitmesh.devti.context.VariableContext
4 | import cc.unitmesh.devti.context.builder.VariableContextBuilder
5 | import com.goide.psi.GoVarOrConstDefinition
6 | import com.intellij.psi.PsiElement
7 |
8 | class GoVariableContextBuilder : VariableContextBuilder {
9 | override fun getVariableContext(
10 | psiElement: PsiElement,
11 | withMethodContext: Boolean,
12 | withClassContext: Boolean,
13 | gatherUsages: Boolean
14 | ): VariableContext? {
15 | if (psiElement !is GoVarOrConstDefinition) {
16 | return null
17 | }
18 |
19 | val name = psiElement.name
20 |
21 | return VariableContext(
22 | psiElement, psiElement.text, name, null, null, emptyList(), false, false
23 | )
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/goland/src/main/kotlin/cc/unitmesh/go/indexer/provider/GoLangDictProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.go.indexer.provider
2 |
3 | import cc.unitmesh.devti.indexer.provider.LangDictProvider
4 | import com.goide.GoFileType
5 | import com.intellij.openapi.application.runReadAction
6 | import com.intellij.openapi.project.Project
7 | import com.intellij.psi.search.FileTypeIndex
8 | import com.intellij.psi.search.ProjectScope
9 |
10 | class GoLangDictProvider : LangDictProvider {
11 | override suspend fun collectFileNames(project: Project): List {
12 | val searchScope = ProjectScope.getProjectScope(project)
13 | val javaFiles = runReadAction {
14 | FileTypeIndex.getFiles(GoFileType.INSTANCE, searchScope)
15 | }
16 |
17 | val filenames = javaFiles.mapNotNull {
18 | it.nameWithoutExtension
19 | }
20 |
21 | return filenames
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/goland/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | dokka = "1.9.10"
3 | kotlin = "2.1.20"
4 | changelog = "2.2.1"
5 | gradleIntelliJPlugin = "2.1.0"
6 | qodana = "0.1.13"
7 | kover = "0.7.5"
8 |
9 | chapi = "2.1.2"
10 |
11 | [libraries]
12 |
13 |
14 | [plugins]
15 | changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
16 | dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
17 | gradleIntelliJPlugin = { id = "org.jetbrains.intellij.platform", version.ref = "gradleIntelliJPlugin" }
18 | kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
19 | kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
20 | qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
21 | serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
22 |
23 | [bundles]
24 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unit-mesh/auto-dev/78b9d8c1c7fcf91643cc9753c47ecf3c97e19e54/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/java/src/main/kotlin/cc/unitmesh/idea/MvcUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.idea
2 |
3 | object MvcUtil {
4 | fun isController(fileName: String, lang: String): Boolean {
5 | return fileName.endsWith("Controller.${lang.lowercase()}")
6 | }
7 |
8 | fun isService(fileName: String, lang: String) =
9 | fileName.endsWith("Service.$${lang.lowercase()}") || fileName.endsWith("ServiceImpl.$${lang.lowercase()}")
10 |
11 | fun isRepository(fileName: String, lang: String) =
12 | fileName.endsWith("Repository.$${lang.lowercase()}") || fileName.endsWith("Repo.$${lang.lowercase()}")
13 | }
14 |
--------------------------------------------------------------------------------
/java/src/main/kotlin/cc/unitmesh/idea/flow/ControllerContext.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.idea.flow
2 |
3 | import com.intellij.psi.PsiClass
4 |
5 | data class ControllerContext(
6 | val services: List,
7 | val models: List,
8 | val repository: List = listOf(),
9 | )
--------------------------------------------------------------------------------
/java/src/main/kotlin/cc/unitmesh/idea/flow/JavaParseUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.idea.flow
2 |
3 | object JavaParseUtil {
4 | // split java code string to multiple class string
5 | // like: public class A {} public class B {} => [public class A {}, public class B {}]
6 | fun splitClass(code: String): List {
7 | val classes = mutableListOf()
8 | var classStart = 0
9 | var braceCount = 0
10 |
11 | for (i in code.indices) {
12 | if (code[i] == '{') {
13 | braceCount++
14 | } else if (code[i] == '}') {
15 | braceCount--
16 | }
17 |
18 | if (braceCount == 0 && code[i] == '}') {
19 | classes.add(code.substring(classStart, i + 1))
20 | classStart = i + 1
21 | }
22 | }
23 |
24 | return classes
25 | }
26 | }
--------------------------------------------------------------------------------
/java/src/main/kotlin/cc/unitmesh/idea/observer/GradleTaskAgentObserver.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.idea.observer
2 |
3 | import cc.unitmesh.devti.provider.observer.AgentObserver
4 | import com.intellij.openapi.project.Project
5 |
6 |
7 | class GradleTaskAgentObserver : AgentObserver {
8 | override fun onRegister(project: Project) {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/java/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/javascript/src/223/main/kotlin/cc/unitmesh/ide/javascript/util/JsUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.ide.javascript.util
2 |
3 | import com.intellij.psi.PsiFile
4 |
5 | object JsUtil {
6 | fun guessTestFrameworkName(file: PsiFile): String? {
7 | return null
8 | }
9 | }
--------------------------------------------------------------------------------
/javascript/src/233/main/kotlin/cc/unitmesh/ide/javascript/util/JsUtil.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.ide.javascript.util
2 |
3 | import com.intellij.javascript.testing.JSTestRunnerManager
4 | import com.intellij.openapi.application.runReadAction
5 | import com.intellij.psi.PsiFile
6 |
7 | object JsUtil {
8 | fun guessTestFrameworkName(file: PsiFile): String? {
9 | val findPackageDependentProducers =
10 | runReadAction { JSTestRunnerManager.getInstance().findPackageDependentProducers(file) }
11 |
12 | val testRunConfigurationProducer = findPackageDependentProducers.firstOrNull()
13 | return testRunConfigurationProducer?.configurationType?.displayName
14 | }
15 | }
--------------------------------------------------------------------------------
/javascript/src/main/kotlin/cc/unitmesh/ide/javascript/provider/testing/JestCodeModifier.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.ide.javascript.provider.testing
2 |
3 | import cc.unitmesh.ide.javascript.util.LanguageApplicableUtil
4 | import com.intellij.lang.Language
5 |
6 | class JestCodeModifier : JavaScriptTestCodeModifier() {
7 | override fun isApplicable(language: Language): Boolean {
8 | return LanguageApplicableUtil.isJavaScriptApplicable(language)
9 | }
10 | }
--------------------------------------------------------------------------------
/javascript/src/test/resources/ts/Sample.tsx:
--------------------------------------------------------------------------------
1 | class MyDocument {
2 | render() {
3 | return (
4 |
5 | );
6 | }
7 | }
8 |
9 | export default MyDocument;
--------------------------------------------------------------------------------
/kotlin/src/main/kotlin/cc/unitmesh/kotlin/provider/KotlinContextPrompter.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.kotlin.provider
2 |
3 | import cc.unitmesh.idea.prompting.JavaContextPrompter
4 |
5 | class KotlinContextPrompter: JavaContextPrompter() {
6 | override val psiElementDataBuilder = KotlinPsiElementDataBuilder()
7 | }
--------------------------------------------------------------------------------
/kotlin/src/main/kotlin/cc/unitmesh/kotlin/provider/KotlinCustomPromptProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.kotlin.provider
2 |
3 | import cc.unitmesh.idea.provider.JavaCustomPromptProvider
4 |
5 | class KotlinCustomPromptProvider : JavaCustomPromptProvider() {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/pycharm/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rust/src/main/kotlin/cc/unitmesh/rust/indexer/provider/RustLangDictProvider.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.rust.indexer.provider
2 |
3 | import cc.unitmesh.devti.indexer.provider.LangDictProvider
4 | import com.intellij.openapi.application.runReadAction
5 | import com.intellij.openapi.project.Project
6 | import com.intellij.psi.search.FileTypeIndex
7 | import com.intellij.psi.search.ProjectScope
8 | import org.rust.lang.RsFileType
9 |
10 | class RustLangDictProvider : LangDictProvider {
11 | override suspend fun collectFileNames(project: Project): List {
12 | val searchScope = ProjectScope.getProjectScope(project)
13 | val javaFiles = runReadAction {
14 | FileTypeIndex.getFiles(RsFileType, searchScope)
15 | }
16 |
17 | val filenames = javaFiles.mapNotNull {
18 | it.nameWithoutExtension
19 | }
20 |
21 | return filenames
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/rust/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | cc.unitmesh.devti
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "AutoDev-Intellij"
2 |
3 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
4 |
5 | include("core");
6 |
7 | include(
8 | "pycharm",
9 | "java",
10 | "kotlin",
11 | "javascript",
12 | "goland",
13 | "rust",
14 | )
15 |
16 | include(
17 | "exts:ext-database",
18 | "exts:ext-terminal",
19 | // git4idea is the git plugin for IntelliJ IDEA, so we rename it to `exts-git`
20 | "exts:ext-git",
21 | // for http test
22 | "exts:ext-http-client",
23 | "exts:ext-plantuml",
24 | "exts:ext-mermaid",
25 | "exts:ext-endpoints",
26 | "exts:ext-vue",
27 | "exts:ext-dependencies",
28 | "exts:ext-container",
29 | "exts:ext-openrewrite",
30 | "exts:ext-wechat",
31 |
32 | // the Input Language support for AutoDev
33 | "exts:devins-lang"
34 | )
35 |
--------------------------------------------------------------------------------
/src/description.html:
--------------------------------------------------------------------------------
1 | Github | Issues.
2 |
3 |
4 | 🧙AutoDev: The AI-powered coding wizard with multilingual support 🌐, auto code generation 🏗️, and a helpful bug-slaying
5 | assistant 🐞! Customizable prompts 🎨 and a magic Auto Testing feature 🧪 included! 🚀
6 |
--------------------------------------------------------------------------------
/src/main/kotlin/cc/unitmesh/devti/Placeholder.kt:
--------------------------------------------------------------------------------
1 | package cc.unitmesh.devti
2 |
3 | /// Intellij Gradle Plugin required for not empty package
4 | class Placeholder {
5 | }
--------------------------------------------------------------------------------