diff --git a/contrib/fx/bootstrap.sh b/contrib/fx/bootstrap.sh new file mode 100644 index 0000000..d3c3f05 --- /dev/null +++ b/contrib/fx/bootstrap.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Fetches f() and fx() (plus all default sources) into a temp dir and +# sources them into your CURRENT shell -- no git, no cloning. +# +# Run with eval so sourcing happens in your real shell, not a subshell +# that vanishes when the script exits: +# +# eval "$(curl -fsSL https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main/contrib/fx/bootstrap.sh)" +# +# After that: f and fx are ready to use in this shell session. To keep +# them in every new shell, add the same eval line to your rc file. + +_base="https://huggingface.co/spaces/Daveswo/self-healing-autopoietic-shell/raw/main" +_dir="${TMPDIR:-/tmp}/self-healing-shell-$$" +mkdir -p "$_dir/sources.d" 2>/dev/null + +_fetch_ok=1 +curl -fsSL "$_base/src/f.sh" -o "$_dir/f.sh" || _fetch_ok=0 +curl -fsSL "$_base/contrib/fx/fx.sh" -o "$_dir/fx.sh" || _fetch_ok=0 +for s in 10-known.sh 20-history.sh 30-selfdiag.sh 40-pathfuzzy.sh 50-thefuck.sh 90-team-shared.sh; do + curl -fsSL "$_base/contrib/fx/sources.d/$s" -o "$_dir/sources.d/$s" || _fetch_ok=0 +done + +if [ "$_fetch_ok" != 1 ]; then + echo "bootstrap: fetch failed, check your connection" >&2 +else + chmod +x "$_dir"/*.sh "$_dir"/sources.d/*.sh 2>/dev/null + FX_SOURCES_DIR="$_dir/sources.d" + export FX_SOURCES_DIR + . "$_dir/f.sh" + . "$_dir/fx.sh" + echo "f() and fx() are ready in this shell. Try: fx " +fi + +unset _base _dir _fetch_ok s diff --git a/index.html b/index.html index aa7c7af..4aa752f 100644 --- a/index.html +++ b/index.html @@ -20,6 +20,26 @@ } h1{font-size:1.4rem; margin:0 0 .4rem; font-weight:600;} header p{color:var(--dim); margin:.2rem 0; font-size:.92rem;} + .runbox{ + max-width:900px; margin:0 auto 1.5rem; padding:0 1.5rem; + } + .runbox-label{font-size:.78rem; text-transform:uppercase; letter-spacing:.06em; color:var(--dim); margin-bottom:.4rem;} + .runbox-cmd{ + display:flex; align-items:stretch; gap:0; background:var(--panel); + border:1px solid var(--accent); border-radius:8px; overflow:hidden; + } + .runbox-cmd code{ + flex:1; padding:.75rem .9rem; font-size:.82rem; overflow-x:auto; + white-space:pre; color:var(--ok); + } + .runbox-cmd button{ + flex-shrink:0; background:var(--accent); border:0; color:#0b0d10; + font:inherit; font-weight:600; font-size:.8rem; padding:0 1.1rem; cursor:pointer; + } + .runbox-cmd button:hover{opacity:.9;} + .runbox-cmd button.copied{background:var(--ok);} + .runbox-note{color:var(--dim); font-size:.8rem; margin-top:.5rem; line-height:1.5;} + .runbox-note code{background:#171b22; padding:.05rem .3rem; border-radius:4px;} main{max-width:900px; margin:0 auto; padding:0 1.5rem 3rem; display:grid; gap:1.25rem; grid-template-columns:1fr; } @media (min-width:760px){ main{grid-template-columns: 1.3fr .9fr;} } .panel{ @@ -70,9 +90,18 @@

🔁 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.

-

This is a live simulation of f() running entirely in your browser. Try a command below.

+

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

@@ -244,6 +273,28 @@ print('// try: cat needs-fix.txt', 'dim'); print('// it will fail once — teach it a fix like: echo hello > needs-fix.txt', 'dim'); })(); + +(function(){ + const btn = document.getElementById('copyBtn'); + const codeEl = document.getElementById('bootstrapCmd'); + if(!btn || !codeEl) return; + btn.addEventListener('click', async () => { + try{ + await navigator.clipboard.writeText(codeEl.textContent); + }catch(e){ + const range = document.createRange(); + range.selectNode(codeEl); + window.getSelection().removeAllRanges(); + window.getSelection().addRange(range); + document.execCommand('copy'); + window.getSelection().removeAllRanges(); + } + const original = btn.textContent; + btn.textContent = 'copied'; + btn.classList.add('copied'); + setTimeout(() => { btn.textContent = original; btn.classList.remove('copied'); }, 1500); + }); +})();