-
Notifications
You must be signed in to change notification settings - Fork 7
feat: 引入 Todo 任务规划及上下文管理优化 #47
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d309565
<feat>:增加todo模块,现在AI可以通过todo工具规划自己的任务
phantom5099 8812102
<fix>:修复todo服务未正确注入问题
phantom5099 76a9d92
<fix>:修复方法缺少导致报错
phantom5099 6baa746
Merge remote-tracking branch 'origin/main'
phantom5099 343aa0f
<fix>:修复两个测试类的参数错误
phantom5099 7c38dfe
Merge remote-tracking branch 'refs/remotes/upstream/main'
phantom5099 b658aed
Merge remote-tracking branch 'refs/remotes/upstream/main'
phantom5099 7bac8ab
<fix>:修复TUI core 层直接引用domain和todo模块大量硬编码问题
phantom5099 4e2293e
<fix>:修复因security_service中“WebFetch”和tool中“Webfetch”不一致导致测试错误问题
phantom5099 8c155b2
<fix>:修复测试结果返回语种错误导致报错问题
phantom5099 cc8cf88
<style>:修改TUI中todo相关的硬编码,修改工具描述的语种为英语
phantom5099 95a1b97
<test>:为todo模块增加测试代码
phantom5099 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package domain | ||
|
|
||
| import ( | ||
| "context" | ||
| "strings" | ||
| ) | ||
|
|
||
| // TodoStatus 表示任务状态 | ||
| type TodoStatus string | ||
|
|
||
| const ( | ||
| TodoPending TodoStatus = "pending" | ||
| TodoInProgress TodoStatus = "in_progress" | ||
| TodoCompleted TodoStatus = "completed" | ||
| ) | ||
|
|
||
| func ParseTodoStatus(input string) (TodoStatus, bool) { | ||
| normalized := TodoStatus(strings.ToLower(strings.TrimSpace(input))) | ||
| switch normalized { | ||
| case TodoPending, TodoInProgress, TodoCompleted: | ||
| return normalized, true | ||
| default: | ||
| return "", false | ||
| } | ||
| } | ||
|
|
||
| type TodoPriority string | ||
|
|
||
| const ( | ||
| TodoPriorityHigh TodoPriority = "high" | ||
| TodoPriorityMedium TodoPriority = "medium" | ||
| TodoPriorityLow TodoPriority = "low" | ||
| ) | ||
|
|
||
| func ParseTodoPriority(input string) (TodoPriority, bool) { | ||
| normalized := TodoPriority(strings.ToLower(strings.TrimSpace(input))) | ||
| switch normalized { | ||
| case TodoPriorityHigh, TodoPriorityMedium, TodoPriorityLow: | ||
| return normalized, true | ||
| default: | ||
| return "", false | ||
| } | ||
| } | ||
|
|
||
| type TodoAction string | ||
|
|
||
| const ( | ||
| TodoActionAdd TodoAction = "add" | ||
| TodoActionUpdate TodoAction = "update" | ||
| TodoActionList TodoAction = "list" | ||
| TodoActionRemove TodoAction = "remove" | ||
| TodoActionClear TodoAction = "clear" | ||
| ) | ||
|
|
||
| func ParseTodoAction(input string) (TodoAction, bool) { | ||
| normalized := TodoAction(strings.ToLower(strings.TrimSpace(input))) | ||
| switch normalized { | ||
| case TodoActionAdd, TodoActionUpdate, TodoActionList, TodoActionRemove, TodoActionClear: | ||
| return normalized, true | ||
| default: | ||
| return "", false | ||
| } | ||
| } | ||
|
|
||
| // Todo 表示任务清单中的一项 | ||
| type Todo struct { | ||
| ID string `json:"id"` | ||
| Content string `json:"content"` | ||
| Status TodoStatus `json:"status"` | ||
| Priority TodoPriority `json:"priority"` | ||
| } | ||
|
phantom5099 marked this conversation as resolved.
|
||
|
|
||
| // TodoService 定义任务清单服务接口 | ||
| type TodoService interface { | ||
| // AddTodo 添加一个新任务 | ||
| AddTodo(ctx context.Context, content string, priority TodoPriority) (*Todo, error) | ||
| // UpdateTodoStatus 更新任务状态 | ||
| UpdateTodoStatus(ctx context.Context, id string, status TodoStatus) error | ||
| // ListTodos 获取所有任务 | ||
| ListTodos(ctx context.Context) ([]Todo, error) | ||
| // ClearTodos 清空所有任务 | ||
| ClearTodos(ctx context.Context) error | ||
| // RemoveTodo 移除特定任务 | ||
| RemoveTodo(ctx context.Context, id string) error | ||
| } | ||
|
|
||
| // TodoRepository 定义任务清单存储接口 | ||
| type TodoRepository interface { | ||
| Add(ctx context.Context, todo Todo) (*Todo, error) | ||
| UpdateStatus(ctx context.Context, id string, status TodoStatus) error | ||
| List(ctx context.Context) ([]Todo, error) | ||
| Clear(ctx context.Context) error | ||
| Remove(ctx context.Context, id string) error | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里看上去写的更像是markdown?而不是 txt ?