pub-package-explorer
8
总安装量
3
周安装量
#34163
全站排名
安装命令
npx skills add https://github.com/exaby73/skills --skill pub-package-explorer
Agent 安装分布
amp
3
opencode
3
kimi-cli
3
codex
3
claude-code
3
Skill 文档
Pub Package Explorer
Use this workflow to read source code for a dependency package in a Dart or Flutter project.
Resolve a Package Source Path
- Confirm the project contains
.dart_tool/package_config.json. - Read the package entry from
packages[]byname. - Extract:
rootUri(package root, usually in pub cache)packageUri(usuallylib/)
- Build source path as
rootUri + packageUri. - Convert
file://URI to a filesystem path before reading files.
Use this command pattern:
PACKAGE="analyzer"
CONFIG=".dart_tool/package_config.json"
SOURCE_URI="$(jq -r --arg pkg "$PACKAGE" '
.packages[]
| select(.name == $pkg)
| (.rootUri + (if (.rootUri | endswith("/")) then "" else "/" end) + .packageUri)
' "$CONFIG")"
Convert the URI to a local path:
SOURCE_PATH="$(printf '%s\n' "$SOURCE_URI" | sed 's#^file://##')"
Then inspect source files under that directory (rg, ls, cat).
Useful Variants
- Return only the package root:
jq -r --arg pkg "$PACKAGE" '
.packages[]
| select(.name == $pkg)
| .rootUri
' .dart_tool/package_config.json
- Return both root and package URI:
jq -r --arg pkg "$PACKAGE" '
.packages[]
| select(.name == $pkg)
| "\(.rootUri)\t\(.packageUri)"
' .dart_tool/package_config.json
Verification and Error Handling
- If no package matches, stop and report that the package is not in
package_config.json. - If
.dart_tool/package_config.jsonis missing, run dependency resolution first (dart pub getorflutter pub get) and retry. - Prefer reading from
rootUri + packageUribecause package APIs are exposed from that subpath, not always from the package root.