Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cad0p/pi-steering-hooks/llms.txt
Use this file to discover all available pages before exploring further.
pi-steering-flags is the first official external plugin for the pi-steering ecosystem. It ships two predicates — requiresFlag and allowlistedFlagsOnly — that encode flag-presence and flag-allowlist checks that don’t belong in the core engine. Which flags count as equivalent (short + long + env)? How aggressive should default-deny be? What exactly counts as a “flag”? These are opinionated policy questions that belong in a plugin so they can iterate on their own release cadence without committing the engine to answers about every CLI’s conventions.
Install
pi-steering-flags declares pi-steering as a peer dependency. Install both together.
Quickstart
when.requiresFlag
The rule fires (command is blocked) when none of the listed flag or env-var equivalents appear in the evaluated command. Use it to enforce that a required flag is always supplied.
Shorthand — requiresFlag: "--profile" is equivalent to requiresFlag: { flag: "--profile" }:
One required flag. The rule blocks when this flag is absent.
Any one of several flags (OR). The rule blocks when none of the listed flags appear.
An environment-variable alternative (bare
VAR=value shell prefix). The rule passes when this env assignment appears, even if the flag itself is absent.Any one of several env-var alternatives (OR). The rule passes when any one appears.
flag, flags, env, or envs must be specified. A malformed arg (empty object) does not fire — fail-open for the rule author’s benefit (better than a silent always-block).
Examples:
when.allowlistedFlagsOnly
The rule fires when any --prefixed token in the command is NOT in the allowlist. Use it for default-deny flag gating — the command may only use the explicitly approved flags, and any unknown flag triggers the block.
The set of permitted flags. Long flags (
--flag) automatically match their --flag=value attached-value form. Short flags (-n, -h) do not get auto-prefix matching.Explicit prefixes to allow for attached-value short flags. For example,
allowPrefixes: ["-o"] permits -ofoo, -obar, etc.-) are ignored.
Helper functions
When the built-in predicates aren’t enough, reach for these helpers insidewhen.condition. All helpers are quote-aware — they read .value before falling back to .text and handle undefined input gracefully.
hasFlag(args, flag)— returnstruewhen the flag appears in args, in either bare form orflag=valueattached-value form.getFlagValue(args, flag)— returns the flag’s value from a separatedflag valuepair or an attachedflag=valueform; returnsnullwhen the flag is absent.hasEnvAssignment(envAssignments, name)— returnstruewhen the named env variable appears as a literalVAR=valueshell assignment.INFO_ONLY— a regex matching-h,--help,-v, and--version. Use it inRule.unlessto carve out informational invocations from a rule entirely.
getFlagValue inside when.condition:
--description actually exists, blocking the command when the file is missing. ctx.exec is memoized per (cmd, args, cwd) within a single tool call, so the test call doesn’t re-fork a process if another rule already ran the same check.