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.72k stars 314 forks source link

/wirte 在1.75版之後失效 #143

Closed ymli0215 closed 4 months ago

ymli0215 commented 5 months ago
/write:len/README.md#L1-L12
`` `<-- Here is ``` inside code block
public class Controller {
    public void method() {
        System.out.println("Hello, World!");
    }
}
`` `

上述的內容,在1.73版可以正常執行且寫入到檔案中 但1.75版之後就無法成功,會跳出chat panel,並出現下面的訊息,就是想透過chat來解決問題

You are a top software developer in the world, which can help me to fix the issue. When I use shell-like language and compile the script, I got an error, can you help me to fix it? Origin script: `devin /write:len/README.md public class Controller { public void method() { System.out.println("Hello, World!"); } } ` Script with result: #### : Must not change document outside command or undo-transparent action. See com.intellij.openapi.command.WriteCommandAction or com.intellij.openapi.command.CommandProcessor

看到比較有關的log是 : Read access is allowed from inside read-action (see Application.runReadAction())


嘗試把原有內容改成下方內容

`` `devin  <-- Here is ``` inside code block

/write:len/README.md#L1-L12

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

雖然執行結果成功,但是並沒有真的寫文字到指定檔案中..


可以許願讓 /write 可以自動產生不存在的檔案嗎??? 這樣可以讓產生test code的情境上更加方便,不用先新增檔案後才能去/write

phodal commented 5 months ago

应该是 bug 了

phodal commented 5 months ago

@ymli0215 可以从这里下载测试试试:https://github.com/unit-mesh/auto-dev/actions/runs/8626280030

ymli0215 commented 5 months ago

@phodal 感謝迅速處理,/write 已經可以正常寫入內容

希望作者可以加入 針對不存在檔案可以自動產生檔案而不要報錯 謝謝

phodal commented 5 months ago

@ymli0215 你要的这个功能应该加了,可以试试

ymli0215 commented 5 months ago

@ @phodal 我知道問題了,這邊回報一下

如果是有資料夾路徑的話

/write:len/test2.java#L1-L12
`` `<-- Here is ``` inside code block
public class Controller {
    public void method() {
        System.out.println("Hello, World!");
    }
}
`` `

他就會報錯誤 Error running 'write.devin' Invalid file name: 'len/test2.java'

但我改成,檔案路徑沒有資料夾

/write:test2.java#L1-L12
`` `<-- Here is ``` inside code block
public class Controller {
    public void method() {
        System.out.println("Hello, World!");
    }
}
`` `

結果會變成產生一個相同檔名的資料夾,然後檔案產生在資料夾下 image

phodal commented 5 months ago

哦,bug 了,我处理一下,

phodal commented 5 months ago

前面没处理好,等这个 bug 跑完就可以下载了:https://github.com/unit-mesh/auto-dev/actions/runs/8627964871

ymli0215 commented 5 months ago

@phodal 回報一下

這版測試,應該是程式中有用 File.separator 來處理,所以導致要分成windows/Mac兩種情況了

  1. /write:test2.java

    • 會在專案目錄下產生test2.java
  2. /write:len\test2.java,len資料夾存在,test2.java不存在

    • 在len資料夾下產生test2.java
    • windows環境要改成\ 才會正常,len/test2.java 會錯
  3. /write:len\test2.java,len資料夾存在,test2.java有存在

    • len\test2.java、len/test2.java 都正常
  4. /write:len2\test2.java,len2資料夾不存在

    • 會產生一個len2資料夾,並產生一個test2.java
    • windows環境要改成\ 才會正常,len2/test2.java 會錯
phodal commented 5 months ago

@ymli0215 那就只改成 / 方式 ?

ymli0215 commented 5 months ago

應該可以寫死/了,提供的範例全部都是 / 大家都習慣了,反正windows 在 lookupFile() 丟 len/test.java 也是正常

謝謝

phodal commented 5 months ago

提交上去了: https://github.com/unit-mesh/auto-dev/actions/runs/8628639425

phodal commented 4 months ago

没有失败,或者从这里下载:https://github.com/unit-mesh/auto-dev/releases/tag/v1.8.1

我刚好在测试一个 JB 市场的问题。

ymli0215 commented 4 months ago

回報結果

已經測試完畢,新檔案/新資料夾都可以正常建立了

謝謝

phodal commented 4 months ago

@ymli0215 有新需求,欢迎来 issue

ymli0215 commented 4 months ago

@phodal 回報一個問題

因為正在嘗試透過 agent 來做一些連續性的流程 下面內容,透過 .devin 可以正常產生出新檔案,test.java不存在的話 但是agent回傳的話,就沒有辦法產生新檔案,如果檔案已經存在的話,就可以正常寫入

/write:len/test.java#L1-L12

`` `java
public class Controller {
    public void method() {
        System.out.println("Hello, World!441");
    }
}

`` `

我是透過nodejs來寫一個agent

app.post("/api/agent/junit", (req, res) => {
    const reqCtx = req.body.messages[0].content;

    res.type('text/plain');
    res.send( `
/write:len/test.java#L1-L12

\`\`\`java
public class Controller {
    public void method() {
        System.out.println("Hello, World!441");
    }
}

\`\`\`
`);
});
phodal commented 4 months ago

新建个 issue? 方便区别,顺便给一下建议?

参考一下这个 example/custom_agent/server.py