First, it's worth to make clear that Nupic is the official implementation of the HTM (together with htm.java), but there are plenty of others. As an implementation aimed, among other things, for commercial/industrial applications, it's may not be very faithful to the theory when performance is critical. The hierarchical part, altought is core to the theory, is not yet implemented, but people at Numenta is working on it. You could make a hierarchy with the Network API or by yourself, but getting good results is difficult, as there is not yet an aproppiate "glue" between regions.
To know how the SP and the current TM implementation works (The mathematical fundations), you could take a look at this paper. There's an equation of how many contexts can a region learn for each input: http://arxiv.org/abs/1511.00083
