PFS is a command-line tool that diagnoses and corrects your last failed shell command using a local or hosted Large Language Model (LLM) powered by Ollama.
When you run a command that results in an error (i.e., has a non-zero exit code), simply type pfs. The tool will analyze the failed command and provide an explanation of the error and a corrected command. You can then choose to execute the corrected command instantly.
- Local First: Works entirely with your local Ollama models, ensuring privacy and offline capability.
- Intelligent Correction: Leverages LLMs to understand the context of your error and provide accurate fixes.
- Interactive Workflow: Explains the error and prompts for confirmation before executing any command.
- Reliable Capture: A robust shell function ensures that the command, its output, and exit code are all captured correctly for analysis.
- Go 1.22+: For building the application.
- jq: For safely handling command output in the shell wrapper. You can install it with your system's package manager (e.g.,
sudo dnf install jq,sudo apt-get install jq,brew install jq). - ollama: The LLM that application talks with. After installing, ollama must serving (
ollama serve &) and at least 1 model is downloaded to your machine (ollama pull deepseek-r1:1.5b).
git clone https://github.com/tatlilimon/PFS.git
cd PFSBuild the binary and move the binary to a directory in your system's PATH.
go build -o /usr/local/bin/pfs ./cmd/sudo mv pfs /usr/local/bin/PFS uses a .env file in your home directory to store your Ollama settings.
Copy the provided template to ~/.pfs.env.
cp .env.template ~/.pfs.envOpen the file and set the OLLAMA_BASE_URL for your Ollama instance and the OLLAMA_MODEL you wish to use.
nano ~/.pfs.envThe quality of the command correction depends heavily on the model you choose. For best results, use a model that is specifically fine-tuned for code or command-line instructions.
To make PFS work, you need to source the provided wrapper script in your shell's startup file (e.g., .bashrc, .zshrc).
Open your shell's configuration file:
# For Bash
nano ~/.bashrc
# For Zsh
nano ~/.zshrcAdd the following line to the end of the file. Make sure to use the actual absolute path to the cloned repository.
source /path/to/your/PFS/pfs_wrapper.shFor the changes to take effect, either restart your terminal or source your configuration file:
# For Bash
source ~/.bashrc
# For Zsh
source ~/.zshrc- Run any shell command.
- If it fails, simply type
pfsand press Enter. - The tool will provide an explanation and a corrected command.
- Press
yand Enter to execute the new command, ornto abort.
PFS provides a --verbose flag for debugging purposes, which provides detailed output about the interaction with the Ollama model.
Example:
pfs --verboseYou can help me to developing this app by opening a pull request or issue.