Install Auto Mode Gate
Install the package only after reviewing its source. OpenCode plugins and Pi extensions run with the user’s system permissions.
Install from npm
Section titled “Install from npm”OpenCode
Section titled “OpenCode”The recommended setup is to declare the package in the plugin array of your project or global opencode.json:
{ "$schema": "https://opencode.ai/config.json", "plugin": ["auto-mode-gate@0.3.0"]}Merge that entry into an existing plugin array without removing other plugins or configuration. OpenCode resolves configured npm plugins when it starts.
Alternatively, install it for the current project:
opencode plugin auto-mode-gate@0.3.0Add --global to install it for every project.
Verify the resolved plugin list:
opencode debug configThe resolved plugin list must contain the Auto Mode Gate entry.
Install globally:
pi install npm:auto-mode-gate@0.3.0Add -l for a project-local installation. Verify the package entry:
pi listInstall from a checkout
Section titled “Install from a checkout”The source loader flow uses one small loader file and does not edit host settings. Run the commands from the checkout root, keep the checkout at the same path, and restart the host after installing the loader.
OpenCode source loader
Section titled “OpenCode source loader”$scope = "project"$targetProject = "C:\path\to\project"$source = [System.Uri]::new((Resolve-Path .\src\opencode-runtime.ts).Path).AbsoluteUri$pluginRoot = if ($scope -eq "project") { Join-Path (Resolve-Path $targetProject).Path ".opencode\plugins"} elseif ($env:OPENCODE_CONFIG_DIR) { Join-Path $env:OPENCODE_CONFIG_DIR "plugins"} else { Join-Path $HOME ".config\opencode\plugins"}New-Item -ItemType Directory -Force $pluginRoot | Out-Null"export { AutoModeGatePlugin } from `"$source`";" | Set-Content -Encoding utf8 (Join-Path $pluginRoot "auto-mode-gate.ts")Verify discovery:
if ($scope -eq "project") { Push-Location $targetProject try { opencode debug config } finally { Pop-Location }} else { opencode debug config}Pi source loader
Section titled “Pi source loader”$scope = "project"$targetProject = "C:\path\to\project"$source = [System.Uri]::new((Resolve-Path .\src\pi-runtime.ts).Path).AbsoluteUri$extensionRoot = if ($scope -eq "project") { Join-Path (Resolve-Path $targetProject).Path ".pi\extensions\auto-mode-gate"} elseif ($env:PI_CODING_AGENT_DIR) { Join-Path $env:PI_CODING_AGENT_DIR "extensions\auto-mode-gate"} else { Join-Path $HOME ".pi\agent\extensions\auto-mode-gate"}New-Item -ItemType Directory -Force $extensionRoot | Out-Null"export { default } from `"$source`";" | Set-Content -Encoding utf8 (Join-Path $extensionRoot "index.ts")Pi loads project extensions after the project is trusted. A startup-only check that does not contact model providers is:
if ($scope -eq "project") { Push-Location $targetProject try { pi --offline --list-models } finally { Pop-Location }} else { pi --offline --list-models}Remove an installation
Section titled “Remove an installation”For npm installations, remove the package with the same scope used to install it:
pi remove npm:auto-mode-gatepi remove npm:auto-mode-gate -lOpenCode 1.18.18 has no plugin removal subcommand. Use opencode debug config to locate the configuration that supplied the plugin, remove only the matching Auto Mode Gate entry from its plugin array, restart OpenCode, and confirm that the plugin no longer appears.
For a source installation, delete only the loader created for Auto Mode Gate:
Remove-Item <plugin-root>\auto-mode-gate.tsRemove-Item -Recurse <extension-root>\auto-mode-gate