Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .codex/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Run this PowerShell block exactly:
$repoRoot = Join-Path $HOME '.codex\codex-environment-backup'
$skillsRoot = Join-Path $HOME '.agents\skills'
$skillNamespace = Join-Path $skillsRoot 'codex-environment-backup'
$expectedSkillTarget = Join-Path $repoRoot 'skills'

if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
throw 'git is required before installing codex-environment-backup.'
Expand Down Expand Up @@ -69,14 +70,19 @@ if (Test-Path $repoRoot) {
throw 'codex-environment-backup is already installed. Follow UPDATE.md instead.'
}

if (Test-Path $skillNamespace) {
throw 'The skill namespace link already exists. Remove it or follow UNINSTALL.md before reinstalling.'
$skillItem = Get-Item -LiteralPath $skillNamespace -Force -ErrorAction SilentlyContinue
if ($skillItem) {
if (($skillItem.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) {
Remove-Item -LiteralPath $skillNamespace -Force
} else {
throw 'The skill namespace path already exists and is not a link. Remove it or follow UNINSTALL.md before reinstalling.'
}
}

New-Item -ItemType Directory -Force -Path $skillsRoot | Out-Null
git clone https://github.com/gaoguobin/codex-environment-backup.git $repoRoot
& $pythonCmd -m pip install --user -e $repoRoot
cmd /d /c "mklink /J `"$skillNamespace`" `"$repoRoot\skills`""
cmd /d /c "mklink /J `"$skillNamespace`" `"$expectedSkillTarget`""
& $pythonCmd -m agent_environment_backup --profile codex doctor
```

Expand Down
3 changes: 2 additions & 1 deletion .codex/UNINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ if ($pythonCmd) {
& $pythonCmd -m pip uninstall -y agent-environment-backup codex-environment-backup
}

if (Test-Path $skillNamespace) {
$skillItem = Get-Item -LiteralPath $skillNamespace -Force -ErrorAction SilentlyContinue
if ($skillItem) {
cmd /d /c "rmdir `"$skillNamespace`""
}

Expand Down
24 changes: 22 additions & 2 deletions .codex/UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Run this PowerShell block exactly:
```powershell
$repoRoot = Join-Path $HOME '.codex\codex-environment-backup'
$skillNamespace = Join-Path $HOME '.agents\skills\codex-environment-backup'
$expectedSkillTarget = Join-Path $repoRoot 'skills'
$pythonCmd = $null

foreach ($candidate in @('python3', 'python')) {
Expand Down Expand Up @@ -56,9 +57,28 @@ git -C $repoRoot pull --ff-only
& $pythonCmd -m pip uninstall -y codex-environment-backup
& $pythonCmd -m pip install --user -e $repoRoot

if (-not (Test-Path $skillNamespace)) {
$skillItem = Get-Item -LiteralPath $skillNamespace -Force -ErrorAction SilentlyContinue
$recreateSkillLink = $false
if (-not $skillItem) {
$recreateSkillLink = $true
} elseif (($skillItem.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) {
$target = $skillItem.Target
if ($target -is [array]) {
$target = $target[0]
}
$currentTarget = [IO.Path]::GetFullPath([string]$target)
$wantedTarget = [IO.Path]::GetFullPath($expectedSkillTarget)
if ($currentTarget -ne $wantedTarget -or -not (Test-Path (Join-Path $skillNamespace 'codex-environment-backup\SKILL.md'))) {
Remove-Item -LiteralPath $skillNamespace -Force
$recreateSkillLink = $true
}
} elseif (-not (Test-Path (Join-Path $skillNamespace 'codex-environment-backup\SKILL.md'))) {
throw "Existing skill namespace is not a link and does not contain codex-environment-backup/SKILL.md: $skillNamespace"
}

if ($recreateSkillLink) {
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $skillNamespace) | Out-Null
cmd /d /c "mklink /J `"$skillNamespace`" `"$repoRoot\skills`""
cmd /d /c "mklink /J `"$skillNamespace`" `"$expectedSkillTarget`""
}

& $pythonCmd -m agent_environment_backup --profile codex doctor
Expand Down
Loading