diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-21 14:29:03 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-21 14:29:28 +0200 |
| commit | a8d5787e8ef561037f73b669128f46ae1b1e8553 (patch) | |
| tree | b606adbc85069d60cc518c74508a7ecbc87c051b /internal/llm | |
| parent | 9ae6af8856ca6a13d575ec6a8989a5f6ee4297b1 (diff) | |
| download | opencode-a8d5787e8ef561037f73b669128f46ae1b1e8553.tar.gz opencode-a8d5787e8ef561037f73b669128f46ae1b1e8553.zip | |
config validation
Diffstat (limited to 'internal/llm')
| -rw-r--r-- | internal/llm/agent/agent.go | 2 | ||||
| -rw-r--r-- | internal/llm/tools/edit.go | 27 | ||||
| -rw-r--r-- | internal/llm/tools/write.go | 11 |
3 files changed, 31 insertions, 9 deletions
diff --git a/internal/llm/agent/agent.go b/internal/llm/agent/agent.go index ae5bcb231..6c5808eab 100644 --- a/internal/llm/agent/agent.go +++ b/internal/llm/agent/agent.go @@ -471,7 +471,7 @@ func createAgentProvider(agentName config.AgentName) (provider.Provider, error) provider.WithReasoningEffort(agentConfig.ReasoningEffort), ), ) - } else if model.Provider == models.ProviderAnthropic && model.CanReason { + } else if model.Provider == models.ProviderAnthropic && model.CanReason && agentName == config.AgentCoder { opts = append( opts, provider.WithAnthropicOptions( diff --git a/internal/llm/tools/edit.go b/internal/llm/tools/edit.go index b7b813ca7..23c44399b 100644 --- a/internal/llm/tools/edit.go +++ b/internal/llm/tools/edit.go @@ -196,11 +196,16 @@ func (e *editTool) createNewFile(ctx context.Context, filePath, content string) content, filePath, ) + rootDir := config.WorkingDirectory() + permissionPath := filepath.Dir(filePath) + if strings.HasPrefix(filePath, rootDir) { + permissionPath = rootDir + } p := e.permissions.Request( permission.CreatePermissionRequest{ - Path: filepath.Dir(filePath), + Path: permissionPath, ToolName: EditToolName, - Action: "create", + Action: "write", Description: fmt.Sprintf("Create file %s", filePath), Params: EditPermissionsParams{ FilePath: filePath, @@ -301,11 +306,16 @@ func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string filePath, ) + rootDir := config.WorkingDirectory() + permissionPath := filepath.Dir(filePath) + if strings.HasPrefix(filePath, rootDir) { + permissionPath = rootDir + } p := e.permissions.Request( permission.CreatePermissionRequest{ - Path: filepath.Dir(filePath), + Path: permissionPath, ToolName: EditToolName, - Action: "delete", + Action: "write", Description: fmt.Sprintf("Delete content from file %s", filePath), Params: EditPermissionsParams{ FilePath: filePath, @@ -415,11 +425,16 @@ func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newS newContent, filePath, ) + rootDir := config.WorkingDirectory() + permissionPath := filepath.Dir(filePath) + if strings.HasPrefix(filePath, rootDir) { + permissionPath = rootDir + } p := e.permissions.Request( permission.CreatePermissionRequest{ - Path: filepath.Dir(filePath), + Path: permissionPath, ToolName: EditToolName, - Action: "replace", + Action: "write", Description: fmt.Sprintf("Replace content in file %s", filePath), Params: EditPermissionsParams{ FilePath: filePath, diff --git a/internal/llm/tools/write.go b/internal/llm/tools/write.go index 2b3fa3dd0..3a94b47b6 100644 --- a/internal/llm/tools/write.go +++ b/internal/llm/tools/write.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" "github.com/kujtimiihoxha/opencode/internal/config" @@ -159,11 +160,17 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error params.Content, filePath, ) + + rootDir := config.WorkingDirectory() + permissionPath := filepath.Dir(filePath) + if strings.HasPrefix(filePath, rootDir) { + permissionPath = rootDir + } p := w.permissions.Request( permission.CreatePermissionRequest{ - Path: filePath, + Path: permissionPath, ToolName: WriteToolName, - Action: "create", + Action: "write", Description: fmt.Sprintf("Create file %s", filePath), Params: WritePermissionsParams{ FilePath: filePath, |
