tools.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. tools.NewConfigureLspServerTool(),
  36. NewAgentTool(sessions, messages, lspClients),
  37. }, otherTools...,
  38. )
  39. }
  40. func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool {
  41. return []tools.BaseTool{
  42. tools.NewGlobTool(),
  43. tools.NewGrepTool(),
  44. tools.NewLsTool(),
  45. tools.NewSourcegraphTool(),
  46. tools.NewViewTool(lspClients),
  47. }
  48. }