Open
Description
Add support for analyzing npm packages directly
Feature Request
Add the ability to analyze npm packages directly using their package name similar to the existing GitHub repository support.
Motivation
Many developers use npm and know packages by name rather than the corresponding github repo. This would streamline the workflow for:
- Quick analysis of dependencies
- Evaluating potential packages before installation
- Understanding package internals for debugging or learning purposes
Proposed Implementation
-
Primary Method: Extract GitHub repository information from package.json
repomix --npm-package express
- Parse the package's metadata to find the GitHub repository URL
- Use existing GitHub repository analysis functionality
-
Fallback Method: Direct package analysis from npm tarball
repomix --npm-package express --use-tarball
- Download and extract the package tarball
- Analyze contents directly when GitHub repository isn't available
Technical Details
-
Use the npm registry API to fetch package metadata:
https://registry.npmjs.org/[package-name]
-
Extract repository information from:
repository
field in package.jsonhomepage
field (if it's a GitHub URL)bugs
field (if it points to GitHub issues)
-
For tarball fallback:
- Use the
dist.tarball
URL from the package metadata - Extract and analyze the contents locally
- Use the
Example Usage
# Using package name
repomix --npm-package express
# Specific version
repomix --npm-package express@4.18.2
# Force tarball analysis
repomix --npm-package express --use-tarball
# With other existing options
repomix --npm-package express --compress --style markdown
Note: scoped packages like @org/package-name also exist and should work just fine.
Questions
- What would the website UI be for using npm package names & the tarball option?