🔁 Self-Healing Autopoietic Shell

A shell function that learns from its own failures — run a command, teach it a fix when it fails, and it never fails that way again.

The simulation below is a browser mockup, not a real shell — this page is static, so nothing here can actually execute anything. To run the real thing in your real shell:

run this in your terminal — no git clone needed
eval "$(curl -fsSL https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main/contrib/fx/bootstrap.sh)"
fetches f(), fx(), and all default fix-sources into a temp dir and sources them into your current shell — add the same line to your rc file to keep it every session.

Simulated shell

$ f

p  (learned fixes)

// empty — nothing learned yet
f() {
    FIX=""
    if [ -f p ]; then
        while IFS= read -r line; do
            case "$line" in
                "$*="*) FIX="${line#"$*="}" ;;
            esac
        done < p
    fi
    until { eval "$FIX" 2>/dev/null; "$@"; }; do
        printf '\n[LEARN] "%s" failed. Enter a fix (blank to give up): ' "$*" >&2
        read -r n
        [ -n "$n" ] || return 1
        echo "$*=$n" >> p
        FIX="$n"
    done
}