Get list of networked devices via CLI
You are using the correct dns-sd to discover local services. The problem is you need to search for all the potential items.

Screen sharing, AFP file sharing, SMB file sharing, etc...

Worse, if you have Back to My Mac and iCloud connected devices, not all of them are local, but they are still discoverable from the command line:


Is it possible to terminal login remotely (outside local network) to my mac at home via SSH + VPN?
Does Apple Remote Desktop connect to computers over the internet?
Screen Share connects to wrong device


If you wanted to pick apart all the ports / protocols you could use the Network Utility to port scan each device you see in you finder sidebar and look for the common ports that are listening.

Apple’s big list of ports and names is here:


https://support.apple.com/en-us/HT202944


I think you’ll get good coverage if you start with remote control, file sharing (VNC/AFP/SMB) though.