This point was raised by Pakistan Amb. to US. That Afghanistan is given access to Pakistani ports because it is a landlocked country and according to international law must be given transit rights to access ports. He then said according the same international law Afghanistan must give transit rights to Tajikistan and other CARs to access Pakistani ports.
First Pakistan must sign a pact with Afghanistan to uphold international law in this regard. Their 3 million citizens in Pakistan seems like the only leverage we have, so if they don't agree push a hundred thousand Afghan citizens into Afghanistan and keep doing it in intervals until they agree or we have zero Afghans.