Skip to content

Add support for analyzing npm packages directly #412

Open
@eastlondoner

Description

@eastlondoner

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

  1. 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
  2. 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

  1. Use the npm registry API to fetch package metadata:

    https://registry.npmjs.org/[package-name]
    
  2. Extract repository information from:

    • repository field in package.json
    • homepage field (if it's a GitHub URL)
    • bugs field (if it points to GitHub issues)
  3. For tarball fallback:

    • Use the dist.tarball URL from the package metadata
    • Extract and analyze the contents locally

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

  1. What would the website UI be for using npm package names & the tarball option?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions