unit-mesh / auto-dev

🧙‍AutoDev: The AI-powered coding wizard(AI 驱动编程助手)with multilingual support 🌐, auto code generation 🏗️, and a helpful bug-slaying assistant 🐞! Customizable prompts 🎨 and a magic Auto Dev/Testing/Document/Agent feature 🧪 included! 🚀
https://ide.unitmesh.cc/
Mozilla Public License 2.0
2.78k stars 317 forks source link

custom agent 執行 /write 語法 產生問題 #146

Closed ymli0215 closed 6 months ago

ymli0215 commented 6 months ago

依照最新版本以及規格

custom agent設定"responseAction": "DevIns"

agent 回應下方內容

`` `devin <--- should be ```

/write:test.java#L1-L12

\`\`\`java
public class Controller {
    public void method() {
        System.out.println("Hello, World!666");
    }
}
\`\`\`
`` ` <--- should be ```

檔案已存在的情境下,可以正常寫入,但是會出現錯誤,以及出現chat panel image

error log

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action (see Application.runReadAction()); see https://jb.gg/ij-platform-threading for details
Current thread: Thread[DefaultDispatcher-worker-1,6,main] 2090338088 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 2003423441
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:149)
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:107)
    at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1012)
    at com.intellij.psi.impl.source.tree.TreeElement.assertReadAccessAllowed(TreeElement.java:421)
    at com.intellij.psi.impl.source.tree.CompositeElement.getChildrenAsPsiElements(CompositeElement.java:385)
    at com.intellij.psi.impl.source.PsiFileImpl.getChildren(PsiFileImpl.java:733)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler.compile(DevInsCompiler.kt:39)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.executeTask(DevInsProcessProcessor.kt:88)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.process(DevInsProcessProcessor.kt:61)
    at cc.unitmesh.devti.language.run.DevInsProgramRunner$doExecute$1.runFinish(DevInsProgramRunner.kt:37)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:700)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:660)
    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423)
    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402)
    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461)
    at jdk.proxy15/jdk.proxy15.$Proxy224.runFinish(Unknown Source)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$execute$1.processTerminated(DevInsRunConfigurationProfileState.kt:57)
    at com.intellij.execution.process.ProcessHandler$2.processTerminated(ProcessHandler.java:259)
    at com.intellij.execution.process.ProcessHandler.lambda$notifyTerminated$2(ProcessHandler.java:204)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.notifyTerminated(ProcessHandler.java:187)
    at com.intellij.execution.process.ProcessHandler.notifyProcessTerminated(ProcessHandler.java:183)
    at cc.unitmesh.devti.language.run.DevInsProcessHandler.detachProcessImpl(DevInsProcessHandler.kt:9)
    at com.intellij.execution.process.ProcessHandler.lambda$detachProcess$1(ProcessHandler.java:140)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.detachProcess(ProcessHandler.java:137)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$agentRun$1$1.invokeSuspend(DevInsRunConfigurationProfileState.kt:152)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

如果檔案不存在,預期要能新建檔案 雖然說已經完成,但沒有看到新增的檔案,並且會有錯誤

error log

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action (see Application.runReadAction()); see https://jb.gg/ij-platform-threading for details
Current thread: Thread[DefaultDispatcher-worker-1,6,main] 829454477 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1067343825
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:149)
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:107)
    at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1012)
    at com.intellij.psi.impl.source.tree.TreeElement.assertReadAccessAllowed(TreeElement.java:421)
    at com.intellij.psi.impl.source.tree.CompositeElement.getChildrenAsPsiElements(CompositeElement.java:385)
    at com.intellij.psi.impl.source.PsiFileImpl.getChildren(PsiFileImpl.java:733)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler.compile(DevInsCompiler.kt:39)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.executeTask(DevInsProcessProcessor.kt:88)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.process(DevInsProcessProcessor.kt:61)
    at cc.unitmesh.devti.language.run.DevInsProgramRunner$doExecute$1.runFinish(DevInsProgramRunner.kt:37)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:700)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:660)
    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423)
    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402)
    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461)
    at jdk.proxy15/jdk.proxy15.$Proxy207.runFinish(Unknown Source)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$execute$1.processTerminated(DevInsRunConfigurationProfileState.kt:57)
    at com.intellij.execution.process.ProcessHandler$2.processTerminated(ProcessHandler.java:259)
    at com.intellij.execution.process.ProcessHandler.lambda$notifyTerminated$2(ProcessHandler.java:204)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.notifyTerminated(ProcessHandler.java:187)
    at com.intellij.execution.process.ProcessHandler.notifyProcessTerminated(ProcessHandler.java:183)
    at cc.unitmesh.devti.language.run.DevInsProcessHandler.detachProcessImpl(DevInsProcessHandler.kt:9)
    at com.intellij.execution.process.ProcessHandler.lambda$detachProcess$1(ProcessHandler.java:140)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.detachProcess(ProcessHandler.java:137)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$agentRun$1$1.invokeSuspend(DevInsRunConfigurationProfileState.kt:152)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
java.lang.RuntimeException: Cannot invoke (class=, method=runFinish, topic=DevInsRunListener)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:677)
    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423)
    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402)
    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461)
    at jdk.proxy15/jdk.proxy15.$Proxy207.runFinish(Unknown Source)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$execute$1.processTerminated(DevInsRunConfigurationProfileState.kt:57)
    at com.intellij.execution.process.ProcessHandler$2.processTerminated(ProcessHandler.java:259)
    at com.intellij.execution.process.ProcessHandler.lambda$notifyTerminated$2(ProcessHandler.java:204)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.notifyTerminated(ProcessHandler.java:187)
    at com.intellij.execution.process.ProcessHandler.notifyProcessTerminated(ProcessHandler.java:183)
    at cc.unitmesh.devti.language.run.DevInsProcessHandler.detachProcessImpl(DevInsProcessHandler.kt:9)
    at com.intellij.execution.process.ProcessHandler.lambda$detachProcess$1(ProcessHandler.java:140)
    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:322)
    at com.intellij.execution.process.ProcessHandler.detachProcess(ProcessHandler.java:137)
    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$agentRun$1$1.invokeSuspend(DevInsRunConfigurationProfileState.kt:152)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Caused by: java.lang.IllegalStateException: Current thread: Thread[DefaultDispatcher-worker-1,6,main]; expected: Thread[AWT-EventQueue-0,6,main]
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkWriteThreadAccess(ReadMostlyRWLock.java:316)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkForPossibilityOfWriteLock(ReadMostlyRWLock.java:251)
    at com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1094)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:961)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
    at com.intellij.openapi.application.ActionsKt.runWriteAction(actions.kt:16)
    at cc.unitmesh.devti.language.compiler.exec.WriteInsCommand.execute(WriteInsCommand.kt:31)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler$processingCommand$execResult$1.invokeSuspend(DevInsCompiler.kt:219)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler.processingCommand(DevInsCompiler.kt:219)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler.processUsed(DevInsCompiler.kt:108)
    at cc.unitmesh.devti.language.compiler.DevInsCompiler.compile(DevInsCompiler.kt:51)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.executeTask(DevInsProcessProcessor.kt:88)
    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.process(DevInsProcessProcessor.kt:61)
    at cc.unitmesh.devti.language.run.DevInsProgramRunner$doExecute$1.runFinish(DevInsProgramRunner.kt:37)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:700)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:660)
    ... 22 more
phodal commented 6 months ago

:cry::cry::cry: 复现还是有难度,你要不创建个 gist ,把 server 贴上去,

ymli0215 commented 6 months ago

試試看這樣的設定,打到我的agent server

{ "name": "junit2", "description": "產生junit test code", "url": "http://noodletw.asuscomm.com:8502/api/agent/junit2", "responseAction": "DevIns" }

phodal commented 6 months ago

有可能最新版本真的可以:https://github.com/unit-mesh/auto-dev/actions/runs/8647351673

  1. 2024.1 + 最新的 build 版本是 OK 的
  2. 2023.3 + 最新的 build 版本是 OK 的
ymli0215 commented 6 months ago

先回報一下

windows : 三個版本都測試過,都是一樣的問題 mac : 測試241,也是一樣的問題

請同事也一起幫忙測試,有結果再來回報

ymli0215 commented 6 months ago

請問都已經移除又安裝,甚至使用今天最新版本還是有一樣的問題,是否有建議可以找出問題的方式嗎??

另外想請問,若是我自己可以怎樣做,來找出可能的問題呢? 例如怎樣可以包出一樣的zip??

phodal commented 6 months ago

我再确认一下是从哪里下载的包?

理论上是可以构建出一样的,但是 idea 插件学习成本高

ymli0215 commented 6 months ago

我就是直接從github上clone下來的 看起來是要確認執行哪些gradle task才能包出zip

phodal commented 6 months ago
  1. 需要根据你的 IDEA 版本修改 gradle.properties 中的 platformVersion,241 对应 2024, 233,应该是对应 2023.3,其它是 222
  2. 执行对应的 task 是:./gradlew :plugin:buildPlugin

因为要下载各种 IDEA 资源,估计初次构建要 1 小时左右?

详细,可以参考一下 GitHub Action 。

ymli0215 commented 6 months ago

我有嘗試過,只是不確定要哪些task

剛剛安裝自己建立的版本後,問題依舊... XD

phodal commented 6 months ago

2333,主要是我用了你的服务是好的

ymli0215 commented 6 months ago

我先回報我看到的

我有提到當我檔案存在時,他可以正常寫入沒錯,但是會跳出chat panel 看log是會執行到這裡,最後會呼叫sendToChatWindow,所以才會跳出對話視窗 我剛剛把它拿掉,就是符合我預期的行為 : 有存在的檔案會正常寫入內容,且不會跳出對話視窗

DevInsProcessProcessor.kt

image

phodal commented 6 months ago

哦,哦,我懂了:意思是不想要 panel 是吧?Panel 的原本意图是用来 debug 用的。

你看是加个配置??或者你自己先改改用?然后我看最后怎么设计?

ymli0215 commented 6 months ago

因為 我直接寫一個 .devin 檔案 ,內容就是直接寫 /write:test.java
他也不會出現對話視窗,我想說行為應該要一致的吧...

我以為
透過agent傳回 平常寫在.devin檔內的 devin language,行為應該都是一致的

phodal commented 6 months ago

嗯,懂了,那我在 responseAction 是 DevIns 去掉这个 panel。

主要是 Custom Agent 原来的行为都是在 Panel 里方便调试,我晚点想想怎么加个别的 debug 方式。

感谢建议

ymli0215 commented 6 months ago

我剛剛加了log看,應該就是你說的原因

這是執行的結果內容,平常 .devin 執行 是直接在結果輸出視窗印出 Writing to file: len/test.java 但是現在不管成功或失敗,都把 Writing to file: len/test.java 直接丟去對話視窗了 依照你剛剛用來debug的想法,應該是失敗的話,才會把prompt丟去對話視窗要求產出解決方案 成功就不用做這動作了

 DevInsCompiledResult(input=/write:len/test.java#L1-L12
`` `java
public class Controller {
    public void method() {
        System.out.println("Hello, World!666");
    }
}
`` `, output=Writing to file: len/test.java
phodal commented 6 months ago

哈哈,要不你直接来个 PR?

ymli0215 commented 6 months ago

我還不知道要怎樣改 .. @@ 只能先幫忙找出可能性了

第二個問題,沒有產生檔案的問題 看起來是 DevInsProcessProcessor 執行 executeTask 的 val compiledResult = DevInsCompiler(project, newScript).compile() 這行有了問題 如果檔案已經存在,他也是走這邊來寫入內容,他不會有問題

對照 143 issue的調整 WriteInsCommand 這邊就先去判斷檔案是否存在再來寫內容

phodal commented 6 months ago

第一个问题的话,如果想把结果返回回去,可以改为:

    /**
     * This function is responsible for running a task with a new script.
     * @param newScript The new script to be run.
     */
    fun executeTask(newScript: DevInFile) {
        val compiledResult = DevInsCompiler(project, newScript).compile()
        val prompt = compiledResult.output

        if (compiledResult.hasError) {
            val llmProvider = LlmFactory().create(project)
            val output: Flow<String> = llmProvider.stream(prompt, "", keepHistory = false)
            // handle output
        }
    }

如果要出于 AI Agent 的话,是需要继续对话的,怎么设计就比较痛苦了。不太确定,或者你要的是:

        if (compiledResult.hasError) {
            sendToChatWindow(project, ChatActionType.CHAT) { panel, service ->
                service.handlePromptAndResponse(panel, object : ContextPrompter() {
                    override fun displayPrompt(): String = prompt
                    override fun requestPrompt(): String = prompt
                }, null, true)
        }
ymli0215 commented 6 months ago

第一個 val llmProvider = LlmFactory().create(project) 這個用途不太清楚是啥耶

第二個改法至少是針對你現行程式執行成功不需要出對話視窗,至少是跟原有相同反應,有錯才跳出建議

phodal commented 6 months ago

@ymli0215 那你来 PR 吧,哈哈哈哈。难得试了这么多

ymli0215 commented 6 months ago

無法產生檔案的問題應該算找到了??? 就是最後還是會進到 WriteInsCommand 準備寫入資料 但因為檔案不存在,所以觸發 if (virtualFile == null) { } 準備產生檔案 結果在 return runWriteAction { } 就發生錯誤了,沒辦法正確執行產生檔案 我特地在這邊加上 try catch才印出錯誤

error


java.lang.IllegalStateException: Current thread: Thread[DefaultDispatcher-worker-1,6,main]; expected: Thread[AWT-EventQueue-0,6,main]

    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkWriteThreadAccess(ReadMostlyRWLock.java:315)

    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkForPossibilityOfWriteLock(ReadMostlyRWLock.java:250)

    at com.intellij.openapi.application.impl.RwLockHolder.startWrite(RwLockHolder.kt:507)

    at com.intellij.openapi.application.impl.RwLockHolder.runWriteAction(RwLockHolder.kt:352)

    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:888)

    at com.intellij.openapi.application.ActionsKt.runWriteAction(actions.kt:16)

    at cc.unitmesh.devti.language.compiler.exec.WriteInsCommand.execute(WriteInsCommand.kt:35)

    at cc.unitmesh.devti.language.compiler.DevInsCompiler$processingCommand$execResult$1.invokeSuspend(DevInsCompiler.kt:252)

    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)

    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)

    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)

    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)

    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)

    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)

    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)

    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)

    at cc.unitmesh.devti.language.compiler.DevInsCompiler.processingCommand(DevInsCompiler.kt:252)

    at cc.unitmesh.devti.language.compiler.DevInsCompiler.processUsed(DevInsCompiler.kt:137)

    at cc.unitmesh.devti.language.compiler.DevInsCompiler.compile(DevInsCompiler.kt:72)

    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.executeTask(DevInsProcessProcessor.kt:88)

    at cc.unitmesh.devti.language.run.flow.DevInsProcessProcessor.process(DevInsProcessProcessor.kt:61)

    at cc.unitmesh.devti.language.run.DevInsProgramRunner$doExecute$1.runFinish(DevInsProgramRunner.kt:37)

    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:700)

    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:660)

    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423)

    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402)

    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)

    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461)

    at jdk.proxy15/jdk.proxy15.$Proxy199.runFinish(Unknown Source)

    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$execute$1.processTerminated(DevInsRunConfigurationProfileState.kt:57)

    at com.intellij.execution.process.ProcessHandler$2.processTerminated(ProcessHandler.java:262)

    at com.intellij.execution.process.ProcessHandler.lambda$notifyTerminated$2(ProcessHandler.java:207)

    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:325)

    at com.intellij.execution.process.ProcessHandler.notifyTerminated(ProcessHandler.java:190)

    at com.intellij.execution.process.ProcessHandler.notifyProcessTerminated(ProcessHandler.java:186)

    at cc.unitmesh.devti.language.run.DevInsProcessHandler.detachProcessImpl(DevInsProcessHandler.kt:9)

    at com.intellij.execution.process.ProcessHandler.lambda$detachProcess$1(ProcessHandler.java:143)

    at com.intellij.execution.process.ProcessHandler$TasksRunner.execute(ProcessHandler.java:325)

    at com.intellij.execution.process.ProcessHandler.detachProcess(ProcessHandler.java:140)

    at cc.unitmesh.devti.language.run.DevInsRunConfigurationProfileState$agentRun$1$1.invokeSuspend(DevInsRunConfigurationProfileState.kt:152)

    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)

    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)

    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)

    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)

    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)

    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

太尷尬了 根本不知道要怎樣修正... XD

phodal commented 6 months ago

按理说,35 行只是找目录,看上去不会报错

https://github.com/unit-mesh/auto-dev/blob/9f67671eeebe61798a0c78f2a955fb79b2ac519a/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/WriteInsCommand.kt#L33-L38

ymli0215 commented 6 months ago

我覺得比較可能是 runWriteAction 本身的問題,不是 runWriteAction {} 內部程式的問題

因為我直接下log去看,val hasChildPath = filepath.contains(pathSeparator) 這行都還沒有執行到就死了

phodal commented 6 months ago

那就有点难办了,你用的操作系统是 Windows 还是?

phodal commented 6 months ago

@ymli0215 我优化了一下 runWriteAction,你有空的时候再看看具体在哪里出问题?

https://github.com/unit-mesh/auto-dev/blob/42d1219d3c440250fc68f3520db6350d7b4235e6/exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/WriteInsCommand.kt#L49-L64

ymli0215 commented 6 months ago

@phodal

因為我看了runWriteAction 的應用情境,都是提到UI,然後聯想到你說之前版本測試都是正常的,我卻是都有問題 我覺得是我們兩人測試的方式不同

我猜你是直接透過對話視窗去執行的,直接指定custom agent後去執行,如下圖 image

但是我是在新增一個 .devin 檔案,在檔案中下 @junit 這樣去執行的,如下圖 image

我跑去安裝幾天前的版本,如果我是在對話視窗中去跑custom agent的話,的確就是你說的結果,測試都是正常的 但是依照我的做法就依然是我說的問題

我猜我們的差異就是在這邊,但是這邊就變成在流程中就要去判斷是對話視窗或是檔案執行模式了 感覺修改的難度高

這應該就是我一直會碰到 IllegalStateException 這種錯誤的原因吧

phodal commented 6 months ago

复现了,我晚点修复一下问题

phodal commented 6 months ago

@ymli0215 我提交上去了,你可以拉下来代码试试

ymli0215 commented 6 months ago

另外問一個情境喔,要請問這是你預期的嗎???

就是對話視窗這邊選擇custom agent的時候 執行第二次就不會有效果

例如我用agent : junit 他會把內容寫入到 test.java 第一次會成功,但是我把檔案內容拿掉,同一個對話視窗再執行一次 預期會在寫入一次內容,但是就沒有反應了...

ymli0215 commented 6 months ago

回報一下

結果都符合預期了 不管是用對話視窗或是單獨的 devin檔案

phodal commented 6 months ago

custom agent 默认的场景是基于公司内部知识库 rag 来提供上下文,所以默认第二次不走 agent。期望的是,agent 能一次根据上下文解决

如果有别的需求,可以再提 issue,哈哈哈