Understand the opensrc resolution process
mainWhen you run opensrc path <package>, the tool performs the following steps to locate and provide the source code:
- Registry lookup: Queries the registry (e.g., npm) for package metadata.
- Repository detection: Extracts the
repositoryfield frompackage.jsonto find the source URL. - Version tagging: Maps the version to a git tag.
- Shallow clone: Performs a
git clone --depth 1for the specific version. - Cache storage: Saves the source in the local cache.
- Path output: Prints the absolute path to
stdout(progress information is sent tostderrto ensure compatibility with subshells).
Subsequent requests for the same package and version skip steps 1-4 and return the cached path immediately.