tools.go 1.4 KB

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