Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade it to latest intellij version #36

Merged
merged 66 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
dfdae3d
:sparkles: Add chat box so we can continue conversations, this featur…
Jul 26, 2023
bf338d3
:sparkles: Add chat box so we can continue conversations, this featur…
Jul 26, 2023
319411e
:sparkles: Add chat box so we can continue conversations, this featur…
Jul 26, 2023
2877915
:sparkles: Add chat box so we can continue conversations, this featur…
Jul 26, 2023
16202e0
:sparkles: Add proper chat window
Jul 27, 2023
c687003
:sparkles: Remove border
Jul 27, 2023
46cc004
:sparkles: Add promp npl analysis and remove vowels to save chars
Jul 27, 2023
acc10d5
:sparkles: Add proper spacing
Jul 27, 2023
f8ccf48
:sparkles: Add empty button
Jul 27, 2023
1cd9d4f
:sparkles: Add comment
Jul 27, 2023
b8e9bef
:sparkles: Add empty button
Jul 27, 2023
338bec7
:sparkles: Add pitfall
Jul 27, 2023
0dd3f2a
:bug: Broken chat message
Jul 27, 2023
0ad35a7
:bug: Add another test
Jul 27, 2023
621e126
:sparkles: Add proper spacing
Jul 27, 2023
8d0b099
:bug: Broken chat message
Jul 27, 2023
5ca269c
:sparkles: Add empty button
Jul 27, 2023
9cc557b
:bug: showing wrong info
Jul 27, 2023
610b521
:bug: indentation
Jul 27, 2023
ae95af8
:sparkle: Add history clickable chat textare with jlist
Jul 27, 2023
ae866b2
:sparkle: Add history clickable chat textare with jlist
Jul 27, 2023
d02aa6f
:bug: Add correct logic for cell height dynamically calculated
Jul 28, 2023
49e6f26
:bug: Improve system message for follow up question
Jul 28, 2023
41f697c
:bug: Correct padding and dimension
Jul 28, 2023
174cedd
:sparkles: Add follow up logic
Jul 28, 2023
4e69e26
:sparkles: Add follow up logic
Jul 28, 2023
ad8df76
:bug: remove deprecation
Jul 28, 2023
892c23e
:bug: remove deprecation
Jul 28, 2023
3bc637c
:sparkles: W.I.P add actions timeline to keep track of the actions do…
Jul 29, 2023
cde1d13
:sparkles: W.I.P add actions timeline to keep track of the actions do…
Jul 29, 2023
d14b9b3
:sparkles: W.I.P add actions timeline to keep track of the actions do…
Jul 29, 2023
7aedcf5
:sparkles: W.I.P add actions timeline to keep track of the actions do…
Jul 29, 2023
fc176de
:sparkles: W.I.P add actions timeline to keep track of the actions do…
Jul 29, 2023
488b46e
:sparkles: Fix bug always using same tabName
Jul 29, 2023
16ccaff
:sparkles: Fix bug always using same tabName
Jul 29, 2023
2df3507
:bug: fix getPrompts, now it returns the tab structure correctly
Jul 30, 2023
8fa0cb9
:bug: Moved timeline to the proper place
Jul 30, 2023
646e8f3
:bug: Timeline almost working
Jul 30, 2023
b3b4e24
:bug: broken run action
Jul 30, 2023
79daab0
:bug: For selecting current tam for run prompt action
Jul 30, 2023
d751312
:bug: Add counter to "No File" tab and chat window finally adding mes…
Jul 30, 2023
edad0e0
:bug: Invert labels in pipeline
Jul 30, 2023
64c069d
:bug: add pop up on chat
Jul 30, 2023
4eb6e04
:bug: hopefully avoided problem with popups freezing the intellij ui
Jul 30, 2023
ff99bbe
:sparkles: add double click
Jul 30, 2023
dfffaac
:sparkles: add POC of replay mechanism
Jul 30, 2023
6ea68ee
:sparkles: Timeline working almost
Aug 2, 2023
0b0a87d
:fire: Removing timeline since it's way too difficult and it gives ve…
Aug 3, 2023
50ce61a
:bug: Fix bug with prompt length and not controlling errors from http…
Aug 3, 2023
885e4c7
:bug: Missing b2b_rates for b2c
Sep 1, 2023
b6ddf7d
:bug: Fix run all prompts apparently
sloppylopez Nov 26, 2024
ca2df3b
:bug: Fix incompatibility problems with intellij plugin
sloppylopez Nov 27, 2024
baf2c21
:bug: Fix incompatibility problems with intellij plugin
sloppylopez Nov 27, 2024
31c8f27
:bug: Fix incompatibility problems with intellij plugin, remove tests
sloppylopez Nov 27, 2024
649e63f
:bug: Fix incompatibility problems with intellij plugin, remove tests
sloppylopez Nov 27, 2024
17e5402
:bug: Fix incompatibility problems with intellij plugin, remove tests
sloppylopez Nov 27, 2024
c2d2e38
:alembic: Fix memory leak,
sloppylopez Nov 27, 2024
e503a6b
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
a6b26b8
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
6dbd137
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
0b7ad8f
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
e8612e0
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
c831115
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
95ed57e
:alembic: Fix memory leaks
sloppylopez Nov 27, 2024
1f92e00
:alembic: Fix bug with DRy selection
sloppylopez Nov 28, 2024
19aada3
:alembic: Fix bug with not selecting all code in editors
sloppylopez Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
// kotlin("plugin.serialization") version "1.6.0" // Kotlin Serialization support
}

group = properties("pluginGroup").get()
Expand All @@ -25,12 +26,15 @@ repositories {
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0-M1")
testImplementation("org.mockito:mockito-core:5.4.0")
testImplementation("junit:junit:4.13.2")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.0")
implementation("com.google.api:gax:2.31.0")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.1")
implementation("org.jetbrains:annotations:23.0.0")
// implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0")
// implementation("org.openjfx:javafx:11")
}

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
Expand Down
22 changes: 21 additions & 1 deletion docs/PITFALLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,24 @@
</tbody>
</table>
<p class="notion-text notion-block-5649da35ca0f43e3bf40151f26a16966"><em>Last updated March 11th, 2023
from </em><em><a class="notion-link" href="https://openai.com/pricing">openai.com/pricing</a></em></p></section>
from </em><em><a class="notion-link" href="https://openai.com/pricing">openai.com/pricing</a></em></p></section>

5) I prefix each new Prompt with this phrase : analyse the Prompt and using NLP return topic, context, intent, named
entities, keywords and sentiment ending each sentence with a full stop and then respond to the Follow Up question.

It results in useful NLP analysis of the Response and creates a virtuous circle with the next Prompt. An example of such
an analysis was: Topic: Heinrich Schliemann and Homer’s Iliad and Odyssey: Context: Excavation at Hissarlik: Intent: To
search for and verify the historical accuracy of Homer’s descriptions of the cities: Named Entities: Heinrich
Schliemann, Hissarlik, Homer’s Iliad and Odyssey: Keywords: Excavate, verify, historical accuracy, Homer’s descriptions,
cities: Sentiment: Neutral

The period symbol ‘.’ helps separate discreet elements of the response. It is also good practise to terminate prompts
with characters such as ‘?.!’ which helps GPT recognise questions, sentences and exclamations.

![img.png](img.png)

6) How to debug
A) From main IDE run config 'runIde'
B) From second IDE run 'Attach to process'
C) Breaking points go on FIRST IDE
D) Profit :)
Binary file added docs/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 10 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = com.github.sloppylopez.moneypennyideaplugin
pluginName = moneypenny-idea-plugin
pluginRepositoryUrl = https://github.com/sloppylopez/moneypenny-idea-plugin
pluginGroup=com.github.sloppylopez.moneypennyideaplugin
pluginName=moneypenny-idea-plugin
pluginRepositoryUrl=https://github.com/sloppylopez/moneypenny-idea-plugin
# SemVer format -> https://semver.org
pluginVersion = 1.1.1-SNAPSHOT

pluginVersion=2.0.2-SNAPSHOT
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
pluginUntilBuild = 232.*

pluginSinceBuild=243.0
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = 2022.2.5

platformType=IC
platformVersion=2024.3
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java, org.intellij.plugins.markdown

platformPlugins=com.intellij.java, org.intellij.plugins.markdown
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.1.1

gradleVersion=8.1.1
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false
kotlin.stdlib.default.dependency=false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.github.sloppylopez.moneypennyideaplugin.actions

import com.github.sloppylopez.moneypennyideaplugin.services.ProjectService
import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project

@Service(Service.Level.PROJECT)
class AddTextAction(private val project: Project) : AnAction() {
private val service = project.service<ProjectService>()

Check warning on line 16 in src/main/kotlin/com/github/sloppylopez/moneypennyideaplugin/actions/AddTextAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "service" is never used

init {
templatePresentation.icon = AllIcons.Chooser.Left
templatePresentation.text = "Send to Editor"
}

override fun actionPerformed(e: AnActionEvent) {
ApplicationManager.getApplication().runWriteAction {
WriteCommandAction.runWriteCommandAction(project) {
val editor = e.getData(CommonDataKeys.EDITOR)
val selectionModel = editor?.selectionModel
val selectedText = selectionModel?.selectedText
val startOffset = selectionModel?.selectionStart
val endOffset = selectionModel?.selectionEnd
val textToAdd = "Hello World"//TODO here we should send the code returned by AI

if (selectedText == null) {
editor?.document?.insertString(startOffset!!, textToAdd)
} else {
editor.document.replaceString(startOffset!!, endOffset!!, textToAdd)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.sloppylopez.moneypennyideaplugin.actions

import com.github.sloppylopez.moneypennyideaplugin.global.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.data.GlobalData
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.Presentation
Expand Down Expand Up @@ -50,13 +50,6 @@ class ComboBoxEnginesAction(
}

private fun addEngineToGlobalData(selectedOption: String) {
// val notification = Notification(
// "MoneyPenny",
// "Selected Option",
// selectedOption,
// NotificationType.INFORMATION
// )
// Notifications.Bus.notify(notification)
GlobalData.engine = selectedOption
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.sloppylopez.moneypennyideaplugin.actions

import com.github.sloppylopez.moneypennyideaplugin.global.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.data.GlobalData
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.Presentation
Expand Down Expand Up @@ -50,7 +50,7 @@ class ComboBoxRolesAction(
}

private fun addEngineToGlobalData(selectedOption: String) {
GlobalData.role = selectedOption.split(" ")[1]
GlobalData.role = selectedOption
}

override fun getActionUpdateThread(): ActionUpdateThread {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.github.sloppylopez.moneypennyideaplugin.actions

import com.github.sloppylopez.moneypennyideaplugin.global.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.data.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.services.ProjectService
import com.github.sloppylopez.moneypennyideaplugin.services.PromptService
import com.intellij.icons.AllIcons
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project

@Service(Service.Level.PROJECT)
class CopyPromptAction(private var project: Project) : AnAction() {
private val service: ProjectService by lazy { project.service<ProjectService>() }
private val promptService: PromptService by lazy { project.service<PromptService>() }
Expand All @@ -17,15 +19,16 @@

init {
templatePresentation.icon = AllIcons.Actions.Copy
templatePresentation.text = "Copy prompt"

Check warning on line 22 in src/main/kotlin/com/github/sloppylopez/moneypennyideaplugin/actions/CopyPromptAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Copy prompt' is not properly capitalized. It should have title capitalization
}

override fun actionPerformed(e: AnActionEvent) {
project = e.project!!

val tabName = GlobalData.tabbedPane?.getTitleAt(GlobalData.tabbedPane!!.selectedIndex)
val tabName = GlobalData.selectedTabbedPane?.getTitleAt(GlobalData.selectedTabbedPane!!.selectedIndex)
val prompts = promptService.getPrompts()
val promptList = service.getPromptListByKey(prompts!!, tabName!!)
val promptList = service.getPromptListByKey(prompts, tabName!!)

if (promptList.isNotEmpty()) {
val promptsText = promptList.joinToString("\n")
service.copyToClipboard(promptsText)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.sloppylopez.moneypennyideaplugin.actions

import com.github.sloppylopez.moneypennyideaplugin.client.ChatGptMessage
import com.github.sloppylopez.moneypennyideaplugin.global.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.data.GlobalData
import com.github.sloppylopez.moneypennyideaplugin.services.ChatGPTService
import com.github.sloppylopez.moneypennyideaplugin.services.ProjectService
import com.github.sloppylopez.moneypennyideaplugin.toolWindow.ProgressBarFactory
Expand Down Expand Up @@ -36,12 +36,12 @@ class DRYSelectionAction(private var project: Project) : AnAction() {
editor
)
chatGPTService.sendChatPrompt(
getPrompt(selectedText), createCallback(file)
getPrompt(selectedText), createCallback(file), null, null
).whenComplete { _, _ ->
progressBarFactory.removeProgressBar(GlobalData.innerPanel!!, jProgressBar)
}
}

//This is for right click action only
private fun getPrompt(selectedText: String?): String {
val prePrompt = "Refactor code:\n"
val postPrompt = "\nDRY it following best practices and using one-liners if possible"
Expand All @@ -66,10 +66,16 @@ class DRYSelectionAction(private var project: Project) : AnAction() {

private fun createCallback(file: VirtualFile): ChatGPTService.ChatGptChoiceCallback {
return object : ChatGPTService.ChatGptChoiceCallback {
override fun onCompletion(choice: ChatGptMessage) {
override fun onCompletion(
choice: ChatGptMessage,
prompt: String,
upperTabName: String?,
promptList: List<String>?
) {
try {
var content = choice.content
if (GlobalData.role == "refactor-machine" && service.isCodeCommented(content)) {
val role = GlobalData.role.split(" ")[1]
if (role == "refactor-machine" && service.isCodeCommented(content)) {
content = service.extractCommentsFromCode(content)
}
if (!content.contains("Error: No response from GPT")) {
Expand Down
Loading
Loading