opensrc
Original:🇺🇸 English
Translated
Fetch source code for npm, PyPI, or crates.io packages and GitHub/GitLab repos to provide AI agents with implementation context beyond types and docs. Use when needing to understand how a library works internally, debug dependency issues, or explore package implementations.
4installs
Sourcethird774/dotfiles
Added on
NPX Install
npx skill4agent add third774/dotfiles opensrcTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →opensrc
CLI tool to fetch source code for packages/repos, giving AI coding agents deeper implementation context.
When to Use
- Need to understand how a library/package works internally (not just its interface)
- Debugging issues where types alone are insufficient
- Exploring implementation patterns in dependencies
- Agent needs to reference actual source code of a package
Quick Start
bash
# Install globally or use npx
npm install -g opensrc
# Fetch npm package (auto-detects installed version from lockfile)
npx opensrc zod
# Fetch from other registries
npx opensrc pypi:requests # Python/PyPI
npx opensrc crates:serde # Rust/crates.io
# Fetch GitHub repo directly
npx opensrc vercel/ai # owner/repo shorthand
npx opensrc github:owner/repo # explicit prefix
npx opensrc https://github.com/colinhacks/zod # full URL
# Fetch specific version/ref
npx opensrc zod@3.22.0
npx opensrc owner/repo@v1.0.0Commands
| Command | Description |
|---|---|
| Fetch source for packages/repos |
| List all fetched sources |
| Remove specific source |
| Remove all sources |
Output Structure
After fetching, sources stored in directory:
opensrc/opensrc/
├── settings.json # User preferences
├── sources.json # Index of fetched packages/repos
└── repos/
└── github.com/
└── owner/
└── repo/ # Cloned source codeFile Modifications
On first run, opensrc prompts to modify:
- - adds
.gitignoreto ignore listopensrc/ - - excludes
tsconfig.jsonfrom compilationopensrc/ - - adds section pointing agents to source code
AGENTS.md
Use or to skip prompt.
--modify--modify=falseKey Behaviors
- Version Detection - For npm, auto-detects installed version from ,
node_modules,package-lock.json, orpnpm-lock.yamlyarn.lock - Repository Resolution - Resolves package to its git repo via registry API, clones at matching tag
- Monorepo Support - Handles packages in monorepos via field
repository.directory - Shallow Clone - Uses for efficient cloning, removes
--depth 1after clone.git - Tag Fallback - Tries ,
v{version}, then default branch if tag not found{version}
Common Workflows
Fetching a Package
bash
# Agent needs to understand zod's implementation
npx opensrc zod
# → Detects version from lockfile
# → Finds repo URL from npm registry
# → Clones at matching git tag
# → Source available at opensrc/repos/github.com/colinhacks/zod/Updating Sources
bash
# Re-run same command to update to currently installed version
npx opensrc zod
# → Checks if version changed
# → Re-clones if neededMultiple Sources
bash
# Fetch multiple at once
npx opensrc react react-dom next
npx opensrc zod pypi:pydantic vercel/aiReferences
For detailed information:
- CLI Usage & Options - Full command reference
- Architecture - Code structure and extension
- Registry Support - npm, PyPI, crates.io details