tools.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package agent
  2. import (
  3. "context"
  4. "github.com/sst/opencode/internal/history"
  5. "github.com/sst/opencode/internal/llm/tools"
  6. "github.com/sst/opencode/internal/lsp"
  7. "github.com/sst/opencode/internal/message"
  8. "github.com/sst/opencode/internal/permission"
  9. "github.com/sst/opencode/internal/session"
  10. )
  11. func PrimaryAgentTools(
  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. mcpTools := GetMcpTools(ctx, permissions)
  20. return append(
  21. []tools.BaseTool{
  22. tools.NewBashTool(permissions),
  23. tools.NewEditTool(lspClients, permissions, history),
  24. tools.NewFetchTool(permissions),
  25. tools.NewGlobTool(),
  26. tools.NewGrepTool(),
  27. tools.NewLsTool(),
  28. tools.NewViewTool(lspClients),
  29. tools.NewPatchTool(lspClients, permissions, history),
  30. tools.NewWriteTool(lspClients, permissions, history),
  31. tools.NewDiagnosticsTool(lspClients),
  32. tools.NewDefinitionTool(lspClients),
  33. tools.NewReferencesTool(lspClients),
  34. tools.NewDocSymbolsTool(lspClients),
  35. tools.NewWorkspaceSymbolsTool(lspClients),
  36. tools.NewCodeActionTool(lspClients),
  37. NewAgentTool(sessions, messages, lspClients),
  38. }, mcpTools...,
  39. )
  40. }
  41. func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool {
  42. return []tools.BaseTool{
  43. tools.NewGlobTool(),
  44. tools.NewGrepTool(),
  45. tools.NewLsTool(),
  46. tools.NewViewTool(lspClients),
  47. tools.NewDefinitionTool(lspClients),
  48. tools.NewReferencesTool(lspClients),
  49. tools.NewDocSymbolsTool(lspClients),
  50. tools.NewWorkspaceSymbolsTool(lspClients),
  51. }
  52. }