explorer.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. `;
  26. export function createExplorerAgent(
  27. model: string,
  28. customPrompt?: string,
  29. customAppendPrompt?: string,
  30. ): AgentDefinition {
  31. let prompt = EXPLORER_PROMPT;
  32. if (customPrompt) {
  33. prompt = customPrompt;
  34. } else if (customAppendPrompt) {
  35. prompt = `${EXPLORER_PROMPT}\n\n${customAppendPrompt}`;
  36. }
  37. return {
  38. name: 'explorer',
  39. description:
  40. "Fast codebase search and pattern matching. Use for finding files, locating code patterns, and answering 'where is X?' questions.",
  41. config: {
  42. model,
  43. temperature: 0.1,
  44. prompt,
  45. },
  46. };
  47. }