diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-03 15:20:15 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-03 17:23:41 +0200 |
| commit | cfdd687216799cb5b47f099f1e7cd5dd16b3bdd0 (patch) | |
| tree | a822bfde1463a7080c0ea06dd17796d7a1617d3d /internal/llm/tools/write.go | |
| parent | afd9ad0560d76c2a6d161dad52553b10ff428905 (diff) | |
| download | opencode-cfdd687216799cb5b47f099f1e7cd5dd16b3bdd0.tar.gz opencode-cfdd687216799cb5b47f099f1e7cd5dd16b3bdd0.zip | |
add initial lsp support
Diffstat (limited to 'internal/llm/tools/write.go')
| -rw-r--r-- | internal/llm/tools/write.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/llm/tools/write.go b/internal/llm/tools/write.go index 003753d08..3d66d64e2 100644 --- a/internal/llm/tools/write.go +++ b/internal/llm/tools/write.go @@ -9,10 +9,13 @@ import ( "time" "github.com/kujtimiihoxha/termai/internal/config" + "github.com/kujtimiihoxha/termai/internal/lsp" "github.com/kujtimiihoxha/termai/internal/permission" ) -type writeTool struct{} +type writeTool struct { + lspClients map[string]*lsp.Client +} const ( WriteToolName = "write" @@ -96,6 +99,8 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error if err = os.MkdirAll(dir, 0o755); err != nil { return NewTextErrorResponse(fmt.Sprintf("Failed to create parent directories: %s", err)), nil } + + notifyLspOpenFile(ctx, filePath, w.lspClients) p := permission.Default.Request( permission.CreatePermissionRequest{ Path: filePath, @@ -122,7 +127,10 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error recordFileWrite(filePath) recordFileRead(filePath) - return NewTextResponse(fmt.Sprintf("File successfully written: %s", filePath)), nil + result := fmt.Sprintf("File successfully written: %s", filePath) + result = fmt.Sprintf("<result>\n%s\n</result>", result) + result += appendDiagnostics(filePath, w.lspClients) + return NewTextResponse(result), nil } func writeDescription() string { @@ -156,6 +164,8 @@ TIPS: - Always include descriptive comments when making changes to existing code` } -func NewWriteTool() BaseTool { - return &writeTool{} +func NewWriteTool(lspClients map[string]*lsp.Client) BaseTool { + return &writeTool{ + lspClients, + } } |
