Bash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it)
The example in the project readme is imo already a bad example.
$ ai ask "Check process running on port"
Answer
Command is `lsof -i tcp:8000`
Apart from the facts that
- I would say the chances that lsof is installed are significant smaller than ss or netstat
- is lsof notably slower than ss
it is also inferior for the requested task because
- it returns any process connecting to this port not only the listening one. Which process is running on port 443 on my desktop? None. How many processes does 'lsof -i tcp:443` return? 20.
- it does not work if the listening process is from another user (if lsof is not run by root). In this case lsof -i returns nothing while ss -nltp returns the information that the port is listened and only cannot tell by which process because of missing permissions.
My answer to "which process uses port x"
ss -nltp sport = x