Provisionally expel them all to Afghanistan and set up an actual immigration system complete with thorough background checks and interrogation for traitors allowing professionals, skilled labor, and traders which would benefit Pakistan.
Make an exception for those married to Pakistanis, widows, orphans, and economically/socially backwards Afghans. Give them full citizenship and integrate them into mainstream Pakistani society.
Make it mandatory for parents to send their children to Pakistani schools and treat them as Pakistanis. If they require assistance, state can provide it, or more preferably the state can collect donations from international NGOs on their behalf.