librarian.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. ${READONLY_FILE_OPERATIONS_RULES}
  14. **Behavior**:
  15. - Provide evidence-based answers with sources
  16. - Quote relevant code snippets
  17. - Link to official docs when available
  18. - Distinguish between official and community patterns
  19. `;
  20. export function createLibrarianAgent(
  21. model: string,
  22. customPrompt?: string,
  23. customAppendPrompt?: string,
  24. ): AgentDefinition {
  25. let prompt = LIBRARIAN_PROMPT;
  26. if (customPrompt) {
  27. prompt = customPrompt;
  28. } else if (customAppendPrompt) {
  29. prompt = `${LIBRARIAN_PROMPT}\n\n${customAppendPrompt}`;
  30. }
  31. return {
  32. name: 'librarian',
  33. description:
  34. 'External documentation and library research. Use for official docs lookup, GitHub examples, and understanding library internals.',
  35. config: {
  36. model,
  37. temperature: 0.1,
  38. prompt,
  39. },
  40. };
  41. }