@@ -314,7 +314,17 @@ if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
314314fi
315315
316316# --- Codex CLI / Desktop app support (only if Codex is installed or configured) ---
317- if command -v codex > /dev/null 2>&1 || [ -d " $HOME /.codex" ]; then
317+ codex_home_has_user_config () {
318+ [ -d " $HOME /.codex" ] || return 1
319+ [ -n " $( find " $HOME /.codex" -mindepth 1 -maxdepth 1 ! -name skills ! -name .DS_Store -print -quit 2> /dev/null) " ]
320+ }
321+
322+ codex_available=0
323+ if command -v codex > /dev/null 2>&1 || codex_home_has_user_config; then
324+ codex_available=1
325+ fi
326+
327+ if [ " $codex_available " -eq 1 ]; then
318328 CODEX_DIR=" $HOME /.codex"
319329 CODEX_CONFIG=" $CODEX_DIR /config.toml"
320330 CODEX_HOOKS=" $CODEX_DIR /hooks.json"
@@ -624,12 +634,52 @@ COMMAND_EOF
624634
625635echo " Installed /plannotator-last command to ${OPENCODE_COMMANDS_DIR} /plannotator-last.md"
626636
637+ # Remove legacy Codex-oriented skills from the older shared agent scope.
638+ LEGACY_AGENTS_SKILLS_DIR=" $HOME /.agents/skills"
639+ legacy_skills_removed=0
640+ if [ -d " $LEGACY_AGENTS_SKILLS_DIR " ]; then
641+ for skill in plannotator-review plannotator-annotate plannotator-last; do
642+ if [ -d " $LEGACY_AGENTS_SKILLS_DIR /$skill " ]; then
643+ rm -rf " $LEGACY_AGENTS_SKILLS_DIR /$skill "
644+ legacy_skills_removed=1
645+ fi
646+ done
647+ fi
648+ if [ " $legacy_skills_removed " -eq 1 ]; then
649+ echo " Removed legacy Plannotator skills from ${LEGACY_AGENTS_SKILLS_DIR} "
650+ fi
651+
652+ # Remove Plannotator skills that belong in the shared agent scope from Codex.
653+ STALE_CODEX_SKILLS_DIR=" $HOME /.codex/skills"
654+ stale_codex_skills_removed=0
655+ if [ -d " $STALE_CODEX_SKILLS_DIR " ]; then
656+ for skill in plannotator-compound plannotator-setup-goal; do
657+ if [ -d " $STALE_CODEX_SKILLS_DIR /$skill " ]; then
658+ rm -rf " $STALE_CODEX_SKILLS_DIR /$skill "
659+ stale_codex_skills_removed=1
660+ fi
661+ done
662+ fi
663+ if [ " $stale_codex_skills_removed " -eq 1 ]; then
664+ echo " Removed shared-agent Plannotator skills from ${STALE_CODEX_SKILLS_DIR} "
665+ fi
666+
627667# Install skills (requires git)
628668if command -v git & > /dev/null; then
629669 CLAUDE_SKILLS_DIR=" ${CLAUDE_CONFIG_DIR:- $HOME / .claude} /skills"
670+ CODEX_SKILLS_DIR=" $HOME /.codex/skills"
630671 AGENTS_SKILLS_DIR=" $HOME /.agents/skills"
631672 skills_tmp=$( mktemp -d)
632673
674+ copy_skill_if_present () {
675+ local source_dir=" $1 "
676+ local target_dir=" $2 "
677+
678+ if [ -d " $source_dir " ]; then
679+ cp -r " $source_dir " " $target_dir /"
680+ fi
681+ }
682+
633683 # Wrap the cd-bearing block in a subshell so any `cd` is scoped to
634684 # the subshell and can't leave the parent script with a dangling CWD.
635685 # Previous version chained `cd` inside an `&&` condition, and if
@@ -642,18 +692,30 @@ if command -v git &>/dev/null; then
642692 # equivalent — the parent shell's CWD is inherited in, and any
643693 # cd inside the subshell disappears when the subshell exits.
644694 if (
645- cd " $skills_tmp " &&
695+ set -e
696+ cd " $skills_tmp "
646697 git clone --depth 1 --filter=blob:none --sparse \
647- " https://github.com/${REPO} .git" --branch " $latest_tag " repo 2> /dev/null &&
648- cd repo &&
649- git sparse-checkout set apps/skills 2> /dev/null &&
650- [ -d " apps/skills" ] &&
651- [ " $( ls -A apps/skills 2> /dev/null) " ] &&
652- mkdir -p " $CLAUDE_SKILLS_DIR " " $AGENTS_SKILLS_DIR " &&
653- cp -r apps/skills/* " $CLAUDE_SKILLS_DIR /" &&
654- cp -r apps/skills/* " $AGENTS_SKILLS_DIR /"
698+ " https://github.com/${REPO} .git" --branch " $latest_tag " repo 2> /dev/null
699+ cd repo
700+ git sparse-checkout set apps/skills 2> /dev/null
701+ [ -d " apps/skills" ]
702+ [ " $( ls -A apps/skills 2> /dev/null) " ]
703+ mkdir -p " $CLAUDE_SKILLS_DIR " " $AGENTS_SKILLS_DIR "
704+ cp -r apps/skills/* " $CLAUDE_SKILLS_DIR /"
705+ copy_skill_if_present apps/skills/plannotator-compound " $AGENTS_SKILLS_DIR "
706+ copy_skill_if_present apps/skills/plannotator-setup-goal " $AGENTS_SKILLS_DIR "
707+ if [ " $codex_available " -eq 1 ]; then
708+ mkdir -p " $CODEX_SKILLS_DIR "
709+ copy_skill_if_present apps/skills/plannotator-review " $CODEX_SKILLS_DIR "
710+ copy_skill_if_present apps/skills/plannotator-annotate " $CODEX_SKILLS_DIR "
711+ copy_skill_if_present apps/skills/plannotator-last " $CODEX_SKILLS_DIR "
712+ fi
655713 ); then
656- echo " Installed skills to ${CLAUDE_SKILLS_DIR} / and ${AGENTS_SKILLS_DIR} /"
714+ if [ " $codex_available " -eq 1 ]; then
715+ echo " Installed skills to ${CLAUDE_SKILLS_DIR} /, Codex command skills to ${CODEX_SKILLS_DIR} /, and shared agent skills to ${AGENTS_SKILLS_DIR} /"
716+ else
717+ echo " Installed skills to ${CLAUDE_SKILLS_DIR} / and shared agent skills to ${AGENTS_SKILLS_DIR} /"
718+ fi
657719 else
658720 echo " Skipping skills install (git sparse-checkout failed or apps/skills empty)"
659721 fi
0 commit comments