add confirm-destructive, git-checkpoint, notify extensions
This commit is contained in:
@@ -109,7 +109,57 @@ The status bar shows `⚡ own master` or `⚡ system master` so you can see whic
|
||||
|
||||
---
|
||||
|
||||
## Adding a new extension
|
||||
### `confirm-destructive.ts`
|
||||
|
||||
Confirmation gates for dangerous bash commands and destructive session actions. Always-on — no flag needed.
|
||||
|
||||
**Bash commands intercepted:**
|
||||
- Recursive removes (`rm -rf`, `rm -r`, etc.)
|
||||
- Any `sudo` command
|
||||
- `chmod`/`chown 777`
|
||||
- `dd if=` (disk operations)
|
||||
- `mkfs` (format filesystem)
|
||||
- `git push --force` / `git push -f`
|
||||
- Writes to `/dev/*`
|
||||
- `truncate --size 0`
|
||||
|
||||
In non-interactive mode (e.g. `pi -p`) dangerous commands are blocked outright rather than prompted.
|
||||
|
||||
**Session actions gated:**
|
||||
- `/new` — confirms before clearing the session
|
||||
- `/resume` — confirms before switching away if the current session has messages
|
||||
- `/fork` — always confirms
|
||||
|
||||
---
|
||||
|
||||
### `git-checkpoint.ts`
|
||||
|
||||
Creates a git stash checkpoint at the start of each turn, keyed to the session entry ID. If you `/fork` from a past entry, you're offered the option to restore the code to that point.
|
||||
|
||||
Silently skips when the working directory isn't inside a git repo, or when there are no changes to stash. Status bar shows `⎇ N checkpoints` during active sessions.
|
||||
|
||||
**Notes:**
|
||||
- Uses `git stash create` — non-destructive, doesn't touch your working tree
|
||||
- Stash objects persist in the git repo even after pi exits, so you can apply them manually with `git stash apply <ref>` if needed
|
||||
- Checkpoints are in-memory per session — the entry→ref mapping is lost on restart, but the underlying stash objects remain
|
||||
|
||||
---
|
||||
|
||||
### `notify.ts`
|
||||
|
||||
Sends a native terminal notification when the agent finishes and is waiting for input. Only fires when the agent ran for longer than the threshold (default 8 seconds) — quick responses are silently skipped.
|
||||
|
||||
**Terminal support:**
|
||||
- Kitty (`KITTY_WINDOW_ID`) → OSC 99
|
||||
- Windows Terminal / WSL (`WT_SESSION`) → Windows toast
|
||||
- Everything else (iTerm2, WezTerm, Ghostty) → OSC 777
|
||||
|
||||
**Flag:**
|
||||
|
||||
```bash
|
||||
pi --notify-min-secs 15 # only notify for tasks over 15 seconds
|
||||
pi --notify-min-secs 0 # notify on every agent completion
|
||||
```
|
||||
|
||||
1. Drop a `.ts` file into `extensions/`
|
||||
2. Re-run `./install.sh` — it picks up the new file and symlinks it
|
||||
|
||||
Reference in New Issue
Block a user