This article was translated from Japanese by AI and may contain inaccuracies. For the most accurate content, please refer to the original Japanese version.
アクアパッツァのイラスト

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

With the aqua: protocol added in pnpm 12.26.0, CLI tools such as gh and jq can be managed through devDependencies and pnpm-lock.yaml. This article walks through how it works and how to set it up.

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, the JavaScript package manager, added the aqua: protocol in pnpm 12.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) maintained by the aqua 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) looks like this:

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:

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).

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:

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:

package.json
{
  "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:

pnpm add --save-prod aqua:jqlang/jq
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.

pnpm-lock.yaml
importers:
 
  .:
    devDependencies:
      gh:
        specifier: aqua:cli/cli@^2.106.0
        version: cli@aqua:cli/[email protected]
      jq:
        specifier: aqua:jqlang/jq@^1.8.2
        version: aqua:jqlang/[email protected]
 
packages:
 
  cli@aqua:cli/[email protected]:
    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/[email protected]:
    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/[email protected] and jq@aqua:jqlang/[email protected], 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.

pnpm install --frozen-lockfile --offline
✓ 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.

ls -la node_modules/.bin
-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 as three separate lists, resolve, fetch, and required, to address these problems.

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:

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.

package.json
{
  "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.

pnpm run gh:version
$ gh --version
gh version 2.106.0 (2026-11-25)
https://github.com/cli/cli/releases/tag/v2.106.0
pnpm run jq:name
$ jq -r .name package.json
pnpm-aqua-protocol-dev-dependencies
pnpm exec jq --version
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.

pnx aqua:jqlang/jq --version
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

Comprehension check

Answer the following questions to deepen your understanding of the article.

When adding an `aqua:` protocol tool with `pnpm add`, which statement correctly describes which dependency group it goes into, and why?

  • Without `-D` it goes into `dependencies`; it is recorded in `devDependencies` only when `--save-dev` is passed

    Try again

    `aqua:` tools are added to `devDependencies` automatically even without `-D`. They cannot be placed in `dependencies`.

  • It is added to `devDependencies` even without `-D`, and trying to put it in another group with `--save-prod` or similar fails with an error

    Correct!

    A published package's `dependencies` and similar fields are also read by npm and Yarn, which do not understand `aqua:`. Tools are therefore restricted to `devDependencies`, and `--save-prod` and similar flags are rejected with `ERR_PNPM_TOOL_OUTSIDE_DEV_DEPENDENCIES`.

  • It can be added to `optionalDependencies`, and other package managers simply ignore it

    Try again

    Declaring a tool in `dependencies`, `optionalDependencies`, or `peerDependencies` all cause an error at install time.

  • It is recorded in a dedicated section of `pnpm-workspace.yaml`, so nothing is added to `package.json`

    Try again

    `aqua:` tools are written to `devDependencies` in `package.json` like any other dependency.

If you add a tool without an alias, as in `pnpm add aqua:cli/cli`, which combination of dependency name in `package.json` and command name linked into `node_modules/.bin` is correct?

  • The dependency name is `cli/cli`, and the command name is also `cli/cli`

    Try again

    When the alias is omitted, the last segment of `<name>` is used, so the dependency name is `cli`, not `cli/cli`.

  • The dependency name is `cli`, and the command name is the same `cli`

    Try again

    The command name linked into `node_modules/.bin` follows the aqua registry definition, not the alias, so it is not `cli`.

  • The dependency name is `cli`, and the command name is `gh`, as defined in the aqua registry

    Correct!

    Omitting the alias makes the last segment, `cli`, the dependency name, while the command name follows the aqua registry definition and is `gh`.

  • Both the dependency name and the command name are automatically converted to `gh`, so specifying `gh@` is unnecessary

    Try again

    To name the dependency `gh`, you need to specify the alias explicitly, as in `gh@aqua:cli/cli`.

Which `supportedArchitectures` setting makes dependency resolution fail when an `aqua:` tool has no asset for a listed platform?

  • `resolve`

    Try again

    `resolve` limits the range of platforms recorded in `pnpm-lock.yaml`.

  • `fetch`

    Try again

    `fetch` selects what gets downloaded to the local environment. Its default value is `[current]`.

  • `current`

    Try again

    `current` is a value that refers to the running environment, used in lists such as `fetch`. It is not a key that checks for required platforms.

  • `required`

    Correct!

    If an `aqua:` tool is missing an asset for a platform listed in `required`, dependency resolution fails with an error.