Dual-Mode Prompt System for AI prompt optimization using 4-D methodology
Project description
DMPS - Dual-Mode Prompt System
A secure, enterprise-grade Python package for AI prompt optimization using the 4-D methodology (Deconstruct, Develop, Design, Deliver).
Features
Core Optimization
- Intent Detection: Automatically classifies prompt intent (creative, technical, educational, analytical)
- Gap Analysis: Identifies missing information and optimization opportunities
- 4-D Optimization: Systematic optimization using proven methodologies
- Dual Output Modes: Conversational and structured JSON formats
- Platform Support: Optimized for Claude, ChatGPT, Gemini, and generic platforms
Security & Performance (v0.2.0)
- Enterprise Security: Path traversal protection, RBAC, input sanitization
- Token Tracking: Cost estimation and usage monitoring
- Context Engineering: Performance evaluation and optimization metrics
- Observability: Real-time monitoring and alerting dashboard
- Code Quality: Pre-commit hooks, automated testing, type safety
Installation
From PyPI (Recommended)
pip install dmps==0.2.0
From Source
# Clone the repository
git clone https://github.com/MrBinnacle/dmps.git
cd dmps
# Install in development mode
pip install -e .
Prerequisites
- Python 3.8+
- pip (Python package manager)
Development Installation
-
Clone the repository:
git clone https://github.com/MrBinnacle/dmps.git cd dmps
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
Install the package in development mode:
pip install -e .
Usage
Quick Start
from dmps import optimize_prompt
# Simple optimization with automatic security validation
result = optimize_prompt("Write a story about AI")
print(result)
Advanced Usage
from dmps import PromptOptimizer
optimizer = PromptOptimizer()
result, validation = optimizer.optimize(
"Explain machine learning",
mode="conversational",
platform="claude"
)
# Check for security warnings
if validation.warnings:
print("Security warnings:", validation.warnings)
# Access optimization metadata
print(f"Token reduction: {result.metadata['token_metrics']['token_reduction']}")
print(f"Quality score: {result.metadata['evaluation']['overall_score']}")
print(result.optimized_prompt)
Token Tracking & Observability
from dmps.observability import dashboard
from dmps.token_tracker import token_tracker
# Monitor performance
dashboard.print_session_summary()
# Export metrics
dashboard.export_metrics("metrics.json")
# Get performance alerts
alerts = dashboard.get_performance_alerts()
for alert in alerts:
print(f"Alert: {alert}")
🛡️ Enterprise Security (v0.2.0)
DMPS includes comprehensive security protections:
- CWE-22 Protection: Path traversal attack prevention
- Input Sanitization: XSS and code injection prevention
- RBAC Authorization: Role-based access control for all operations
- Rate Limiting: Protection against abuse and DoS attacks
- Secure Error Handling: Information leak prevention
- Audit Logging: Complete security event tracking
- Token Validation: Secure API token management
Security Compliance: Follows OWASP guidelines and enterprise security standards.
CLI Usage
# Basic usage with automatic security validation
dmps "Your prompt here" --mode conversational --platform claude
# File input/output (automatically validates paths)
dmps --file input.txt --output results.txt
# Interactive mode with security monitoring
dmps --interactive
# REPL shell mode with RBAC protection
dmps --shell
# Show performance metrics
dmps "Optimize this" --metrics
# Export metrics to file
dmps "Test prompt" --export-metrics metrics.json
# Help
dmps --help
Security Features:
- Automatic path traversal protection
- Input sanitization and validation
- RBAC-controlled command access
- Rate limiting and session management
- Secure file operations with extension validation
Development
Setup Development Environment
# Install development tools and pre-commit hooks
python setup-dev.py
# Run quality checks
python scripts/format.py
Running Tests
python -m pytest tests/ -v
Code Quality
# Automated formatting and linting
black src/
isort src/
flake8 src/
mypy src/
# Security scanning
bandit -r src/
safety check
Quality Guardrails
- Pre-commit hooks: Automatic code quality validation
- CI/CD pipeline: Automated testing and security scanning
- Type checking: Full mypy integration
- Security scanning: Bandit and safety checks
See DEVELOPMENT.md for complete guidelines.
What's New in v0.2.0
- Enterprise Security: Complete security hardening with CWE-22 protection
- Token Tracking: Cost estimation and usage monitoring
- Observability Dashboard: Real-time performance monitoring
- Code Quality Guardrails: Pre-commit hooks and automated validation
- Enhanced Performance: 3-5x improvement in pattern matching
- Type Safety: Full mypy integration and type annotations
See CHANGELOG.md for complete release notes.
Contributing
Contributions are welcome! Please read DEVELOPMENT.md for guidelines.
- Fork the repository
- Create a feature branch
- Run quality checks:
python scripts/format.py - Submit a Pull Request
All contributions must pass security and quality checks.
Links
- PyPI: https://pypi.org/project/dmps/
- GitHub: https://github.com/MrBinnacle/dmps
- Documentation: docs/
- Security Guide: docs/SECURITY_GUIDE.md
- Development Guide: DEVELOPMENT.md
License
This project is licensed under the MIT License - see the LICENSE file for details.
DMPS v0.2.0 - Enterprise-grade AI prompt optimization with comprehensive security and observability.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dmps-0.2.1.tar.gz.
File metadata
- Download URL: dmps-0.2.1.tar.gz
- Upload date:
- Size: 63.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4c6bc05436428408e7854de72eba619ae61ff6f5cc7b54e35479127a3a5622f
|
|
| MD5 |
4b1394818c823900144131a754077cf8
|
|
| BLAKE2b-256 |
7fced437b8573137c2d1eaa6d405eb0466ea00167d2fd0ae8098e79af46c0e68
|
File details
Details for the file dmps-0.2.1-py3-none-any.whl.
File metadata
- Download URL: dmps-0.2.1-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc3321fe41ef7b89d8e4fe6a230ce726972d24c0d3a9716e28d73e567df5461
|
|
| MD5 |
9f0fe3c3959f3be33dff8471b314257c
|
|
| BLAKE2b-256 |
06456c93ae633615d47bf459d04ede2586072e07ec4d5f2ad601ee124a0aa742
|