Skip to content

Commit c6c1210

Browse files
committed
feat(plan): enhance plan structure and verification steps #331
- Add auto-testing and verification step to ensure code correctness. - Update plan structure to use markdown ordered and unordered lists. - Simplify PlanTask class and add serialization support.
1 parent f896e26 commit c6c1210

File tree

6 files changed

+43
-31
lines changed

6 files changed

+43
-31
lines changed

core/src/main/kotlin/cc/unitmesh/devti/observer/agent/PlanList.kt

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
11
package cc.unitmesh.devti.observer.agent
22

3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
36
data class PlanList(
47
val title: String,
58
val planTasks: List<PlanTask>,
69
val completed: Boolean = false
710
)
811

9-
/**
10-
* 表示计划项中的单个任务
11-
*
12-
* @property description 任务描述文本
13-
* @property completed 任务是否已完成
14-
*/
15-
data class PlanTask(
16-
val description: String,
17-
var completed: Boolean = false
18-
) {
12+
@Serializable
13+
data class PlanTask(val description: String, var completed: Boolean = false) {
1914
companion object {
20-
/**
21-
* 从任务文本创建Task对象
22-
*
23-
* @param taskText 任务文本,可能包含完成标记
24-
* @return 封装了任务描述和状态的Task对象
25-
*/
2615
fun fromText(taskText: String): PlanTask {
2716
val isCompleted = taskText.contains("") ||
28-
Regex("\\[\\s*([xX])\\s*\\]").containsMatchIn(taskText)
17+
Regex("\\[\\s*([xX])\\s*\\]").containsMatchIn(taskText)
2918

30-
// 清理描述文本,移除完成标记
3119
val cleanedDescription = taskText
3220
.replace("", "")
3321
.replace(Regex("\\[\\s*[xX]\\s*\\]"), "[ ]")

core/src/main/resources/genius/en/code/plan.devin

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You are Sketch, a open-source agentic AI coding assistant designed by the Unit Mesh. Exclusively available in Sketch,
1+
You are Sketch, a open-source autonomous agentic coding programmer designed by the Unit Mesh. Exclusively available in Sketch,
22
you operate on the revolutionary AI Flow paradigm, enabling you to work both independently and collaboratively with a USER.
33

44
You are pair programming with a USER to solve their coding task. You need to ask some information about their current
@@ -47,6 +47,8 @@ Here is the rule you should follow:
4747
4. Propose and explain the necessary code modifications to resolve `<user.question>`, ensuring that edge cases are
4848
properly handled. Analyze these modifications before implementing them.
4949
5. use `<devin></devin>` command and code-fence block to Edit the source code in the repo to resolve `<user.question>`.
50+
6. You should alwasy think verify or auto-test your code to ensure it is correct and meets the requirements of `<user.question>`.
51+
7. Each plan should use a markdown ordered list to describe tasks and an unordered list to outline the steps for each task.
5052

5153
If `<user.question>` directly contradicts any of these steps, follow the instructions from `<user.question>`
5254
first. Be thorough in your thinking process, so it's okay if it is lengthy.

core/src/main/resources/genius/en/code/sketch.vm

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,22 @@ I will create a test file `test_routes.py` to test the routes defined in `routes
9090
# Step 5. Run the application, test, and verify
9191
Now, I will start the Flask server and run our application. I will generate IntelliJ IDEA's `.http` code to help you with API testing; you can try uploading and searching for photos on the website to see if everything works fine.
9292

93-
# Summary of changes
94-
By creating `routes.py` and `main.js`, I have made our photo application interactive. Users can now upload and search for photos using natural language queries. Additionally, I have made some modifications to the codebase to improve code organization and readability. Run the application and try uploading and searching for photos. If you encounter any errors or want to add new features, please let me know!
93+
```plan
94+
1. 创建 routes.py
95+
- [x] 定义 "/upload" 和 "/query" 端点
96+
- [x] 添加 "/" 作为 main.html 的端点。
97+
2. 创建 main.js。存储所有的交互式前端代码
98+
- [x] 创建并定义 UI 元素
99+
3. 更新 index.html
100+
- [x] 将所有 JavaScript 代码移到 main.js 中
101+
- [x] 在 index.html 中导入 main.js
102+
4. 自动化测试与验证
103+
- [ ] 使用 Flask 的测试框架编写自动化测试用例
104+
5. 运行应用程序,测试和验证
105+
- [ ] 运行应用程序
106+
```
107+
108+
根据我先前的计划,还有一些步骤需要完成。如果您遇到任何错误或想添加新功能,请告诉我!
95109

96110
// then you can start coding with DevIn language. When you need to or patch, write execute the code, you should use the DevIn language
97111
// If you need to create a new file, you should use `/write` command, then write the code in the code block
@@ -102,8 +116,8 @@ By creating `routes.py` and `main.js`, I have made our photo application interac
102116
// from flask import Flask
103117
```
104118
</devin>
105-
// patch to call tools for step 3 with DevIn language, should use `<devin></devin>` tag with DevIn language
106-
// 如果要应用补丁,请使用 `/patch` 命令,然后在代码块中编写补丁
119+
// patch to call tools for step 3 with DevIn language, should use `<devin />` tag with DevIn language
120+
// 如果要应用补丁,请使用 `/patch` 命令,然后在代码块中编写补丁,每个 patch 只能修改一个文件,并且使用独立的 `<devin />` 标签
107121
<devin>
108122
/patch:src/main/index.html
109123
```patch
@@ -158,13 +172,16 @@ feat: add delete blog functionality
158172
// here the tools will be called and send to your result.
159173
</user.answer.step1>
160174
<your.answer.step2>
161-
# Step 1. 重命名函数以让代码更易于理解
162-
我建议将 `time` 函数重命名为 `currentTime`,以便更清晰地表达其功能。这样,其他开发人员在阅读代码时就能更快地理解其作用。
175+
根据您提供的代码库上下文信息,我建议按照以下步骤来优化 `SketchRunContext` 代码结构:
163176

164-
# Step 2. 优化代码结构
177+
```plan
178+
1. 重命名函数以让代码更易于理解
179+
- 将 `time` 函数重命名为 `currentTime`,以便更清晰地表达其功能
180+
2. 优化代码结构
165181
...
182+
```
166183

167-
// 要修改引用端,建议使用 refactor 函数进行重命名
184+
接下来,我将 `time` 函数重命名为 `currentTime`,这样其他开发人员在阅读代码时就能更快地理解其作用。
168185
<devin>
169186
/refactor:rename cc.unitmesh.devti.language.run.DevInsProgramRunner to cc.unitmesh.devti.language.run.DevInsProgramRunnerImpl
170187
</devin>
@@ -209,6 +226,7 @@ This approach allows you to:
209226
2. Address any issues or errors that arise immediately.
210227
3. Adapt your approach based on new information or unexpected results.
211228
4. Ensure that each action builds correctly on the previous ones.
229+
5. Update the plan todo list if you already finished the step.
212230

213231
By waiting for and carefully considering the user's response after each tool use, you can react
214232
accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure

core/src/main/resources/genius/zh/code/plan.devin

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You are Sketch, a open-source agentic AI coding assistant designed by the Unit Mesh. Exclusively available in Sketch,
1+
You are Sketch, a open-source autonomous agentic coding programmer designed by the Unit Mesh. Exclusively available in Sketch,
22
you operate on the revolutionary AI Flow paradigm, enabling you to work both independently and collaboratively with a USER.
33

44
You are pair programming with a USER to solve their coding task. You need to ask some information about their current
@@ -47,6 +47,8 @@ Here is the rule you should follow:
4747
4. Propose and explain the necessary code modifications to resolve `<user.question>`, ensuring that edge cases are
4848
properly handled. Analyze these modifications before implementing them.
4949
5. use `<devin></devin>` command and code-fence block to Edit the source code in the repo to resolve `<user.question>`.
50+
6. You should alwasy think verify or auto-test your code to ensure it is correct and meets the requirements of `<user.question>`.
51+
7. Each plan should use a markdown ordered list to describe tasks and an unordered list to outline the steps for each task.
5052

5153
If `<user.question>` directly contradicts any of these steps, follow the instructions from `<user.question>`
5254
first. Be thorough in your thinking process, so it's okay if it is lengthy.

core/src/main/resources/genius/zh/code/sketch.vm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ have created a routes.py and main.js file, and updated the main.html file.
9393
看看是否一切正常。
9494

9595
# 总结
96-
如是,我已经完成了您的需求,您可以继续测试和验证应用程序。我的进度如下
96+
如是,我已经完成了您的需求,您可以继续测试和验证应用程序。如下是更新后的计划
9797

9898
```plan
9999
1. 创建 routes.py
@@ -177,6 +177,8 @@ feat: add delete blog functionality
177177
// here the tools will be called and send to your result.
178178
</user.answer.step1>
179179
<your.answer.step2>
180+
根据您提供的代码库上下文信息,我建议按照以下步骤来优化 `SketchRunContext` 代码结构:
181+
180182
```plan
181183
1. 重命名函数以让代码更易于理解
182184
- 将 `time` 函数重命名为 `currentTime`,以便更清晰地表达其功能
@@ -229,6 +231,7 @@ This approach allows you to:
229231
2. Address any issues or errors that arise immediately.
230232
3. Adapt your approach based on new information or unexpected results.
231233
4. Ensure that each action builds correctly on the previous ones.
234+
5. Update the plan in every conversation turn based on the user's responses.
232235

233236
By waiting for and carefully considering the user's response after each tool use, you can react
234237
accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/WriteInsCommand.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ class WriteInsCommand(val myProject: Project, val argument: String, val content:
102102

103103
runInEdt {
104104
FileEditorManager.getInstance(myProject).openFile(newFile, true)
105+
document.setText(content)
105106
}
106107

107-
document.setText(content)
108-
109108
return "Writing to file: $argument"
110109
}
111110

0 commit comments

Comments
 (0)