A Unified Evaluation-Instructed Framework for Query-Dependent Prompt Optimization