feat: consolidate proxy config into structured section and add support for custom commands to skip proxy (#240)

* feat: add ProxyConfig struct with per-PM skip_commands and legacy fallback

* feat: consolidate proxy config into structured section with backward compat

Replaces flat proxy_mode/proxy_install_only keys with a structured proxy
section supporting per-package-manager skip_commands. Legacy keys are
respected via fallback when user's config lacks the new proxy section.
Removes deprecated experimental_proxy_mode config and flag.

* fix: env var resolution for nested config keys and deduplicate skip command matching

- Add "." to "_" in Viper env key replacer so nested keys like
  sandbox.enabled resolve from PMG_SANDBOX_ENABLED (was silently broken)
- Export IsFirstNonFlagArgInList and remove duplicate from proxy_flow.go
- Add table-driven tests for skip command matching with real-world cases
- Remove redundant env var test

* docs: update proxy configuration and env var documentation

Update config.md env var table to reflect new proxy.enabled and
proxy.install_only keys. Add proxy configuration section to proxy.md
covering config structure, per-PM skip commands, CLI flags, and env vars.

* fix: legacy fallback precedence
This commit is contained in:
Sahil Bansal
2026-05-06 18:27:23 +05:30
committed by GitHub
parent d6755d3f44
commit d1dd2560a4
15 changed files with 423 additions and 71 deletions
+4 -4
View File
@@ -47,7 +47,7 @@ type ParsedCommand struct {
// IsKnownNonDownloadCommand is true for commands that are known to not download packages
// (e.g., npm ls, pip list, yarn why). Used by the proxy to decide whether to skip
// interception when proxy_install_only is enabled. Unknown commands default to false so
// interception when proxy.install_only is enabled. Unknown commands default to false so
// the proxy runs — fail safe when a new subcommand is added to a package manager.
IsKnownNonDownloadCommand bool
}
@@ -77,10 +77,10 @@ func (pc *ParsedCommand) ShouldExtractFromManifest() bool {
return pc.IsManifestInstall && !pc.HasInstallTarget()
}
// isFirstNonFlagArgInList checks if the first non-flag argument in args is in nonDownloadCmds.
// IsFirstNonFlagArgInList checks if the first non-flag argument in args is in the given list.
// Only the first non-flag arg (the subcommand) is checked to avoid false positives when package
// names or script arguments happen to match a known non-download command.
func isFirstNonFlagArgInList(args []string, nonDownloadCmds []string) bool {
// names or script arguments happen to match a known command.
func IsFirstNonFlagArgInList(args []string, nonDownloadCmds []string) bool {
for _, arg := range args {
if strings.HasPrefix(arg, "-") {
continue