omp packages

@e4779/shell-gate0.3.0

pi extension: shell command valve — bash parse check + ShellCheck + the gate's own rules before bash runs

GitHub Actions Published 2 days ago ISC ~452 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

shell-gate

Pre-execution shell hygiene gate for agent shell commands and .sh writes.

Why

Agents write shell fast and sloppy, then burn turns debugging quotes character by character. The gate blocks the sloppy command BEFORE execution and hands diagnostics back to the model as the block reason — the fix loop is one turn, with SC codes in hand.

Layers

  1. bash --norc -n — parse check, always available: unbalanced quotes, broken heredocs, parse errors. The "unexpected EOF" class.
  2. ShellCheck — semantic layer (word splitting, quoting, rm -rf on empty variables). Host shellcheck binary first (BSD hosts ship it at /usr/local/bin); on a machine without it, shellcheck-wasm (this package's npm dependency), run by wasm-lint.ts in a child process, one per lint. In-process that runtime crashed after a run of back-to-back lints and its crash could end the agent process; in its own process every crash dies with the lint that caused it, which alone is skipped, silently.
  3. The gate's own rules — ESLint with the @eslint/shell language, in process (eslint-lint.ts). ShellCheck takes no rule from us; a real shell parser does, and a rule on the syntax tree never trips over a quoted mention. One rule today: a tmux command names its socket (-L <name>, -S <path> or a TMUX_TMPDIR= prefix), on commands and .sh writes alike. A bare tmux lands on whichever server the environment picks, and -L default is that same socket. Blind spots: a wrapper (command tmux, a function defined elsewhere, eval) and a script-wide export TMUX_TMPDIR= — name the socket per command instead.

Every layer fails open: any internal error passes the command through.

Bash commands start from a wider suppression list than .sh writes: the notes that fire on correct one-off commands (unused variables, bare globs, ls | grep, single-quoted $x, a && b || c) do not block a command, while word splitting, rm -rf on an unquoted variable and cd x; … (a failed cd runs the next command in the wrong directory) still do. The list is DEFAULT_CMD_SUPPRESSED in index.ts; commandSuppressedCodes in the config replaces it.

What it does NOT catch

Syntactically clean but operationally dangerous commands (git clean -fd, pkill -f self-matches, blind send-keys). Shell hygiene is not operational safety — that is a different gate.

Escape hatches

  • The model may prepend # shellcheck disable=SCxxxx directive lines to confirm an intentional pattern (plain bash comments; ShellCheck respects them). The block reason lists the exact codes to use, and a byte-identical retry passes. The gate's own rules have neither way round: their switches are "eslint": false in the config and, for tmux, a TMUX_TMPDIR already set in the agent's environment.
  • PI_SHELL_GATE=off disables the gate for a session.
  • ~/.pi/agent/shell-gate.json tunes thresholds — see the header of index.ts for every key.

User !-bash (the user_bash event) is never gated.