New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

opencode-package-managers-hook

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencode-package-managers-hook

OpenCode plugin that rewrites package manager commands to your preferred tools — uv/pipx over pip, pnpm over npm, rbenv over bare gem, and more

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

opencode-package-managers-hook

OpenCode plugin that rewrites package manager commands to your preferred tools — uv/pipx over pip, pnpm over npm, rbenv over bare gem, and more.

npm version npm downloads License made with vibes

Stop OpenCode from running pip install --break-system-packages or any other bare package manager you'd rather not use. Every ecosystem is independently configurable with three modes: rewrite (silently transform), block (throw an error with guidance), or off (leave it alone).

Supported ecosystems

EcosystemBanned commandsDefault rewrite target
Pythonpip, pip3, python -m pip, virtualenv, python -m venv, bare pythonuv pip, pipx install (global), uv venv, uv run python
Nodenpm, npx, yarnpnpm, pnpm dlx
Rubybare gem, bare bundlerbenv exec gem, rbenv exec bundle

The plugin probes your $PATH at startup — if a preferred tool (e.g. uv, pnpm, rbenv) isn't installed, that ecosystem's rewriter is silently disabled.

Install

opencode plugin opencode-package-managers-hook -g

Or manually:

npm install -g opencode-package-managers-hook

Then add to your opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-package-managers-hook"]
}

Configuration

Pass options via the tuple form in your opencode.json:

{
  "plugin": [
    ["opencode-package-managers-hook", {
      "python": {
        "mode": "rewrite",
        "install": "uv pip install",
        "globalInstall": "pipx install",
        "venv": "uv venv",
        "run": "uv run python",
        "stripBreakSystemPackages": true,
        "poetryMode": "off"
      },
      "node": {
        "mode": "rewrite",
        "target": "pnpm",
        "exec": "pnpm dlx",
        "rewriteYarn": true
      },
      "ruby": {
        "mode": "block",
        "rbenvExec": true
      },
      "verbose": false
    }]
  ]
}

All fields are optional — the defaults shown above apply when omitted.

Per-ecosystem options

Python

OptionTypeDefaultDescription
mode"rewrite" | "block" | "off""rewrite"Action when pip/pip3 is used
installstring"uv pip install"Replacement for pip install
globalInstallstring"pipx install"Replacement for pip install --user and pipx install
venvstring"uv venv"Replacement for python -m venv / virtualenv
runstring"uv run python"Replacement for bare python <script>
stripBreakSystemPackagesbooleantrueRemove --break-system-packages from any surviving command
poetryMode"rewrite" | "block" | "off""off"Whether to also rewrite poetry commands to uv equivalents

Node

OptionTypeDefaultDescription
mode"rewrite" | "block" | "off""rewrite"Action when npm/npx is used
targetstring"pnpm"Tool to rewrite npm commands to
execstring"pnpm dlx"Tool to rewrite npx to
rewriteYarnbooleantrueAlso rewrite yarn to target

Ruby

OptionTypeDefaultDescription
mode"rewrite" | "block" | "off""block"Action when bare gem/bundle is used
rbenvExecbooleantruePrepend rbenv exec to gem/bundle

Disabling an ecosystem

Set any ecosystem to false to disable it entirely:

{
  "plugin": [
    ["opencode-package-managers-hook", {
      "ruby": false
    }]
  ]
}

Blocking instead of rewriting

Use "block" mode to hard-fail with a helpful error message instead of silently rewriting:

{
  "plugin": [
    ["opencode-package-managers-hook", {
      "python": { "mode": "block" },
      "node": { "mode": "block" }
    }]
  ]
}

How it works

  • On startup, the plugin checks which preferred tools (uv, pipx, pnpm, rbenv) exist on your $PATH.
  • It builds a chain of rewriters for each enabled ecosystem whose tools are present.
  • On every bash tool invocation, the tool.execute.before hook runs the command through the rewriter chain.
  • Commands already using preferred tools (uv, pnpm, bun, rbenv, etc.) are skipped.
  • In "rewrite" mode, the command is silently transformed. In "block" mode, an error is thrown with guidance on what to use instead.

Rewrite examples

OriginalRewritten to
pip install requestsuv pip install requests
pip3 install --user awsclipipx install awscli
pip install --break-system-packages foouv pip install foo
python -m pip install flaskuv pip install flask
python -m venv .venvuv venv .venv
virtualenv envuv venv env
python script.pyuv run python script.py
poetry installuv sync (when poetryMode: "rewrite")
poetry add flaskuv add flask (when poetryMode: "rewrite")
npm install expresspnpm install express
npx create-react-app my-apppnpm dlx create-react-app my-app
yarn add lodashpnpm add lodash
gem install railsrbenv exec gem install rails (rewrite) or blocked
bundle installrbenv exec bundle install (rewrite) or blocked

Development

bun install
bun run typecheck
bun run build

Releasing

npm version patch && git push --follow-tags

The publish workflow handles npm (Trusted Publishing + provenance) and the GitHub Release.

License

MIT

Keywords

opencode

FAQs

Package last updated on 17 Jun 2026

Related posts