Skip to content

feat(tools): NuGet enrichment in get_dependency_blast_radius - #105

Open
manus-use wants to merge 1 commit into
mainfrom
feat/enrich-nuget
Open

feat(tools): NuGet enrichment in get_dependency_blast_radius#105
manus-use wants to merge 1 commit into
mainfrom
feat/enrich-nuget

Conversation

@manus-use

Copy link
Copy Markdown
Owner

Summary

Adds .NET / NuGet enrichment to get_dependency_blast_radius, completing six-ecosystem coverage for the blast-radius tool:

Ecosystem Enricher Status
npm _enrich_npm ✅ merged
PyPI _enrich_pypi ✅ merged
Maven _enrich_maven ✅ merged
crates.io (Rust) _enrich_crates 🟡 PR #103 open
RubyGems (Ruby) _enrich_rubygems 🟡 PR #104 open
NuGet (.NET) _enrich_nuget this PR

What changed

src/manus_agent/tools/get_dependency_blast_radius.py

New helpers:

  • _extract_nuget_first_release(pages) — walks NuGet registration pages to find the earliest published date and count total versions; handles all ISO-8601 variants (Z suffix, +HH:MM offset, no-TZ naive, sub-second fractions including 7-digit .NET ticks); isolated per-item try/except so one malformed date doesn't abort the scan.

  • _enrich_nuget(name) — two-call enrichment, consistent with the other enrichers:

    1. NuGet Search API (azuresearch-usnc.nuget.org/query?q={name}&prerelease=false) → total_downloads, latest_version, description (truncated to 120 chars), home_page
    2. NuGet Registration API (api.nuget.org/v3/registration5/{name}/index.json) → total_versions, first_release_date, age_years

    Both calls are individually guarded; failure of either does not prevent the other from returning data.

Updated:

  • _enrich_package dispatch — routes "nuget" / ".net" / "dotnet" / "csharp" / "c#" to _enrich_nuget.
  • _blast_score — when weekly_downloads is absent, proxies from total_downloads / max(age_years * 52, 1). NuGet's search API returns all-time totals rather than per-week stats; the same fallback strategy is used by the crates.io and RubyGems enrichers in PRs feat: add crates.io enrichment to get_dependency_blast_radius #103/feat(tools): RubyGems enrichment in get_dependency_blast_radius #104.
  • NuGet output block added to the main tool report (latest version, total versions, all-time downloads, first-release date with age, description, home page).
  • Module-level docstring updated (added sources 7 & 8; NuGet added to per-ecosystem metrics list).

tests/test_nuget_enrichment.py (new, 34 tests)

Class Coverage
TestExtractNugetFirstRelease All ISO-8601 variants, multi-page aggregation, malformed date skipping, empty pages, age_years, total_versions
TestEnrichNuget Happy path, case-insensitive ID match, description truncation, search error, registration error, both errors, non-matching result, version count
TestEnrichPackageNuGetDispatch All five ecosystem aliases routing to _enrich_nuget
TestBlastScoreNuGetFallback total_downloads proxy, weekly_downloads precedence, zero-age guard

Suite result: 1192 passed, 0 failures (was 1158 before this PR).

No real HTTP calls

All 34 tests use unittest.mock.patch on requests.get. Zero network I/O.

Existing open PRs checked (no overlap)

Confirmed no duplication against: #51, #53, #54, #58, #60, #64, #65, #67, #74, #75, #76, #77, #78, #79, #80, #82, #83, #85, #86, #87, #88, #89, #90, #96, #97, #98, #100, #103, #104

None of the open PRs implement NuGet enrichment or touch _enrich_nuget.

Add _enrich_nuget(name) + _extract_nuget_first_release(pages) helpers to
get_dependency_blast_radius.py, completing five-ecosystem coverage:
npm ✓  PyPI ✓  Maven ✓  crates.io (PR #103) ✓  RubyGems (PR #104) ✓  NuGet ✓

Two-call enrichment pattern (consistent with the other enrichers):
  1. NuGet Search API (azuresearch-usnc.nuget.org/query) →
       total_downloads, latest_version, description (truncated to 120 chars),
       home_page (projectUrl)
  2. NuGet Registration API (api.nuget.org/v3/registration5/{name}/index.json) →
       version history, first_release_date (ISO 8601 → YYYY-MM-DD),
       age_years, total_versions; each call isolated so failure does not
       prevent the other from returning data.

_blast_score updated: when weekly_downloads is absent, proxy weekly from
total_downloads / max(age_years * 52, 1) — same approach as the crates.io
and RubyGems enrichers in open PRs #103 / #104.

Ecosystem dispatch: "nuget" / ".net" / "dotnet" / "csharp" / "c#"
NuGet output block added to main tool report section.
Docstring updated (data sources list + per-ecosystem metric docs).

34 new tests in tests/test_nuget_enrichment.py covering:
  - _extract_nuget_first_release: all ISO-8601 variants (Z suffix,
    +HH:MM offset, no TZ, sub-second fraction, 7-digit fraction),
    multi-page aggregation, malformed date skipping, empty pages,
    version count, age_years
  - _enrich_nuget: happy path, case-insensitive ID match, description
    truncation, graceful degradation for search error, registration
    error, both errors, non-matching search result, version count
  - _enrich_package dispatch: all five NuGet ecosystem aliases
  - _blast_score: total_downloads proxy, precedence of weekly_downloads,
    zero age_years guard (no ZeroDivisionError)

1192 tests pass, 0 failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant