$ show linshenkx/prompt-optimizer
Prompt Optimizer is a multi-platform AI prompt optimization tool that helps users craft better prompts for large language models (LLMs) and image generation models. The system supports web (Vue 3 + Naive UI), desktop (Electron), Chrome extension, MCP server, and Docker deployment via a pnpm monorepo. Core workflows include system/user prompt optimization, evaluation with structured compare (pair-judge, synthesis), image generation (text2image, image2image, multi-image), variable extraction/value generation, a template system with 40+ built-in bilingual (zh/en) templates, and smart favorites with resource-aware asset management. The architecture cleanly separates framework-agnostic core services (LLM adapters, evaluation, storage, template processing) from UI composables and Electron proxies, using adapter, registry, and factory patterns extensively. A notable strength is the comprehensive test infrastructure spanning unit (Vitest), integration (real LLM API helpers gated by environment flags), and E2E (Playwright with VCR record/replay). Weaknesses include significant template duplication (bilingual files maintained separately), IPC fragility between Electron main/renderer, provider adapter maintenance overhead (16+ text adapters, 6+ image adapters), and some dead/deprecated code paths carrying legacy migration layers.
The LLM identified 3 files worth highlighting for reuse:
Provides a storage abstraction through `IStorageProvider` interface and `StorageFactory` that selects between Dexie (IndexedDB), LocalStorage, Memory, and File implementations based on environment. Each implementation supports atomic updates, batch operations, import/export, and key-level locking. This pattern is cleanly isolated: another project could extract it to add offline persistence with pluggable backends. Demonstrates non-obvious skill in handling browser vs Node vs Electron storage differences with fallback strategies and startup safety checks.
A VCR (Video Cassette Recorder) test utility that records LLM API responses to JSON fixtures during `record` mode and replays them during `replay` mode, enabling deterministic, fast, and offline-compatible integration tests. It integrates with Playwright and Vitest, providing helpers like `waitForConditionOrVCRFailure` and `throwIfCurrentTestHasVCRFailure` to avoid cascading failures when fixtures drift. This is a self-contained, extractable asset: any project testing LLM-based features could adopt this pattern to reduce flakiness and API costs.
A Vue 3 composable that implements intelligent auto-scroll behavior for streaming output containers. It detects when the user manually scrolls away (via scroll direction/position heuristics) and pauses auto-scroll, resuming only when the user scrolls back to the bottom. It also handles edge cases like window resize and content overflow. The composable is fully isolated (no internal imports), depends only on Vue's `ref` and `onMounted`/`onUnmounted`, and can be dropped into any streaming UI component with minimal adaptation. Demonstrates user-experience craftsmanship beyond simple `scrollTop = scrollHeight`.