I'm a bit confused by implementation ambiguities - for instance rotating the hue wheel by 180 degrees "feels" right for getting a complementary color, but at the same time Adobe Kuler produces identical output for both dark and light shades of the "seed" color. I'm not sure if this is a bug/feature of the Adobe tool specifically, or a chapter of color theory that I've missed completely.
Is there a js library (or one portable from a different language) that adheres to "reference" formulas for calculation of such related color palettes? I am referring to "conventional" analogous, complementary, compound etc. palettes.
Edit: to avoid treating this as "off-topic", I'm seeking a javascript implementation - but will accept answers in other languages or formulas/reference sufficient to build one from scratch.