$PWD should start at the current working directory, and that is not the same if
you run the command in the terminal or if you runit from your program. You will
(and should) get different answers. Even if you run in the IDE compared to a
standalone.
If you want the home catalog you can use $HOM
There is some cool technology built by the Swedish company 13th Lab called
PointCloud. There is both an SDK, that might be turned in to an external, and a
PointCloud browser that you control with HTML/JavaScript that should not be
that hard to integrate into a LC app.
http://pointcloud.io
Ski