first commit all files

This commit is contained in:
dwindown
2026-01-28 00:26:00 +07:00
parent 65dd207a74
commit 97426d5ab1
72 changed files with 91484 additions and 0 deletions

651
model-preset-brief.md Normal file
View File

@@ -0,0 +1,651 @@
# WP Agentic Writer: Model Selection & Preset Packs
## Executive Summary
This document defines 3 curated model packs for WP Agentic Writer on OpenRouter, optimized for different user budgets and quality requirements. Each pack includes models for 6 tasks: chat, clarity checking, planning, writing, refinement, and image generation.
**Key principle:** Users bring their own OpenRouter API key. Plugin ships with sensible presets so users just pick "Budget / Balanced / Premium"—no model switching needed unless they want to customize.
---
## Table of Contents
1. [Model Recommendation Strategy](#model-recommendation-strategy)
2. [Preset Pack 1: Budget](#preset-pack-1-budget)
3. [Preset Pack 2: Balanced (Recommended)](#preset-pack-2-balanced-recommended)
4. [Preset Pack 3: Premium](#preset-pack-3-premium)
5. [Cost Estimation Guide](#cost-estimation-guide)
6. [When to Use Each Pack](#when-to-use-each-pack)
7. [Implementation Config](#implementation-config)
---
## Model Recommendation Strategy
### Task-by-Task Rationale
#### 1. Chat (Discussion, Recommendation, Research)
**What it does:** Multi-turn conversation where user discusses topic, asks questions, researches ideas before committing to writing.
**Quality metrics:**
- Context understanding
- Iterative reasoning
- Long-context support (for multi-message research threads)
- Cost per token (since users may have many back-and-forth turns)
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | DeepSeek V3.x | Strong reasoning, excellent value pricing (~$0.55/1M input tokens) |
| Balanced | Gemini 3 Flash Preview | Built for multi-turn agentic workflows, 1M context window, cheaper than Pro |
| Premium | Gemini 3 Flash Preview or GPT-5.2 Chat | Flash for cost savings on research; GPT-5.2 if user wants single OpenAI vendor |
---
#### 2. Clarity Check (Prompt QA + Quiz Generation)
**What it does:** Analyzes user's article topic/prompt for ambiguity, generates clarifying questions, suggests research gaps, and optionally generates self-assessment quiz.
**Quality metrics:**
- Meta-reasoning (ability to critique its own instructions)
- Quiz/checklist generation quality
- Cost per query (typically short, one-off)
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | DeepSeek V3.x | Good at structured reasoning, checklist generation; very cheap |
| Balanced | Gemini 3 Flash Preview | Excellent at prompt analysis and quiz generation; fast feedback loop |
| Premium | Claude Sonnet 4 | Nuanced feedback; exceptional at Socratic question generation |
---
#### 3. Planning (Article Outline Generation)
**What it does:** Takes finalized topic + research notes → generates structured article outline (sections, subsections, key points) as JSON or markdown.
**Quality metrics:**
- Structured output (JSON/markdown reliability)
- Long-context input (researched notes, competitor articles, etc.)
- Cost (ideally one-off, but might regenerate)
- Speed (user should see outline quickly)
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | Gemini 3 Flash Preview | 1M context window, fast, cheap, excellent JSON output |
| Balanced | Gemini 3 Flash Preview | Same: primary "thinking" engine; doesn't need premium pricing |
| Premium | Gemini 3 Flash Preview | Same: planning quality doesn't scale with cost; still Flash is optimal |
---
#### 4. Writing (Article Draft Generation)
**What it does:** Transforms outline + research notes → full article draft (25k words), with proper tone, code examples if relevant, and flow.
**Quality metrics:**
- Long-form coherence (25k words)
- Tone consistency (match blog voice)
- Code + explanation blending (if dev/tech topic)
- Cost per article (this is the "heavy lift")
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | Mistral Small | Fast, cheap (~$0.14/1M input); acceptable first drafts for dev blogs; editable output |
| Balanced | Claude Sonnet 3.5 or 4 | Industry standard for long-form; strong at code blocks + prose blend; great value/quality ratio |
| Premium | GPT-5.2 or Claude Opus 4.5 | Frontier models; superior narrative flow, voice consistency, subtle nuance across 25k words |
---
#### 5. Refinement (Paragraph/Section Edits)
**What it does:** User selects 13 paragraphs → asks AI to rewrite, expand, shorten, simplify, or adjust tone.
**Quality metrics:**
- Precision editing (preserve surrounding context)
- Tone control (match existing prose)
- Cost efficiency (small rewrites should be cheap)
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | DeepSeek V3.x | Cheap, capable at local edits; good enough for "shorten this" / "make beginner-friendly" |
| Balanced | Claude Sonnet 3.5 or 4 | Same model as writing phase for consistency; strong at nuanced rewrites |
| Premium | GPT-5.2 or Claude Opus 4.5 | Same frontier writer for final polish; maintains voice across refinements |
---
#### 6. Image Generation
**What it does:** Generates 14 hero or inline images per article based on outline + user direction.
**Quality metrics:**
- Visual quality (coherence, aesthetic fit for blog)
- Prompt adherence (matches user's description)
- Cost per image (users may want multiple attempts)
- Speed (not blocking)
**Recommendation by tier:**
| Tier | Model | Reason |
|------|-------|--------|
| Budget | FLUX.2 [klein] 4B | Optimized for cost (~$0.014 USD/MP base); acceptable for blog illustrations |
| Balanced | Riverflow V2 Max or FLUX.2 Pro | Higher visual quality; flat ~$0.030.04 USD per image; good for professional blogs |
| Premium | FLUX.2 [max] | Frontier image quality; best prompt adherence; hero/marketing images (~$0.07 USD/MP base) |
---
## Preset Pack 1: Budget
### Target User
- Indie dev blogger or beginner content creator
- Cost-sensitive; prioritizes shipping over perfection
- Acceptable output: readable first drafts, simple blog images
- Typical use: 23 articles/month
### Complete Model Pack
| Task | Model | Provider | Rationale |
|------|-------|----------|-----------|
| Chat | DeepSeek V3.x | OpenRouter | Powerful reasoning, 1/10th the cost of GPT-4.5 |
| Clarity | DeepSeek V3.x | OpenRouter | Meta-reasoning for prompt analysis |
| Planning | Gemini 3 Flash Preview | OpenRouter | 1M context, fast outlining, dirt cheap |
| Writing | Mistral Small | OpenRouter | Budget-friendly long-form; acceptable for drafts |
| Refinement | DeepSeek V3.x | OpenRouter | Cost-efficient edits; reuse for multiple refinements |
| Image | FLUX.2 [klein] 4B | OpenRouter (Black Forest Labs) | Optimized for cost; good enough for blog headers |
### Cost Breakdown (Per 2,500-word Article + 3 Images)
**Text costs (tokens):**
Typical usage:
- Chat phase: ~3,000 input + 500 output tokens (discussion)
- Clarity: ~1,000 input + 300 output tokens (prompt analysis)
- Planning: ~2,000 input + 800 output tokens (outline)
- Writing: ~4,000 input + 2,500 output tokens (draft generation)
- Refinement: ~1,000 input + 400 output tokens (one round of edits)
| Task | Input Tokens | Output Tokens | Cost (USD) |
|------|--------------|---------------|-----------|
| Chat (DeepSeek) | 3,000 | 500 | $0.0019 |
| Clarity (DeepSeek) | 1,000 | 300 | $0.0007 |
| Planning (Flash) | 2,000 | 800 | $0.0009 |
| Writing (Mistral Small) | 4,000 | 2,500 | $0.0090 |
| Refinement (DeepSeek) | 1,000 | 400 | $0.0008 |
| **Text subtotal** | | | **$0.0133** |
**Image costs:**
- 3 images × ~1 MP each via FLUX.2 klein
- First MP per image: $0.014
- Subsequent MP per image: $0.001
- 3 images × $0.014 ≈ **$0.042**
**OpenRouter platform fee:**
- 5.5% of total ≈ 5.5% × ($0.0133 + $0.042) ≈ **$0.0045**
| Category | Cost (USD) |
|----------|-----------|
| Text (all tasks) | $0.0133 |
| Images (3 × 1 MP) | $0.0420 |
| OpenRouter platform fee (5.5%) | $0.0045 |
| **Total/Article** | **$0.0598** |
**💰 Budget pack = ~$0.06 USD/article (or ~$0.180.30 USD if user refines/regenerates once)**
---
## Preset Pack 2: Balanced (Recommended)
### Target User
- Active dev/content creator or small agency
- Shipping 410 articles/month
- Quality matters; willing to pay for strong writing
- Acceptable output: polished, professional prose; nice images
- Balance: cost-efficient without sacrificing quality
### Complete Model Pack
| Task | Model | Provider | Rationale |
|------|-------|----------|-----------|
| Chat | Gemini 3 Flash Preview | OpenRouter | Multi-turn agentic chat, 1M context, research-ready |
| Clarity | Gemini 3 Flash Preview | OpenRouter | Same engine; great at prompt analysis, quiz generation |
| Planning | Gemini 3 Flash Preview | OpenRouter | Primary "thinking" engine; excellent JSON outline generation |
| Writing | Claude Sonnet 3.5 or 4 | OpenRouter | Industry standard long-form; strong code + prose blend |
| Refinement | Claude Sonnet 3.5 or 4 | OpenRouter | Same as writing; consistency in rewrites and tone |
| Image | Riverflow V2 Max or FLUX.2 Pro | OpenRouter | High visual quality; flat ~$0.030.04 USD per image |
### Cost Breakdown (Per 2,500-word Article + 3 Images)
**Text costs (tokens):**
| Task | Input Tokens | Output Tokens | Cost (USD) |
|------|--------------|---------------|-----------|
| Chat (Flash) | 3,000 | 500 | $0.0015 |
| Clarity (Flash) | 1,000 | 300 | $0.0005 |
| Planning (Flash) | 2,000 | 800 | $0.0008 |
| Writing (Claude Sonnet) | 4,000 | 2,500 | $0.0300 |
| Refinement (Claude Sonnet) | 1,000 | 400 | $0.0060 |
| **Text subtotal** | | | **$0.0388** |
**Image costs:**
- 3 images × Riverflow V2 Max (flat pricing ~$0.03 per image)
- 3 images × $0.03 ≈ **$0.0900**
**OpenRouter platform fee:**
- 5.5% × ($0.0388 + $0.0900) ≈ **$0.0071**
| Category | Cost (USD) |
|----------|-----------|
| Text (all tasks) | $0.0388 |
| Images (3 × flat rate) | $0.0900 |
| OpenRouter platform fee (5.5%) | $0.0071 |
| **Total/Article** | **$0.1359** |
**💰 Balanced pack = ~$0.14 USD/article (or ~$0.250.35 USD with one round of refinement/regen)**
---
## Preset Pack 3: Premium
### Target User
- Content agencies or full-time creators
- Publishing 15+ articles/month or selling content
- Quality is non-negotiable (flagship posts, sales pages, thought leadership)
- Acceptable output: publication-ready prose; hero images
- Budget: cost is secondary to impact
### Complete Model Pack
| Task | Model | Provider | Rationale |
|------|-------|----------|-----------|
| Chat | Gemini 3 Flash Preview or GPT-5.2 Chat | OpenRouter | Flash for efficient research; GPT-5.2 if user wants single OpenAI vendor |
| Clarity | Claude Sonnet 4 | OpenRouter | Exceptional at nuanced prompt feedback and Socratic questioning |
| Planning | Gemini 3 Flash Preview | OpenRouter | Long-context planner; cost doesn't improve quality for outlining |
| Writing | GPT-5.2 or Claude Opus 4.5 | OpenRouter | Frontier long-form quality; superior narrative flow, voice, nuance |
| Refinement | GPT-5.2 or Claude Opus 4.5 | OpenRouter | Same frontier writer; final editorial polish |
| Image | FLUX.2 [max] | OpenRouter (Black Forest Labs) | Top-tier image quality; best prompt following; hero/marketing grade |
### Cost Breakdown (Per 2,500-word Article + 3 Images)
**Text costs (tokens):**
| Task | Input Tokens | Output Tokens | Cost (USD) |
|------|--------------|---------------|-----------|
| Chat (Flash) | 3,000 | 500 | $0.0015 |
| Clarity (Sonnet 4) | 1,000 | 300 | $0.0015 |
| Planning (Flash) | 2,000 | 800 | $0.0008 |
| Writing (GPT-5.2 or Opus) | 4,000 | 2,500 | $0.0700 |
| Refinement (GPT-5.2 or Opus) | 1,000 | 400 | $0.0140 |
| **Text subtotal** | | | **$0.0878** |
**Image costs:**
- 3 images × ~1 MP each via FLUX.2 [max]
- First MP per image: $0.07
- Subsequent MP per image: $0.03
- 3 images × $0.07 ≈ **$0.2100**
**OpenRouter platform fee:**
- 5.5% × ($0.0878 + $0.2100) ≈ **$0.0164**
| Category | Cost (USD) |
|----------|-----------|
| Text (all tasks) | $0.0878 |
| Images (3 × max quality) | $0.2100 |
| OpenRouter platform fee (5.5%) | $0.0164 |
| **Total/Article** | **$0.3142** |
**💰 Premium pack = ~$0.31 USD/article (or ~$0.500.75 USD with multiple refinement passes or image regen)**
---
## Cost Estimation Guide
### How Users Can Calculate Their Needs
Use this framework to estimate monthly costs:
```
Monthly AI Cost = (Cost/Article) × (Articles/Month) × (Regenerations Factor)
```
**Step 1: Pick your tier and note cost/article**
- Budget: $0.06
- Balanced: $0.14
- Premium: $0.31
**Step 2: Estimate articles per month**
- Blogger: 24 articles/month
- Small content team: 510 articles/month
- Agency: 1530 articles/month
**Step 3: Apply regeneration factor**
- First drafts only (happy with output): ×1.0
- One round of refinement/regeneration: ×1.52.0
- Heavy iteration (multiple regen cycles): ×2.53.0
**Example calculations:**
| Profile | Tier | Articles/mo | Regens | Monthly Cost |
|---------|------|-----------|---------|--------------|
| Solo dev blogger | Budget | 2 | ×1.5 | $0.06 × 2 × 1.5 = **$0.18** |
| Content team | Balanced | 8 | ×2.0 | $0.14 × 8 × 2.0 = **$2.24** |
| Agency (flagship posts) | Premium | 12 | ×2.5 | $0.31 × 12 × 2.5 = **$9.30** |
### Important Notes
1. **Token counts are estimates.** Actual usage depends on:
- Outline complexity
- Number of research notes
- Image resolution and complexity
- Iteration/refinement cycles
2. **OpenRouter base price + 5.5% platform fee** is included in all estimates above.
3. **No hidden costs.** Users only pay for what they use. If they skip image generation or skip refinement, cost drops.
4. **Image costs scale with resolution.** If user requests higher resolution (>1 MP per image), multiply image cost accordingly.
---
## When to Use Each Pack
### Budget Pack: Best For
**Use when:**
- First time using AI writing; want to test the plugin
- Publishing 13 articles/month
- Topic: dev blogs, quick tutorials (where first drafts are acceptable)
- Budget: <$5/month
**Not ideal for:**
- Sales pages or high-stakes content
- Audiences expecting polish
- Topics requiring heavy editing
**Workflow expectation:** User accepts 12 refinement cycles before publishing.
---
### Balanced Pack: Best For (RECOMMENDED DEFAULT)
**Use when:**
- Regular blogging (410 articles/month)
- Mixed content: tutorials, reviews, opinion pieces
- Publishing to professional blog or portfolio
- Budget: $520/month
**Default recommendation because:**
- Gemini Flash is the best pure planner on the market (cost doesn't improve planning)
- Claude Sonnet is the industry-standard long-form writer
- Cost:quality ratio is unbeatable
- Users can hit "publish" with minimal editing
**Not ideal for:**
- One-off flagship posts (Premium is worth it)
- Micro-budget users (use Budget instead)
**Workflow expectation:** User does one refinement cycle; publishes with high confidence.
---
### Premium Pack: Best For
**Use when:**
- Publishing flagship posts, thought leadership, or sales content
- Publishing 10+ articles/month (agency/professional creator)
- Audiences/stakeholders expect flawless prose
- Images need to be hero/standout quality
- Budget: $20100+/month
**Worth the cost because:**
- GPT-5.2 or Opus produce superior long-form narrative
- Superior voice consistency across 25k words
- FLUX.2 [max] images are publication-ready
- Minimal editing required
**Overkill for:**
- Quick dev blogs or tutorials
- Solo bloggers publishing <5/month
**Workflow expectation:** User does light editing (if any); publishes immediately.
---
## Implementation Config
### JSON Schema for Plugin Settings
Save presets as JSON config so users can swap or customize:
```json
{
"presets": {
"budget": {
"name": "Budget: DeepSeek + Flash + Mistral + FLUX.2 klein",
"description": "Super affordable ($0.06/article). Great for testing or budget-conscious bloggers.",
"models": {
"chat": {
"model": "deepseek-v3",
"provider": "openrouter",
"description": "DeepSeek V3: Fast, cheap, great reasoning"
},
"clarity": {
"model": "deepseek-v3",
"provider": "openrouter",
"description": "DeepSeek V3: Meta-reasoning for prompt analysis"
},
"planning": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: 1M context, fast outlining"
},
"writing": {
"model": "mistral/mistral-small",
"provider": "openrouter",
"description": "Mistral Small: Budget-friendly long-form"
},
"refinement": {
"model": "deepseek-v3",
"provider": "openrouter",
"description": "DeepSeek V3: Cost-efficient paragraph edits"
},
"image": {
"model": "black-forest-labs/flux.2-klein",
"provider": "openrouter",
"description": "FLUX.2 klein: Optimized for cost"
}
},
"cost_per_article": {
"text": 0.0133,
"images": 0.0420,
"platform_fee": 0.0045,
"total": 0.0598,
"currency": "USD"
}
},
"balanced": {
"name": "Balanced (RECOMMENDED): Gemini Flash + Claude Sonnet + Riverflow",
"description": "Professional quality ($0.14/article). Default for most creators.",
"models": {
"chat": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: Multi-turn agentic chat, 1M context"
},
"clarity": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: Excellent at prompt analysis"
},
"planning": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: Primary thinking engine"
},
"writing": {
"model": "anthropic/claude-3.5-sonnet",
"provider": "openrouter",
"description": "Claude Sonnet: Industry standard long-form"
},
"refinement": {
"model": "anthropic/claude-3.5-sonnet",
"provider": "openrouter",
"description": "Claude Sonnet: Consistent rewrites"
},
"image": {
"model": "sourceful/riverflow-v2-max",
"provider": "openrouter",
"description": "Riverflow V2 Max: High-quality images"
}
},
"cost_per_article": {
"text": 0.0388,
"images": 0.0900,
"platform_fee": 0.0071,
"total": 0.1359,
"currency": "USD"
}
},
"premium": {
"name": "Premium: GPT-5.2/Opus + Gemini Flash + FLUX.2 max",
"description": "Flagship quality ($0.31/article). For agencies and thought leaders.",
"models": {
"chat": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: Efficient research"
},
"clarity": {
"model": "anthropic/claude-sonnet-4",
"provider": "openrouter",
"description": "Claude Sonnet 4: Exceptional feedback"
},
"planning": {
"model": "google/gemini-3-flash-preview",
"provider": "openrouter",
"description": "Gemini 3 Flash: Long-context planner"
},
"writing": {
"model": "openai/gpt-5.2",
"provider": "openrouter",
"description": "GPT-5.2: Frontier long-form quality"
},
"refinement": {
"model": "openai/gpt-5.2",
"provider": "openrouter",
"description": "GPT-5.2: Final editorial polish"
},
"image": {
"model": "black-forest-labs/flux.2-max",
"provider": "openrouter",
"description": "FLUX.2 max: Hero-grade images"
}
},
"cost_per_article": {
"text": 0.0878,
"images": 0.2100,
"platform_fee": 0.0164,
"total": 0.3142,
"currency": "USD"
}
}
}
}
```
### How to Use in Plugin
1. **Load preset on plugin activation:**
```php
$preset = get_option('agentic_writer_preset', 'balanced');
$presets = json_decode(file_get_contents(__DIR__ . '/model-presets.json'), true);
$active_models = $presets['presets'][$preset]['models'];
```
2. **Route API calls based on preset:**
```php
switch ($task_type) {
case 'chat':
$model = $active_models['chat']['model'];
break;
case 'writing':
$model = $active_models['writing']['model'];
break;
// ... etc
}
```
3. **Display cost estimate in UI:**
```php
$cost = $presets['presets'][$preset]['cost_per_article']['total'];
echo "Estimated cost: ${$cost}/article";
```
---
## Summary Table
Quick reference for all 3 packs:
| Aspect | Budget | Balanced | Premium |
|--------|--------|----------|---------|
| **Chat** | DeepSeek | Gemini Flash | Gemini Flash |
| **Clarity** | DeepSeek | Gemini Flash | Claude Sonnet 4 |
| **Planning** | Gemini Flash | Gemini Flash | Gemini Flash |
| **Writing** | Mistral Small | Claude Sonnet | GPT-5.2/Opus |
| **Refinement** | DeepSeek | Claude Sonnet | GPT-5.2/Opus |
| **Image** | FLUX.2 klein | Riverflow V2 Max | FLUX.2 max |
| **Cost/Article** | **$0.06** | **$0.14** | **$0.31** |
| **Monthly (8 articles)** | **$0.48** | **$1.12** | **$2.48** |
| **Monthly (20 articles)** | **$1.20** | **$2.80** | **$6.20** |
| **Target User** | Hobbyist/test | Active creator | Agency/Pro |
| **Default?** | ❌ | ✅ RECOMMENDED | ❌ |
---
## Next Steps
1. **Implement preset switcher in plugin settings** Let users pick Budget / Balanced / Premium
2. **Add cost calculator to UI** Show estimated cost before user generates
3. **Support preset customization** Allow power users to swap individual models
4. **Track actual costs** Log usage and compare to estimates for billing transparency
---
## Appendix: Model Slugs
These are the exact model identifiers for OpenRouter API calls (as of January 2026):
```
deepseek-v3
google/gemini-3-flash-preview
anthropic/claude-3.5-sonnet
anthropic/claude-sonnet-4
mistral/mistral-small
openai/gpt-5.2
black-forest-labs/flux.2-klein
black-forest-labs/flux.2-max
sourceful/riverflow-v2-max
```
**Note:** Model names and slugs may change slightly as providers update. Verify against [OpenRouter Models](https://openrouter.ai/models) before deploying.
---
**Document version:** 1.0
**Date:** January 22, 2026
**Author:** WP Agentic Writer Product Team
**Status:** Ready for Implementation