-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Promptimprover operates as a local stdio MCP server sitting between your AI CLI and the language model. Every prompt passes through the refinement pipeline before reaching the model.
flowchart LR
CLI["AI CLI\n(Claude / Cursor)"] -->|"stdio"| PI["Promptimprover\n(prompt-refiner)"]
subgraph internal["Promptimprover Engine"]
RAG["RAG Snippets\n(FlexSearch)"]
Memory["SQLite Memory\n(LocalBrain)"]
AutoHeal["Auto-Heal\n(BackgroundService)"]
end
PI --> RAG
PI --> Memory
PI --> AutoHeal
internal --> Out["Augmented Prompt"]
The MCP server entry point (src/core/server.ts). Registers MCP tools, handles refine_prompt tool calls over stdio transport, and coordinates the refinement pipeline. All prompt augmentation logic is triggered from here.
Stack detection layer (src/detectors/project-scout.ts). NodeDetector, PythonDetector, and ArchitecturalScout inspect the project root at startup to identify the tech stack and architectural patterns. This context is injected into every refined prompt.
FlexSearch-based retrieval over the local codebase (src/memory/neural-snippets.ts). Indexes source files and retrieves the most relevant code examples matching each incoming prompt. Provides concrete, project-specific code context rather than generic examples.
JSON-backed pattern store in .refiner/memory.json (src/memory/local-brain.ts). Accumulates project-specific coding rules and standards patterns learned over time. Grows more accurate as the system observes more prompts and outcomes.
Core augmentation logic (src/refiners/prompt-refiner.ts, src/refiners/prompt-optimizer.ts). Applies project context from ProjectScout, learned patterns from LocalBrain, RAG snippets from NeuralSnippets, and any mandates from .gemini-refiner.json to produce the augmented prompt.
chokidar file watcher (src/core/background-service.ts). Monitors the project directory for file changes and triggers commit ingestion and lesson extraction automatically. Keeps the memory and context stores current without requiring manual intervention.
SQLite-backed history pipeline (src/history/). CommitIngester reads git log; CorrelationEngine links commits to outcomes; LessonExtractor derives actionable lessons. These feed back into LocalBrain for predictive prompt refinement.
Local web UI on port 3000 (src/core/dashboard.ts). Displays agent activity logs and AgenticBlackboard state. Not exposed externally — local inspection only.