diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-21 19:48:36 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-21 19:53:55 +0200 |
| commit | 3a6a26981a8074b6ab0eaadb520db986e04799ff (patch) | |
| tree | 4fe2c022305f13775f2cab3cdd80cd808259765b /internal/llm/tools | |
| parent | d7569d79c6da1437fe46343ed13810df6c8cae1f (diff) | |
| download | opencode-3a6a26981a8074b6ab0eaadb520db986e04799ff.tar.gz opencode-3a6a26981a8074b6ab0eaadb520db986e04799ff.zip | |
init command
Diffstat (limited to 'internal/llm/tools')
| -rw-r--r-- | internal/llm/tools/bash.go | 8 | ||||
| -rw-r--r-- | internal/llm/tools/edit.go | 3 | ||||
| -rw-r--r-- | internal/llm/tools/fetch.go | 6 | ||||
| -rw-r--r-- | internal/llm/tools/patch.go | 3 | ||||
| -rw-r--r-- | internal/llm/tools/write.go | 1 |
5 files changed, 20 insertions, 1 deletions
diff --git a/internal/llm/tools/bash.go b/internal/llm/tools/bash.go index 18533b761..a17506197 100644 --- a/internal/llm/tools/bash.go +++ b/internal/llm/tools/bash.go @@ -51,7 +51,7 @@ var safeReadOnlyCommands = []string{ "git status", "git log", "git diff", "git show", "git branch", "git tag", "git remote", "git ls-files", "git ls-remote", "git rev-parse", "git config --get", "git config --list", "git describe", "git blame", "git grep", "git shortlog", - "go version", "go list", "go env", "go doc", "go vet", "go fmt", "go mod", "go test", "go build", "go run", "go install", "go clean", + "go version", "go help", "go list", "go env", "go doc", "go vet", "go fmt", "go mod", "go test", "go build", "go run", "go install", "go clean", } func bashDescription() string { @@ -261,9 +261,15 @@ func (b *bashTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error) } } } + + sessionID, messageID := GetContextValues(ctx) + if sessionID == "" || messageID == "" { + return ToolResponse{}, fmt.Errorf("session ID and message ID are required for creating a new file") + } if !isSafeReadOnly { p := b.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: config.WorkingDirectory(), ToolName: BashToolName, Action: "execute", diff --git a/internal/llm/tools/edit.go b/internal/llm/tools/edit.go index 23c44399b..e2e257875 100644 --- a/internal/llm/tools/edit.go +++ b/internal/llm/tools/edit.go @@ -203,6 +203,7 @@ func (e *editTool) createNewFile(ctx context.Context, filePath, content string) } p := e.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: permissionPath, ToolName: EditToolName, Action: "write", @@ -313,6 +314,7 @@ func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string } p := e.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: permissionPath, ToolName: EditToolName, Action: "write", @@ -432,6 +434,7 @@ func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newS } p := e.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: permissionPath, ToolName: EditToolName, Action: "write", diff --git a/internal/llm/tools/fetch.go b/internal/llm/tools/fetch.go index 827755863..47ff03e57 100644 --- a/internal/llm/tools/fetch.go +++ b/internal/llm/tools/fetch.go @@ -116,8 +116,14 @@ func (t *fetchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error return NewTextErrorResponse("URL must start with http:// or https://"), nil } + sessionID, messageID := GetContextValues(ctx) + if sessionID == "" || messageID == "" { + return ToolResponse{}, fmt.Errorf("session ID and message ID are required for creating a new file") + } + p := t.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: config.WorkingDirectory(), ToolName: FetchToolName, Action: "fetch", diff --git a/internal/llm/tools/patch.go b/internal/llm/tools/patch.go index 903404497..7e20e378e 100644 --- a/internal/llm/tools/patch.go +++ b/internal/llm/tools/patch.go @@ -194,6 +194,7 @@ func (p *patchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error patchDiff, _, _ := diff.GenerateDiff("", *change.NewContent, path) p := p.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: dir, ToolName: PatchToolName, Action: "create", @@ -220,6 +221,7 @@ func (p *patchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error dir := filepath.Dir(path) p := p.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: dir, ToolName: PatchToolName, Action: "update", @@ -238,6 +240,7 @@ func (p *patchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error patchDiff, _, _ := diff.GenerateDiff(*change.OldContent, "", path) p := p.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: dir, ToolName: PatchToolName, Action: "delete", diff --git a/internal/llm/tools/write.go b/internal/llm/tools/write.go index 3a94b47b6..ec6fc1dc4 100644 --- a/internal/llm/tools/write.go +++ b/internal/llm/tools/write.go @@ -168,6 +168,7 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error } p := w.permissions.Request( permission.CreatePermissionRequest{ + SessionID: sessionID, Path: permissionPath, ToolName: WriteToolName, Action: "write", |
