I just built something similar, specific to Claude Code. It runs as a transparent HTTP proxy that reads & rewrites the entire messages array that CC sends to its API. Same “dreaming” consolidation approach (using Haiku and another instance of CC itself, so it uses your subscription). Check it out!
https://github.com/LabLeaks/spotless