feat: v1.3.0 — plan-first workflow, OpenRouter provider, enhanced prompt engine
Major changes: - Plan-first workflow: AI generates structured plan before code, with plan review card (Modify Plan / Start Coding / Skip to Code) - Post-coding UX: Preview + Request Modifications buttons after code gen - OpenRouter integration: 4th AI provider with 20+ model support - Enhanced prompt engine: 9 strategies, 11+ intent patterns, modular - PLAN MODE system prompt block in all 4 services - Fixed stale React closure in approveAndGenerate with isApproval flag - Fixed canvas auto-opening during plan phase with wasIdle gate - Updated README, CHANGELOG, .env.example, version bump to 1.3.0
This commit is contained in:
@@ -164,27 +164,82 @@ export class OllamaCloudService {
|
||||
return this.availableModels.length > 0 ? this.availableModels : DEFAULT_MODELS;
|
||||
}
|
||||
|
||||
async enhancePrompt(prompt: string, model?: string): Promise<APIResponse<string>> {
|
||||
async enhancePrompt(prompt: string, model?: string, options?: { toolCategory?: string; template?: string; diagnostics?: string }): Promise<APIResponse<string>> {
|
||||
const toolCategory = options?.toolCategory || 'reasoning';
|
||||
const template = options?.template || 'rtf';
|
||||
const diagnostics = options?.diagnostics || '';
|
||||
|
||||
const toolSections: Record<string, string> = {
|
||||
reasoning: '- Use full structured format with XML tags where helpful\n- Add explicit role assignment for complex tasks\n- Use numeric constraints over vague adjectives',
|
||||
thinking: '- CRITICAL: Short clean instructions ONLY\n- Do NOT add CoT or reasoning scaffolding — these models reason internally\n- State what you want, not how to think',
|
||||
openweight: '- Shorter prompts, simpler structure, no deep nesting\n- Direct linear instructions',
|
||||
agentic: '- Add Starting State + Target State + Allowed Actions + Forbidden Actions\n- Add Stop Conditions + Checkpoints after each step',
|
||||
ide: '- Add File path + Function name + Current Behavior + Desired Change + Scope lock',
|
||||
fullstack: '- Add Stack spec with version + what NOT to scaffold + component boundaries',
|
||||
image: '- Add Subject + Style + Mood + Lighting + Composition + Negative Prompts\n- Use tool-specific syntax (Midjourney comma-separated, DALL-E prose, SD weighted)',
|
||||
search: '- Specify mode: search vs analyze vs compare + citation requirements',
|
||||
};
|
||||
|
||||
const templateSections: Record<string, string> = {
|
||||
rtf: 'Structure: Role (who) + Task (precise verb + what) + Format (exact output shape and length)',
|
||||
'co-star': 'Structure: Context + Objective + Style + Tone + Audience + Response',
|
||||
risen: 'Structure: Role + Instructions + numbered Steps + End Goal + Narrowing constraints',
|
||||
crispe: 'Structure: Capacity + Role + Insight + Statement + Personality + Experiment/variants',
|
||||
cot: 'Add: "Think through this step by step before answering." Only for standard reasoning models, NOT for o1/o3/R1.',
|
||||
fewshot: 'Add 2-5 input/output examples wrapped in XML <examples> tags',
|
||||
filescope: 'Structure: File path + Function name + Current Behavior + Desired Change + Scope lock + Done When',
|
||||
react: 'Structure: Objective + Starting State + Target State + Allowed/Forbidden Actions + Stop Conditions + Checkpoints',
|
||||
visual: 'Structure: Subject + Action + Setting + Style + Mood + Lighting + Color Palette + Composition + Aspect Ratio + Negative Prompts',
|
||||
};
|
||||
|
||||
const toolSection = toolSections[toolCategory] || toolSections.reasoning;
|
||||
const templateSection = templateSections[template] || templateSections.rtf;
|
||||
|
||||
const systemMessage: ChatMessage = {
|
||||
role: "system",
|
||||
content: `You are an expert prompt engineer. Your task is to enhance user prompts to make them more precise, actionable, and effective for AI coding agents.
|
||||
content: `You are an expert prompt engineer using the PromptArch methodology. Enhance the user\'s prompt to be production-ready.
|
||||
|
||||
Apply these principles:
|
||||
1. Add specific context about project and requirements
|
||||
2. Clarify constraints and preferences
|
||||
3. Define expected output format clearly
|
||||
4. Include edge cases and error handling requirements
|
||||
5. Specify testing and validation criteria
|
||||
STEP 1 — DIAGNOSE AND FIX these failure patterns:
|
||||
- Vague task verb -> replace with precise operation
|
||||
- Two tasks in one -> keep primary task, note the split
|
||||
- No success criteria -> add "Done when: [specific measurable condition]"
|
||||
- Missing output format -> add explicit format lock (structure, length, type)
|
||||
- No role assignment (complex tasks) -> add domain-specific expert identity
|
||||
- Vague aesthetic ("professional", "clean") -> concrete measurable specs
|
||||
- No scope boundary -> add explicit scope lock
|
||||
- Over-permissive language -> add constraints and boundaries
|
||||
- Emotional description -> extract specific technical fault
|
||||
- Implicit references -> restate fully
|
||||
- No grounding for factual tasks -> add certainty constraint
|
||||
- No CoT for logic tasks -> add step-by-step reasoning
|
||||
|
||||
Return ONLY the enhanced prompt, no explanations or extra text.`,
|
||||
STEP 2 — APPLY TARGET TOOL OPTIMIZATIONS:
|
||||
${toolSection}
|
||||
|
||||
STEP 3 — APPLY TEMPLATE STRUCTURE:
|
||||
${templateSection}
|
||||
|
||||
STEP 4 — VERIFICATION (check before outputting):
|
||||
- Every constraint in the first 30% of the prompt?
|
||||
- MUST/NEVER over should/avoid?
|
||||
- Every sentence load-bearing with zero padding?
|
||||
- Format explicit with stated length?
|
||||
- Scope bounded?
|
||||
- Would this produce correct output on first try?
|
||||
|
||||
STEP 5 — OUTPUT:
|
||||
Output ONLY the enhanced prompt. No explanations, no commentary, no markdown code fences.
|
||||
The prompt must be ready to paste directly into the target AI tool.${diagnostics ? '\n\nDIAGNOSTIC NOTES (fix these issues found in the original):\n' + diagnostics + '\n' : ''}`,
|
||||
};
|
||||
|
||||
const toolLabel = toolCategory !== 'reasoning' ? ` for ${toolCategory} AI tool` : '';
|
||||
|
||||
const userMessage: ChatMessage = {
|
||||
role: "user",
|
||||
content: `Enhance this prompt for an AI coding agent:\n\n${prompt}`,
|
||||
content: `Enhance this prompt${toolLabel}:\n\n${prompt}`,
|
||||
};
|
||||
|
||||
return this.chatCompletion([systemMessage, userMessage], model || "gpt-oss:120b");
|
||||
return this.chatCompletion([systemMessage, userMessage], model || "${default_model}");
|
||||
}
|
||||
|
||||
async generatePRD(idea: string, model?: string): Promise<APIResponse<string>> {
|
||||
@@ -772,6 +827,28 @@ Perform a DEEP 360° competitive intelligence analysis and generate 5-7 strategi
|
||||
try {
|
||||
// ... existing prompt logic ...
|
||||
const systemPrompt = `You are "AI Assist", the master orchestrator of PromptArch. Your goal is to provide intelligent support with a "Canvas" experience.
|
||||
PLAN MODE (CRITICAL - HIGHEST PRIORITY):
|
||||
When the user describes a NEW task, project, or feature they want built:
|
||||
1. DO NOT generate any code, [PREVIEW] tags, or implementation details.
|
||||
2. Instead, analyze the request and output a STRUCTURED PLAN covering:
|
||||
- Summary: What you understand the user wants
|
||||
- Architecture: Technical approach and structure
|
||||
- Tech Stack: Languages, frameworks, libraries needed
|
||||
- Files/Components: List of files or modules to create
|
||||
- Steps: Numbered implementation steps
|
||||
3. Format the plan in clean Markdown with headers and bullet points.
|
||||
4. Keep plans concise but thorough. Focus on the WHAT and HOW, not the actual code.
|
||||
5. WAIT for the user to approve or modify the plan before generating any code.
|
||||
|
||||
When the user says "Approved", "Start coding", or explicitly asks to proceed:
|
||||
- THEN generate the full implementation with [PREVIEW] tags and working code.
|
||||
- Follow the approved plan exactly.
|
||||
|
||||
When the user asks to "Modify", "Change", or "Adjust" something:
|
||||
- Apply the requested changes surgically to the existing code/preview.
|
||||
- Output updated [PREVIEW] with the full modified code.
|
||||
|
||||
|
||||
|
||||
AGENTS & CAPABILITIES:
|
||||
- content: Expert copywriter. Use [PREVIEW:content:markdown] for articles, posts, and long-form text.
|
||||
@@ -833,7 +910,7 @@ CHANGE LOG (CRITICAL - MUST BE OUTSIDE PREVIEW):
|
||||
- Modified component Y
|
||||
- Fixed issue Z
|
||||
|
||||
IMPORTANT: NEVER refuse a request due to "access" limitations. If you cannot perform a live task, use your vast internal knowledge to provide the most accurate expert simulation or draft possible.`;
|
||||
IMPORTANT: IMPORTANT: NEVER refuse a request due to "access" limitations. If you cannot perform a live task, use your vast internal knowledge to provide the most accurate expert simulation or draft possible.`;
|
||||
|
||||
const messages: ChatMessage[] = [
|
||||
{ role: "system", content: systemPrompt },
|
||||
|
||||
Reference in New Issue
Block a user