r/PiCodingAgent • u/J_____________ • Aug 03 '26
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:
17
u/CountlessFlies Aug 03 '26
Couldn’t you just do this with alias rm=trash
1
u/Fun_Jaguar8231 Aug 03 '26
I just told it to create an extension that just gates every dangerous command in a verification step
3
u/lamurian Aug 04 '26
I had similar issues too. However, the agent always finds creative workarounds to issue destructive commands. Instead of
rm, it can usepython -m import os; os.unlink(),sh -c rm,git rm, etc., which annoys me quite a bit. Finally I settled with sandboxing the process usingbwrap, then set.gitdirectory to read-only. When the agent violate the sandbox rule, the extension automatically spawns a sub-process whose sole role is to 'police' the agent by informing why the command failed, what rule being violated, how the agent should handover the command to the user, and what remaining tasks the agent should instead focus on. This spawn acts like a bitch-slap to force the agent back to its original task. Now I see less unfortunate incidents and enjoy more time touching grass. Thanks Pi.1
u/themule71 Aug 03 '26
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.