Skip to content

Commit 7c6dc14

Browse files
authored
Install Plannotator command skills under Codex home (#669)
* Install Plannotator skills under Codex home * Keep shared Plannotator skills in agent scope * Harden scoped skill migration
1 parent ff2759b commit 7c6dc14

4 files changed

Lines changed: 276 additions & 18 deletions

File tree

scripts/install.cmd

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,15 @@ echo }
385385
REM Codex hooks on Windows are still experimental upstream. Do not mutate
386386
REM %%USERPROFILE%%\.codex automatically from the cmd installer until that path
387387
REM is verified end-to-end.
388+
set "CODEX_AVAILABLE=0"
388389
where codex >nul 2>&1
389-
if !ERRORLEVEL! equ 0 (
390+
if !ERRORLEVEL! equ 0 set "CODEX_AVAILABLE=1"
391+
if exist "%USERPROFILE%\.codex" (
392+
for /f "delims=" %%C in ('dir /b /a "%USERPROFILE%\.codex" 2^>nul') do (
393+
if /i not "%%C"=="skills" if /i not "%%C"==".DS_Store" set "CODEX_AVAILABLE=1"
394+
)
395+
)
396+
if "!CODEX_AVAILABLE!"=="1" (
390397
echo.
391398
echo Codex detected.
392399
echo Codex plan review hooks are experimental on Windows. To try them manually:
@@ -475,13 +482,36 @@ echo Address the annotation feedback above. The user has reviewed your last mess
475482
echo Installed /plannotator-last command to !CLAUDE_COMMANDS_DIR!\plannotator-last.md
476483

477484
REM Install skills (requires git)
485+
REM Remove legacy Codex-oriented skills from the older shared agent scope.
486+
set "LEGACY_AGENTS_SKILLS_DIR=%USERPROFILE%\.agents\skills"
487+
set "LEGACY_SKILLS_REMOVED=0"
488+
for %%S in (plannotator-review plannotator-annotate plannotator-last) do (
489+
if exist "!LEGACY_AGENTS_SKILLS_DIR!\%%S" (
490+
rmdir /s /q "!LEGACY_AGENTS_SKILLS_DIR!\%%S" >nul 2>&1
491+
set "LEGACY_SKILLS_REMOVED=1"
492+
)
493+
)
494+
if "!LEGACY_SKILLS_REMOVED!"=="1" echo Removed legacy Plannotator skills from !LEGACY_AGENTS_SKILLS_DIR!
495+
496+
REM Remove Plannotator skills that belong in the shared agent scope from Codex.
497+
set "STALE_CODEX_SKILLS_DIR=%USERPROFILE%\.codex\skills"
498+
set "STALE_CODEX_SKILLS_REMOVED=0"
499+
for %%S in (plannotator-compound plannotator-setup-goal) do (
500+
if exist "!STALE_CODEX_SKILLS_DIR!\%%S" (
501+
rmdir /s /q "!STALE_CODEX_SKILLS_DIR!\%%S" >nul 2>&1
502+
set "STALE_CODEX_SKILLS_REMOVED=1"
503+
)
504+
)
505+
if "!STALE_CODEX_SKILLS_REMOVED!"=="1" echo Removed shared-agent Plannotator skills from !STALE_CODEX_SKILLS_DIR!
506+
478507
where git >nul 2>&1
479508
if !ERRORLEVEL! equ 0 (
480509
if defined CLAUDE_CONFIG_DIR (
481510
set "CLAUDE_SKILLS_DIR=%CLAUDE_CONFIG_DIR%\skills"
482511
) else (
483512
set "CLAUDE_SKILLS_DIR=%USERPROFILE%\.claude\skills"
484513
)
514+
set "CODEX_SKILLS_DIR=%USERPROFILE%\.codex\skills"
485515
set "AGENTS_SKILLS_DIR=%USERPROFILE%\.agents\skills"
486516
set "SKILLS_TMP=%TEMP%\plannotator-skills-%RANDOM%"
487517
mkdir "!SKILLS_TMP!" >nul 2>&1
@@ -495,8 +525,17 @@ if !ERRORLEVEL! equ 0 (
495525
if not exist "!CLAUDE_SKILLS_DIR!" mkdir "!CLAUDE_SKILLS_DIR!"
496526
if not exist "!AGENTS_SKILLS_DIR!" mkdir "!AGENTS_SKILLS_DIR!"
497527
xcopy /s /y /q "apps\skills\*" "!CLAUDE_SKILLS_DIR!\" >nul 2>&1
498-
xcopy /s /y /q "apps\skills\*" "!AGENTS_SKILLS_DIR!\" >nul 2>&1
499-
echo Installed skills to !CLAUDE_SKILLS_DIR!\ and !AGENTS_SKILLS_DIR!\
528+
if exist "apps\skills\plannotator-compound" xcopy /s /i /y /q "apps\skills\plannotator-compound" "!AGENTS_SKILLS_DIR!\plannotator-compound\" >nul 2>&1
529+
if exist "apps\skills\plannotator-setup-goal" xcopy /s /i /y /q "apps\skills\plannotator-setup-goal" "!AGENTS_SKILLS_DIR!\plannotator-setup-goal\" >nul 2>&1
530+
if "!CODEX_AVAILABLE!"=="1" (
531+
if not exist "!CODEX_SKILLS_DIR!" mkdir "!CODEX_SKILLS_DIR!"
532+
if exist "apps\skills\plannotator-review" xcopy /s /i /y /q "apps\skills\plannotator-review" "!CODEX_SKILLS_DIR!\plannotator-review\" >nul 2>&1
533+
if exist "apps\skills\plannotator-annotate" xcopy /s /i /y /q "apps\skills\plannotator-annotate" "!CODEX_SKILLS_DIR!\plannotator-annotate\" >nul 2>&1
534+
if exist "apps\skills\plannotator-last" xcopy /s /i /y /q "apps\skills\plannotator-last" "!CODEX_SKILLS_DIR!\plannotator-last\" >nul 2>&1
535+
echo Installed skills to !CLAUDE_SKILLS_DIR!\, Codex command skills to !CODEX_SKILLS_DIR!\, and shared agent skills to !AGENTS_SKILLS_DIR!\
536+
) else (
537+
echo Installed skills to !CLAUDE_SKILLS_DIR!\ and shared agent skills to !AGENTS_SKILLS_DIR!\
538+
)
500539
)
501540

502541
popd

scripts/install.ps1

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,15 @@ if (Test-Path $pluginHooks) {
270270
# $env:USERPROFILE\.codex automatically from the Windows installer until that
271271
# path is verified end-to-end.
272272
$codexDir = "$env:USERPROFILE\.codex"
273-
if ((Get-Command codex -ErrorAction SilentlyContinue) -or (Test-Path $codexDir)) {
273+
$codexHomeHasUserConfig = $false
274+
if (Test-Path $codexDir) {
275+
$codexHomeHasUserConfig = [bool](Get-ChildItem -Force $codexDir -ErrorAction SilentlyContinue |
276+
Where-Object { $_.Name -ne "skills" -and $_.Name -ne ".DS_Store" } |
277+
Select-Object -First 1)
278+
}
279+
$codexAvailable = [bool](Get-Command codex -ErrorAction SilentlyContinue) -or $codexHomeHasUserConfig
280+
281+
if ($codexAvailable) {
274282
$codexExePath = "$installDir\plannotator.exe"
275283
Write-Host ""
276284
Write-Host "Codex detected."
@@ -394,13 +402,53 @@ description: Annotate the last assistant message
394402

395403
Write-Host "Installed /plannotator-last command to $opencodeCommandsDir\plannotator-last.md"
396404

405+
# Remove legacy Codex-oriented skills from the older shared agent scope.
406+
$legacyAgentsSkillsDir = "$env:USERPROFILE\.agents\skills"
407+
$legacySkillsRemoved = $false
408+
foreach ($skill in @("plannotator-review", "plannotator-annotate", "plannotator-last")) {
409+
$legacySkillPath = Join-Path $legacyAgentsSkillsDir $skill
410+
if (Test-Path $legacySkillPath) {
411+
Remove-Item -Recurse -Force $legacySkillPath -ErrorAction SilentlyContinue
412+
$legacySkillsRemoved = $true
413+
}
414+
}
415+
if ($legacySkillsRemoved) {
416+
Write-Host "Removed legacy Plannotator skills from $legacyAgentsSkillsDir"
417+
}
418+
419+
# Remove Plannotator skills that belong in the shared agent scope from Codex.
420+
$staleCodexSkillsDir = "$env:USERPROFILE\.codex\skills"
421+
$staleCodexSkillsRemoved = $false
422+
foreach ($skill in @("plannotator-compound", "plannotator-setup-goal")) {
423+
$staleSkillPath = Join-Path $staleCodexSkillsDir $skill
424+
if (Test-Path $staleSkillPath) {
425+
Remove-Item -Recurse -Force $staleSkillPath -ErrorAction SilentlyContinue
426+
$staleCodexSkillsRemoved = $true
427+
}
428+
}
429+
if ($staleCodexSkillsRemoved) {
430+
Write-Host "Removed shared-agent Plannotator skills from $staleCodexSkillsDir"
431+
}
432+
397433
# Install skills (requires git)
398434
if (Get-Command git -ErrorAction SilentlyContinue) {
399435
$claudeSkillsDir = if ($env:CLAUDE_CONFIG_DIR) { "$env:CLAUDE_CONFIG_DIR\skills" } else { "$env:USERPROFILE\.claude\skills" }
436+
$codexSkillsDir = "$env:USERPROFILE\.codex\skills"
400437
$agentsSkillsDir = "$env:USERPROFILE\.agents\skills"
401438
$skillsTmp = Join-Path ([System.IO.Path]::GetTempPath()) "plannotator-skills-$(Get-Random)"
402439
New-Item -ItemType Directory -Force -Path $skillsTmp | Out-Null
403440

441+
function Copy-SkillIfPresent {
442+
param(
443+
[string]$SourceDir,
444+
[string]$TargetDir
445+
)
446+
447+
if (Test-Path $SourceDir) {
448+
Copy-Item -Recurse -Force $SourceDir $TargetDir
449+
}
450+
}
451+
404452
try {
405453
git clone --depth 1 --filter=blob:none --sparse "https://github.com/$repo.git" --branch $latestTag "$skillsTmp\repo" 2>$null
406454
# git is a native executable — it does not throw under
@@ -423,8 +471,17 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
423471
New-Item -ItemType Directory -Force -Path $claudeSkillsDir | Out-Null
424472
New-Item -ItemType Directory -Force -Path $agentsSkillsDir | Out-Null
425473
Copy-Item -Recurse -Force "apps\skills\*" $claudeSkillsDir
426-
Copy-Item -Recurse -Force "apps\skills\*" $agentsSkillsDir
427-
Write-Host "Installed skills to $claudeSkillsDir\ and $agentsSkillsDir\"
474+
Copy-SkillIfPresent "apps\skills\plannotator-compound" $agentsSkillsDir
475+
Copy-SkillIfPresent "apps\skills\plannotator-setup-goal" $agentsSkillsDir
476+
if ($codexAvailable) {
477+
New-Item -ItemType Directory -Force -Path $codexSkillsDir | Out-Null
478+
Copy-SkillIfPresent "apps\skills\plannotator-review" $codexSkillsDir
479+
Copy-SkillIfPresent "apps\skills\plannotator-annotate" $codexSkillsDir
480+
Copy-SkillIfPresent "apps\skills\plannotator-last" $codexSkillsDir
481+
Write-Host "Installed skills to $claudeSkillsDir\, Codex command skills to $codexSkillsDir\, and shared agent skills to $agentsSkillsDir\"
482+
} else {
483+
Write-Host "Installed skills to $claudeSkillsDir\ and shared agent skills to $agentsSkillsDir\"
484+
}
428485
}
429486
}
430487
} finally {

scripts/install.sh

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,17 @@ if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
314314
fi
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

625635
echo "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)
628668
if 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

Comments
 (0)