pub-package-explorer

📁 exaby73/skills 📅 5 days ago
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

  1. Confirm the project contains .dart_tool/package_config.json.
  2. Read the package entry from packages[] by name.
  3. Extract:
  • rootUri (package root, usually in pub cache)
  • packageUri (usually lib/)
  1. Build source path as rootUri + packageUri.
  2. 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.json is missing, run dependency resolution first (dart pub get or flutter pub get) and retry.
  • Prefer reading from rootUri + packageUri because package APIs are exposed from that subpath, not always from the package root.