A distributable pi-agent extension providing multi-layer security: Guards that block dangerous actions, Scanners that detect risks, and an audit trail that records everything.
# Install from git
pi install git:github.com/mwolff44/pi-secured-setup
# Pin to a version
pi install git:github.com/mwolff44/pi-secured-setup@v1.0.0
# Update (pulls latest, never touches local config)
pi update pi-secured-setup| Guard | Applies To | Behavior |
|---|---|---|
| Boundary | read, write, edit |
Blocks writes outside the project directory (cwd). Confirms reads outside boundary. External paths can be whitelisted. |
| Protected paths | read, write, edit |
Blocks writes to sensitive files (.env, *.key, *.pem, etc.). Confirms reads. Patterns are configurable. |
| Bash gate | bash |
Classifies commands as SAFE / MODERATE / DANGEROUS / EXTERNAL. Dangerous and external commands require confirmation. Unknown commands also require confirmation. |
All three guards run in a single combined handler (ADR-0001) with fixed order: boundary → protected-paths → bash-gate. First block wins.
| Scanner | Mechanism | Behavior |
|---|---|---|
| Secret scanner | before_provider_request |
Recursively walks the provider payload for strings matching 15+ secret patterns (AWS keys, LLM keys, private keys, DB connection strings, GitHub tokens, etc.). Redacts as ***REDACTED:{pattern-name}***. Provider-agnostic. |
| Skill scanner | session_start |
Hashes SKILL.md for every discovered skill. Prompts for approval of new or changed skills. Previously skipped/unapproved skills show a notification only. |
Every guard and scanner action is recorded as a JSONL entry in ~/.pi/agent/security/audit.jsonl. The log rotates automatically (default: 10MB per file, 3 files retained).
| Command | Description |
|---|---|
/security |
Dashboard — blocked/confirmed counts, recent events, skill status |
/security:skills |
Re-trigger skill approval flow for all skills |
/security:trust <skill> |
Approve a skill by name, persist to config |
/security:allow <path> |
Add an external path to the allowed list |
/security:clean [days] |
Trim audit log entries older than N days (default: 30) |
Configuration is loaded from three layers, merged in priority order:
1. defaults/ — shipped with the package
2. ~/.pi/agent/security/ — machine-specific overrides
3. .pi/security/ — project-specific overrides (relative to cwd)
Pattern lists are additive — each layer can add new patterns. A ! prefix excludes an inherited pattern:
Non-pattern fields (like writeAction, readAction) in later layers replace earlier values.
| File | Purpose |
|---|---|
protected-paths.json |
Glob patterns for sensitive files + read/write actions |
command-rules.json |
Regex patterns for SAFE / MODERATE / DANGEROUS / EXTERNAL command classification |
allowed-external.json |
Paths outside the project boundary that are allowed |
audit-config.json |
Log rotation settings (maxFileSize, maxFiles) |
skill-approvals.json |
Auto-managed — skill hashes + approval decisions |
To add project-specific security rules, create a .pi/security/ directory in your project root:
mkdir -p .pi/securityThen add any of these files:
// .pi/security/protected-paths.json
{
"patterns": [
"config/production.json",
"secrets/*.yml"
]
}// .pi/security/command-rules.json
{
"dangerous": [
"terraform destroy",
"kubectl delete"
]
}// .pi/security/allowed-external.json
{
"paths": [
"../shared-lib"
]
}See CONTEXT.md for domain terminology and docs/adr/ for architectural decision records.
extensions/
security.ts # Entry point
lib/
config.ts # Three-layer config merge with ! exclusion
guard-pipeline.ts # Single combined tool_call handler (ADR-0001)
boundary.ts # Boundary evaluation (ADR-0003)
protected-paths.ts # Protected path glob matching
bash-gate.ts # Command classification (SAFE/MODERATE/DANGEROUS/EXTERNAL)
secret-scanner.ts # Provider-agnostic secret redaction (ADR-0002)
skill-scanner.ts # SKILL.md hash verification (ADR-0004)
audit.ts # JSONL audit log + rotation + /security commands
utils.ts # Shared helpers
defaults/
protected-paths.json # Default global protected patterns
command-rules.json # Default command classification rules
allowed-external.json # Default allowed external paths
audit-config.json # Default rotation settings
- Extension loads → detects no
~/.pi/agent/security/directory - Creates directory with default configs
- Scans all skills → prompts approval for each one (once)
- Ready — all guards and scanners active
There is no bypass flag. If a guard is too restrictive:
- Edit the config file (
~/.pi/agent/security/or.pi/security/) - Run
/reloadto apply changes