Error Recovery
Whisp automatically detects command failures and suggests fixes.
Error Recovery
Whisp monitors your shell for failed commands and automatically suggests fixes using AI analysis.
How It Works
Whisp uses shell hooks to intercept command failures:
- Pre-execution hook captures the command you're about to run
- Post-execution hook checks the exit code after the command finishes
- If the command failed (exit code != 0), whisp captures the stderr output
- The error context is sent to the daemon for AI analysis
- A suggested fix is displayed and added to your shell history
$ gcc main.c -o main
main.c: undefined reference to 'sqrt'
Whisp suggests:
➜ gcc main.c -o main -lm
(Added to history - press Up to use)Technical Details
Shell Integration
The error recovery system works through shell-specific hooks:
| Shell | Pre-execution Hook | Post-execution Hook |
|---|---|---|
| Bash | trap DEBUG | PROMPT_COMMAND |
| Zsh | preexec | precmd |
| Fish | fish_preexec | fish_postexec |
What Gets Captured
When a command fails, whisp captures:
- Command: The exact command that was run
- Exit code: The numeric exit status (1-255)
- Stderr: Up to 2000 characters of error output
- Working directory: Where the command was executed
- Session ID: Links the error to your shell session context
Session Context
Whisp maintains context within your shell session. This means if you've been working on a Python project and encounter an error, the AI knows you're likely dealing with Python-related issues and can suggest more relevant fixes.
Common Error Fixes
Missing Dependencies
$ python script.py
ModuleNotFoundError: No module named 'requests'
➜ pip install requests && python script.py$ npm start
Error: Cannot find module 'express'
➜ npm install && npm startPermission Issues
$ ./script.sh
bash: ./script.sh: Permission denied
➜ chmod +x ./script.sh && ./script.sh$ cat /var/log/secure
cat: /var/log/secure: Permission denied
➜ sudo cat /var/log/secureMissing Directories
$ cp file.txt /path/to/new/dir/
cp: cannot create regular file: No such file or directory
➜ mkdir -p /path/to/new/dir && cp file.txt /path/to/new/dir/Syntax Errors
$ python -c "print('hello'"
File "<string>", line 1
print('hello'
^
SyntaxError: unexpected EOF while parsing
➜ python -c "print('hello')"Git Conflicts and Issues
$ git push
error: failed to push some refs to 'origin/main'
hint: Updates were rejected because the remote contains work
➜ git pull --rebase && git push$ git checkout feature-branch
error: Your local changes would be overwritten by checkout
➜ git stash && git checkout feature-branchCommand Not Found
$ htop
bash: htop: command not found
➜ sudo dnf install htop # or apt, brew, etc. based on your systemPackage Manager Failures
$ cargo build
error[E0433]: failed to resolve: use of undeclared crate
➜ cargo fetch && cargo build$ pip install package
ERROR: Could not find a version that satisfies the requirement
➜ pip install --upgrade pip && pip install packageCompilation Errors
$ gcc main.c -o main
main.c: undefined reference to 'sqrt'
➜ gcc main.c -o main -lm$ make
make: *** No rule to make target 'build'. Stop.
➜ make all # or check available targets with: make helpExcluded Commands
Whisp ignores errors from certain commands to avoid noise:
- Commands starting with
whisp(internal commands) - Commands starting with
,(whisp shortcuts) - Internal shell functions (
_whisp_*)
Using the Fix
When whisp suggests a fix:
- The command is automatically added to your shell history
- Press Up arrow to recall the suggested command
- Review it and press Enter to execute
You can also copy the last command to clipboard with ,c.
Configuration
Disabling Error Recovery
Error recovery runs automatically when the daemon is running. To temporarily disable it, stop the daemon:
whisp stopStderr Capture Limits
To prevent memory issues, stderr output is truncated to 2000 characters before being sent to the AI. This is usually sufficient to capture the relevant error message.
Troubleshooting
Suggestions Not Appearing
- Check daemon status:
whisp status - Verify socket exists:
ls -la /tmp/whisp.sock - Test manually: Run a command that will fail and check if whisp responds
Slow Suggestions
Error analysis involves an API call. If suggestions are slow:
- Check your network connection
- Consider using a faster model (e.g.,
gpt-4o-miniinstead ofgpt-4) - Check
whisp healthfor response time metrics