原始内容
@qmxme/pi-git-guard
Blocks destructive git operations in pi to prevent accidental pushes, tag deletions, or hard resets.
Blocked Operations
The following git commands are unconditionally blocked:
| Command | Reason |
|---|---|
git push (any form) |
Publishing is controlled manually |
git tag -d / git tag --delete |
Prevents accidental tag deletion |
git reset --hard |
Prevents discarding uncommitted changes |
Examples
Blocked:
git push # ❌ Blocked
git push origin main # ❌ Blocked
git push --force # ❌ Blocked
git tag -d v1.0 # ❌ Blocked
git tag --delete old-tag # ❌ Blocked
git reset --hard # ❌ Blocked
git reset --hard HEAD~1 # ❌ Blocked
Allowed:
git status # ✅ Allowed
git push --dry-run # ❌ Still blocked (all push blocked)
git pull # ✅ Allowed
git fetch # ✅ Allowed
git reset --soft HEAD # ✅ Allowed
git reset --mixed HEAD # ✅ Allowed
git tag v1.0 # ✅ Allowed (tag creation)
Installation
Install globally:
pi install npm:@qmxme/pi-git-guard
Install project-local:
pi install npm:@qmxme/pi-git-guard -l
Try without installing:
pi -e npm:@qmxme/pi-git-guard
How It Works
When pi attempts to execute a blocked git command:
- The command is intercepted before execution
- A warning notification is shown (if in interactive mode)
- The command is blocked with a clear reason
The LLM will see the block reason in the tool result and can adjust its approach.
Development
npm install # Install dependencies
npm test # Run tests
npm run typecheck # Type check
License
MIT