# WP Agentic Writer

**Plan-first AI writing workflow for WordPress**

A WordPress plugin that transforms how developers and technical writers create blog posts. Instead of the traditional "blank page → write → edit" workflow, it implements a multi-phase agentic AI workflow:

```
Scribble (Ideas) → Research → Plan (Outline) → Execute (Write) → Discussion/Revise
```

## Features

### 5-Phase Workflow

1. **Brainstorm & Scribble** - Share raw ideas, code snippets, or vague topics
2. **Research** - Optional web search for current information (via OpenRouter)
3. **Plan** - Generate structured outline with H2 sections
4. **Execute** - Auto-generate full article from plan
5. **Revise** - Regenerate individual blocks or sections

### Key Features

- ✅ Single API key via OpenRouter
- ✅ Built-in web search with toggle
- ✅ Real-time cost tracking
- ✅ Gutenberg block integration
- ✅ Block-level regeneration
- ✅ Free tier support (25+ free models)

## Installation

1. Download the plugin ZIP file
2. Upload to WordPress plugins directory
3. Activate the plugin
4. Configure settings in **Settings > Agentic Writer**

## Configuration

### Get OpenRouter API Key

1. Visit [OpenRouter.ai](https://openrouter.ai/keys)
2. Create an account (or use free tier)
3. Generate an API key
4. Paste in plugin settings

### Recommended Models

**Planning Model:**
- `google/gemini-2.0-flash-exp` (Free, Fast) - Recommended
- `xiaomi/mimo-v2-flash` (Free, High Quality)
- `anthropic/claude-sonnet-4-20250514` (Paid, Excellent)

**Execution Model:**
- `anthropic/claude-sonnet-4-20250514` (Recommended)
- `anthropic/claude-opus-4-20250514` (Premium, Best Quality)
- `meta-llama/llama-3.3-70b` (Free)
- `qwen/qwen3-coder-480b` (Free, Technical Writing)

**Image Model:**
- `black-forest-labs/flux-schnell` (Fast, $0.04/image)
- `black-forest-labs/flux-pro` (Premium, $0.25/image)

### Web Search

Toggle web search in the Research phase:
- **Cost:** ~$0.02 per search (Exa engine)
- **Engine:** Auto, Native, or Exa
- **Depth:** Low, Medium, or High

## Usage

1. Open WordPress editor for a new post
2. Click "Agentic Writer" in the sidebar
3. **Brainstorm:** Type your raw ideas or topic
4. **Research:** (Optional) AI searches the web for current info
5. **Plan:** Review and edit the generated outline
6. **Execute:** Click to generate the full article
7. **Revise:** Regenerate blocks as needed

## Cost Estimation

**Per Article (2,500 words):**
- Planning: ~$0.0007 (with free model)
- Research: ~$0.02 (if web search enabled)
- Writing: ~$0.633 (with Claude Sonnet)
- Image: ~$0.04 (with FLUX Schnell)
- **Total:** ~$0.70

**Free Tier:**
- Planning & Writing: $0.00 (with free models)
- Research: $0.00 (skip web search)
- **Total:** $0.00

## Requirements

- WordPress 6.6+
- PHP 7.4+
- Gutenberg Editor
- OpenRouter API Key (or use free tier models)

## Security

- API keys are stored encrypted in WordPress options
- All user inputs are sanitized
- Nonces verified for all AJAX requests
- No external data collection

## Support

- GitHub: [https://github.com/wp-agentic-writer/wp-agentic-writer](https://github.com/wp-agentic-writer/wp-agentic-writer)
- Issues: [https://github.com/wp-agentic-writer/wp-agentic-writer/issues](https://github.com/wp-agentic-writer/wp-agentic-writer/issues)

## License

GPL-2.0+

## Credits

Developed with ❤️ for developers who struggle with blogging.

Uses [OpenRouter](https://openrouter.ai/) for unified AI model access.
