Skip to content

Commit 5f10d32

Browse files
committed
feat(devti): enhance auto-sketch mode with additional commands
- Update AutoSketchMode to support more built-in commands - Add new commands to AUTOABLE_COMMANDS set for auto-sketch functionality - Improve code readability and formatting in BuiltinCommand and AutoSketchMode files
1 parent 4554727 commit 5f10d32

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

core/src/main/kotlin/cc/unitmesh/devti/devin/dataprovider/BuiltinCommand.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum class BuiltinCommand(
1717
val hasCompletion: Boolean = false,
1818
val requireProps: Boolean = false,
1919
val enableInSketch: Boolean = true
20-
): Tool {
20+
) : Tool {
2121
FILE("file", "Read the content of a file by project relative path", AllIcons.Actions.Copy, true, true),
2222
REV(
2323
"rev",
@@ -55,7 +55,14 @@ enum class BuiltinCommand(
5555
AllIcons.Vcs.Patch_file,
5656
false
5757
),
58-
RUN("run", "Run the IDE's built-in command, like build tool, test.", AllIcons.Actions.Execute, true, true, enableInSketch = false),
58+
RUN(
59+
"run",
60+
"Run the IDE's built-in command, like build tool, test.",
61+
AllIcons.Actions.Execute,
62+
true,
63+
true,
64+
enableInSketch = false
65+
),
5966
SHELL(
6067
"shell",
6168
"Execute a shell command and collect (ProcessBuild) the result",
@@ -173,8 +180,5 @@ enum class BuiltinCommand(
173180
it.funcNames()
174181
}.flatten()
175182
}
176-
177-
val READ_COMMANDS =
178-
setOf(DIR, LOCAL_SEARCH, FILE, REV, STRUCTURE, SYMBOL, DATABASE, RELATED, RIPGREP_SEARCH, BROWSE)
179183
}
180184
}

core/src/main/kotlin/cc/unitmesh/devti/sketch/AutoSketchMode.kt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
package cc.unitmesh.devti.sketch
22

33
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand
4+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.BROWSE
5+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.DATABASE
6+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.DIR
7+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.FILE
8+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.LOCAL_SEARCH
9+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.PATCH
10+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.RELATED
11+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.REV
12+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.RIPGREP_SEARCH
13+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.STRUCTURE
14+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.SYMBOL
15+
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand.WRITE
416
import cc.unitmesh.devti.observer.agent.AgentStateService
517
import cc.unitmesh.devti.provider.devins.LanguageProcessor
618
import cc.unitmesh.devti.provider.toolchain.ToolchainFunctionProvider
@@ -63,10 +75,26 @@ class AutoSketchMode(val project: Project) {
6375
listener?.manualSend(text)
6476
}
6577

66-
private fun hasReadCommand(fence: CodeFence): Boolean = BuiltinCommand.READ_COMMANDS.any { command ->
78+
private fun hasReadCommand(fence: CodeFence): Boolean = AUTOABLE_COMMANDS.any { command ->
6779
fence.text.contains("/" + command.commandName + ":")
6880
}
6981

82+
val AUTOABLE_COMMANDS =
83+
setOf(
84+
DIR,
85+
LOCAL_SEARCH,
86+
FILE,
87+
REV,
88+
STRUCTURE,
89+
SYMBOL,
90+
DATABASE, // should be handle in run sql
91+
RELATED,
92+
RIPGREP_SEARCH,
93+
BROWSE,
94+
PATCH,
95+
WRITE
96+
)
97+
7098
private fun hasToolchainFunctionCommand(fence: CodeFence): Boolean {
7199
val toolchainCmds = ToolchainFunctionProvider.all().map { it.funcNames() }.flatten()
72100
return toolchainCmds.any {

0 commit comments

Comments
 (0)