UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

118 lines (100 loc) 4.77 kB
/** * Summarization Prompt Builder * * Builds prompts for summarizing conversation context into a 10-section structure. * Supports both initial summarization and incremental merging with existing summaries. */ const SUMMARY_SECTIONS = [ "Primary Request and Intent", "Key Technical Concepts", "Files and Code Sections", "Problem Solving", "Pending Tasks", "Task Evolution", "Current Work", "Next Step", "Required Files", "Constraints and Established Rules", ]; function buildFileContextSection(filesRead, filesModified) { const hasFiles = (filesRead && filesRead.length > 0) || (filesModified && filesModified.length > 0); if (!hasFiles) { return ""; } let section = "\n\nFile Context:\n"; if (filesRead && filesRead.length > 0) { section += "Files Read:\n"; for (const file of filesRead) { section += `- ${file}\n`; } } if (filesModified && filesModified.length > 0) { section += "Files Modified:\n"; for (const file of filesModified) { section += `- ${file}\n`; } } return section; } function buildInitialPrompt(options) { const fileContext = buildFileContextSection(options.filesRead, options.filesModified); return `You are a context summarization assistant. Your task is to analyze the conversation and create a structured summary following a 10-section format. Create a summary with the following sections: ### 1. Primary Request and Intent What is the user's main goal or request? What are they trying to accomplish? ### 2. Key Technical Concepts What technologies, frameworks, patterns, or concepts are central to this conversation? ### 3. Files and Code Sections What specific files, functions, or code sections have been discussed or modified? ### 4. Problem Solving What problems were identified? What solutions were attempted or implemented? ### 5. Pending Tasks What tasks remain incomplete or need follow-up? ### 6. Task Evolution How has the task changed or evolved during the conversation? ### 7. Current Work What is being actively worked on right now? ### 8. Next Step What is the immediate next action to take? ### 9. Required Files What files will need to be accessed or modified to continue? ### 10. Constraints and Established Rules What user-imposed constraints, behavioral directives, coding standards, agreed-upon decisions, or established rules must persist across the conversation? Include any "always do X", "never do Y", naming conventions, architectural patterns, or preferences the user has stated.${fileContext} IMPORTANT: Section 10 (Constraints and Established Rules) must ALWAYS be preserved in full. User constraints and established agreements are never "no longer relevant" — they remain in effect for the entire session unless the user explicitly revokes them. Analyze the conversation thoroughly and fill in each section with relevant information. If a section is not applicable, write "N/A" for that section.`; } function buildIncrementalPrompt(options) { const fileContext = buildFileContextSection(options.filesRead, options.filesModified); return `You are a context summarization assistant. Your task is to MERGE new conversation content with an existing summary. Existing Summary: --- ${options.previousSummary} --- Update sections with new information while preserving important context from the existing summary. Maintain the same 10-section structure. Instructions: 1. Review the existing summary above 2. Analyze the new conversation content 3. MERGE the new information into the appropriate sections 4. Update sections with relevant new information 5. Remove information that is no longer relevant EXCEPT for Section 10 (Constraints and Established Rules) — user constraints and established agreements must ALWAYS be preserved unless the user explicitly revoked them 6. Keep the summary concise but comprehensive 7. Maintain the 10-section format 8. Always carry forward ALL entries from Section 10 of the existing summary, adding any new constraints found in the new content${fileContext} Output the updated summary following the same 10-section structure.`; } /** * Builds a summarization prompt based on the provided options. * * @param options - Configuration for the prompt builder * @returns The constructed prompt string */ export function buildSummarizationPrompt(options) { // For incremental mode, we need a previous summary to merge with // If no previous summary is provided, fall back to initial prompt if (options.isIncremental && options.previousSummary) { return buildIncrementalPrompt(options); } return buildInitialPrompt(options); } export { SUMMARY_SECTIONS };