forked from violetljj/blind-assist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore_codex_skills.ps1
More file actions
46 lines (37 loc) · 1.8 KB
/
Copy pathrestore_codex_skills.ps1
File metadata and controls
46 lines (37 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
param(
[string]$CodexHome = (Join-Path $env:USERPROFILE ".codex"),
[string]$Snapshot = "",
[switch]$NoBackup
)
$ErrorActionPreference = "Stop"
if ([string]::IsNullOrWhiteSpace($Snapshot)) {
$externalSnapshot = "E:\codex-tools\projects\blindassist\state\skills-snapshots\codex-skills-20260522.zip"
$legacySnapshot = Join-Path $PSScriptRoot "..\codex\skills-snapshot\codex-skills-20260522.zip"
$Snapshot = if (Test-Path -LiteralPath $externalSnapshot) { $externalSnapshot } else { $legacySnapshot }
}
$snapshotPath = (Resolve-Path -LiteralPath $Snapshot).Path
$codexHomePath = [System.IO.Path]::GetFullPath($CodexHome)
$skillsPath = Join-Path $codexHomePath "skills"
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$backupPath = Join-Path $codexHomePath "skills-backup-$timestamp"
Write-Host "Codex home: $codexHomePath"
Write-Host "Skills snapshot: $snapshotPath"
New-Item -ItemType Directory -Force -Path $codexHomePath | Out-Null
if ((Test-Path -LiteralPath $skillsPath) -and -not $NoBackup) {
Write-Host "Existing skills folder found. Creating backup: $backupPath"
Copy-Item -LiteralPath $skillsPath -Destination $backupPath -Recurse -Force
}
$tar = Get-Command tar.exe -ErrorAction SilentlyContinue
if ($tar) {
Write-Host "Restoring with tar.exe..."
& $tar.Source -xf $snapshotPath -C $codexHomePath
} else {
Write-Host "tar.exe not found. Restoring with Expand-Archive..."
Expand-Archive -LiteralPath $snapshotPath -DestinationPath $codexHomePath -Force
}
$skillDirs = Get-ChildItem -LiteralPath $skillsPath -Directory -Force
$skillFiles = Get-ChildItem -LiteralPath $skillsPath -Recurse -Force -File
Write-Host "Restore complete."
Write-Host "Skill folders: $($skillDirs.Count)"
Write-Host "Skill files: $($skillFiles.Count)"
Write-Host "Restart Codex to reload restored skills."