tools.go

 1package agent
 2
 3import (
 4	"context"
 5
 6	"github.com/kujtimiihoxha/opencode/internal/history"
 7	"github.com/kujtimiihoxha/opencode/internal/llm/tools"
 8	"github.com/kujtimiihoxha/opencode/internal/lsp"
 9	"github.com/kujtimiihoxha/opencode/internal/message"
10	"github.com/kujtimiihoxha/opencode/internal/permission"
11	"github.com/kujtimiihoxha/opencode/internal/session"
12)
13
14func CoderAgentTools(
15	permissions permission.Service,
16	sessions session.Service,
17	messages message.Service,
18	history history.Service,
19	lspClients map[string]*lsp.Client,
20) []tools.BaseTool {
21	ctx := context.Background()
22	otherTools := GetMcpTools(ctx, permissions)
23	if len(lspClients) > 0 {
24		otherTools = append(otherTools, tools.NewDiagnosticsTool(lspClients))
25	}
26	return append(
27		[]tools.BaseTool{
28			tools.NewBashTool(permissions),
29			tools.NewEditTool(lspClients, permissions, history),
30			tools.NewFetchTool(permissions),
31			tools.NewGlobTool(),
32			tools.NewGrepTool(),
33			tools.NewLsTool(),
34			// TODO: see if we want to use this tool
35			// tools.NewPatchTool(lspClients, permissions, history),
36			tools.NewSourcegraphTool(),
37			tools.NewViewTool(lspClients),
38			tools.NewWriteTool(lspClients, permissions, history),
39			NewAgentTool(sessions, messages, lspClients),
40		}, otherTools...,
41	)
42}
43
44func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool {
45	return []tools.BaseTool{
46		tools.NewGlobTool(),
47		tools.NewGrepTool(),
48		tools.NewLsTool(),
49		tools.NewSourcegraphTool(),
50		tools.NewViewTool(lspClients),
51	}
52}