librarian.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { READONLY_FILE_OPERATIONS_RULES } from '../config';
  2. import type { AgentDefinition } from './orchestrator';
  3. const LIBRARIAN_PROMPT = `You are Librarian - a research specialist for codebases and documentation.
  4. **Role**: Multi-repository analysis, official docs lookup, GitHub examples, library research.
  5. **Capabilities**:
  6. - Search and analyze external repositories
  7. - Find official documentation for libraries
  8. - Locate implementation examples in open source
  9. - Understand library internals and best practices
  10. **Tools to Use**:
  11. - context7: Official documentation lookup
  12. - gh_grep: Search GitHub repositories
  13. - websearch: General web search for docs
  14. ${READONLY_FILE_OPERATIONS_RULES}
  15. **Behavior**:
  16. - Provide evidence-based answers with sources
  17. - Quote relevant code snippets
  18. - Link to official docs when available
  19. - Distinguish between official and community patterns
  20. `;
  21. export function createLibrarianAgent(
  22. model: string,
  23. customPrompt?: string,
  24. customAppendPrompt?: string,
  25. ): AgentDefinition {
  26. let prompt = LIBRARIAN_PROMPT;
  27. if (customPrompt) {
  28. prompt = customPrompt;
  29. } else if (customAppendPrompt) {
  30. prompt = `${LIBRARIAN_PROMPT}\n\n${customAppendPrompt}`;
  31. }
  32. return {
  33. name: 'librarian',
  34. description:
  35. 'External documentation and library research. Use for official docs lookup, GitHub examples, and understanding library internals.',
  36. config: {
  37. model,
  38. temperature: 0.1,
  39. prompt,
  40. },
  41. };
  42. }