diff --git a/graphify/skill-agents.md b/graphify/skill-agents.md index 19d5bea4e..a4adbb02a 100644 --- a/graphify/skill-agents.md +++ b/graphify/skill-agents.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-amp.md b/graphify/skill-amp.md index 19d5bea4e..a4adbb02a 100644 --- a/graphify/skill-amp.md +++ b/graphify/skill-amp.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-claw.md b/graphify/skill-claw.md index bf9dd3431..c275c6b72 100644 --- a/graphify/skill-claw.md +++ b/graphify/skill-claw.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-codex.md b/graphify/skill-codex.md index 04eb5705b..c0ac62a20 100644 --- a/graphify/skill-codex.md +++ b/graphify/skill-codex.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-copilot.md b/graphify/skill-copilot.md index bf9dd3431..c275c6b72 100644 --- a/graphify/skill-copilot.md +++ b/graphify/skill-copilot.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-droid.md b/graphify/skill-droid.md index ffa94995d..daf3ac90c 100644 --- a/graphify/skill-droid.md +++ b/graphify/skill-droid.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-kilo.md b/graphify/skill-kilo.md index 96dfc2e85..c5dda3372 100644 --- a/graphify/skill-kilo.md +++ b/graphify/skill-kilo.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-kiro.md b/graphify/skill-kiro.md index bf9dd3431..c275c6b72 100644 --- a/graphify/skill-kiro.md +++ b/graphify/skill-kiro.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-opencode.md b/graphify/skill-opencode.md index 6613434e8..1c56528a7 100644 --- a/graphify/skill-opencode.md +++ b/graphify/skill-opencode.md @@ -621,15 +621,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-pi.md b/graphify/skill-pi.md index bf9dd3431..c275c6b72 100644 --- a/graphify/skill-pi.md +++ b/graphify/skill-pi.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-trae.md b/graphify/skill-trae.md index 407f091b6..ef54f5803 100644 --- a/graphify/skill-trae.md +++ b/graphify/skill-trae.md @@ -627,15 +627,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-vscode.md b/graphify/skill-vscode.md index f7e7f8442..42ba7d17a 100644 --- a/graphify/skill-vscode.md +++ b/graphify/skill-vscode.md @@ -625,15 +625,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill-windows.md b/graphify/skill-windows.md index 9c7ab7420..56574bef1 100644 --- a/graphify/skill-windows.md +++ b/graphify/skill-windows.md @@ -651,15 +651,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/graphify/skill.md b/graphify/skill.md index bf9dd3431..c275c6b72 100644 --- a/graphify/skill.md +++ b/graphify/skill.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tests/test_skillgen.py b/tests/test_skillgen.py index 0c09e601e..e5303673b 100644 --- a/tests/test_skillgen.py +++ b/tests/test_skillgen.py @@ -8,6 +8,9 @@ """ from __future__ import annotations +import os +import shutil +import subprocess import sys from pathlib import Path @@ -300,6 +303,151 @@ def test_windows_frontmatter_name_and_shell_and_extra(): assert core.index("## Troubleshooting") < core.index("## Honesty Rules") +@pytest.mark.parametrize( + ("manager", "manager_args"), + ( + ("uv", "tool dir"), + ("pipx", "environment --value PIPX_LOCAL_VENVS"), + ), +) +def test_windows_interpreter_guard_recovers_tool_python(tmp_path, manager, manager_args): + """#1619 A1: recovery must probe uv/pipx Python, not graphify.exe.""" + bash = shutil.which("bash") + if bash is None: + pytest.skip("bash is required to exercise the generated recovery guard") + + core, _ = _platform_artifacts("windows") + section = core[core.index("## Interpreter guard for subcommands"):] + fence_start = section.index("```bash\n") + len("```bash\n") + guard = section[fence_start:section.index("\n```", fence_start)] + + distribution_probe = ( + "from importlib.metadata import version; version('graphifyy'); import graphify" + ) + assert 'head -1 "$GRAPHIFY_BIN"' not in guard + for command in ("uv tool dir", "pipx environment --value PIPX_LOCAL_VENVS"): + assert command in guard + for suffix in ("graphifyy/Scripts/python.exe", "graphifyy/bin/python"): + assert suffix in guard + assert guard.count(f'"$_PY" -c "{distribution_probe}"') == 4 + + tool_dir = tmp_path / f"{manager}-tools" + python_exe = tool_dir / "graphifyy" / "Scripts" / "python.exe" + python_exe.parent.mkdir(parents=True) + python_exe.write_text( + "#!/bin/sh\n" + f'[ "$1" = -c ] && [ "$2" = "{distribution_probe}" ]\n', + encoding="utf-8", + ) + python_exe.chmod(0o755) + + fake_bin = tmp_path / "bin" + fake_bin.mkdir() + manager_bin = fake_bin / manager + manager_bin.write_text( + "#!/bin/sh\n" + f'[ "$*" = "{manager_args}" ] || exit 1\n' + f"printf '%s\\n' '{tool_dir}'\n", + encoding="utf-8", + ) + manager_bin.chmod(0o755) + graphify_exe = fake_bin / "graphify" + graphify_exe.write_bytes(b"MZ\x90\x00not-a-script") + graphify_exe.chmod(0o755) + + env = os.environ.copy() + env["PATH"] = os.pathsep.join((str(fake_bin), "/usr/bin", "/bin")) + subprocess.run([bash, "-c", guard], cwd=tmp_path, env=env, check=True) + + saved = (tmp_path / "graphify-out" / ".graphify_python").read_text(encoding="utf-8") + assert saved == str(python_exe) + + +@pytest.mark.parametrize("candidate_state", ("shadow_module", "metadata_only")) +def test_interpreter_guard_rejects_incomplete_cwd_install(tmp_path, candidate_state): + """Cwd artifacts must not validate an unrelated or broken Python.""" + bash = shutil.which("bash") + if bash is None: + pytest.skip("bash is required to exercise the generated recovery guard") + + core, _ = _platform_artifacts("windows") + section = core[core.index("## Interpreter guard for subcommands"):] + fence_start = section.index("```bash\n") + len("```bash\n") + guard = section[fence_start:section.index("\n```", fence_start)] + + if candidate_state == "shadow_module": + (tmp_path / "graphify.py").write_text( + "# shadows an installed package\n", encoding="utf-8" + ) + else: + dist_info = tmp_path / "graphifyy-1.0.dist-info" + dist_info.mkdir() + (dist_info / "METADATA").write_text( + "Metadata-Version: 2.1\nName: graphifyy\nVersion: 1.0\n", + encoding="utf-8", + ) + fake_bin = tmp_path / "bin" + fake_bin.mkdir() + + python_wrapper = "#!/bin/sh\nexec \"$REAL_PYTHON\" -S \"$@\"\n" + for name in ("python3", "python"): + candidate = fake_bin / name + candidate.write_text(python_wrapper, encoding="utf-8") + candidate.chmod(0o755) + for name in ("uv", "pipx"): + unavailable = fake_bin / name + unavailable.write_text("#!/bin/sh\nexit 1\n", encoding="utf-8") + unavailable.chmod(0o755) + graphify_exe = fake_bin / "graphify" + graphify_exe.write_bytes(b"MZ\x90\x00not-a-script") + graphify_exe.chmod(0o755) + + env = os.environ.copy() + env["PATH"] = os.pathsep.join((str(fake_bin), "/usr/bin", "/bin")) + env["REAL_PYTHON"] = sys.executable + env.pop("PYTHONPATH", None) + result = subprocess.run([bash, "-c", guard], cwd=tmp_path, env=env, check=False) + + assert result.returncode != 0 + assert not (tmp_path / "graphify-out" / ".graphify_python").exists() + + +def test_posix_interpreter_guard_preserves_shebang_install(tmp_path): + """The shared #1619 guard must retain ordinary POSIX venv recovery.""" + bash = shutil.which("bash") + if bash is None: + pytest.skip("bash is required to exercise the generated recovery guard") + + core, _ = _platform_artifacts("claude") + section = core[core.index("## Interpreter guard for subcommands"):] + fence_start = section.index("```bash\n") + len("```bash\n") + guard = section[fence_start:section.index("\n```", fence_start)] + + python_exe = tmp_path / "venv" / "bin" / "python" + python_exe.parent.mkdir(parents=True) + python_exe.write_text( + "#!/bin/sh\n" + "[ \"$1\" = -c ] && " + "[ \"$2\" = \"from importlib.metadata import version; " + "version('graphifyy'); import graphify\" ]\n", + encoding="utf-8", + ) + python_exe.chmod(0o755) + + fake_bin = tmp_path / "bin" + fake_bin.mkdir() + graphify = fake_bin / "graphify" + graphify.write_text(f"#!{python_exe}\n", encoding="utf-8") + graphify.chmod(0o755) + + env = os.environ.copy() + env["PATH"] = os.pathsep.join((str(fake_bin), "/usr/bin", "/bin")) + subprocess.run([bash, "-c", guard], cwd=tmp_path, env=env, check=True) + + saved = (tmp_path / "graphify-out" / ".graphify_python").read_text(encoding="utf-8") + assert saved == str(python_exe) + + def test_codex_dispatch_is_agenttask_and_collects_in_memory(): """codex: spawn/wait/close_agent dispatch needing multi_agent = true.""" core, _ = _platform_artifacts("codex") diff --git a/tools/skillgen/expected/graphify__skill-agents.md b/tools/skillgen/expected/graphify__skill-agents.md index 19d5bea4e..a4adbb02a 100644 --- a/tools/skillgen/expected/graphify__skill-agents.md +++ b/tools/skillgen/expected/graphify__skill-agents.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-amp.md b/tools/skillgen/expected/graphify__skill-amp.md index 19d5bea4e..a4adbb02a 100644 --- a/tools/skillgen/expected/graphify__skill-amp.md +++ b/tools/skillgen/expected/graphify__skill-amp.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-claw.md b/tools/skillgen/expected/graphify__skill-claw.md index bf9dd3431..c275c6b72 100644 --- a/tools/skillgen/expected/graphify__skill-claw.md +++ b/tools/skillgen/expected/graphify__skill-claw.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-codex.md b/tools/skillgen/expected/graphify__skill-codex.md index 04eb5705b..c0ac62a20 100644 --- a/tools/skillgen/expected/graphify__skill-codex.md +++ b/tools/skillgen/expected/graphify__skill-codex.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-copilot.md b/tools/skillgen/expected/graphify__skill-copilot.md index bf9dd3431..c275c6b72 100644 --- a/tools/skillgen/expected/graphify__skill-copilot.md +++ b/tools/skillgen/expected/graphify__skill-copilot.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-droid.md b/tools/skillgen/expected/graphify__skill-droid.md index ffa94995d..daf3ac90c 100644 --- a/tools/skillgen/expected/graphify__skill-droid.md +++ b/tools/skillgen/expected/graphify__skill-droid.md @@ -626,15 +626,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-kilo.md b/tools/skillgen/expected/graphify__skill-kilo.md index 96dfc2e85..c5dda3372 100644 --- a/tools/skillgen/expected/graphify__skill-kilo.md +++ b/tools/skillgen/expected/graphify__skill-kilo.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-kiro.md b/tools/skillgen/expected/graphify__skill-kiro.md index bf9dd3431..c275c6b72 100644 --- a/tools/skillgen/expected/graphify__skill-kiro.md +++ b/tools/skillgen/expected/graphify__skill-kiro.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-opencode.md b/tools/skillgen/expected/graphify__skill-opencode.md index 6613434e8..1c56528a7 100644 --- a/tools/skillgen/expected/graphify__skill-opencode.md +++ b/tools/skillgen/expected/graphify__skill-opencode.md @@ -621,15 +621,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-pi.md b/tools/skillgen/expected/graphify__skill-pi.md index bf9dd3431..c275c6b72 100644 --- a/tools/skillgen/expected/graphify__skill-pi.md +++ b/tools/skillgen/expected/graphify__skill-pi.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-trae.md b/tools/skillgen/expected/graphify__skill-trae.md index 407f091b6..ef54f5803 100644 --- a/tools/skillgen/expected/graphify__skill-trae.md +++ b/tools/skillgen/expected/graphify__skill-trae.md @@ -627,15 +627,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-vscode.md b/tools/skillgen/expected/graphify__skill-vscode.md index f7e7f8442..42ba7d17a 100644 --- a/tools/skillgen/expected/graphify__skill-vscode.md +++ b/tools/skillgen/expected/graphify__skill-vscode.md @@ -625,15 +625,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill-windows.md b/tools/skillgen/expected/graphify__skill-windows.md index 9c7ab7420..56574bef1 100644 --- a/tools/skillgen/expected/graphify__skill-windows.md +++ b/tools/skillgen/expected/graphify__skill-windows.md @@ -651,15 +651,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/expected/graphify__skill.md b/tools/skillgen/expected/graphify__skill.md index bf9dd3431..c275c6b72 100644 --- a/tools/skillgen/expected/graphify__skill.md +++ b/tools/skillgen/expected/graphify__skill.md @@ -629,15 +629,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ``` diff --git a/tools/skillgen/fragments/core/core.md b/tools/skillgen/fragments/core/core.md index cf8f03062..9d04220e0 100644 --- a/tools/skillgen/fragments/core/core.md +++ b/tools/skillgen/fragments/core/core.md @@ -564,15 +564,53 @@ Before running any subcommand below (`--update`, `--cluster-only`, `query`, `pat ```bash if [ ! -f graphify-out/.graphify_python ]; then - GRAPHIFY_BIN=$(which graphify 2>/dev/null) - if [ -n "$GRAPHIFY_BIN" ]; then - PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!') - case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac - else - PYTHON="python3" - fi + find_graphify_python() { + if command -v uv >/dev/null 2>&1; then + _TOOL_DIR=$(uv tool dir 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_TOOL_DIR/graphifyy/Scripts/python.exe" "$_TOOL_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + if command -v pipx >/dev/null 2>&1; then + _VENV_DIR=$(pipx environment --value PIPX_LOCAL_VENVS 2>/dev/null | tr -d '\r' | tr '\\' '/') + for _PY in "$_VENV_DIR/graphifyy/Scripts/python.exe" "$_VENV_DIR/graphifyy/bin/python"; do + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + done + fi + _GRAPHIFY_BIN=$(command -v graphify 2>/dev/null) + if [ -f "$_GRAPHIFY_BIN" ] && IFS= read -r _SHEBANG < "$_GRAPHIFY_BIN"; then + case "$_SHEBANG" in + '#!'*) + _PY=${_SHEBANG#\#!} + case "$_PY" in + *[!a-zA-Z0-9/_.@-]*) ;; + *) + if [ -x "$_PY" ] && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + printf '%s\n' "$_PY" + return 0 + fi + ;; + esac + ;; + esac + fi + for _PY in python3 python; do + if command -v "$_PY" >/dev/null 2>&1 && "$_PY" -c "from importlib.metadata import version; version('graphifyy'); import graphify" 2>/dev/null; then + "$_PY" -c "import sys; print(sys.executable.replace(chr(92), '/'))" | tr -d '\r' + return 0 + fi + done + return 1 + } + PYTHON=$(find_graphify_python) || exit 1 mkdir -p graphify-out - "$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)" + printf '%s' "$PYTHON" > graphify-out/.graphify_python fi ```