tools.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. NewAgentTool(sessions, messages, lspClients),
  33. }, mcpTools...,
  34. )
  35. }
  36. func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool {
  37. return []tools.BaseTool{
  38. tools.NewGlobTool(),
  39. tools.NewGrepTool(),
  40. tools.NewLsTool(),
  41. tools.NewViewTool(lspClients),
  42. }
  43. }