codex: keep skills under dotfiles symlink

This commit is contained in:
2026-04-25 16:17:09 -07:00
committed by Ivan Anthony Malison
parent 1bc595dc13
commit 5907395512
5 changed files with 3 additions and 65 deletions

View File

@@ -2,3 +2,4 @@
!.gitignore !.gitignore
!AGENTS.md !AGENTS.md
!config.toml !config.toml
!skills

1
dotfiles/codex/skills Symbolic link
View File

@@ -0,0 +1 @@
../agents/skills

View File

@@ -1,57 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
tracked_skills_dir="${1:?usage: setup_codex_skills TRACKED_SKILLS_DIR [RUNTIME_SKILLS_DIR] [CODEX_SKILLS_LINK]}"
runtime_skills_dir="${2:-${XDG_DATA_HOME:-$HOME/.local/share}/codex/skills}"
codex_skills_link="${3:-$HOME/.codex/skills}"
mkdir -p "$runtime_skills_dir"
mkdir -p "$(dirname "$codex_skills_link")"
# Preserve generated Codex skill bundles while moving them out of the git worktree.
for generated_name in .system codex-primary-runtime; do
generated_src="$tracked_skills_dir/$generated_name"
generated_dest="$runtime_skills_dir/$generated_name"
if [[ -e "$generated_src" && ! -e "$generated_dest" ]]; then
mv "$generated_src" "$generated_dest"
fi
done
if [[ -L "$codex_skills_link" ]]; then
current_target="$(readlink "$codex_skills_link")"
if [[ "$current_target" != "$runtime_skills_dir" ]]; then
rm -f "$codex_skills_link"
fi
elif [[ -e "$codex_skills_link" ]]; then
echo "Skipping $codex_skills_link because it exists and is not a symlink" >&2
codex_skills_link=""
fi
if [[ -n "$codex_skills_link" && ! -e "$codex_skills_link" ]]; then
ln -s "$runtime_skills_dir" "$codex_skills_link"
fi
for skill_src in "$tracked_skills_dir"/*; do
[[ -e "$skill_src" || -L "$skill_src" ]] || continue
skill_name="$(basename "$skill_src")"
case "$skill_name" in
.system|codex-primary-runtime)
continue
;;
esac
skill_dest="$runtime_skills_dir/$skill_name"
if [[ -L "$skill_dest" ]]; then
current_target="$(readlink "$skill_dest")"
if [[ "$current_target" == "$skill_src" ]]; then
continue
fi
rm -f "$skill_dest"
elif [[ -e "$skill_dest" ]]; then
echo "Skipping skill $skill_name because $skill_dest already exists and is not a symlink" >&2
continue
fi
ln -s "$skill_src" "$skill_dest"
done

View File

@@ -109,10 +109,6 @@ in {
fi fi
''; '';
home.activation.linkCodexSkills = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.bash}/bin/bash "${libDir}/bin/setup_codex_skills" "${dotfilesDir}/agents/skills"
'';
home.sessionPath = [ home.sessionPath = [
"$HOME/.cargo/bin" "$HOME/.cargo/bin"
"${libDir}/bin" "${libDir}/bin"

View File

@@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, ... }:
let let
# Replicate the useful part of rcm/rcup: # Replicate the useful part of rcm/rcup:
# - dotfiles live in ~/dotfiles/dotfiles (no leading dots in the repo) # - dotfiles live in ~/dotfiles/dotfiles (no leading dots in the repo)
@@ -71,7 +71,4 @@ in
fi fi
''; '';
home.activation.linkCodexSkills = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.bash}/bin/bash "${worktreeDotfiles}/lib/bin/setup_codex_skills" "${worktreeDotfiles}/agents/skills"
'';
} }