# Managing gh and jq as devDependencies with the aqua: Protocol in pnpm 12.26

Even in Node.js and frontend projects, development scripts and CI jobs often rely on CLI tools that are not npm packages, such as `gh`, `jq`, and ripgrep. These tools tend to be managed twice: locally through a separate tool like Homebrew or mise, and in CI through a dedicated GitHub Action or shell script.

[pnpm](https://pnpm.io/), the JavaScript package manager, added the [`aqua:` protocol](https://pnpm.io/package-sources#tools-from-their-publishers) in [pnpm 12.26.0](https://github.com/pnpm/pnpm/releases/tag/v12.26.0), released on December 2, 2026. With this feature, pnpm fetches CLI tools from the binaries and archives their publishers release, and you can manage them in `package.json` `devDependencies` and `pnpm-lock.yaml` just like any other dependency.

In this article, I use pnpm 12.26.0 to add `gh` and `jq` to `devDependencies` and walk through how to run and manage them.

## What is the `aqua:` protocol?

The `aqua:` protocol downloads and installs CLI tools directly from their publishers' releases, based on the definitions in the [aqua registry (`aquaproj/aqua-registry`)](https://github.com/aquaproj/aqua-registry) maintained by the [aqua](https://aquaproj.github.io/) project. For each tool, the aqua registry has a YAML file that describes "which GitHub repository's releases contain archives or binaries for which OS and CPU, and which file is the executable command."

For example, the definition for `gh` ([`pkgs/cli/cli/registry.yaml`](https://github.com/aquaproj/aqua-registry/blob/main/pkgs/cli/cli/registry.yaml)) looks like this:

```yaml:pkgs/cli/cli/registry.yaml
packages:
  - type: github_release
    repo_owner: cli
    repo_name: cli
    files:
      - name: gh
        src: gh_{{trimV .Version}}_{{.OS}}_{{.Arch}}/bin/gh
    version_constraint: "false"
    version_overrides:
      # Definitions for older versions and fields such as checksum are omitted
      - version_constraint: "true"
        asset: gh_{{trimV .Version}}_{{.OS}}_{{.Arch}}.{{.Format}}
        format: zip
        overrides:
          - goos: linux
            format: tar.gz
          - goos: windows
            files:
              - name: gh
                src: bin/gh.exe
        replacements:
          darwin: macOS
```

This YAML defines the following rules:

- `type`, `repo_owner`, `repo_name`: Specify the source GitHub repository and the distribution channel (GitHub Releases)
- `asset`, `format`, `replacements`: Build the asset name template from the version, OS, and CPU (e.g. `gh_2.106.0_macOS_arm64.zip`), mapping OS names that the release spells differently, such as `darwin`, to `macOS`
- `overrides`: Override per-OS differences. Here, the format for Linux is switched to `tar.gz`, and the executable path for Windows is switched to `bin/gh.exe`
- `files`: Define which file in the archive is linked under which command name (`gh`)

Because pnpm reads this definition and fetches the executable from the publisher's release, you can add tools to a project without going through a wrapper package on npm. In `package.json`, you write them like this:

```json:package.json
{
  "devDependencies": {
    "gh": "aqua:cli/cli@^2.106.0",
    "jq": "aqua:jqlang/jq@^1.8.2"
  }
}
```

Each entry takes the form `"<alias>": "aqua:<name>@<selector>"`. The parts mean the following:

- `<name>`: The tool's name in the aqua registry (usually in the form `<owner>/<repository>`)
- `<selector>`: A SemVer range, an exact version, or a release tag (if omitted, the latest stable release is chosen)
- `<alias>`: The dependency name in `package.json` (if omitted with `pnpm add`, the last segment of `<name>` is used)

Tools added with the `aqua:` protocol can only be placed in `devDependencies`. Declaring them in `dependencies`, `optionalDependencies`, `peerDependencies`, or in the `package.json` of a dependency causes an error at install time. These three fields of a published package are also read by npm, Yarn, and other package managers that do not understand `aqua:`, so the design limits tools to the project's own development dependencies.

## Adding `gh` and `jq` to `devDependencies`

Starting from an empty project, add `gh` and `jq` with `pnpm add`. Because `aqua:` tools are treated as development dependencies, they are written to `devDependencies` automatically even if you omit `-D` (`--save-dev`).

```bash
pnpm add gh@aqua:cli/cli aqua:jqlang/jq
```

Only `gh` has an explicit alias, `gh@`. When the alias is omitted, the last segment of `<name>` becomes the dependency name, so `aqua:jqlang/jq` is registered as `jq`, while `aqua:cli/cli` would be registered as `cli`.

:::warning
Operations that update the lockfile, such as `pnpm add` and `pnpm update`, call GitHub's releases API. Unauthenticated requests are limited to 60 per hour, and exceeding the limit fails with `ERR_PNPM_GITHUB_API_RATE_LIMIT`. Setting a GitHub personal access token in the `GITHUB_TOKEN` environment variable authenticates the requests and raises the limit to 5,000 per hour.
:::

Running the command above with pnpm 12.26.0 downloaded and installed the tools as follows:

```text
Progress: resolved 2, reused 0, downloaded 2, added 1
Packages: +2 (100% downloaded)
↓↓

devDependencies:
+ gh <- cli 2.106.0
+ jq 1.8.2

Done in 4.5s using pnpm v12.26.0
```

The line `+ gh <- cli 2.106.0` shows that `cli`, the last segment of `cli/cli`, was registered under the alias `gh`. After running the command, `package.json` looks like this:

```json:package.json {5-6}
{
  "name": "pnpm-aqua-protocol-dev-dependencies",
  "private": true,
  "devDependencies": {
    "gh": "aqua:cli/cli@^2.106.0",
    "jq": "aqua:jqlang/jq@^1.8.2"
  }
}
```

If you try to add a tool to `dependencies` with `--save-prod`, pnpm rejects it with `ERR_PNPM_TOOL_OUTSIDE_DEV_DEPENDENCIES`:

```bash
pnpm add --save-prod aqua:jqlang/jq
```

```text
Error: ERR_PNPM_TOOL_OUTSIDE_DEV_DEPENDENCIES

  × adding a new package
  ╰─▶ jq is an aqua tool, which can only be a development dependency
  help: Add it without --save-prod, --save-optional or --save-peer. A package's consumers would install any other group, and npm and Yarn do not know the aqua: protocol.
```

`--save-optional` and `--save-peer` produce the same error.

## How `pnpm-lock.yaml` and `node_modules/.bin` behave

When `pnpm add` or `pnpm update` resolves an `aqua:` tool, pnpm consults the aqua registry definition and the GitHub API (release information) to determine, for each OS and CPU, the download URL of the archive or binary, its format, the path of the executable, and its SHA-256 checksum. It then writes them to the `importers`, `packages`, and `snapshots` sections of `pnpm-lock.yaml`. This lets development machines on different OSes and CI reproduce the same untampered binaries, and installs from the lockfile do not need to query the aqua registry or the GitHub API again.

Let's look at the key parts of the generated `pnpm-lock.yaml`.

```yaml:pnpm-lock.yaml {5-10,14,19,22,32,35,45,50,53}
importers:

  .:
    devDependencies:
      gh:
        specifier: aqua:cli/cli@^2.106.0
        version: cli@aqua:cli/cli@2.106.0
      jq:
        specifier: aqua:jqlang/jq@^1.8.2
        version: aqua:jqlang/jq@1.8.2

packages:

  cli@aqua:cli/cli@2.106.0:
    resolution:
      type: variations
      variants:
        - resolution:
            archive: tarball
            bin:
              gh: bin/gh
            integrity: sha256-pHZEn6liVBPFSjc07e1i6eSA5J9CH/COfzs4ecBZoDM=
            type: binary
            url: https://github.com/cli/cli/releases/download/v2.106.0/gh_2.106.0_linux_amd64.tar.gz
          targets:
            - cpu: x64
              os: linux
            - cpu: x64
              os: linux
              libc: musl
        - resolution:
            archive: zip
            bin:
              gh: gh_2.106.0_macOS_arm64/bin/gh
            integrity: sha256-IrK3I9+8abYCKxsIYE/1HA21qotndLTO0aR7hBOpldY=
            type: binary
            url: https://github.com/cli/cli/releases/download/v2.106.0/gh_2.106.0_macOS_arm64.zip
          targets:
            - cpu: arm64
              os: darwin
        # Variants for linux/arm64, darwin/x64, win32/x64, and win32/arm64 follow
    version: 2.106.0
    hasBin: true

  jq@aqua:jqlang/jq@1.8.2:
    resolution:
      type: variations
      variants:
        - resolution:
            archive: file
            bin:
              jq: jq
            integrity: sha256-LXU0C6V6S0tMhwiiHC3I6VikiqqLuhOyf3f25MDsoH4=
            type: binary
            url: https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-macos-arm64
          targets:
            - cpu: arm64
              os: darwin
        # Variants for linux/x64, linux/arm64, darwin/x64, and win32/x64 and arm64 follow
    version: 1.8.2
    hasBin: true
```

This lockfile has the following characteristics:

- As in `cli@aqua:cli/cli@2.106.0` and `jq@aqua:jqlang/jq@1.8.2`, the package-name position holds the last segment of the registry name, and the version position is qualified as `aqua:<registry name>@<version>`. pnpm uses the package name as a directory name and validates it against npm's package name rules, so a registry name containing a slash, like `cli/cli`, cannot be used as the package name. Instead, as with the URL of a git dependency, the registry name is carried on the version side. Because the key does not depend on the alias, referencing the same tool under different aliases shares one entry, and no key can be mistaken for an npm package's
- For `gh`, the Linux variants are recorded as `archive: tarball` and the macOS and Windows variants as `archive: zip`, with `bin/gh` or `gh_2.106.0_macOS_arm64/bin/gh` inside the archive mapped to the `gh` command. `jq`, on the other hand, is distributed as a standalone binary rather than a compressed archive, so it is recorded as `archive: file`
- Each platform's download URL is pinned with `integrity: sha256-...`. Even when you run `pnpm add` on macOS, the URLs and checksums for Linux and Windows are recorded as well, so other OSes and CI environments can install from the same lockfile as is

`pnpm install --frozen-lockfile`, which installs from the lockfile, skips the resolution step and does not contact the aqua registry or the GitHub API. On a fresh environment with no cache, pnpm downloads only the binaries from the URLs in the lockfile and verifies their hashes; if the pnpm store already has them cached, it can restore them entirely offline. When I copied only `package.json` and `pnpm-lock.yaml` to another directory and reinstalled with `--offline`, it finished in 126ms from the store cache.

```bash
pnpm install --frozen-lockfile --offline
```

```text
✓ Lockfile passes supply-chain policies
· Lockfile is up to date, resolution step is skipped
Progress: resolved 2, reused 2, downloaded 0, added 0
Packages: +2 (100% reused)
++

Done in 126ms using pnpm v12.26.0
```

Looking at `node_modules/.bin` after the install, both `gh` and `jq` are there as executables that invoke the binaries in the virtual store.

```bash
ls -la node_modules/.bin
```

```text
-rwxr-xr-x@ 1 user  staff  3844 Dec  6 11:28 gh
-rwxr-xr-x@ 1 user  staff  3780 Dec  6 11:28 jq
```

### Controlling target platforms with `supportedArchitectures`

By default, every OS and CPU a tool is distributed for is recorded in `pnpm-lock.yaml`. In team development and CI, however, this can cause two problems:

- For assets whose digest the GitHub API does not report, pnpm downloads the file for each OS it locks and computes the hash itself. If OSes your project never uses are included, fetching those unnecessary binaries costs time and bandwidth
- If you `pnpm add` a tool on one OS when it does not ship binaries for another OS, the add succeeds, and the error only surfaces later when a teammate on the unsupported OS or CI runs `pnpm install --frozen-lockfile`

pnpm 12.26.0 lets you specify [`supportedArchitectures`](https://pnpm.io/settings/dependency-resolution#lockfile-coverage-and-local-downloads) as three separate lists, `resolve`, `fetch`, and `required`, to address these problems.

```yaml:pnpm-workspace.yaml
supportedArchitectures:
  resolve: [darwin-arm64, linux-x64, win32-x64]
  fetch: [current]
  required: [darwin-arm64, linux-x64]
```

Each key does the following:

- `resolve`: Limits the range of platforms recorded in `pnpm-lock.yaml`, avoiding hashing and locking for OSes you don't need
- `fetch`: Selects what gets downloaded to the local environment (default: `[current]`)
- `required`: Specifies the platforms your team or CI must support. If an `aqua:` tool has no asset for a listed platform, dependency resolution such as `pnpm add` fails with an error

When I actually removed the current environment from `resolve`, I got the following error:

```bash
Error: ERR_PNPM_UNSUPPORTED_PLATFORM
  ╰─▶ supportedArchitectures.fetch target current (darwin-arm64) is outside supportedArchitectures.resolve
```

## Running tools with `pnpm exec` and `scripts`

Tools linked into `node_modules/.bin` can be invoked with `pnpm exec` or from `scripts` in `package.json`, just like the CLI of a regular npm package.

First, add scripts that run `gh` and `jq` to `package.json`.

```json:package.json {4-7}
{
  "name": "pnpm-aqua-protocol-dev-dependencies",
  "private": true,
  "scripts": {
    "gh:version": "gh --version",
    "jq:name": "jq -r .name package.json"
  },
  "devDependencies": {
    "gh": "aqua:cli/cli@^2.106.0",
    "jq": "aqua:jqlang/jq@^1.8.2"
  }
}
```

When you run these scripts or `pnpm exec`, the versions pinned in `devDependencies` are launched, regardless of whether `gh` or `jq` is also installed locally through Homebrew or similar.

```bash
pnpm run gh:version
```

```text
$ gh --version
gh version 2.106.0 (2026-11-25)
https://github.com/cli/cli/releases/tag/v2.106.0
```

```bash
pnpm run jq:name
```

```text
$ jq -r .name package.json
pnpm-aqua-protocol-dev-dependencies
```

```bash
pnpm exec jq --version
```

```text
jq-1.8.2
```

As with regular dependencies, `pnpm outdated`, `pnpm update`, `pnpm remove`, and `pnpm why` all work as usual.

### Running a tool once with `pnx` without adding it as a dependency

If you want to run a tool just once without adding it to the project's `package.json`, use `pnx`.

```bash
pnx aqua:jqlang/jq --version
```

```text
Packages: +1 (100% reused)
+

devDependencies:
+ jq 1.8.2
jq-1.8.2

Done in 1.3s using pnpm v12.26.0
```

If the same version is already cached in pnpm's content-addressable store, it is reused without being downloaded again.

## Summary

- With the `aqua:` protocol in pnpm 12.26.0, you can fetch CLI tools registered in the aqua registry, such as `gh` and `jq`, from their publishers' releases and manage them as `devDependencies`
- `pnpm add gh@aqua:cli/cli aqua:jqlang/jq` adds tools to `devDependencies` even without `-D`, while `--save-prod` or declaring them in `dependencies` fails with `ERR_PNPM_TOOL_OUTSIDE_DEV_DEPENDENCIES`
- `pnpm-lock.yaml` records the download URL and SHA-256 checksum for each OS and CPU as `variations`, and installs with `--frozen-lockfile` do not contact the GitHub API or the aqua registry
- Installed tools are linked into `node_modules/.bin`, so you can run them with `pnpm exec` or from `scripts` in `package.json` just like regular npm tools, and use `pnx` for one-off runs
- Use the `resolve`, `fetch`, and `required` lists of `supportedArchitectures` to control which platforms are locked and which are required

## References

- [Supported package sources - Tools from their publishers | pnpm](https://pnpm.io/package-sources#tools-from-their-publishers)
- [Dependency resolution settings - supportedArchitectures | pnpm](https://pnpm.io/settings/dependency-resolution#lockfile-coverage-and-local-downloads)
- [Release pnpm 12.26 (v12.26.0) · pnpm/pnpm](https://github.com/pnpm/pnpm/releases/tag/v12.26.0)
- [PR #18587: feat: install command-line tools from their publishers' releases · pnpm/pnpm](https://github.com/pnpm/pnpm/pull/18587)
- [PR #18593: feat: configure platforms for resolution and fetching · pnpm/pnpm](https://github.com/pnpm/pnpm/pull/18593)
- [aquaproj/aqua-registry](https://github.com/aquaproj/aqua-registry)
  