Skip to content

Commit 5d35874

Browse files
authored
1.8.2 (#196)
* 1.8.2 * 1.8.2 * 1.8.2 * 1.8.2
1 parent 4ea41d1 commit 5d35874

File tree

16 files changed

+315
-438
lines changed

16 files changed

+315
-438
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repositories {
2828

2929
val jetty_version = "11.0.24"
3030
val slf4j_version = "2.0.16"
31-
val skyenet_version = "1.2.13"
31+
val skyenet_version = "1.2.14"
3232
val remoterobot_version = "0.11.23"
3333
val jackson_version = "2.17.2"
3434

@@ -43,7 +43,7 @@ dependencies {
4343
implementation("com.googlecode.java-diff-utils:diffutils:1.3.0")
4444
implementation(group = "org.apache.httpcomponents.client5", name = "httpclient5", version = "5.2.3")
4545

46-
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.10")
46+
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.1.11")
4747
implementation(group = "com.simiacryptus.skyenet", name = "kotlin", version = skyenet_version)
4848
implementation(group = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
4949
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pluginName=intellij-aicoder
22
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
3-
pluginVersion=1.8.1
3+
pluginVersion=1.8.2
44
jvmArgs=-Xmx8g
55
org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1g
66
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/AutoPlanChatAction.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ class AutoPlanChatAction : BaseAction() {
3737
),
3838
temperature = AppSettingsState.instance.temperature,
3939
workingDir = UITools.getSelectedFolder(e)?.toFile?.absolutePath ?: "",
40-
env = mapOf()
40+
env = mapOf(),
41+
githubToken = AppSettingsState.instance.githubToken,
42+
googleApiKey = AppSettingsState.instance.googleApiKey,
43+
googleSearchEngineId = AppSettingsState.instance.googleSearchEngineId,
4144
)
4245
)
4346
if (dialog.showAndGet()) {

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/MassPatchAction.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import com.simiacryptus.skyenet.webui.application.AppInfoData
3232
import com.simiacryptus.skyenet.webui.application.ApplicationServer
3333
import com.simiacryptus.skyenet.webui.application.ApplicationSocketManager
3434
import com.simiacryptus.skyenet.webui.session.SocketManager
35-
import com.simiacryptus.skyenet.webui.session.SocketManagerBase
3635
import java.awt.BorderLayout
3736
import java.awt.Dimension
3837
import java.nio.file.Files
@@ -47,6 +46,7 @@ import javax.swing.JComboBox
4746
import javax.swing.JComponent
4847
import javax.swing.JLabel
4948
import javax.swing.JPanel
49+
import javax.swing.JCheckBox
5050

5151
class MassPatchAction : BaseAction() {
5252
override fun getActionUpdateThread() = ActionUpdateThread.BGT
@@ -64,17 +64,20 @@ class MassPatchAction : BaseAction() {
6464

6565
@Name("Recent Instructions")
6666
val recentInstructions = JComboBox<String>()
67+
@Name("Auto Apply")
68+
val autoApply = JCheckBox("Auto Apply Changes")
6769

6870
}
6971

7072
class UserSettings(
7173
var transformationMessage: String = "Review, fix, and improve",
7274
var filesToProcess: List<Path> = listOf(),
75+
var autoApply: Boolean = false,
7376
)
7477

7578
class Settings(
7679
val settings: UserSettings? = null,
77-
val project: Project? = null
80+
val project: Project? = null,
7881
)
7982

8083
fun getConfig(project: Project?, e: AnActionEvent): Settings? {
@@ -89,6 +92,7 @@ class MassPatchAction : BaseAction() {
8992
files.forEach { path ->
9093
filesToProcess.setItemSelected(path, true)
9194
}
95+
autoApply.isSelected = false
9296
}
9397
val mruPatchInstructions = AppSettingsState.instance.getRecentCommands("PatchInstructions")
9498
settingsUI.recentInstructions.model = DefaultComboBoxModel(
@@ -121,6 +125,7 @@ class MassPatchAction : BaseAction() {
121125
val config = getConfig(project, e)
122126

123127
val session = Session.newGlobalID()
128+
SessionProxyServer.chats[session] = MassPatchServer(config=config!!, api=api, autoApply = config.settings?.autoApply ?: false)
124129
ApplicationServer.appInfoMap[session] = AppInfoData(
125130
applicationName = "Code Chat",
126131
singleInput = true,
@@ -150,6 +155,7 @@ class MassPatchAction : BaseAction() {
150155
this.title = title
151156
// Set the default values for the UI elements from userSettings
152157
settingsUI.transformationMessage.text = userSettings.transformationMessage
158+
settingsUI.autoApply.isSelected = userSettings.autoApply
153159
init()
154160
}
155161

@@ -168,6 +174,8 @@ class MassPatchAction : BaseAction() {
168174
add(Box.createVerticalStrut(10))
169175
add(JLabel("AI Instruction"))
170176
add(settingsUI.transformationMessage)
177+
add(Box.createVerticalStrut(10))
178+
add(settingsUI.autoApply)
171179
}
172180
add(optionsPanel, BorderLayout.SOUTH)
173181
}
@@ -179,13 +187,15 @@ class MassPatchAction : BaseAction() {
179187
userSettings.transformationMessage = settingsUI.transformationMessage.text
180188
userSettings.filesToProcess =
181189
settingsUI.filesToProcess.items.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }
190+
userSettings.autoApply = settingsUI.autoApply.isSelected
182191
}
183192
}
184193
}
185194

186195
class MassPatchServer(
187196
val config: Settings,
188-
val api: ChatClient
197+
val api: ChatClient,
198+
val autoApply: Boolean
189199
) : ApplicationServer(
190200
applicationName = "Multi-file Patch Chat",
191201
path = "/patchChat",
@@ -286,17 +296,18 @@ class MassPatchServer(
286296
mainActor.answer(toInput(it), api = api)
287297
},
288298
outputFn = { design: String ->
289-
var markdown = (ui as SocketManagerBase).addApplyFileDiffLinks(
290-
root = _root as Path,
291-
response = design as String,
299+
var markdown = ui.socketManager?.addApplyFileDiffLinks(
300+
root = _root,
301+
response = design,
292302
handle = { newCodeMap: Map<Path, String> ->
293303
newCodeMap.forEach { (path, newCode) ->
294304
fileTask.complete("<a href='${"fileIndex/$session/$path"}'>$path</a> Updated")
295305
}
296-
} as (Map<Path, String>) -> Unit,
306+
},
297307
ui = ui,
298308
api = api as API,
299-
shouldAutoApply = { true } as (Path) -> Boolean,
309+
shouldAutoApply = { autoApply },
310+
model = AppSettingsState.instance.fastModel.chatModel(),
300311
)
301312
"""<div>${renderMarkdown(markdown!!)}</div>"""
302313
},
@@ -318,12 +329,11 @@ class MassPatchServer(
318329
}
319330
}
320331
}, 10, java.util.concurrent.TimeUnit.MILLISECONDS)
321-
322332
}
323333
return socketManager
324334
}
325335

326336
companion object {
327337
val log = org.slf4j.LoggerFactory.getLogger(MassPatchServer::class.java)
328338
}
329-
}
339+
}

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanAheadAction.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class PlanAheadAction : BaseAction() {
3535
),
3636
temperature = AppSettingsState.instance.temperature,
3737
workingDir = UITools.getSelectedFolder(e)?.toFile?.absolutePath ?: "",
38-
env = mapOf()
38+
env = mapOf(),
39+
githubToken = AppSettingsState.instance.githubToken,
40+
googleApiKey = AppSettingsState.instance.googleApiKey,
41+
googleSearchEngineId = AppSettingsState.instance.googleSearchEngineId,
3942
)
4043
)
4144
if (dialog.showAndGet()) {

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PlanChatAction.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class PlanChatAction : BaseAction() {
3333
),
3434
temperature = AppSettingsState.instance.temperature,
3535
workingDir = UITools.getSelectedFolder(e)?.toFile?.absolutePath ?: "",
36-
env = mapOf()
36+
env = mapOf(),
37+
githubToken = AppSettingsState.instance.githubToken,
38+
googleApiKey = AppSettingsState.instance.googleApiKey,
39+
googleSearchEngineId = AppSettingsState.instance.googleSearchEngineId,
3740
)
3841
)
3942
if (dialog.showAndGet()) {

src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/PrePlanAction.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class PrePlanAction : BaseAction() {
6464
workingDir = root.absolutePath,
6565
env = mapOf(),
6666
language = if (isWindows) "powershell" else "bash",
67+
githubToken = AppSettingsState.instance.githubToken,
68+
googleApiKey = AppSettingsState.instance.googleApiKey,
69+
googleSearchEngineId = AppSettingsState.instance.googleSearchEngineId,
6770
)
6871
planSettings = PlanAheadConfigDialog(e.project, planSettings).let {
6972
if (!it.showAndGet()) throw RuntimeException("User cancelled")

src/main/kotlin/com/github/simiacryptus/aicoder/config/AppSettingsComponent.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ import javax.swing.table.DefaultTableCellRenderer
3232
import javax.swing.table.DefaultTableModel
3333

3434
class AppSettingsComponent : com.intellij.openapi.Disposable {
35+
@Suppress("unused")
36+
@Name("GitHub Token")
37+
val githubToken = JBTextField().apply {
38+
toolTipText = "GitHub Personal Access Token"
39+
columns = 30
40+
}
41+
@Suppress("unused")
42+
@Name("Google API Key")
43+
val googleApiKey = JBTextField().apply {
44+
toolTipText = "Google API Key"
45+
columns = 30
46+
}
47+
@Suppress("unused")
48+
@Name("Google Search Engine ID")
49+
val googleSearchEngineId = JBTextField().apply {
50+
toolTipText = "Google Search Engine ID"
51+
columns = 30
52+
}
3553
@Suppress("unused")
3654
@Name("Store Metadata")
3755
val storeMetadata = JTextArea().apply {
@@ -268,6 +286,10 @@ class AppSettingsComponent : com.intellij.openapi.Disposable {
268286
}
269287

270288
init {
289+
// Initialize new fields
290+
githubToken.text = AppSettingsState.instance.githubToken ?: ""
291+
googleApiKey.text = AppSettingsState.instance.googleApiKey ?: ""
292+
googleSearchEngineId.text = AppSettingsState.instance.googleSearchEngineId ?: ""
271293
// Initialize executables list
272294
setExecutables(AppSettingsState.instance.executables)
273295
fun getExecutables(): Set<String> {

src/main/kotlin/com/github/simiacryptus/aicoder/config/AppSettingsState.kt

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ data class AppSettingsState(
5858
var executables: MutableSet<String> = mutableSetOf(),
5959
var recentArguments: MutableList<String> = mutableListOf(),
6060
val recentCommands: MutableMap<String, MRUItems> = mutableMapOf<String, MRUItems>(),
61-
var userSuppliedModels: MutableList<UserSuppliedModel> = mutableListOf()
61+
var userSuppliedModels: MutableList<UserSuppliedModel> = mutableListOf(),
62+
var githubToken: String? = null,
63+
var googleApiKey: String? = null,
64+
var googleSearchEngineId: String? = null
6265
) : PersistentStateComponent<SimpleEnvelope> {
6366
private var onSettingsLoadedListeners = mutableListOf<() -> Unit>()
6467

@@ -122,6 +125,9 @@ data class AppSettingsState(
122125
if (executables != other.executables) return false
123126
//userSuppliedModels
124127
if (userSuppliedModels.toTypedArray().contentDeepEquals(other.userSuppliedModels.toTypedArray()).not()) return false
128+
if (googleApiKey != other.googleApiKey) return false
129+
if (googleSearchEngineId != other.googleSearchEngineId) return false
130+
if (githubToken != other.githubToken) return false
125131
return true
126132
}
127133

@@ -151,16 +157,13 @@ data class AppSettingsState(
151157
result = 31 * result + enableLegacyActions.hashCode()
152158
result = 31 * result + executables.hashCode()
153159
result = 31 * result + userSuppliedModels.hashCode()
160+
result = 31 * result + (googleApiKey?.hashCode() ?: 0)
161+
result = 31 * result + (googleSearchEngineId?.hashCode() ?: 0)
162+
result = 31 * result + (githubToken?.hashCode() ?: 0)
154163
return result
155164
}
156165

157166
companion object {
158-
/**
159-
* Gets the instance of AppSettingsState for the current project.
160-
*
161-
* @return The AppSettingsState instance.
162-
*/
163-
164167
val log = LoggerFactory.getLogger(AppSettingsState::class.java)
165168
var auxiliaryLog: File? = null
166169
const val WELCOME_VERSION: String = "1.5.0"
@@ -184,27 +187,5 @@ data class AppSettingsState(
184187
var modelId: String = "",
185188
var provider: APIProvider = APIProvider.OpenAI
186189
)
187-
/**
188-
* The API key used for authentication with the AI service.
189-
*/
190-
/**
191-
* The selected AI model to be used for code generation and analysis.
192-
*/
193-
/**
194-
* The temperature setting for AI responses (0.0 to 1.0).
195-
*/
196-
/**
197-
* The maximum number of tokens to be used in AI requests.
198-
*/
199-
/**
200-
* Gets the instance of AppSettingsState.
201-
*
202-
* @return The current instance of AppSettingsState.
203-
*/
204-
/**
205-
* Loads the state from the given state object.
206-
*
207-
* @param state The state object to load from.
208-
*/
209190
var analyticsEnabled: Boolean = false
210191
}

0 commit comments

Comments
 (0)