# Changelog

All notable changes to the MCP Prompt Optimizer package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2025-06-21

### Added
- **MAJOR**: AI Context Detection and Enhanced Optimization
  - Automatic AI context detection for prompts (image_generation, llm_interaction, technical_automation, human_communication)
  - Enhanced goal mapping with AI-specific optimization goals
  - Parameter preservation for technical prompts (e.g., Midjourney --ar, --v parameters)
  - Context-aware optimization routing based on prompt content

### New Features
- **AI-Specific Optimization Goals**:
  - `keyword_density` - Enhanced keyword optimization for AI models
  - `parameter_preservation` - Preserves technical parameters during optimization
  - `token_efficiency` - Optimizes token usage for LLM interactions
  - `embedding_strength` - Enhances semantic embedding effectiveness
  - `context_specificity` - Improves context relevance for AI models
  - `ai_model_compatibility` - Optimizes for specific AI model requirements
  - `quality_enhancement` - Adds quality indicators for better AI responses
  - `role_clarity` - Enhances role-playing and persona clarity
  - `code_protection` - Protects code elements during optimization

- **Enhanced Tool Parameters**:
  - `ai_context` - Manual AI context specification (auto-detected if not provided)
  - `preserve_formatting` - Controls technical parameter preservation
  - `target_ai_model` - Specify target AI model for optimization
  - `optimization_level` - Choose between conservative, balanced, or aggressive optimization

### Improved
- **Enhanced Response Information**:
  - Shows detected AI context in optimization results
  - Displays optimization strategy used
  - Indicates when goal enhancement was applied
  - Reports preserved parameters count
  - Shows original vs enhanced goals comparison

- **Better AI Integration**:
  - Automatic detection of Midjourney, DALL-E, and Stable Diffusion prompts
  - Smart handling of LLM role-playing prompts
  - Code and technical automation prompt protection
  - Context-aware optimization strategies

### Technical Improvements
- Updated MCP server version to 1.1.0
- Enhanced API client with AI optimization options
- Improved error handling for AI-specific features
- Added comprehensive AI context validation

### Documentation
- Updated tool schema with new AI-specific parameters
- Enhanced descriptions for all new optimization goals
- Added AI context detection documentation
- Improved examples with AI optimization use cases

### Backward Compatibility
- All existing functionality remains unchanged
- New AI features are automatically applied when beneficial
- Existing goal names and functionality preserved
- No breaking changes to API or configuration

## [1.0.3] - 2025-06-18

### Fixed
- **CRITICAL**: Fixed binary execution issue on Windows systems
  - Changed binary configuration to point directly to index.js instead of bin/start-server
  - Resolved issue where global installation commands (--help, --version) failed silently
  - Improved version detection for global installations
  - Fixed Windows batch file generation issues

### Improved
- Enhanced binary path resolution for global installations
- Added fallback version detection when package.json path resolution fails
- Better error handling in binary execution

### Notes
- This fix resolves the issue where `mcp-prompt-optimizer --help` and `mcp-prompt-optimizer --version` returned no output
- Existing functionality remains unchanged
- No breaking changes to API or configuration

## [1.0.2] - 2025-06-18

### Fixed
- **CRITICAL**: Fixed pricing information discrepancy in documentation
  - Corrected subscription tier pricing to match backend implementation
  - Updated rate limit documentation for accuracy
  - Resolved conflicting pricing information between different sources
- Improved documentation consistency across all package files

### Documentation
- Updated README.md with accurate subscription tiers and pricing
- Clarified rate limiting structure for all subscription levels
- Enhanced troubleshooting guide for pricing-related questions
- Improved consistency between npm package docs and web dashboard

### Notes
- This is a documentation-only update with no functional changes
- Existing API functionality and rate limits remain unchanged
- Users should verify current pricing at the web dashboard

## [1.0.1] - 2025-06-05

### Changed
- **CRITICAL**: Updated default backend URL from placeholder to production deployment
  - Changed from `https://your-app.code.run` to `https://p01--project-optimizer--fvrdk8m9k9j.code.run`
  - Ensures out-of-the-box functionality without manual configuration
- Updated package repository information to proper GitHub URLs
- Enhanced error handling in API client for server errors (500 status)
- Improved documentation with backend infrastructure details

### Added
- Added comprehensive backend connectivity documentation
- Added troubleshooting section for backend connection issues
- Added environment variable documentation for debugging
- Added changelog file for version tracking
- Enhanced test suite with backend URL validation
- Added npm test script for package validation

### Fixed
- Fixed default backend URL configuration in `lib/config.js`
- Ensured consistency between API client and config defaults
- Improved package metadata and author information

### Documentation
- Updated README.md with production backend information
- Enhanced client configuration guide with backend details
- Added backend health check endpoints
- Improved troubleshooting documentation

## [1.0.0] - 2025-05-XX

### Added
- Initial release of MCP Prompt Optimizer package
- Support for Claude Desktop, Cursor, and Windsurf MCP clients
- API key authentication system with secure local storage
- Complete optimization goal support (10 different goals)
- MCP Protocol 2024-11-05 compliance
- Real-time quota tracking and usage monitoring
- Comprehensive error handling and validation
- Interactive setup command for API key configuration
- Global npm package installation support
- Cross-platform compatibility (Windows, macOS, Linux)

### Features
- **optimize_prompt** tool with advanced goal selection
- Secure API key management with local storage
- Base64 configuration encoding for MCP protocol compliance
- Automatic retry logic and rate limiting handling
- Health check and connectivity validation
- Development and production environment support

### Security
- HTTPS-only communication with backend
- Local-only API key storage
- No persistent data storage on servers
- Enterprise-grade security compliance

---

## Backend Compatibility

| Package Version | Backend API Version | Deployment URL | AI Features |
|-----------------|--------------------|--------------------|-------------|
| 1.1.0 | v0.3.0+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | Full AI Context Detection |
| 1.0.3 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
| 1.0.2 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
| 1.0.1 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
| 1.0.0 | v0.2.0+ | Placeholder URL (manual configuration required) | None |

## Migration Guide

### From 1.0.3 to 1.1.0

**New AI Features Available:**
- Automatic AI context detection
- Enhanced optimization goals
- Parameter preservation
- Target AI model specification

**Update process:**
```bash
# Update the package
npm update -g mcp-prompt-optimizer

# Verify new version and AI features
mcp-prompt-optimizer --version

# Test with an AI prompt (example)
# The tool will now automatically detect and optimize for AI contexts
```

**New Usage Examples:**
```json
// Image generation prompt (auto-detected)
{
  "prompt": "A beautiful sunset over mountains --ar 16:9 --v 5.2",
  "goals": ["clarity", "keyword_density"]
}

// LLM interaction prompt (auto-detected)  
{
  "prompt": "Act as a professional copywriter and help me write...",
  "goals": ["role_clarity", "context_specificity"]
}

// Manual AI context specification
{
  "prompt": "Create a photorealistic image...", 
  "ai_context": "image_generation",
  "target_ai_model": "midjourney"
}
```

### From 1.0.2 to 1.0.3

No breaking changes. This update fixes binary execution issues on Windows systems.

**Update process:**
```bash
# Update the package
npm update -g mcp-prompt-optimizer

# Verify new version and functionality
mcp-prompt-optimizer --version
mcp-prompt-optimizer --help

# No configuration changes needed
```

### From 1.0.1 to 1.0.2

No breaking changes. This is a documentation-only update.

**Update process:**
```bash
# Update the package
npm update -g mcp-prompt-optimizer

# Verify new version
mcp-prompt-optimizer --version

# No configuration changes needed
```

### From 1.0.0 to 1.0.1

No breaking changes. The update automatically configures the correct backend URL.

**If you previously configured a custom backend URL:**
- Your configuration will be preserved
- To use the new default: delete `~/.prompt-optimizer/config.json` and run `mcp-prompt-optimizer --setup`

**For existing installations:**
```bash
# Update the package
npm update -g mcp-prompt-optimizer

# Verify new version
mcp-prompt-optimizer --version

# Test connectivity (optional)
npm test
```

## Known Issues

### 1.1.0
- None known at release time

### 1.0.3
- None known at release time

### 1.0.2
- Binary execution issues on Windows (fixed in 1.0.3)

### 1.0.1
- Pricing documentation inconsistency (fixed in 1.0.2)
- Binary execution issues on Windows (fixed in 1.0.3)

### 1.0.0
- Required manual backend URL configuration
- Placeholder URLs in documentation

## AI Optimization Examples

### Image Generation Prompts
```javascript
// Midjourney prompt with parameters preserved
{
  "prompt": "Professional headshot of a business executive --ar 1:1 --v 5.2 --stylize 100",
  "goals": ["keyword_density", "parameter_preservation", "quality_enhancement"]
}
```

### LLM Role-Playing
```javascript
// Role-playing prompt with enhanced clarity
{
  "prompt": "Act as a senior software architect and help me design...",
  "goals": ["role_clarity", "context_specificity", "actionability"]
}
```

### Technical Automation
```javascript  
// Code-related prompt with protection
{
  "prompt": "Write a Python function that processes API responses...",
  "goals": ["code_protection", "technical_precision", "clarity"]
}
```

## Support

For version-specific support:
- [GitHub Issues](https://github.com/prompt-optimizer/mcp-prompt-optimizer/issues)
- [Support Portal](https://promptoptimizer-blog.vercel.app/support)
- [Documentation](https://promptoptimizer-blog.vercel.app/docs)

When reporting issues, please include:
- Package version (`mcp-prompt-optimizer --version`)
- Node.js version (`node --version`)
- Operating system
- MCP client type and version
- Error messages and logs
- AI context and optimization goals used (for AI-related issues)