Okay, this took me a few days because I decided I needed visual aids. I'm still genuinely not sure if this will make sense to anyone's brain but my own, but I'll give it a try.
Here's the setup before you start:
This is all stockinette in the round, so the knit side of the stitches is facing you on the front needle, and the purl side is facing you on the back needle. We'll be thinking of the stitches on the back needle as purl stitches from now on.
So, the basic principles are:
Go through each stitch twice: once purlwise and once knitwise (but not necessarily in that order).
After the first pass through a stitch, switch to the other needle.
Here's the key: the second pass ("off") through each stitch matches the type of stitch it is. In other words, if the knit side of the stitch is facing you, knit it off. If the purl side is facing you, purl it off.
That means that the first pass ("on") is the opposite. If you're looking at knit stitches, you want to purl on. If you're looking at purl stitches, knit on.
You can see in the photo that the yarn tail is coming off the last stitch on the back needle. You'll start on the front needle. Since this is the first pass through the stitch and it's a knit stitch, you go through purlwise.
That was your first pass through the stitch, so now you switch to the back needle. It's a purl stitch, and this is your first pass through it, so you go through knitwise.
Now you're looking at the purl side. This is the first pass, so you knit on and switch to the front. (No photo here because I can't get one where you can really see what's happening, but hopefully you get the idea. Sorry friends, I only have two hands and no special photography equipment.)
Again, that was your first pass through, so you switch to the front needle. You've already gone through the stitch once now, so it's ready to come off. Knitwise, because it's a knit stitch.
Then you go on to the next stitch on that needle. First pass through it is purlwise.
Then you switch needles again and take the first stitch off purlwise, because it's a purl stitch. Go on to the next stitch and pass through it knitwise and switch. And continue on like that until you're out of stitches.
This is really hard to write out verbally, but I find it a lot easier to think through it this way than to memorize an incantation. It also means that if you get interrupted, it's easy to figure out where you were and what comes next:
Where am I? Well, the yarn is coming out of a stitch on the front needle, so I must just have gone through that purlwise. I need to switch needles and take off the last stitch on the back needle, and it's going to be purlwise since that's the purl side.
Et voila! It's...well, in this case it's a weird little pouch thing.
I think this principle should work for non-stockinette grafting, but I haven't tried it since the only thing I ever graft is sock toes.