@crimsonmartin/pi-trash-guard

Pi extension: rewrite rm to trash-put (trash-cli) so agents never irreversibly delete; confirm for absolute paths

Packages

Package details

extension

Install @crimsonmartin/pi-trash-guard from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@crimsonmartin/pi-trash-guard
Package
@crimsonmartin/pi-trash-guard
Version
0.1.0
Published
Sep 14, 2026
Downloads
120/mo · 120/wk
Author
crimsonmartin
License
MIT
Types
extension
Size
9.4 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-trash-guard

Pi extension that stops agents from irreversibly deleting files. It intercepts the bash tool before execution and rewrites rm to trash-put (from trash-cli), so everything an agent "deletes" is recoverable via trash-list / trash-restore.

Pattern Behavior
rm foo.txt, rm -rf node_modules, rm -irf ./logs Rewritten to trash-put (flags mapped: -f/-i kept, -r/-R/--recursive dropped since trash-put handles dirs, unknown flags dropped). No prompt.
rm of absolute paths (rm -rf /home/..., rm -rf /tmp/x, rm -rf /) Rewritten to trash-put and requires your confirmation in the TUI. Headless runs: blocked outright.
shred / srm Blocked — irreversible by design.
trash-empty Requires confirmation (permanently deletes trashed files).
anything else Untouched (git rm, find -delete, trash-*, echo rm ..., …).

The tokenizer is quote/shell-aware (pipes, ;, &&, backticks, newlines) and only matches exact command-segment positions.

Install

pi install npm:@crimsonmartin/pi-trash-guard

Prerequisite (system-level):

sudo apt install trash-cli   # provides trash-put / trash-list / trash-restore

Tests

npm install
npm test

Run from this directory.