feat(update): configurable remote + offline mode + portable editor detection
WP3: Remote-URLs nicht mehr hartkodiert (192.168.178.6). Aufloesung COPILOT_SETUP_REMOTE_SSH/_HTTP via env, sonst Config-Datei $XDG_CONFIG_HOME/copilot-setup/config (sh sourcet, fish parst), env hat Vorrang. WP5: Offline-Betrieb (lokaler Klon ohne .git nutzbar; Pull-Fehler nutzt Cache); fehlende/unerreichbare Quelle endet graceful mit exit 0 statt exit 1. WP4: detect_vscode_user_dir deckt Server/Insiders/VSCodium/Cursor/Flatpak/macOS/Windows-WSL ab. sh+fish verhalten sich identisch (getestet: graceful skip, offline-local, config-remote).
This commit is contained in:
parent
80b6248fe3
commit
5890bff4e0
2 changed files with 223 additions and 62 deletions
|
|
@ -11,44 +11,142 @@
|
||||||
# fish ~/.local/bin/copilot-update.fish
|
# fish ~/.local/bin/copilot-update.fish
|
||||||
# git copilot-update (via Alias, ruft copilot-update.sh auf)
|
# git copilot-update (via Alias, ruft copilot-update.sh auf)
|
||||||
|
|
||||||
set SETUP_REPO_SSH "ssh://git@192.168.178.6:2222/cschulz/rd13_copilot_setup.git"
|
# ── Konfiguration laden: env > config-file > leer ─────────────────────────
|
||||||
set SETUP_REPO_HTTP "http://192.168.178.6:8083/cschulz/rd13_copilot_setup.git"
|
# Env-Variablen (Vorrang):
|
||||||
|
# COPILOT_SETUP_REMOTE_SSH / _HTTP Remote-URLs des Setup-Repos
|
||||||
|
# COPILOT_SETUP_DIR lokaler Klon/Arbeitskopie (Offline)
|
||||||
|
# COPILOT_SETUP_CONFIG alternativer Pfad zur Config-Datei
|
||||||
|
# Config-Datei (sh-Syntax KEY="value", wird geparst): $XDG_CONFIG_HOME/copilot-setup/config
|
||||||
|
# Standalone-Skript -> keine gemeinsame Lib sourcebar; gleiche Aufloesung in deploy.fish.
|
||||||
|
|
||||||
if set -q COPILOT_SETUP_DIR
|
# Wert fuer KEY aus sh-style Config lesen (KEY="value" | KEY=value); letzte Definition gewinnt
|
||||||
|
function _cfg_get --argument-names file key
|
||||||
|
test -f "$file"; or return 1
|
||||||
|
set -l line (grep -E "^[[:space:]]*$key=" "$file" 2>/dev/null | tail -n1)
|
||||||
|
test -n "$line"; or return 1
|
||||||
|
set -l val (string replace -r "^[[:space:]]*$key=" '' -- $line)
|
||||||
|
set val (string trim -- $val)
|
||||||
|
set val (string trim --chars '"' -- $val)
|
||||||
|
set val (string trim --chars "'" -- $val)
|
||||||
|
printf '%s' $val
|
||||||
|
end
|
||||||
|
|
||||||
|
# VS Code User-Verzeichnis portabel ueber Editionen/OS ermitteln (identisch zu deploy.fish)
|
||||||
|
function detect_vscode_user_dir
|
||||||
|
for d in \
|
||||||
|
"$HOME/.vscode-server/data/User" \
|
||||||
|
"$HOME/.vscode-server-insiders/data/User" \
|
||||||
|
"$HOME/Library/Application Support/Code/User" \
|
||||||
|
"$HOME/Library/Application Support/Code - Insiders/User" \
|
||||||
|
"$HOME/Library/Application Support/VSCodium/User" \
|
||||||
|
"$HOME/Library/Application Support/Cursor/User" \
|
||||||
|
"$HOME/.config/Code/User" \
|
||||||
|
"$HOME/.config/Code - Insiders/User" \
|
||||||
|
"$HOME/.config/VSCodium/User" \
|
||||||
|
"$HOME/.config/Cursor/User" \
|
||||||
|
"$HOME/.var/app/com.visualstudio.code/config/Code/User" \
|
||||||
|
"/mnt/c/Users/$USER/AppData/Roaming/Code/User" \
|
||||||
|
"/mnt/c/Users/$USER/AppData/Roaming/Code - Insiders/User"
|
||||||
|
if test -d "$d"
|
||||||
|
echo $d
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
switch (uname -s)
|
||||||
|
case Darwin
|
||||||
|
echo "$HOME/Library/Application Support/Code/User"
|
||||||
|
case '*'
|
||||||
|
echo "$HOME/.config/Code/User"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Config-Datei-Pfad bestimmen
|
||||||
|
if set -q COPILOT_SETUP_CONFIG
|
||||||
|
set CONFIG_FILE $COPILOT_SETUP_CONFIG
|
||||||
|
else if set -q XDG_CONFIG_HOME
|
||||||
|
set CONFIG_FILE $XDG_CONFIG_HOME/copilot-setup/config
|
||||||
|
else
|
||||||
|
set CONFIG_FILE $HOME/.config/copilot-setup/config
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remote/Cache aufloesen: env hat Vorrang, sonst Config, sonst Default
|
||||||
|
if set -q COPILOT_SETUP_REMOTE_SSH; and test -n "$COPILOT_SETUP_REMOTE_SSH"
|
||||||
|
set SETUP_REPO_SSH $COPILOT_SETUP_REMOTE_SSH
|
||||||
|
else
|
||||||
|
set SETUP_REPO_SSH (_cfg_get $CONFIG_FILE COPILOT_SETUP_REMOTE_SSH)
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q COPILOT_SETUP_REMOTE_HTTP; and test -n "$COPILOT_SETUP_REMOTE_HTTP"
|
||||||
|
set SETUP_REPO_HTTP $COPILOT_SETUP_REMOTE_HTTP
|
||||||
|
else
|
||||||
|
set SETUP_REPO_HTTP (_cfg_get $CONFIG_FILE COPILOT_SETUP_REMOTE_HTTP)
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q COPILOT_SETUP_DIR; and test -n "$COPILOT_SETUP_DIR"
|
||||||
set CACHE_DIR $COPILOT_SETUP_DIR
|
set CACHE_DIR $COPILOT_SETUP_DIR
|
||||||
else
|
else
|
||||||
set CACHE_DIR $HOME/.copilot-setup
|
set CACHE_DIR (_cfg_get $CONFIG_FILE COPILOT_SETUP_DIR)
|
||||||
|
test -n "$CACHE_DIR"; or set CACHE_DIR $HOME/.copilot-setup
|
||||||
end
|
end
|
||||||
|
|
||||||
echo "=== Copilot Update ==="
|
echo "=== Copilot Update ==="
|
||||||
|
|
||||||
# ── 1. Setup-Repo Cache aktuell halten ───────────────────────────────────────
|
# ── 1. Setup-Repo Cache aktuell halten ───────────────────────────────────────
|
||||||
|
set HAVE_REMOTE 0
|
||||||
|
if test -n "$SETUP_REPO_SSH"; or test -n "$SETUP_REPO_HTTP"
|
||||||
|
set HAVE_REMOTE 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set SOURCE_OK 0
|
||||||
if test -d $CACHE_DIR/.git
|
if test -d $CACHE_DIR/.git
|
||||||
|
if test $HAVE_REMOTE -eq 1
|
||||||
echo " → Pulling latest from setup repo..."
|
echo " → Pulling latest from setup repo..."
|
||||||
if git -C $CACHE_DIR pull --ff-only --quiet 2>/dev/null
|
if git -C $CACHE_DIR pull --ff-only --quiet 2>/dev/null
|
||||||
echo " ✓ Cache aktualisiert: $CACHE_DIR"
|
echo " ✓ Cache aktualisiert: $CACHE_DIR"
|
||||||
else
|
else
|
||||||
echo " ✗ git pull fehlgeschlagen – versuche neu zu klonen..."
|
echo " ⚠ git pull fehlgeschlagen – nutze vorhandenen Cache (offline)"
|
||||||
rm -rf $CACHE_DIR
|
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
|
echo " ─ Kein Remote konfiguriert – nutze lokalen Klon: $CACHE_DIR"
|
||||||
if not test -d $CACHE_DIR/.git
|
end
|
||||||
|
set SOURCE_OK 1
|
||||||
|
else if test -d $CACHE_DIR/git-templates
|
||||||
|
echo " ─ Lokale Setup-Quelle ohne .git (Offline-Betrieb): $CACHE_DIR"
|
||||||
|
set SOURCE_OK 1
|
||||||
|
else
|
||||||
|
if test -n "$SETUP_REPO_SSH"
|
||||||
echo " → Klone Setup-Repo (SSH)..."
|
echo " → Klone Setup-Repo (SSH)..."
|
||||||
if git clone --quiet $SETUP_REPO_SSH $CACHE_DIR 2>/dev/null
|
if git clone --quiet $SETUP_REPO_SSH $CACHE_DIR 2>/dev/null
|
||||||
echo " ✓ Geklont via SSH"
|
echo " ✓ Geklont via SSH"
|
||||||
|
set SOURCE_OK 1
|
||||||
else
|
else
|
||||||
echo " ✗ SSH fehlgeschlagen – versuche HTTP-Fallback..."
|
echo " ✗ SSH fehlgeschlagen"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if test $SOURCE_OK -eq 0; and test -n "$SETUP_REPO_HTTP"
|
||||||
|
echo " → Klone Setup-Repo (HTTP)..."
|
||||||
if git clone --quiet $SETUP_REPO_HTTP $CACHE_DIR 2>/dev/null
|
if git clone --quiet $SETUP_REPO_HTTP $CACHE_DIR 2>/dev/null
|
||||||
echo " ✓ Geklont via HTTP"
|
echo " ✓ Geklont via HTTP"
|
||||||
|
set SOURCE_OK 1
|
||||||
else
|
else
|
||||||
|
echo " ✗ HTTP fehlgeschlagen"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test $SOURCE_OK -eq 0
|
||||||
echo ""
|
echo ""
|
||||||
echo " ✗ FEHLER: Setup-Repo nicht erreichbar."
|
echo " ⚠ Keine Setup-Quelle verfuegbar – Update uebersprungen."
|
||||||
echo " SSH: $SETUP_REPO_SSH"
|
if test $HAVE_REMOTE -eq 1
|
||||||
echo " HTTP: $SETUP_REPO_HTTP"
|
echo " Remote nicht erreichbar:"
|
||||||
exit 1
|
test -n "$SETUP_REPO_SSH"; and echo " SSH: $SETUP_REPO_SSH"
|
||||||
end
|
test -n "$SETUP_REPO_HTTP"; and echo " HTTP: $SETUP_REPO_HTTP"
|
||||||
|
else
|
||||||
|
echo " Kein Remote konfiguriert. Setze COPILOT_SETUP_REMOTE_SSH/_HTTP,"
|
||||||
|
echo " COPILOT_SETUP_DIR (lokaler Klon) oder lege $CONFIG_FILE an."
|
||||||
end
|
end
|
||||||
|
echo " (Kein Fehler – ohne Quelle gibt es nichts zu aktualisieren.)"
|
||||||
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
set SOURCE $CACHE_DIR
|
set SOURCE $CACHE_DIR
|
||||||
|
|
@ -87,15 +185,9 @@ cp $SOURCE/git-templates/history/summary/PROJECT_CONTEXT.md $GIT_TEMPLATE_DIR/hi
|
||||||
echo " ✓ ~/.git-templates/ aktualisiert"
|
echo " ✓ ~/.git-templates/ aktualisiert"
|
||||||
|
|
||||||
# ── 3. VS Code Prompt-Dateien aktualisieren ───────────────────────────────────
|
# ── 3. VS Code Prompt-Dateien aktualisieren ───────────────────────────────────
|
||||||
if test -d $HOME/.vscode-server/data/User
|
set VSCODE_USER (detect_vscode_user_dir)
|
||||||
set VSCODE_USER $HOME/.vscode-server/data/User
|
|
||||||
else if test -d "$HOME/Library/Application Support/Code/User"
|
|
||||||
set VSCODE_USER "$HOME/Library/Application Support/Code/User"
|
|
||||||
else
|
|
||||||
set VSCODE_USER $HOME/.config/Code/User
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -d $VSCODE_USER
|
if test -d "$VSCODE_USER"
|
||||||
mkdir -p $VSCODE_USER/prompts
|
mkdir -p $VSCODE_USER/prompts
|
||||||
set PROMPTS_UPDATED 0
|
set PROMPTS_UPDATED 0
|
||||||
for f in $SOURCE/prompts/*.prompt.md
|
for f in $SOURCE/prompts/*.prompt.md
|
||||||
|
|
|
||||||
|
|
@ -11,38 +11,113 @@
|
||||||
# copilot-update.sh # aktuelles Verzeichnis (Git-Repo optional)
|
# copilot-update.sh # aktuelles Verzeichnis (Git-Repo optional)
|
||||||
# git copilot-update # via Git-Alias
|
# git copilot-update # via Git-Alias
|
||||||
|
|
||||||
SETUP_REPO_SSH="ssh://git@192.168.178.6:2222/cschulz/rd13_copilot_setup.git"
|
# ── Konfiguration laden: env > config-file > leer ─────────────────────────
|
||||||
SETUP_REPO_HTTP="http://192.168.178.6:8083/cschulz/rd13_copilot_setup.git"
|
# Env-Variablen (Vorrang):
|
||||||
|
# COPILOT_SETUP_REMOTE_SSH / _HTTP Remote-URLs des Setup-Repos
|
||||||
|
# COPILOT_SETUP_DIR lokaler Klon/Arbeitskopie (Offline)
|
||||||
|
# COPILOT_SETUP_CONFIG alternativer Pfad zur Config-Datei
|
||||||
|
# Config-Datei (sh-Syntax, gesourct): $XDG_CONFIG_HOME/copilot-setup/config
|
||||||
|
# Standalone-Skript -> keine gemeinsame Lib sourcebar; gleiche Aufloesung in
|
||||||
|
# deploy.sh. Bei Aenderungen beide Stellen pflegen.
|
||||||
|
_env_ssh="${COPILOT_SETUP_REMOTE_SSH:-}"
|
||||||
|
_env_http="${COPILOT_SETUP_REMOTE_HTTP:-}"
|
||||||
|
_env_dir="${COPILOT_SETUP_DIR:-}"
|
||||||
|
|
||||||
|
CONFIG_FILE="${COPILOT_SETUP_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/copilot-setup/config}"
|
||||||
|
if [ -f "$CONFIG_FILE" ]; then
|
||||||
|
. "$CONFIG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Env ueberschreibt Werte aus der Config-Datei
|
||||||
|
[ -n "$_env_ssh" ] && COPILOT_SETUP_REMOTE_SSH="$_env_ssh"
|
||||||
|
[ -n "$_env_http" ] && COPILOT_SETUP_REMOTE_HTTP="$_env_http"
|
||||||
|
[ -n "$_env_dir" ] && COPILOT_SETUP_DIR="$_env_dir"
|
||||||
|
|
||||||
|
SETUP_REPO_SSH="${COPILOT_SETUP_REMOTE_SSH:-}"
|
||||||
|
SETUP_REPO_HTTP="${COPILOT_SETUP_REMOTE_HTTP:-}"
|
||||||
CACHE_DIR="${COPILOT_SETUP_DIR:-$HOME/.copilot-setup}"
|
CACHE_DIR="${COPILOT_SETUP_DIR:-$HOME/.copilot-setup}"
|
||||||
|
|
||||||
|
have_remote() { [ -n "$SETUP_REPO_SSH" ] || [ -n "$SETUP_REPO_HTTP" ]; }
|
||||||
|
|
||||||
|
clone_setup_repo() {
|
||||||
|
if [ -n "$SETUP_REPO_SSH" ]; then
|
||||||
|
echo " → Klone Setup-Repo (SSH)..."
|
||||||
|
if git clone --quiet "$SETUP_REPO_SSH" "$CACHE_DIR" 2>/dev/null; then
|
||||||
|
echo " ✓ Geklont via SSH"; return 0
|
||||||
|
fi
|
||||||
|
echo " ✗ SSH fehlgeschlagen"
|
||||||
|
fi
|
||||||
|
if [ -n "$SETUP_REPO_HTTP" ]; then
|
||||||
|
echo " → Klone Setup-Repo (HTTP)..."
|
||||||
|
if git clone --quiet "$SETUP_REPO_HTTP" "$CACHE_DIR" 2>/dev/null; then
|
||||||
|
echo " ✓ Geklont via HTTP"; return 0
|
||||||
|
fi
|
||||||
|
echo " ✗ HTTP fehlgeschlagen"
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# VS Code User-Verzeichnis portabel ueber Editionen/OS ermitteln.
|
||||||
|
# Identischer Block in deploy.sh (Standalone -> keine Lib sourcebar).
|
||||||
|
detect_vscode_user_dir() {
|
||||||
|
for d in \
|
||||||
|
"$HOME/.vscode-server/data/User" \
|
||||||
|
"$HOME/.vscode-server-insiders/data/User" \
|
||||||
|
"$HOME/Library/Application Support/Code/User" \
|
||||||
|
"$HOME/Library/Application Support/Code - Insiders/User" \
|
||||||
|
"$HOME/Library/Application Support/VSCodium/User" \
|
||||||
|
"$HOME/Library/Application Support/Cursor/User" \
|
||||||
|
"$HOME/.config/Code/User" \
|
||||||
|
"$HOME/.config/Code - Insiders/User" \
|
||||||
|
"$HOME/.config/VSCodium/User" \
|
||||||
|
"$HOME/.config/Cursor/User" \
|
||||||
|
"$HOME/.var/app/com.visualstudio.code/config/Code/User" \
|
||||||
|
"/mnt/c/Users/$USER/AppData/Roaming/Code/User" \
|
||||||
|
"/mnt/c/Users/$USER/AppData/Roaming/Code - Insiders/User"
|
||||||
|
do
|
||||||
|
if [ -d "$d" ]; then
|
||||||
|
printf '%s\n' "$d"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Darwin) printf '%s\n' "$HOME/Library/Application Support/Code/User" ;;
|
||||||
|
*) printf '%s\n' "$HOME/.config/Code/User" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
echo "=== Copilot Update ==="
|
echo "=== Copilot Update ==="
|
||||||
|
|
||||||
# ── 1. Setup-Repo Cache aktuell halten ───────────────────────────────────────
|
# ── 1. Setup-Repo Cache aktuell halten ───────────────────────────────────────
|
||||||
if [ -d "$CACHE_DIR/.git" ]; then
|
if [ -d "$CACHE_DIR/.git" ]; then
|
||||||
|
if have_remote; then
|
||||||
echo " → Pulling latest from setup repo..."
|
echo " → Pulling latest from setup repo..."
|
||||||
if git -C "$CACHE_DIR" pull --ff-only --quiet 2>/dev/null; then
|
if git -C "$CACHE_DIR" pull --ff-only --quiet 2>/dev/null; then
|
||||||
echo " ✓ Cache aktualisiert: $CACHE_DIR"
|
echo " ✓ Cache aktualisiert: $CACHE_DIR"
|
||||||
else
|
else
|
||||||
echo " ✗ git pull fehlgeschlagen – versuche neu zu klonen..."
|
echo " ⚠ git pull fehlgeschlagen – nutze vorhandenen Cache (offline)"
|
||||||
rm -rf "$CACHE_DIR"
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$CACHE_DIR/.git" ]; then
|
|
||||||
echo " → Klone Setup-Repo (SSH)..."
|
|
||||||
if git clone --quiet "$SETUP_REPO_SSH" "$CACHE_DIR" 2>/dev/null; then
|
|
||||||
echo " ✓ Geklont via SSH"
|
|
||||||
else
|
else
|
||||||
echo " ✗ SSH fehlgeschlagen – versuche HTTP-Fallback..."
|
echo " ─ Kein Remote konfiguriert – nutze lokalen Klon: $CACHE_DIR"
|
||||||
if git clone --quiet "$SETUP_REPO_HTTP" "$CACHE_DIR" 2>/dev/null; then
|
fi
|
||||||
echo " ✓ Geklont via HTTP"
|
elif [ -d "$CACHE_DIR/git-templates" ]; then
|
||||||
|
echo " ─ Lokale Setup-Quelle ohne .git (Offline-Betrieb): $CACHE_DIR"
|
||||||
|
else
|
||||||
|
if have_remote && clone_setup_repo; then
|
||||||
|
:
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo " ✗ FEHLER: Setup-Repo nicht erreichbar."
|
echo " ⚠ Keine Setup-Quelle verfuegbar – Update uebersprungen."
|
||||||
echo " SSH: $SETUP_REPO_SSH"
|
if have_remote; then
|
||||||
echo " HTTP: $SETUP_REPO_HTTP"
|
echo " Remote nicht erreichbar:"
|
||||||
exit 1
|
[ -n "$SETUP_REPO_SSH" ] && echo " SSH: $SETUP_REPO_SSH"
|
||||||
|
[ -n "$SETUP_REPO_HTTP" ] && echo " HTTP: $SETUP_REPO_HTTP"
|
||||||
|
else
|
||||||
|
echo " Kein Remote konfiguriert. Setze COPILOT_SETUP_REMOTE_SSH/_HTTP,"
|
||||||
|
echo " COPILOT_SETUP_DIR (lokaler Klon) oder lege $CONFIG_FILE an."
|
||||||
fi
|
fi
|
||||||
|
echo " (Kein Fehler – ohne Quelle gibt es nichts zu aktualisieren.)"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -83,13 +158,7 @@ cp "$SOURCE/git-templates/history/summary/PROJECT_CONTEXT.md" "$GIT_TEMPLATE_DIR
|
||||||
echo " ✓ ~/.git-templates/ aktualisiert"
|
echo " ✓ ~/.git-templates/ aktualisiert"
|
||||||
|
|
||||||
# ── 3. VS Code Prompt-Dateien aktualisieren ───────────────────────────────────
|
# ── 3. VS Code Prompt-Dateien aktualisieren ───────────────────────────────────
|
||||||
if [ -d "$HOME/.vscode-server/data/User" ]; then
|
VSCODE_USER="$(detect_vscode_user_dir)"
|
||||||
VSCODE_USER="$HOME/.vscode-server/data/User"
|
|
||||||
elif [ -d "$HOME/Library/Application Support/Code/User" ]; then
|
|
||||||
VSCODE_USER="$HOME/Library/Application Support/Code/User"
|
|
||||||
else
|
|
||||||
VSCODE_USER="$HOME/.config/Code/User"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$VSCODE_USER" ]; then
|
if [ -d "$VSCODE_USER" ]; then
|
||||||
mkdir -p "$VSCODE_USER/prompts"
|
mkdir -p "$VSCODE_USER/prompts"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue