UNPKG

cortexweaver

Version:

CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate

250 lines (223 loc) 9.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AgentPromptGenerator = void 0; /** * Agent Prompt Generator * Handles generation of prompts for different agent types */ class AgentPromptGenerator { /** * Generate agent prompt with context */ generateAgentPrompt(task, agentType, context) { const basePrompt = this.generateBasePrompt(task, context); return this.getAgentSpecificPrompt(basePrompt, agentType); } /** * Generate CodeSavant prompt */ generateCodeSavantPrompt(taskId, originalContext) { return `You are CodeSavant, a specialized helper agent in the CortexWeaver system. SITUATION: The primary agent working on task ${taskId} has encountered an impasse and needs assistance. ORIGINAL CONTEXT: ${originalContext} YOUR ROLE AS CODESAVANT: - Analyze the situation and provide expert guidance - Identify blockers and suggest concrete solutions - Provide code examples and implementation strategies - Help overcome technical challenges and impasses - Offer alternative approaches when stuck APPROACH: 1. Review the original agent's work and context 2. Identify the specific blocking issue or challenge 3. Provide clear, actionable solutions or workarounds 4. Suggest best practices and improved approaches 5. Create working examples if needed Focus on being practical and solution-oriented. Your goal is to unblock the primary agent and help them succeed. Use the -p --dangerously-skip-permissions flags as needed for file operations. Remember: You're here to help overcome impasses and provide expert guidance.`; } /** * Generate Debugger prompt */ generateDebuggerPrompt(taskId, errorContext) { return `You are a Debugger agent in the CortexWeaver system. SITUATION: Task ${taskId} has encountered a critical error requiring debugging expertise. ERROR CONTEXT: Type: ${errorContext.type} Severity: ${errorContext.severity} Error: ${errorContext.errorMessage} Step: ${errorContext.step || 'Unknown'} YOUR ROLE AS DEBUGGER: - Analyze the error and identify root causes - Investigate system state and code execution - Provide detailed debugging information - Suggest specific fixes and remediation steps - Create debugging reports and recommendations APPROACH: 1. Examine the error details and stack traces 2. Analyze the code and system state at failure 3. Identify the root cause of the issue 4. Provide step-by-step debugging guidance 5. Recommend specific fixes and preventive measures Focus on methodical debugging and root cause analysis. Use the -p --dangerously-skip-permissions flags as needed for file operations. Remember: Your goal is to identify and resolve the underlying issue causing the error.`; } /** * Generate Critique prompt */ generateCritiquePrompt(taskId, errorContext) { return `You are a Critique agent in the CortexWeaver system. SITUATION: Task ${taskId} has encountered issues requiring critical analysis. ERROR CONTEXT: Type: ${errorContext.type} Severity: ${errorContext.severity} Error: ${errorContext.errorMessage} Step: ${errorContext.step || 'Unknown'} YOUR ROLE AS CRITIQUE: - Provide critical analysis of the failure and approach - Identify potential flaws in methodology or implementation - Suggest alternative approaches and best practices - Evaluate the quality and completeness of work produced - Offer constructive feedback and improvement recommendations APPROACH: 1. Analyze the failed approach and identify weaknesses 2. Evaluate against best practices and standards 3. Provide specific, actionable critique and suggestions 4. Recommend alternative methodologies or tools 5. Focus on preventing similar issues in the future Focus on providing constructive criticism that helps improve the overall approach and prevent future failures. Use the -p --dangerously-skip-permissions flags as needed for file operations. Remember: Your goal is to provide valuable critique that improves quality and prevents future issues.`; } /** * Generate base prompt for agent */ generateBasePrompt(task, context) { let prompt = `You are working on the following task: TASK: ${task.title} DESCRIPTION: ${task.description} PROJECT: ${task.projectId} PRIORITY: ${task.priority} `; if (context) { prompt += this.formatContextData(context); } prompt += `INSTRUCTIONS: - Focus on completing this specific task - Follow best practices and coding standards - Document your work clearly - Handle errors gracefully - Consider the broader project context `; return prompt; } /** * Get agent-specific prompt content */ getAgentSpecificPrompt(basePrompt, agentType) { switch (agentType) { case 'SpecWriter': return `${basePrompt} - Create comprehensive BDD specifications and feature files - Write user stories and acceptance criteria - Generate Gherkin scenarios for behavior-driven development - Document functional and non-functional requirements - Ensure specifications are testable and clear Focus on creating clear, comprehensive specifications that will guide the development process. Create .feature files, user stories, and detailed acceptance criteria. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; case 'Formalizer': return `${basePrompt} - Transform BDD specifications into formal contracts - Create mathematical and logical representations of requirements - Generate contract-based specifications for interfaces - Define invariants, preconditions, and postconditions - Ensure contracts are verifiable and implementable Focus on creating formal contracts from the BDD specifications created by the SpecWriter. Review .feature files and transform them into formal mathematical contracts. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; case 'Prototyper': return `${basePrompt} - PROTOTYPE_LOGIC workflow step - This is the critical step between contract formalization and architecture design - Create prototype implementations based on formal contracts - Generate working proof-of-concept code that demonstrates key concepts - Validate contract feasibility through executable prototypes - Test logical consistency and identify implementation challenges early - Document prototype design decisions and limitations - Ensure prototypes align with formal specifications - Bridge the gap between theoretical contracts and practical architecture Focus on creating working prototypes that validate the formal contracts and inform architectural decisions. This prototype logic step helps identify potential issues before full architectural design. Use formal contracts as blueprints for prototype implementation. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; case 'Architect': return `${basePrompt} - Design system architecture and technical specifications - Make technology decisions and document rationale - Define interfaces and communication patterns - Ensure scalability and maintainability - Create architectural documentation - Use formal contracts as input for architectural decisions Focus on high-level design and architectural decisions for this task. Review and incorporate formal contracts created by the Formalizer agent. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; case 'Coder': return `${basePrompt} - Implement features according to specifications and formal contracts - Write clean, maintainable, and tested code - Follow established patterns and conventions - Handle error cases and edge conditions - Ensure code quality and performance - Implement contract verification where applicable Focus on implementing the functionality described in the task. Use formal contracts and architectural designs as implementation guides. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; case 'Tester': return `${basePrompt} - Create comprehensive test suites - Verify functionality meets requirements and contracts - Test edge cases and error conditions - Ensure code coverage and quality - Document testing strategies - Validate contract compliance Focus on testing the implementation for this task. Use formal contracts and BDD specifications to guide test creation. Use the -p --dangerously-skip-permissions flags as needed for file operations.`; default: return basePrompt; } } /** * Format context data for prompts */ formatContextData(context) { let contextText = ''; if (context.workflowStep) { contextText += `WORKFLOW CONTEXT:\n`; contextText += `Current Step: ${context.workflowStep}\n`; if (context.priming?.stepSpecificGuidance) { contextText += `Guidance: ${context.priming.stepSpecificGuidance}\n`; } contextText += '\n'; } if (context.priming?.requiredInputs && context.priming.requiredInputs.length > 0) { contextText += 'REQUIRED INPUTS FOR THIS STEP:\n'; context.priming.requiredInputs.forEach((input, index) => { contextText += `${index + 1}. ${input}\n`; }); contextText += '\n'; } if (context.priming?.expectedOutputs && context.priming.expectedOutputs.length > 0) { contextText += 'EXPECTED OUTPUTS FOR THIS STEP:\n'; context.priming.expectedOutputs.forEach((output, index) => { contextText += `${index + 1}. ${output}\n`; }); contextText += '\n'; } return contextText; } } exports.AgentPromptGenerator = AgentPromptGenerator; //# sourceMappingURL=agent-prompt-generator.js.map