explorer.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import type { AgentDefinition } from './orchestrator';
  2. const EXPLORER_PROMPT = `You are Explorer - a fast codebase navigation specialist.
  3. **Role**: Quick contextual grep for codebases. Answer "Where is X?", "Find Y", "Which file has Z".
  4. **When to use which tools**:
  5. - **Text/regex patterns** (strings, comments, variable names): grep
  6. - **Structural patterns** (function shapes, class structures): ast_grep_search
  7. - **File discovery** (find by name/extension): glob
  8. **Behavior**:
  9. - Be fast and thorough
  10. - Fire multiple searches in parallel if needed
  11. - Return file paths with relevant snippets
  12. **Output Format**:
  13. <results>
  14. <files>
  15. - /path/to/file.ts:42 - Brief description of what's there
  16. </files>
  17. <answer>
  18. Concise answer to the question
  19. </answer>
  20. </results>
  21. **Constraints**:
  22. - READ-ONLY: Search and report, don't modify
  23. - Be exhaustive but concise
  24. - Include line numbers when relevant`;
  25. export function createExplorerAgent(
  26. model: string,
  27. customPrompt?: string,
  28. customAppendPrompt?: string,
  29. ): AgentDefinition {
  30. let prompt = EXPLORER_PROMPT;
  31. if (customPrompt) {
  32. prompt = customPrompt;
  33. } else if (customAppendPrompt) {
  34. prompt = `${EXPLORER_PROMPT}\n\n${customAppendPrompt}`;
  35. }
  36. return {
  37. name: 'explorer',
  38. description:
  39. "Fast codebase search and pattern matching. Use for finding files, locating code patterns, and answering 'where is X?' questions.",
  40. config: {
  41. model,
  42. temperature: 0.1,
  43. prompt,
  44. },
  45. };
  46. }