diff options
| author | adamdottv <[email protected]> | 2025-05-01 06:26:20 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-01 06:26:20 -0500 |
| commit | d08e58279db42b9892ad32e0fd8cdf086b4027d5 (patch) | |
| tree | e1f4b40f6afebfa46eaef6c863cc7d4d5ff1a4c6 /internal/llm | |
| parent | 7bc542abff85d18112b3e61556659a496d6dc668 (diff) | |
| download | opencode-d08e58279db42b9892ad32e0fd8cdf086b4027d5.tar.gz opencode-d08e58279db42b9892ad32e0fd8cdf086b4027d5.zip | |
feat: lsp discovery
Diffstat (limited to 'internal/llm')
| -rw-r--r-- | internal/llm/agent/tools.go | 1 | ||||
| -rw-r--r-- | internal/llm/tools/lsp.go | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/internal/llm/agent/tools.go b/internal/llm/agent/tools.go index e6b0119ae..df1dd1b66 100644 --- a/internal/llm/agent/tools.go +++ b/internal/llm/agent/tools.go @@ -35,6 +35,7 @@ func CoderAgentTools( tools.NewViewTool(lspClients), tools.NewPatchTool(lspClients, permissions, history), tools.NewWriteTool(lspClients, permissions, history), + tools.NewConfigureLspServerTool(), NewAgentTool(sessions, messages, lspClients), }, otherTools..., ) diff --git a/internal/llm/tools/lsp.go b/internal/llm/tools/lsp.go new file mode 100644 index 000000000..c2b4b04f3 --- /dev/null +++ b/internal/llm/tools/lsp.go @@ -0,0 +1,49 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/opencode-ai/opencode/internal/lsp/discovery/tool" +) + +// ConfigureLspServerTool is a tool for configuring LSP servers +type ConfigureLspServerTool struct{} + +// NewConfigureLspServerTool creates a new ConfigureLspServerTool +func NewConfigureLspServerTool() *ConfigureLspServerTool { + return &ConfigureLspServerTool{} +} + +// Info returns information about the tool +func (t *ConfigureLspServerTool) Info() ToolInfo { + return ToolInfo{ + Name: "configureLspServer", + Description: "Searches for an LSP server for the given language", + Parameters: map[string]any{ + "language": map[string]any{ + "type": "string", + "description": "The language identifier (e.g., \"go\", \"typescript\", \"python\")", + }, + }, + Required: []string{"language"}, + } +} + +// Run executes the tool +func (t *ConfigureLspServerTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error) { + result, err := tool.ConfigureLspServer(ctx, json.RawMessage(params.Input)) + if err != nil { + return NewTextErrorResponse(err.Error()), nil + } + + // Convert the result to JSON + resultJSON, err := json.MarshalIndent(result, "", " ") + if err != nil { + return NewTextErrorResponse(fmt.Sprintf("Failed to marshal result: %v", err)), nil + } + + return NewTextResponse(string(resultJSON)), nil +} + |
