@kleosr/pe2-cli
Version:
š KleoSr PE2-CLI: Convert raw prompts to PE2-optimized prompts using adaptive intelligence
93 lines (67 loc) ⢠2.55 kB
JavaScript
export const DIFFICULTY_INDICATORS = {
NOVICE: 'š¢',
INTERMEDIATE: 'š”',
ADVANCED: 'š ',
EXPERT: 'š“',
MASTER: 'š£'
};
export const getInitialTemplate = (rawPrompt) => `
You are an expert prompt engineer specializing in PE² (Prompt Engineering 2.0) optimization.
Transform the following raw prompt into a structured PE² format with exactly these 5 sections:
Raw prompt to optimize:
${rawPrompt}
Return ONLY a valid JSON object with these exact keys:
{
"context": "Comprehensive problem description and scope",
"role": "Expert persona for the LLM to adopt",
"task": "Step-by-step breakdown of required actions",
"constraints": "Rules, limitations, and boundaries",
"output": "Expected format and structure of the response"
}
CRITICAL: Return ONLY the JSON object. No explanations or additional text.
`;
export const getRefinementTemplate = (currentPromptJson, iterationNum) => `
You are refining a PE² prompt for iteration ${iterationNum}.
Current PE² Prompt:
${currentPromptJson}
Analyze and improve the prompt by:
1. Enhancing clarity and specificity
2. Ensuring all PE² sections are well-balanced
3. Optimizing for better LLM performance
4. Maintaining logical consistency
5. Improving actionability
Return ONLY the improved JSON object with the same 5 sections.
`;
export function formatMarkdownOutput(pe2Prompt, history, metrics, difficulty, complexityScore) {
const indicator = DIFFICULTY_INDICATORS[difficulty];
return `
# PE²-Optimized Prompt ${indicator}
**Difficulty Level:** ${difficulty} | **Complexity Score:** ${complexityScore}/20 | **Generated:** ${new Date().toLocaleString()}
## Agentic Analysis
- **Optimization Level:** ${metrics.optimization_level || 'N/A'}
- **Overall Quality:** ${metrics.quality_score || 'N/A'}
## Context
${pe2Prompt.context || 'N/A'}
## Role
${pe2Prompt.role || 'N/A'}
## Task
${pe2Prompt.task || 'N/A'}
## Constraints
${pe2Prompt.constraints || 'N/A'}
## Output
${pe2Prompt.output || 'N/A'}
# Refinement History
${history.map(item => `### Iteration ${item.iteration}\n- ${item.edits}\n`).join('\n')}
# Performance Metrics
- **Estimated Accuracy Gain**: ${metrics.accuracy_gain || 'N/A'}
- **Complexity Analysis**: ${difficulty} level prompt with ${complexityScore}/20 complexity score
- **Optimization Level**: ${history.length} iterations applied
- **Generated by**: KleoSr PE²-CLI
*Generated with ā¤ļø by KleoSr PE²-CLI*
`;
}