Skip to content

Extract proxy internals as shared libraries #12

Closed

Description

@andrew

The proxy is a caching proxy that sits between package managers and their registries. It intercepts download requests, caches archives locally, and provides a web UI for inspecting cached packages. Several of its internal packages would be useful as shared libraries for the CLI.

Version delta

The proxy's internal/diff package downloads two version archives and generates a unified diff of their contents. It shows files added/deleted/modified/renamed, line counts, handles binary detection, and strips ecosystem-specific prefixes (npm's package/ wrapper). The core function is diff.Compare(), which takes two archives.Reader interfaces and returns a CompareResult with file-level diffs.

This is the missing step between git pkgs outdated telling you a new version exists and understanding what actually changed in it. A git pkgs delta lodash 4.17.20 4.17.21 command would fetch both archives, diff them, and show the result.

The diff library itself is generic. Extracting it from the proxy would let both the CLI and extensions use it directly.

Archive browsing

The proxy's internal/server/browse.go has handlers that list files inside a published package archive and extract individual files with MIME type detection. The API endpoints are:

  • GET /api/browse/{ecosystem}/{name}/{version} -- list files in a directory
  • GET /api/browse/{ecosystem}/{name}/{version}/file/* -- extract a single file

Combined with the registries module's URLBuilder.Download() for fetching the archive and the archives module for extraction, this could become a git pkgs browse --registry <package> mode that inspects published archives rather than locally installed packages.

The existing browse command handles installed packages. This would handle packages you haven't installed yet, or versions you're considering upgrading to.

Upstream URL resolution

The proxy's internal/upstream/resolver.go determines download URLs for 16 ecosystems with circuit breaker patterns and configurable authentication. The registries module has URLBuilder.Download() for some of this, but the resolver handles additional cases. Worth consolidating so the download logic lives in one place that both the proxy and CLI can use.

Activity

  1. transferred this issue fromgit-pkgs/git-pkgson Feb 27, 2026
  2. andrew commented on Feb 27, 2026

    @andrew
    ContributorAuthor

    Archive browsing and upstream URL resolution are done -- internal/archive was replaced by the archives module (4d5098e) and internal/upstream was replaced by registries/fetch (be8c4b9). The version delta diff package (internal/diff) is the remaining piece.

  3. andrew commented on Feb 27, 2026

    @andrew
    ContributorAuthor

    Diff package extracted. The archives module now has a diff subpackage (git-pkgs/archives#2) and the proxy imports it instead of its internal copy (#13). All three items from this issue are done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions