Update script

This commit is contained in:
MaksTinyWorkshop
2026-03-08 14:28:32 +01:00
parent f3b4345429
commit af07410196

View File

@@ -12,6 +12,7 @@ PROJECTS_CONF="$SCRIPT_DIR/_projects.conf"
# --- Détection machine --- # --- Détection machine ---
OS="$(uname -s)" OS="$(uname -s)"
CHANGED=0
# --- Construire la table markdown des projets --- # --- Construire la table markdown des projets ---
build_projects_table() { build_projects_table() {
@@ -39,7 +40,11 @@ generate() {
local header="$1" local header="$1"
local dest="$2" local dest="$2"
local projects_table local projects_table
local tmp
projects_table="$(build_projects_table "$OS")" projects_table="$(build_projects_table "$OS")"
tmp="$(mktemp)"
mkdir -p "$(dirname "$dest")"
{ {
echo "$header" echo "$header"
@@ -52,23 +57,38 @@ generate() {
echo "$line" echo "$line"
fi fi
done < "$SOURCE" done < "$SOURCE"
} > "$dest" } > "$tmp"
echo " -> $dest"
if [ ! -f "$dest" ] || ! cmp -s "$tmp" "$dest"; then
mv "$tmp" "$dest"
CHANGED=1
else
rm -f "$tmp"
fi
} }
ensure_symlink() { ensure_symlink() {
local target="$1" local target="$1"
local link_path="$2" local link_path="$2"
mkdir -p "$(dirname "$link_path")"
if [ -L "$link_path" ]; then
local current_target
current_target="$(readlink "$link_path")"
if [ "$current_target" = "$target" ]; then
return 0
fi
fi
rm -f "$link_path" rm -f "$link_path"
ln -s "$target" "$link_path" ln -s "$target" "$link_path"
echo " -> $link_path -> $target" CHANGED=1
} }
echo "Sync AI instructions (OS: $OS)"
CLAUDE_HEADER="# Instructions globales — Lead Tech Copilote CLAUDE_HEADER="# Instructions globales — Lead Tech Copilote
Ce fichier est chargé automatiquement par Claude Code ou Codex à chaque session. Ce fichier est chargé automatiquement par Claude Code à chaque session.
Il pointe vers la base de connaissance commune à tous les projets." Il pointe vers la base de connaissance commune à tous les projets."
generate "$CLAUDE_HEADER" "$HOME/.claude/CLAUDE.md" generate "$CLAUDE_HEADER" "$HOME/.claude/CLAUDE.md"
@@ -77,4 +97,7 @@ generate "$CLAUDE_HEADER" "$SCRIPT_DIR/CLAUDE.md"
ensure_symlink "$HOME/.claude/CLAUDE.md" "$HOME/.codex/AGENTS.md" ensure_symlink "$HOME/.claude/CLAUDE.md" "$HOME/.codex/AGENTS.md"
ensure_symlink "$SCRIPT_DIR/CLAUDE.md" "$SCRIPT_DIR/AGENTS.md" ensure_symlink "$SCRIPT_DIR/CLAUDE.md" "$SCRIPT_DIR/AGENTS.md"
echo "Sync terminé." if [ "$CHANGED" -eq 1 ]; then
echo "Sync AI instructions (OS: $OS)"
echo "Sync terminée."
fi