Skip to content

Commit

Permalink
1.5.9 (#171)
Browse files Browse the repository at this point in the history
* 1.5.9

* wip

* Update build.gradle.kts

* Update settings.gradle.kts

* autofix

* Update CommandAutofixAction.kt

* autofix

* wip
  • Loading branch information
acharneski authored Jun 17, 2024
1 parent 910d5a2 commit 3d846d7
Show file tree
Hide file tree
Showing 11 changed files with 1,345 additions and 114 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
val kotlin_version = "2.0.0-Beta5"
val jetty_version = "11.0.18"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.75"
val skyenet_version = "1.0.77"
val remoterobot_version = "0.11.21"
val jackson_version = "2.17.0"

Expand All @@ -42,7 +42,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin", module = "")
}

implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.60")
implementation(group = "com.simiacryptus", name = "jo-penai", version = "1.0.61")
{
exclude(group = "org.jetbrains.kotlin", module = "")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginName=intellij-aicoder
pluginRepositoryUrl=https://github.com/SimiaCryptus/intellij-aicoder
pluginVersion=1.5.8
pluginVersion=1.5.9

jvmArgs=-Xmx8g
org.gradle.jvmargs=-Xmx8g
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ import java.nio.file.Path
import java.util.concurrent.Executors
import java.util.concurrent.Future
import java.util.concurrent.TimeUnit
import javax.swing.BoxLayout
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.*


class GenerateDocumentationAction : FileContextAction<GenerateDocumentationAction.Settings>() {
Expand All @@ -43,6 +40,9 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
}

class SettingsUI {
@Name("Single Output File")
val singleOutputFile = JCheckBox("Produce a single output file", true)

@Name("Files to Process")
val filesToProcess = CheckBoxList<Path>()

Expand All @@ -57,6 +57,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
var transformationMessage: String = "Create user documentation",
var outputFilename: String = "compiled_documentation.md",
var filesToProcess: List<Path> = listOf(),
var singleOutputFile: Boolean = true
)

class Settings(
Expand All @@ -79,8 +80,9 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
}
val dialog = DocumentationCompilerDialog(project, settingsUI)
dialog.show()
val result = dialog.isOK
val settings: UserSettings = dialog.userSettings
settings.singleOutputFile = settingsUI.singleOutputFile.isSelected
val result = dialog.isOK
settings.filesToProcess = when {
result -> files.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }.toList()
else -> listOf()
Expand Down Expand Up @@ -116,22 +118,32 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
val fileContent =
IOUtils.toString(FileInputStream(path.toFile()), "UTF-8") ?: return@submit null
val transformContent = transformContent(fileContent, transformationMessage)
markdownContent.append("# ${root.relativize(path)}\n\n")
markdownContent.append(transformContent.replace("(?s)(?<![^\\n])#".toRegex(), "\n##"))
markdownContent.append("\n\n")
if (config?.settings?.singleOutputFile == true) {
markdownContent.append("# ${root.relativize(path)}\n\n")
markdownContent.append(transformContent.replace("(?s)(?<![^\\n])#".toRegex(), "\n##"))
} else {
root.relativize(path).let { it.parent.resolve(it.fileName.toString().split('.').dropLast(1).joinToString(".") + "_" + outputPath.fileName) }
val individualOutputPath = root.resolve("${root.relativize(path)}.md")
Files.write(individualOutputPath, transformContent.toByteArray())
}
path
}
}.toTypedArray().map { future ->
try {
future.get() ?: return@map null
future.get()
} catch (e: Exception) {
log.warn("Error processing file", e)
return@map null
}
}.filterNotNull()
Files.write(outputPath, markdownContent.toString().toByteArray())
open(config?.project!!, outputPath)
return arrayOf(outputPath.toFile())
if (config?.settings?.singleOutputFile == true) {
Files.write(outputPath, markdownContent.toString().toByteArray())
open(config?.project!!, outputPath)
return arrayOf(outputPath.toFile())
} else {
open(config?.project!!, outputPath)
return pathList.toList().map { it.toFile() }.toTypedArray()
}
} finally {
executorService.shutdown()
}
Expand Down Expand Up @@ -199,7 +211,6 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
val filesScrollPane = JBScrollPane(settingsUI.filesToProcess).apply {
preferredSize = Dimension(400, 300) // Adjust the preferred size as needed
}
add(JLabel("Files to Process"), BorderLayout.NORTH)
add(filesScrollPane, BorderLayout.CENTER) // Make the files list the dominant element

val optionsPanel = JPanel().apply {
Expand All @@ -208,6 +219,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
add(settingsUI.transformationMessage)
add(JLabel("Output File"))
add(settingsUI.outputFilename)
add(settingsUI.singleOutputFile)
}
add(optionsPanel, BorderLayout.SOUTH)
}
Expand All @@ -222,6 +234,7 @@ class GenerateDocumentationAction : FileContextAction<GenerateDocumentationActio
// userSettings.filesToProcess = settingsUI.filesToProcess.selectedValuesList
userSettings.filesToProcess =
settingsUI.filesToProcess.items.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }
userSettings.singleOutputFile = settingsUI.singleOutputFile.isSelected
}
}
}
Expand All @@ -233,4 +246,4 @@ val <T> CheckBoxList<T>.items: List<T>
items.add(getItemAt(i)!!)
}
return items
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ class MultiDiffChatAction : BaseAction() {
) {
override val singleInput = false
override val stickyInput = true
private val mainActor: SimpleActor
get() = SimpleActor(
override fun userMessage(
session: Session,
user: User?,
userMessage: String,
ui: ApplicationInterface,
api: API
) {
val mainActor = SimpleActor(
prompt = """
|You are a helpful AI that helps people with coding.
|
Expand Down Expand Up @@ -138,13 +144,6 @@ class MultiDiffChatAction : BaseAction() {
model = AppSettingsState.instance.defaultSmartModel()
)

override fun userMessage(
session: Session,
user: User?,
userMessage: String,
ui: ApplicationInterface,
api: API
) {
val settings = getSettings(session, user) ?: Settings()
if (api is ClientManager.MonitoredClient) api.budget = settings.budget ?: 2.00

Expand Down
Loading

0 comments on commit 3d846d7

Please sign in to comment.