Just take a look at the current implementation of Pkg.installed():
function installed()
@warn "Pkg.installed() is deprecated"
deps = dependencies()
installs = Dict{String, VersionNumber}()
for (uuid, dep) in deps
dep.is_direct_dep || continue
dep.version === nothing && continue
installs[dep.name] = dep.version
end
return installs
end
You just need to look at the field is_direct_dep
.