Opensrc
FreeFetch source code for npm packages to give AI coding agents deeper context
FreeFree tier
About Opensrc
Opensrc is a command-line tool that gives AI coding agents access to the source code of packages from npm, PyPI, crates.io, and GitHub repositories. It fetches and caches the source code locally, returning the file path so it can be used with standard Unix tools like grep, rg, or cat. This allows agents to read implementations, search patterns, and explore code beyond type definitions.
Key Features
Fetches source code for npm, PyPI, crates.io, and GitHub packages
Caches source code locally for instant repeated access
Outputs the cached path to stdout, compatible with subshells
Works with any command-line tool (rg, grep, cat, find, ls)
Progress information goes to stderr, path to stdout
Requirements: Node.js 18+ and Git
Pros & Cons
Pros
- Supports multiple package registries (npm, PyPI, crates.io, GitHub)
- Caches source locally for fast repeated access
- Works seamlessly with existing CLI tools via subshell expansion
- Simple and lightweight: a single command-line tool
- Clear separation of progress (stderr) and output (stdout)
Cons
- Requires Node.js 18+ and Git to be installed
- Currently only provides the 'path' command (limited command set)
- No direct integration with AI agents; requires manual piping
- Only fetches source code; no built-in search or analysis
Best For
AI coding agents gaining contextual understanding from source codeDebugging by reading package implementationsSearching across package source patterns with grep or ripgrepExploring library internals during developmentIntegrating package source into automated code analysis pipelines
FAQ
What is Opensrc?
Opensrc is a command-line tool that gives AI coding agents access to the source code of packages from various registries like npm, PyPI, crates.io, and GitHub.
How do I install Opensrc?
Install it globally via npm: npm install -g opensrc
Which registries are supported?
Opensrc supports npm, PyPI, crates.io (Cargo), and GitHub repositories (e.g., vercel/next.js).
How does caching work?
The source code is fetched on first use and then cached locally. Subsequent calls return the cached path instantly.
What commands are available?
The main command is 'path', which outputs the cached path to the package's source code. The tool is designed to be used within subshells.