Skip to content
harmless-beepPublic

About

Your command failed. fix explains why in plain English, patches the fix, and re-runs it. Zero dependencies — works with any OpenAI-compatible API, or no key at all for common mistakes.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

fix

You make a typo, the command fails, and fix figures out the correct command — literally, from your own shell history — then asks yes or no before running it. No LLM, no API key, no network. 100% offline.

fix — offline typo fix

fix — ranked candidates

fix — no fix found

What's new in 0.2

  • No LLM, no API key, no network. Ever. Offline rules are the only path by default; the model wiring is still there but strictly opt-in (fix --llm).
  • ~4× more offline rules and a fuzzy suggestion engine that ranks candidates from executables on $PATH, your own shell history, and common commands.
  • A real TUI (still pure stdlib, zero dependencies): box-drawn panels, a spinner, colored diffs, and an interactive ↑/↓ picker when a few fixes are plausible. Falls back to a numbered prompt when piped/scripted.
  • Auto-retry loop — if the fix you chose still fails, it captures the new error and suggests the next candidate (up to FIX_MAX_ATTEMPTS tries).

Install

Python 3.9+. Nothing else.

pip install fix-cli          # once it's on PyPI
# or from source:
git clone https://github.com/harmless-beep/fixer && cd fixer && pip install -e .

Try it right now, no key, no setup:

fix git puhs                 # -> git push
fix --no-rerun npmm install x
fix --doctor                 # shows offline indexes (commands + history lines)

What it can fix (offline)

When What it suggests
git puhs, git commmit -m hi git push, git commit -m hi
npmm install x / pythno app.py nearest real command (PATH + history + common commands)
python app.py → ModuleNotFoundError: No module named 'PIL' pip install pillow
node app.js → Cannot find module 'chalk' npm install chalk (verifies against your package.json)
mkdir /root/x → Permission denied sudo mkdir /root/x
cd nosuchdir mkdir -p nosuchdir && cd nosuchdir, nearest existing ancestor, closest dir
python app.pyy (file typo) nearest real file in the same folder
"Address already in use" netstat -ano | findstr :PORT (Win) / lsof -i :PORT, fuser -k PORT/tcp (Unix)
git push → "no upstream branch" git push -u origin <branch>
git merge → conflicts git merge --abort
pip --no-cash-dir list parsed from the tool's own --help → pip --no-cache-dir list
anything close to a command you ran before your shell history, as a memory
none of the above honest "no offline fix found" + nearest-command hints

Usage

fix npm run build                  # fix a specific command
fix                                # fix whatever failed last (needs the hook)
fix --dry-run python test.py       # show all candidate fixes, apply nothing
fix --yes git puhs                 # auto-accept the best fix (scripting)
fix --limit 3 git puhs             # cap the candidate list
fix --llm somecmd                  # opt-in model fallback (needs a key)
fix --install-hook                 # remember the last command for bare `fix`

Bare fix reads your shell history for the last command. The hook makes it reliable — it also remembers the exit code:

fix --install-hook

Opt-in LLM (still offline by default)

If you want a model on top, fix --llm ... falls back to one when the offline rules can't fix it. Works with any OpenAI-compatible API (FIX_API_KEY / FIX_BASE_URL / FIX_MODEL); Ollama keeps everything local. The offline rules always run first.

Where the suggestions come from

Every fix is computed locally:

  1. Offline rules — git typos, missing sudo/module/package, cd-into-missing-dir, file-name typos, occupied ports, merge conflicts, flag typos (parsed from the tool's own --help output).
  2. A fuzzy engine — Damerau-Levenshtein distance + first-letter/prefix/frequency bonuses, scored over:
    • every executable on your $PATH
    • every command in your shell histories — bash, zsh, fish, and PSReadLine — weighted by how often you've typed it
    • a small list of common commands
  3. History lookalikes — when nothing specific matches, "you ran a near-identical command before". This is the approx-correct-prompt magic: it literally remembers the command you got right last time.

Run fix --doctor to see how many commands and history lines are indexed.

Safety

It re-runs your command, so it can have side effects. Destructive commands (rm -rf /, dd, git push --force, fuser -k, kill -9, ...) trigger an extra confirmation. Every fix is shown first and confirmed: Run it? [y/N]. --yes skips all prompts — use it only when you know what you're doing. Nothing ever leaves your machine.

Configuration (all environment variables, all optional)

Variable What it does Default
FIX_MAX_ATTEMPTS auto-retry tries 3
--limit max candidates shown 5
FIX_RERUN_TIMEOUT command re-run timeout (s) 60
FIX_TIMEOUT LLM timeout (s, --llm only) 90
FIX_API_KEY / FIX_BASE_URL / FIX_MODEL model endpoint (--llm) auto-detected

What's next

  • more rules (docker/kubectl typos, git pull → git reset, npm script name typos)
  • fix blame — explain someone else's log
  • a fix rebase interactive view for multi-fix sessions

MIT.

About

Your command failed. fix explains why in plain English, patches the fix, and re-runs it. Zero dependencies — works with any OpenAI-compatible API, or no key at all for common mistakes.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages