UNPKG

mcp-product-manager

Version:

MCP Orchestrator for task and project management with web interface

157 lines (139 loc) 7.1 kB
// feedbackTemplates.js - Automatic feedback collection templates // Generates bug reports and feedback requests with metadata export function generateErrorFeedbackTask(errorContext) { const { errorType = 'unknown', errorMessage = 'No error message provided', toolName = 'unknown_tool', project = 'unknown_project', model = 'unknown_model', endpoint = 'unknown_endpoint', stackTrace = null, requestData = null, agent = 'system', severity = 'medium' } = errorContext; const taskId = `SUGG-ERROR-${Date.now().toString().slice(-6)}`; const bugReportDescription = `[${taskId}] ${errorType} in ${toolName}: ${errorMessage.substring(0, 100)}`; const detailedContext = ` **🛑 AUTOMATIC ERROR REPORT 🛑** **Error Details:** - **Error Type**: ${errorType} - **Error Message**: ${errorMessage} - **Tool/Endpoint**: ${toolName} (${endpoint}) - **Severity**: ${severity} **Context Metadata:** - **Project**: ${project} - **Model**: ${model} - **Agent**: ${agent} - **Timestamp**: ${new Date().toISOString()} **Request Information:** ${requestData ? `- **Request Data**: \`\`\`json\n${JSON.stringify(requestData, null, 2)}\n\`\`\`` : '- **Request Data**: Not captured'} ${stackTrace ? `**Stack Trace:**\n\`\`\`\n${stackTrace}\n\`\`\`` : ''} **Reproduction Steps:** 1. Call ${toolName} with the above request data 2. Error occurs immediately/during processing 3. System returns error response **Expected Behavior**: Tool should complete successfully without errors **Actual Behavior**: ${errorMessage} **Impact**: This error prevents agents from completing their tasks and requires immediate attention. **Development Area**: suggestions_improvements **Priority**: ${severity} **Auto-Generated**: true `; return { project: 'claude-workflow', description: bugReportDescription, priority: severity === 'critical' ? 'critical' : severity === 'high' ? 'high' : 'medium', category: 'bug', technical_context: detailedContext, success_criteria: `Error resolved and ${toolName} works reliably`, implementation_guide: `1. Investigate ${toolName} implementation\n2. Fix root cause of ${errorType}\n3. Add error handling if needed\n4. Test thoroughly\n5. Update documentation if required`, task_group: 'error_handling', model: 'sonnet', // Bug fixes typically don't need OPUS handoff_notes: `Auto-generated from ${model} agent error in ${project} project` }; } export function generateFeedbackTask(feedbackContext) { const { feedbackType = 'improvement_suggestion', toolName = 'unknown_tool', project = 'unknown_project', model = 'unknown_model', agent = 'system', currentBehavior = 'Not specified', suggestedImprovement = 'Not specified', missingInformation = 'Not specified', userExperience = 'Not specified', priority = 'low', endpoint = 'unknown_endpoint' } = feedbackContext; const taskId = `SUGG-FDBK-${Date.now().toString().slice(-6)}`; const feedbackDescription = `[${taskId}] ${feedbackType} for ${toolName}: ${suggestedImprovement.substring(0, 80)}`; const detailedFeedback = ` **💡 AGENT FEEDBACK REQUEST 💡** **Feedback Type**: ${feedbackType} **Tool/Endpoint**: ${toolName} (${endpoint}) **Agent Context:** - **Project**: ${project} - **Model**: ${model} - **Agent**: ${agent} - **Timestamp**: ${new Date().toISOString()} **Current Experience:** ${currentBehavior} **Suggested Improvement:** ${suggestedImprovement} **Missing Information:** ${missingInformation} **User Experience Impact:** ${userExperience} **Why This Matters:** Agents need clear, complete information to work effectively. This feedback helps improve the claude-workflow system for all users. **Development Area**: suggestions_improvements **Priority**: ${priority} **Auto-Generated**: false (Agent-initiated feedback) `; return { project: 'claude-workflow', description: feedbackDescription, priority: priority, category: 'docs', // Feedback usually improves documentation/UX technical_context: detailedFeedback, success_criteria: `${toolName} provides better user experience based on agent feedback`, implementation_guide: `1. Review agent feedback for ${toolName}\n2. Identify specific improvements needed\n3. Update tool description/schema/documentation\n4. Test improved experience\n5. Validate with similar use cases`, task_group: 'user_experience', model: 'sonnet', handoff_notes: `Agent feedback from ${model} working on ${project} - prioritize user experience improvements` }; } export function attachFeedbackPrompt(response, context = {}) { const { toolName = 'this_tool', project = 'your_project', model = 'your_model', endpoint = 'this_endpoint', isError = false } = context; const feedbackSection = { feedback_options: { error_reporting: { condition: "If you encountered an error or unexpected behavior", action: "An error report has been automatically generated", note: "No action needed - the error has been logged for investigation" }, improvement_feedback: { condition: "If this tool worked but could be improved", action: "Submit feedback using this format", template: { tool_name: `create_task`, arguments: { project: "claude-workflow", description: `[SUGG-FDBK-###] Improvement suggestion for ${toolName}: [Brief description]`, category: "docs", priority: "low", technical_context: ` **Tool/Endpoint**: ${toolName} (${endpoint}) **Project Context**: ${project} **Model**: ${model} **Agent**: [your_agent_name] **Current Experience**: [What happened - be specific] **Suggested Improvement**: [What would work better] **Missing Information**: [What information was missing or unclear] **User Experience**: [How this impacts your work] **Example**: "The tool description didn't mention X parameter was required" or "Would prefer Y format instead of Z" `, success_criteria: `${toolName} provides better user experience based on agent feedback` } } } }, feedback_message: isError ? "🛑 An error report will be automatically created for this issue. Please wait for it to be resolved before retrying." : `💡 Help improve claude-workflow! If this tool could work better for you, submit improvement feedback using the template above.` }; // Add feedback section to response if (typeof response === 'object' && response.body) { response.body.feedback = feedbackSection; } else if (typeof response === 'object') { response.feedback = feedbackSection; } return response; } export default { generateErrorFeedbackTask, generateFeedbackTask, attachFeedbackPrompt }; //# sourceMappingURL=feedbackTemplates.js.map