mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-30 05:29:53 +00:00
handle errors correctly in the other tools
This commit is contained in:
parent
921f5ee5bd
commit
0b3e5f5bd4
8 changed files with 72 additions and 26 deletions
|
|
@ -27,8 +27,9 @@ type EditPermissionsParams struct {
|
|||
}
|
||||
|
||||
type EditResponseMetadata struct {
|
||||
Additions int `json:"additions"`
|
||||
Removals int `json:"removals"`
|
||||
Diff string `json:"diff"`
|
||||
Additions int `json:"additions"`
|
||||
Removals int `json:"removals"`
|
||||
}
|
||||
|
||||
type editTool struct {
|
||||
|
|
@ -216,6 +217,7 @@ func (e *editTool) createNewFile(ctx context.Context, filePath, content string)
|
|||
return WithResponseMetadata(
|
||||
NewTextResponse("File created: "+filePath),
|
||||
EditResponseMetadata{
|
||||
Diff: diff,
|
||||
Additions: stats.Additions,
|
||||
Removals: stats.Removals,
|
||||
},
|
||||
|
|
@ -308,6 +310,7 @@ func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string
|
|||
return WithResponseMetadata(
|
||||
NewTextResponse("Content deleted from file: "+filePath),
|
||||
EditResponseMetadata{
|
||||
Diff: diff,
|
||||
Additions: stats.Additions,
|
||||
Removals: stats.Removals,
|
||||
},
|
||||
|
|
@ -401,6 +404,7 @@ func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newS
|
|||
return WithResponseMetadata(
|
||||
NewTextResponse("Content replaced in file: "+filePath),
|
||||
EditResponseMetadata{
|
||||
Diff: diff,
|
||||
Additions: stats.Additions,
|
||||
Removals: stats.Removals,
|
||||
}), nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue