If arriving SJU from the US you WILL NOT have to clear Immigration, Customs or Agriculture. You’ll simply deplane and follow the overhead signs to the departure gate for your Cape Air flight. Make sure you don’t inadvertently leave the secure area because if you do you’ll have to re-clear TSA.

Assuming you’ll be flying back through SJU on your return trip, you’ll go through Immigration, Customs & TSA when you land at SJU and then connect to your flight back to the US mainland.