librarian.ts 1.3 KB

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