# 把旧版 qingjian/ 目录整理成 system + data 双区布局(Windows PowerShell)。 # # 只迁移程序资产,不碰历史案件数据。 # 用法: # powershell -ExecutionPolicy Bypass -File deploy/storage-layout-init.ps1 -DryRun # powershell -ExecutionPolicy Bypass -File deploy/storage-layout-init.ps1 param( [switch]$DryRun ) $ErrorActionPreference = "Stop" $Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path $Base = Join-Path $Root "qingjian" function Run([scriptblock]$Action, [string]$Label) { if ($DryRun) { Write-Host "[dry-run] $Label" } else { Write-Host "[run] $Label" & $Action } } function EnsureDir([string]$Path) { Run { New-Item -ItemType Directory -Force -Path $Path | Out-Null } "mkdir $Path" } function MoveIfExists([string]$Src, [string]$Dst) { if (-not (Test-Path $Src)) { return } # 应用可能已提前创建空的目标目录(StorageBootstrap):空目录先摘掉再移动 if ((Test-Path $Src -PathType Container) -and (Test-Path $Dst -PathType Container) -and -not (Get-ChildItem -LiteralPath $Dst -Force -ErrorAction SilentlyContinue)) { Run { Remove-Item -LiteralPath $Dst -Force } "rmdir $Dst" } if (Test-Path $Dst) { Write-Host "[skip] 目标已存在:$Dst(源 $Src 保留,请人工确认)" return } EnsureDir (Split-Path $Dst -Parent) Run { Move-Item -LiteralPath $Src -Destination $Dst } "move $Src -> $Dst" } # 1. 根目录大小写:Windows 大小写不敏感,先改成临时名再改成小写 $legacy = Join-Path $Root "QingJian" if ((Test-Path $legacy) -and -not (Test-Path $Base)) { Run { Rename-Item -LiteralPath $legacy -NewName "qingjian" } "rename QingJian -> qingjian" } elseif (Test-Path $legacy) { $tmp = Join-Path $Root ".qingjian-case-tmp" Run { Rename-Item -LiteralPath $legacy -NewName ".qingjian-case-tmp" } "rename QingJian -> .qingjian-case-tmp" Run { Rename-Item -LiteralPath $tmp -NewName "qingjian" } "rename .qingjian-case-tmp -> qingjian" } # 2. 目录骨架 EnsureDir (Join-Path $Base "system") EnsureDir (Join-Path $Base "system\db") EnsureDir (Join-Path $Base "system\rocksdb") EnsureDir (Join-Path $Base "system\libs") EnsureDir (Join-Path $Base "system\models") EnsureDir (Join-Path $Base "system\tools") EnsureDir (Join-Path $Base "system\extension") EnsureDir (Join-Path $Base "data\cases") EnsureDir (Join-Path $Base "data\users") EnsureDir (Join-Path $Base "data\tmp") EnsureDir (Join-Path $Base "data\index") # 3. 程序资产迁移 MoveIfExists (Join-Path $Base "conf") (Join-Path $Base "system\conf") MoveIfExists (Join-Path $Base "db\5w8mf4kf") (Join-Path $Base "system\db\5w8mf4kf") MoveIfExists (Join-Path $Base "db\plat") (Join-Path $Base "system\db\plat") MoveIfExists (Join-Path $Base "db\temp") (Join-Path $Base "system\db\temp") MoveIfExists (Join-Path $Base "license") (Join-Path $Base "system\license") MoveIfExists (Join-Path $Base "d5e03ad1") (Join-Path $Base "system\rocksdb\d5e03ad1") MoveIfExists (Join-Path $Base "uy76tkp8") (Join-Path $Base "system\rocksdb\uy76tkp8") MoveIfExists (Join-Path $Base "w6df89sk") (Join-Path $Base "system\libs\cell") MoveIfExists (Join-Path $Base "7Zip") (Join-Path $Base "system\libs\7zip") MoveIfExists (Join-Path $Base "extension") (Join-Path $Base "system\extension") MoveIfExists (Join-Path $Root "data\native") (Join-Path $Base "system\native") MoveIfExists (Join-Path $Root "bge-m3") (Join-Path $Base "system\models\bge-m3") MoveIfExists (Join-Path $Root "vosk-model") (Join-Path $Base "system\models\vosk-model") MoveIfExists (Join-Path $Root "tools\ffmpeg") (Join-Path $Base "system\tools\ffmpeg") Write-Host "" Write-Host "完成。当前布局:" Write-Host " system : $Base\system" Write-Host " data : $Base\data" Write-Host "历史目录(未处理):$Base\workspace、$Base\chat-attachments、$Base\agent、$Base\tmp、$Base\graph_his、$Root\.agentscope、$Root\data\files"