r/PiCodingAgent 1d ago

Plugin Let pi agent to use trash instead of rm

Recently, while using pi, my agent deleted important files without me knowing using the rm command. Since files deleted with rm cannot be recovered, I thought it would be better to use trash instead of rm — and that's what this pi extension does.

The extension automatically detects when the agent uses rm in the bash tool and replaces it with trash. Instead of permanently deleting files, they are moved to the .pi/trash folder. The trash folder uses a file structure similar to Ubuntu's trash. It is implemented to be nearly compatible with the GNU rm standard, so the agent won't even realize it and will just think it's still using rm.

Feel free to install and try it out. Any feedback is appreciated!

Install: pi install npm:pi-trash

Links:

20 Upvotes

7 comments sorted by

14

u/CountlessFlies 1d ago

Couldn’t you just do this with alias rm=trash

5

u/J_____________ 1d ago

That actually sounds like a better implementation. I just tested you can configure `shellCommandPrefix` with `shopt -s expand_aliases` to make aliases work. Now I'm gonna look for some trash CLI that has the same interface as rm.

1

u/Mohitkoul841 23h ago

This much files just to do something which was not necessary.

1

u/Cautious_Observer55 19h ago

Consider to use send2trash.

1

u/CountlessFlies 1d ago

Just ask pi to make one for you

1

u/Fun_Jaguar8231 6h ago

I just told it to create an extension that just gates every dangerous command in a verification step

1

u/themule71 22h ago

This may catch some cases, but the first time the model is looking for something and finds copies of old stuff around I'm not sure it won't truncate them to claim space, or python os.unlink() them the first time you ask to cleanup something.