I spent a couple months creating a modular wave function collapse library that solves any kind of constraint problem where you can specify the collapse algorithm to match the problem. It's domain-independent since it uses generic "nodes" (graph nodes that can be of any predefined state) that have relationships with other nodes.
There are a few examples, so please feel free to experiment. If you can answer the questions listed out in the readme's Usage section, you'll have no trouble following an example similar to your problem's domain.