@lukeramsden/pi-prevent-stuck
v1.0.1
Published
Extension for the pi coding agent: prevent shell commands that commonly hang agents by blocking interactive editors, pagers, REPLs, watch/TUI commands, prompt-only logins, and interactive git rebase.
Maintainers
Readme
@lukeramsden/pi-prevent-stuck
A pi extension that keeps coding agents out of known shell traps: interactive editors, pagers, REPLs, terminal UIs, watch loops, prompt-only logins, and interactive git rebase.
Why
Agents run shell commands through a non-interactive tool boundary. Commands that wait for a full-screen UI, a pager, an editor, a password/login prompt, a REPL, or an interrupt can hang the run until a timeout.
What it blocks
Conservative default blocks include:
- Editors:
vi,vim,nvim,nano,pico,emacs,emacsclient - Pagers/help browsers:
less,more,most,man,info - TUIs and interrupt-only loops:
top,htop,btop,watch,tmux,screen,fzf,peco - REPLs when run without a script/command:
python,python3,node,deno,bun; plusirb,pry, andphp -a - Interactive database/shell clients unless given a command/file/stdin:
psql,mysql,mariadb,sqlite3,redis-cli - Remote/file-transfer shells:
sshwithout a remote command,sftp,ftp - Prompt-only Docker auth:
docker loginunless credentials are provided with--password-stdinor--password git rebase -i/git rebase --interactiveunlessGIT_SEQUENCE_EDITORorgit -c sequence.editor=...is set inline
Git hardening
For Git commands that are otherwise allowed, the extension prepends:
GIT_TERMINAL_PROMPT=0 GIT_PAGER=cat PAGER=cat GIT_EDITOR=: EDITOR=: VISUAL=:This disables terminal credential prompts, Git pagers, and editor launches. Interactive rebase is still blocked unless you explicitly provide a non-interactive sequence editor.
Install
pi install npm:@lukeramsden/pi-prevent-stuckOr try it for a single run:
pi -e npm:@lukeramsden/pi-prevent-stuckExamples
Blocked:
git rebase -i HEAD~3
vim src/app.ts
less huge.log
docker login -u luke
ssh prod-box
watch npm testAllowed or rewritten:
git log -n 20 # rewritten with GIT_PAGER=cat
GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash main
docker login --username foo --password-stdin < token.txt
python -c 'print("ok")'
psql -c 'select 1'
ssh prod-box 'uname -a'Verify
npm run verifyResearch notes
- Git documents
--no-pager,GIT_PAGER=cat,GIT_EDITOR,GIT_ASKPASS, andGIT_TERMINAL_PROMPT=0for non-interactive behavior. - Git documents
sequence.editorandGIT_SEQUENCE_EDITORforgit rebase -itodo editing. - Docker documents
docker login --password-stdinas the non-interactive login path. - CircleCI documents that non-interactive shells can time out on prompts and pagers, and recommends disabling pagination such as with
git --no-pager.
License
MIT
