← Catalog

auto-mode-gate

Deterministic-first permission control for OpenCode and Pi

Package

Install

Install with PiG

pig install npm:auto-mode-gate

Install with Pi

pi install npm:auto-mode-gate
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/pi-runtime.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.4.4 (README.md). PiG does not review it.

Auto Mode Gate logo

Auto Mode Gate

Deterministic-first permission control for OpenCode and Pi.

CI status npm version MIT license

Documentation · Install · Releases · Contributing

[!IMPORTANT] Auto Mode Gate covers only the built-in bash tool through validated host hooks and is not an operating-system sandbox. A separately launched child host must load its own adapter. Read the security policy.

What it does

Auto Mode Gate is a pre-tool gate for people running OpenCode or Pi who want deterministic checks on built-in bash calls before they run. It evaluates fixed rules first, blocks dangerous or ambiguous commands, and allows only narrow read-only commands that start with a configured absolute executable path.

Only eligible unresolved Git requests can reach the secondary permission judge in Pi. OpenCode has no verified isolated judge transport and blocks those eligible cases as unavailable. Deterministic denials always hold, native host permissions still apply after an allowance, and missing or malformed inputs fail closed.

Status and version

Version 0.4.4 is published on npm, GitHub Releases, and the documentation site. It rebuilds the public documentation and declares the Node.js 24.9.0 baseline in the package without changing the 0.4.0 runtime.

Validated baselines:

  • OpenCode 1.18.18 (tool.execute.before)
  • Pi 0.84.2 (tool_call, persistent controls, and isolated judge transport)
  • Node 24.9.0 (test suite)

Treat only these versions as validated baselines and check the validated baselines reference before assuming broader support.

Decision flow

action
└─ deterministic policy
   ├─ allow-final              -> continue without AI
   ├─ deny-final               -> block without AI
   ├─ unresolved-ineligible    -> block without AI
   └─ unresolved-eligible
      ├─ active Pi judge allow -> continue
      └─ deny/unavailable/fail -> block

Narrow read-only allowances require an exact absolute path from the global trusted-path list and matching adapter shell evidence. Bare command names, shell builtins, relative paths, unsupported syntax, and configuration errors fail closed.

Only simple literal Git diff, log, show, or status requests with a configured Git path become eligible for the judge in enforce mode. Pi sends one isolated request with closed enums and no command text, arguments, paths, or IDs. OpenCode blocks eligible cases as unavailable. See how decisions work.

Install from npm

Review the package source before installing, because host plugins and extensions run with your system permissions.

OpenCode

Declare "auto-mode-gate@0.4.4" in the plugin array of project or global opencode.json, or install it for the current project:

opencode plugin auto-mode-gate@0.4.4
opencode debug config

Add --global for every project. opencode debug config confirms package discovery, not pre-tool enforcement.

Pi

Install globally (add -l for a project-local install) and verify the package entry:

pi install npm:auto-mode-gate@0.4.4
pi list

See the installation guide for opencode.json examples, source loaders, and removal steps.

Configure

OpenCode and Pi read separate host-owned JSON policy files:

ScopeOpenCodePi
Global$OPENCODE_CONFIG_DIR/auto-mode-gate.json or ~/.config/opencode/auto-mode-gate.json$PI_CODING_AGENT_DIR/auto-mode-gate.json or ~/.pi/agent/auto-mode-gate.json
Project<project>/.opencode/auto-mode-gate.json<project>/.pi/auto-mode-gate.json

Minimal global policy example:

{
  "mode": "enforce",
  "shell": "powershell",
  "trustedExecutablePaths": [
    "C:\\Program Files\\Git\\cmd\\git.exe"
  ],
  "permissionJudge": {
    "enabled": true,
    "model": { "provider": "example-provider", "id": "example-model" },
    "timeoutMs": 15000
  }
}

Project policy can only tighten global policy. Invalid JSON, unknown keys, relative paths, and unreadable files fail closed. Restart or reload the host after edits. See configure policy and migrate from 0.2.0 for the full schema.

Pi controls

In Pi TUI mode, /amg-judge opens the control menu. Direct commands also work in RPC mode:

/amg-judge status
/amg-judge on
/amg-judge off
/amg-judge model <provider> <model-id>
/amg-judge thinking <level>
/amg-judge reset

These controls persist requested Auto, secondary judge model, thinking level, and shortcuts (Ctrl+Alt+G and Ctrl+Alt+A by default) in global Pi preferences without changing Pi's primary conversation model or thinking. Requested and effective state remain separate, so project restrictions, unavailable models, or missing scope disable effective Auto without erasing saved choices. Read the Pi controls guide.

Logs and coverage

When global policy sets an absolute logPath, JSONL records include only closed enums, verdict, effect, stable decision code, mode, and an in-memory repeated-rejection count. Commands, arguments, prompts, secrets, session IDs, call IDs, and persistent identifiers are excluded. If an enforce decision cannot be written to the log, the call blocks.

Both adapters enforce only calls to the host's built-in bash tool. Other tools stay under native host permissions, and child host processes must load their own adapter. Read modes and sanitized logs and coverage boundaries.

Development

The package root has no external dependencies. Run the 246 unit, runtime, integration, and shared conformance tests on Node 24.9.0, or inspect the tarball contents:

npm test
npm pack --dry-run

On Linux with OpenCode 1.18.18 installed, npm run test:opencode-host packs the candidate and verifies pre-tool blocking against a loopback provider without external inference (the script exits on Windows). CI runs npm test, npm pack --dry-run, the OpenCode host check, and the documentation build.

License and participation

Auto Mode Gate is released under the MIT License. It accepts reproducible bug reports through GitHub Issues and vulnerability reports through GitHub private vulnerability reporting. Pull requests are not currently reviewed or merged. Auto Mode Gate is independent and is not affiliated with or endorsed by OpenCode or Pi.

Changelog · Security Policy · Contributing · Code of Conduct · MIT License