Closed ymli0215 closed 6 months ago
試試看這樣的設定,打到我的agent server
{ "name": "junit2", "description": "產生junit test code", "url": "http://noodletw.asuscomm.com:8502/api/agent/junit2", "responseAction": "DevIns" }
有可能最新版本真的可以:https://github.com/unit-mesh/auto-dev/actions/runs/8647351673
先回報一下
windows : 三個版本都測試過,都是一樣的問題 mac : 測試241,也是一樣的問題
請同事也一起幫忙測試,有結果再來回報
請問都已經移除又安裝,甚至使用今天最新版本還是有一樣的問題,是否有建議可以找出問題的方式嗎??
另外想請問,若是我自己可以怎樣做,來找出可能的問題呢? 例如怎樣可以包出一樣的zip??
我再确认一下是从哪里下载的包?
理论上是可以构建出一样的,但是 idea 插件学习成本高
我就是直接從github上clone下來的 看起來是要確認執行哪些gradle task才能包出zip
gradle.properties
中的 platformVersion
,241 对应 2024, 233,应该是对应 2023.3,其它是 222./gradlew :plugin:buildPlugin
因为要下载各种 IDEA 资源,估计初次构建要 1 小时左右?
详细,可以参考一下 GitHub Action 。
我有嘗試過,只是不確定要哪些task
剛剛安裝自己建立的版本後,問題依舊... XD
2333,主要是我用了你的服务是好的
我先回報我看到的
我有提到當我檔案存在時,他可以正常寫入沒錯,但是會跳出chat panel 看log是會執行到這裡,最後會呼叫sendToChatWindow,所以才會跳出對話視窗 我剛剛把它拿掉,就是符合我預期的行為 : 有存在的檔案會正常寫入內容,且不會跳出對話視窗
DevInsProcessProcessor.kt
哦,哦,我懂了:意思是不想要 panel 是吧?Panel 的原本意图是用来 debug 用的。
你看是加个配置??或者你自己先改改用?然后我看最后怎么设计?
因為 我直接寫一個 .devin 檔案 ,內容就是直接寫 /write:test.java
他也不會出現對話視窗,我想說行為應該要一致的吧...
我以為
透過agent傳回 平常寫在.devin檔內的 devin language,行為應該都是一致的
嗯,懂了,那我在 responseAction 是 DevIns
去掉这个 panel。
主要是 Custom Agent 原来的行为都是在 Panel 里方便调试,我晚点想想怎么加个别的 debug 方式。
感谢建议
我剛剛加了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
哈哈,要不你直接来个 PR?
我還不知道要怎樣改 .. @@ 只能先幫忙找出可能性了
第二個問題,沒有產生檔案的問題 看起來是 DevInsProcessProcessor 執行 executeTask 的 val compiledResult = DevInsCompiler(project, newScript).compile() 這行有了問題 如果檔案已經存在,他也是走這邊來寫入內容,他不會有問題
對照 143 issue的調整 WriteInsCommand 這邊就先去判斷檔案是否存在再來寫內容
第一个问题的话,如果想把结果返回回去,可以改为:
/**
* 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)
}
第一個 val llmProvider = LlmFactory().create(project) 這個用途不太清楚是啥耶
第二個改法至少是針對你現行程式執行成功不需要出對話視窗,至少是跟原有相同反應,有錯才跳出建議
@ymli0215 那你来 PR 吧,哈哈哈哈。难得试了这么多
無法產生檔案的問題應該算找到了??? 就是最後還是會進到 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
我覺得比較可能是 runWriteAction 本身的問題,不是 runWriteAction {} 內部程式的問題
因為我直接下log去看,val hasChildPath = filepath.contains(pathSeparator) 這行都還沒有執行到就死了
那就有点难办了,你用的操作系统是 Windows 还是?
@ymli0215 我优化了一下 runWriteAction
,你有空的时候再看看具体在哪里出问题?
@phodal
因為我看了runWriteAction 的應用情境,都是提到UI,然後聯想到你說之前版本測試都是正常的,我卻是都有問題 我覺得是我們兩人測試的方式不同
我猜你是直接透過對話視窗去執行的,直接指定custom agent後去執行,如下圖
但是我是在新增一個 .devin 檔案,在檔案中下 @junit 這樣去執行的,如下圖
我跑去安裝幾天前的版本,如果我是在對話視窗中去跑custom agent的話,的確就是你說的結果,測試都是正常的 但是依照我的做法就依然是我說的問題
我猜我們的差異就是在這邊,但是這邊就變成在流程中就要去判斷是對話視窗或是檔案執行模式了 感覺修改的難度高
這應該就是我一直會碰到 IllegalStateException 這種錯誤的原因吧
复现了,我晚点修复一下问题
@ymli0215 我提交上去了,你可以拉下来代码试试
另外問一個情境喔,要請問這是你預期的嗎???
就是對話視窗這邊選擇custom agent的時候 執行第二次就不會有效果
例如我用agent : junit 他會把內容寫入到 test.java 第一次會成功,但是我把檔案內容拿掉,同一個對話視窗再執行一次 預期會在寫入一次內容,但是就沒有反應了...
回報一下
結果都符合預期了 不管是用對話視窗或是單獨的 devin檔案
custom agent 默认的场景是基于公司内部知识库 rag 来提供上下文,所以默认第二次不走 agent。期望的是,agent 能一次根据上下文解决
如果有别的需求,可以再提 issue,哈哈哈
依照最新版本以及規格
custom agent設定"responseAction": "DevIns"
agent 回應下方內容
檔案已存在的情境下,可以正常寫入,但是會出現錯誤,以及出現chat panel
error log
如果檔案不存在,預期要能新建檔案 雖然說已經完成,但沒有看到新增的檔案,並且會有錯誤
error log