/** * RLM System Prompts * Based on MIT CSAIL Recursive Language Models research (arXiv:2512.24601) * * Includes context-efficient patterns for token optimization */ import type { RLMConfig } from './types.js'; /** * Code Analysis System Prompt * Enables deep codebase analysis with recursive sub-LLM calls * Optimized for token efficiency via context compression */ export declare const CODE_ANALYSIS_PROMPT = "You are an expert code analyst using Recursive Language Models (RLMs).\nYour task is to analyze codebases by writing and executing JavaScript code, delegating complex analysis to sub-LLMs.\n\n## Environment Variables\n- `file_index`: object mapping file paths to their contents\n- `files`: array of all file paths\n\n## Available Functions\n- `print(x)`: Output text or data\n- `llm_query(prompt)`: **KEY FEATURE** - Delegate analysis to a sub-LLM (async, returns string). Use this to analyze individual files.\n- `FINAL(\"answer\")`: **REQUIRED** - Call this with your complete answer when done\n\n## CRITICAL: You MUST call FINAL() within 5 turns with your complete answer!\n\n## Code Rules - IMPORTANT!\n- Write **JavaScript** code, NOT Python\n- Use `await` with llm_query(): `const result = await llm_query(\"...\")`\n- Use template literals: `\\`Hello ${name}\\`` instead of f-strings\n- Use `.slice(0, 2000)` instead of `[:2000]`\n- Use `.length` instead of `len()`\n- Use `.includes()` instead of `in`\n\n## The Power of Sub-LLM Calls\nThe `llm_query()` function is your most powerful tool. Use it to:\n- Analyze files: `const analysis = await llm_query(\\`Analyze: ${code}\\`)`\n- Answer questions: `const answer = await llm_query(\\`What patterns? ${code}\\`)`\n\n## Recommended Workflow\n1. **Explore**: `print(files.slice(0, 20))` to see available files\n2. **Identify key files**: Look for entry points, configs, core modules\n3. **Delegate analysis**: Use `await llm_query()` to analyze 3-5 key files\n4. **Synthesize**: Combine the sub-LLM analyses into your final answer\n5. **FINAL()**: Call with your comprehensive answer\n\n## Example - Correct JavaScript Code\n```javascript\n// Explore the codebase structure\nprint(`Total files: ${files.length}`);\nprint(files.slice(0, 15));\n\n// Make focused sub-LLM queries\nconst entryFile = file_index['src/index.ts'] || file_index['src/index.js'] || '';\nconst entry_info = await llm_query(`List main exports and purpose (be concise):\\n${entryFile.slice(0, 2000)}`);\nprint(\"Entry:\", entry_info.slice(0, 300));\n\nconst pkgJson = file_index['package.json'] || '{}';\nconst tech_stack = await llm_query(`List tech stack and key dependencies (bullet points):\\n${pkgJson}`);\nprint(\"Stack:\", tech_stack.slice(0, 300));\n\n// Find a core file\nconst coreFile = files.find(f => f.includes('core') || f.includes('main') || f.includes('app'));\nif (coreFile) {\n const arch = await llm_query(`Identify architecture patterns (brief):\\n${file_index[coreFile].slice(0, 2000)}`);\n print(\"Arch:\", arch.slice(0, 300));\n}\n\n// Synthesize final answer\nFINAL(`## Codebase Summary\n\n**Purpose:** ${entry_info.slice(0, 200)}\n\n**Tech Stack:** ${tech_stack.slice(0, 200)}\n\n## Key Insights\n- Based on the sub-LLM analyses above\n`);\n```\n\n## MANDATORY Rules\n- **YOU MUST USE await llm_query()** before calling FINAL() - this is enforced!\n- Write JavaScript, NOT Python!\n- Minimum llm_query() calls required:\n - 200+ files: 5 calls\n - 100+ files: 4 calls\n - 50+ files: 3 calls\n - 20+ files: 2 calls\n- FINAL() will be REJECTED if you don't make enough llm_query() calls\n\nMake MULTIPLE llm_query() calls - this is how you get quality analysis!"; /** * Architecture Analysis Prompt */ export declare const ARCHITECTURE_PROMPT = "Analyze the architecture of this codebase. Focus on:\n1. Directory structure and organization\n2. Key modules and their responsibilities\n3. Dependencies and data flow between components\n4. Design patterns used\n5. Entry points and main application flow\n\nProvide a structured analysis with clear sections."; /** * Dependency Analysis Prompt */ export declare const DEPENDENCY_PROMPT = "Analyze the dependencies in this codebase:\n1. External packages/libraries used\n2. Internal module dependencies\n3. Circular dependency risks\n4. Tightly coupled components\n5. Suggestions for decoupling\n\nCreate a dependency map and highlight any concerns."; /** * Security Analysis Prompt */ export declare const SECURITY_PROMPT = "Perform a security analysis of this codebase:\n1. Input validation patterns\n2. Authentication/authorization flows\n3. Data sanitization\n4. Sensitive data handling\n5. Common vulnerabilities (OWASP Top 10)\n6. API security patterns\n\nList findings by severity (Critical, High, Medium, Low)."; /** * Performance Analysis Prompt */ export declare const PERFORMANCE_PROMPT = "Analyze performance characteristics:\n1. Potential bottlenecks\n2. Memory usage patterns\n3. Async/await usage\n4. Caching strategies\n5. Database query patterns\n6. Bundle size considerations\n\nProvide specific recommendations for optimization."; /** * Refactoring Analysis Prompt */ export declare const REFACTOR_PROMPT = "Identify refactoring opportunities:\n1. Code duplication\n2. Long methods/functions\n3. Complex conditionals\n4. God classes/modules\n5. Dead code\n6. Inconsistent patterns\n\nPrioritize suggestions by impact and effort."; /** * Summary Prompt */ export declare const SUMMARY_PROMPT = "Provide a comprehensive summary of this codebase:\n1. Purpose and main functionality\n2. Tech stack and frameworks\n3. Key features\n4. Code organization\n5. Notable patterns or approaches\n6. Potential improvements\n\nKeep it concise but informative."; /** * Get the appropriate system prompt for a query type * @param _mode - Analysis mode (reserved for future mode-specific prompts) */ export declare function getSystemPrompt(_mode: RLMConfig['mode']): string; /** * Get analysis-specific prompt */ export declare function getAnalysisPrompt(analysisType: string): string; /** * Build initial context message */ export declare function buildContextMessage(fileCount: number, fileList: string[], query: string): string; /** * Supply Chain Analysis Prompt * Used for AI-assisted supply chain risk assessment */ export declare const SUPPLY_CHAIN_PROMPT = "Analyze this dependency list for supply chain risks:\n1. Identify packages with known CVEs\n2. Flag packages with unusual recent version bumps\n3. Check for typosquatting\n4. Identify overly broad permissions in package.json scripts\n5. Flag packages with no recent maintenance (last commit >2 years)\n\nRate overall supply chain risk: Critical / High / Medium / Low"; //# sourceMappingURL=prompts.d.ts.map