fix: flatten proxy skip_commands schema and move docs to proxy-mode.md (#241)

- Replace nested policies map with flat skip_commands map in ProxyConfig
- Make skip_commands dependent on install_only being enabled
- Move proxy configuration docs from proxy.md to proxy-mode.md
- Update config template and tests for new schema
This commit is contained in:
Sahil Bansal
2026-05-06 19:26:39 +05:30
committed by GitHub
parent d1dd2560a4
commit d8abfb6c41
6 changed files with 63 additions and 84 deletions
+38 -4
View File
@@ -1,6 +1,6 @@
# Proxy Mode
PMG supports proxy based interception as an alternative to the current optimistic dependency resolution. When enabled via `--proxy-mode` flag:
PMG supports proxy based interception as an alternative to the current optimistic dependency resolution. When enabled:
- PMG starts a micro-proxy server on a random localhost port
- Runs `npm` and other supported package managers configured to use the proxy
@@ -10,17 +10,51 @@ PMG supports proxy based interception as an alternative to the current optimisti
## Usage
```bash
pmg --proxy-mode npm install lodash
pmg npm install lodash
```
## Configuration
To permanently enable proxy mode, add the following to your `config.yml` file:
Proxy behavior is configured under the `proxy:` section in `config.yml`:
```yaml
proxy_mode: true
proxy:
enabled: true
```
| Key | Default | Description |
|---|---|---|
| `enabled` | `true` | Enable proxy-based interception. When `false`, PMG falls back to guard-based analysis. |
| `install_only` | `false` | When `true`, only install commands are proxied. Other commands (e.g., `npm ls`, `pip list`) bypass the proxy and execute directly. |
| `skip_commands` | `{}` | Per-package-manager commands to bypass the proxy. Only applies when `install_only` is `true`. |
### Per-package-manager skip commands
The `skip_commands` map lets you define additional commands that should bypass the proxy for specific package managers. This only takes effect when `install_only` is `true`:
```yaml
proxy:
install_only: true
skip_commands:
npm: ["dev", "my-script"]
pip: ["list", "show"]
```
Commands in `skip_commands` are matched against the first non-flag argument. For example, `npm dev` would match `dev`, but `npm install dev` would not since `install` is the first non-flag argument.
### CLI flags
Use `--proxy-mode` to override `proxy.enabled` at runtime.
### Environment variables
| Variable | Description |
|---|---|
| `PMG_PROXY_ENABLED` | Override `proxy.enabled` |
| `PMG_PROXY_INSTALL_ONLY` | Override `proxy.install_only` |
Legacy variables `PMG_PROXY_MODE` and `PMG_PROXY_INSTALL_ONLY` (for the old flat config keys) are still supported when the `proxy:` section does not exist in the config file.
## Supported Package Managers
| Package Manager | Status |
-49
View File
@@ -3,55 +3,6 @@
A generic, extensible HTTP/HTTPS proxy server with man-in-the-middle (MITM) capabilities for intercepting and analyzing package manager traffic.
Built with [goproxy](https://github.com/elazarl/goproxy) library.
## Configuration
Proxy behavior is configured under the `proxy:` section in `config.yml`:
```yaml
proxy:
enabled: true
install_only: false
policies:
npm:
skip_commands: ["my-script"]
```
| Key | Default | Description |
|---|---|---|
| `enabled` | `true` | Enable proxy-based interception. When `false`, PMG falls back to guard-based analysis. |
| `install_only` | `false` | When `true`, only install commands are proxied. Other commands (e.g., `npm ls`, `pip list`) bypass the proxy and execute directly. |
| `policies` | `{}` | Per-package-manager policies. Each entry maps a package manager name to a policy with `skip_commands`. |
### Per-package-manager skip commands
The `policies` section lets you define additional commands that should bypass the proxy for specific package managers:
```yaml
proxy:
policies:
npm:
skip_commands: ["dev", "my-script"]
pip:
skip_commands: ["list", "show"]
```
Commands in `skip_commands` are matched against the first non-flag argument. For example, `npm dev` would match `dev`, but `npm install dev` would not since `install` is the first non-flag argument.
### CLI flags
| Flag | Description |
|---|---|
| `--proxy-mode` | Override `proxy.enabled` |
### Environment variables
| Variable | Description |
|---|---|
| `PMG_PROXY_ENABLED` | Override `proxy.enabled` |
| `PMG_PROXY_INSTALL_ONLY` | Override `proxy.install_only` |
Legacy variables `PMG_PROXY_MODE` and `PMG_PROXY_INSTALL_ONLY` (for the old flat config keys) are still supported when the `proxy:` section does not exist in the config file.
## Features
- Selective interception of HTTPS traffic