-
Notifications
You must be signed in to change notification settings - Fork 22
refactor: 移除过度防御代码 (#45) #46
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ type writeArgs struct { | |
| Path string `json:"path"` | ||
| Content string `json:"content"` | ||
| Append bool `json:"append,omitempty"` | ||
| Create bool `json:"create,omitempty"` | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
维护风险:当前结构体与 schema/运行时的不一致意味着,按照「参数应在 |
||
| } | ||
|
|
||
| func NewWriteTool(root string) *WriteTool { | ||
|
|
@@ -73,10 +72,8 @@ func (t *WriteTool) Execute(_ context.Context, invocation Invocation) (Result, e | |
| } | ||
|
|
||
| create := true | ||
| if invocation.ParsedArgs != nil { | ||
| if v, ok := invocation.ParsedArgs["create"].(bool); ok { | ||
| create = v | ||
| } | ||
| if v, ok := invocation.ParsedArgs["create"].(bool); ok { | ||
| create = v | ||
| } | ||
|
|
||
| return t.write(target, args.Content, args.Append, create) | ||
|
|
||
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.
删除
replacedCount后,replaced_count与total_found现在始终相同(均为count)。今日行为正确——第 94 行守卫保证
!all时count == 1。但若未来允许「有多个匹配时仅替换第一个」,replaced_count将报告错误值(实际替换 1 次,却显示全部匹配数)。建议保留replacedCount以区分两字段的语义,或明确删除其中一个以消除歧义。