pi-trash

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

pi-trash

Intercept rm commands and move files/directories to .pi/trash/ instead of permanently deleting them.

Overview

pi-trash is a pi package that extends pi with a trash can for the coding agent. When the agent runs rm, files are moved to .pi/trash/ instead of being permanently deleted, allowing recovery.

This follows the freedesktop.org XDG Trash Specification:

.pi/trash/
├── files/    ← actual deleted files
└── info/     ← .trashinfo metadata

Features

  • rm interception — Automatically detects and redirects rm commands to .pi/trash/
  • /trash command — List and recover deleted files via the agent's slash command
  • CLI toolbin/pi-trash-rm.mjs for direct command-line usage
  • XDG Trash compatible — Stores files and metadata in .pi/trash/

Installation

npm

pi install npm:pi-trash

Git

pi install git:github.com/Jinsung-L/pi-trash

Project-local

pi install npm:pi-trash -l

After installation, pi loads the extension automatically. No manual configuration needed.

Usage

Automatic rm interception

The agent's rm commands are automatically intercepted:

> rm some-file.txt

Files are moved to .pi/trash/ in the project root instead of being deleted.

/trash command

Manage trashed files using the /trash slash command. Supports four subcommands:

/trash delete <paths...>

Manually move files or directories to trash. This works the same way as the automatic rm interception.

/trash delete file1.txt
/trash delete dir1/ dir2/
/trash delete -v file1.txt file2.txt file3.txt   # verbose: show each deleted path

/trash restore <id>

Restore a trashed item to its original location.

/trash restore abc123def456...

The ID can be found via /trash list. The TUI provides autocomplete for the ID.

/trash list

List all trashed items (most recent first).

/trash list

/trash empty [days]

Permanently delete all trashed items (or items older than <days> days).

/trash empty                    # Delete all trashed items
/trash empty 7                  # Delete items older than 7 days
/trash empty 30d                # Same as above (d suffix is optional)

With UI, a confirmation dialog appears before deletion.