355 lines
17 KiB
PowerShell
355 lines
17 KiB
PowerShell
# BurningTimes 조직 레포 - Windows PC 셋업
|
|
# 사용: PowerShell에서 실행
|
|
# .\setup_windows.ps1 ← 기본 셋업만
|
|
# .\setup_windows.ps1 -CreateShortcuts ← 기본 셋업 + 바탕화면 바로가기 3종 생성 (주의 아래)
|
|
# .\setup_windows.ps1 -BurningTimesRoot "C:\..." ← 레포 경로 지정
|
|
# .\setup_windows.ps1 -CreateShortcuts -ClaudeExePath "C:\Tools\claude\claude.exe"
|
|
# ← claude.exe 자동 탐지 실패 시 경로 수동 지정
|
|
#
|
|
# ⚠️ 바로가기 관련 주의 (2026-04-15 실증)
|
|
# Windows Store(MSIX) 버전 Claude 앱은 single-instance + WorkingDirectory 무시 특성이 있어
|
|
# 바로가기로 부서 세션을 분리할 수 없다. MSIX 앱 사용자는 앱 실행 후 **입력창 위 "폴더 칩"**
|
|
# 을 클릭해 부서 폴더를 선택하는 것이 정답이다. 바로가기 옵션은 non-MSIX 환경(CLI 등)에서만
|
|
# 유의미하므로 필요한 사람만 -CreateShortcuts 로 명시 선택할 것.
|
|
# 상세: memory/org/feedback_permissions_portability.md
|
|
|
|
param(
|
|
[string]$BurningTimesRoot = $(Resolve-Path (Join-Path $PSScriptRoot "..")).Path,
|
|
[string]$UnityRoot = "",
|
|
[string]$FrameworkRoot = "",
|
|
[string]$GiteaUrl = "https://burning.i234.me",
|
|
[string]$GiteaSsh = "ssh://git@burning.i234.me:30030",
|
|
[switch]$CreateShortcuts,
|
|
[string]$ClaudeExePath = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# 경로 추정: BurningTimesRoot 드라이브 기반 동적 default (PC별 하드코딩 회피)
|
|
# 사용자가 -UnityRoot/-FrameworkRoot 명시하면 그 값 우선, 미명시면 BurningTimesRoot 드라이브의 \BurningTimes\* 패턴으로 추정
|
|
$rootDriveLetter = (Split-Path $BurningTimesRoot -Qualifier).TrimEnd(':')
|
|
if (-not $UnityRoot) { $UnityRoot = "${rootDriveLetter}:\BurningTimes\FilGoodBandits\DeckBuilding" }
|
|
if (-not $FrameworkRoot) { $FrameworkRoot = "${rootDriveLetter}:\BurningTimes\BurningTimes.Framework" }
|
|
|
|
Write-Host "=== BurningTimes 조직 레포 셋업 ==="
|
|
Write-Host "BurningTimesRoot: $BurningTimesRoot"
|
|
Write-Host "UnityRoot: $UnityRoot $(if (-not (Test-Path $UnityRoot)) { '(경로 미존재 - paths.local.json 생성 후 수동 수정 권장)' })"
|
|
Write-Host "FrameworkRoot: $FrameworkRoot $(if (-not (Test-Path $FrameworkRoot)) { '(경로 미존재 - paths.local.json 생성 후 수동 수정 권장)' })"
|
|
|
|
# 1. Git 확인
|
|
git --version | Out-Null
|
|
if (-not $?) { throw "Git이 설치되지 않았습니다." }
|
|
|
|
# 2. paths.local.json 생성
|
|
$pathsFile = Join-Path $BurningTimesRoot "paths.local.json"
|
|
if (-not (Test-Path $pathsFile)) {
|
|
$paths = [ordered]@{
|
|
"_description" = "로컬 환경 경로. 커밋 금지."
|
|
BURNINGTIMES_ROOT = $BurningTimesRoot
|
|
UNITY_PROJECT_ROOT = $UnityRoot
|
|
FRAMEWORK_PKG_ROOT = $FrameworkRoot
|
|
TABLE_EXPORT_ROOT = (Join-Path $UnityRoot "Assets\ResWork\Table\Export")
|
|
GITEA_URL = $GiteaUrl
|
|
GITEA_SSH = $GiteaSsh
|
|
HOSTNAME = $env:COMPUTERNAME
|
|
}
|
|
# UTF-8 BOM 없음으로 명시 출력 (PowerShell 5.1의 기본 -Encoding utf8은 BOM 포함 + 한국어 깨짐 이슈 회피)
|
|
$jsonText = $paths | ConvertTo-Json -Depth 5
|
|
[System.IO.File]::WriteAllText($pathsFile, $jsonText, [System.Text.UTF8Encoding]::new($false))
|
|
Write-Host "paths.local.json 작성 완료 (UTF-8 no BOM): $pathsFile"
|
|
} else {
|
|
Write-Host "paths.local.json 이미 존재. 유지."
|
|
}
|
|
|
|
# 3. Claude 사용자 메모리 연결 (junction)
|
|
$claudeMemoryBase = "$env:USERPROFILE\.claude\projects"
|
|
$orgMemoryTarget = Join-Path $BurningTimesRoot "memory\org"
|
|
|
|
if (-not (Test-Path $orgMemoryTarget)) {
|
|
New-Item -ItemType Directory -Path $orgMemoryTarget | Out-Null
|
|
}
|
|
|
|
$hashDirs = @()
|
|
if (Test-Path $claudeMemoryBase) {
|
|
# Claude Code는 프로젝트 경로의 각 세그먼트를 '-'로 이어 해시 폴더명을 만든다
|
|
# (예: E:\BurningTimesAi → E--BurningTimesAi, C:\Users\PC\Documents\BurningTimes → C--Users-PC-Documents-BurningTimes)
|
|
# BurningTimesRoot의 리프 이름·드라이브 prefix·관례적 키워드를 모두 포괄하도록 필터 확장
|
|
$rootLeaf = Split-Path $BurningTimesRoot -Leaf
|
|
$rootDrive = (Split-Path $BurningTimesRoot -Qualifier).TrimEnd(':')
|
|
$hashDirs = Get-ChildItem $claudeMemoryBase -Directory -ErrorAction SilentlyContinue |
|
|
Where-Object {
|
|
$_.Name -like "*Documents*" -or
|
|
$_.Name -like "*BurningTimes*" -or
|
|
$_.Name -like "*BurningTimes*" -or
|
|
$_.Name -like "*$rootLeaf*" -or
|
|
$_.Name -like "$rootDrive--*"
|
|
}
|
|
}
|
|
|
|
foreach ($d in $hashDirs) {
|
|
$memLink = Join-Path $d.FullName "memory"
|
|
if (Test-Path $memLink) {
|
|
$attr = (Get-Item $memLink -Force).Attributes
|
|
if (($attr -band [IO.FileAttributes]::ReparsePoint) -eq 0) {
|
|
# 실체 폴더. 백업 후 junction으로 교체
|
|
$bak = "$memLink.bak_$(Get-Date -Format yyyyMMdd_HHmm)"
|
|
Rename-Item $memLink $bak
|
|
Write-Host "기존 memory 폴더 백업: $bak"
|
|
cmd /c mklink /J "`"$memLink`"" "`"$orgMemoryTarget`"" | Out-Null
|
|
Write-Host "Junction 생성: $memLink -> $orgMemoryTarget"
|
|
} else {
|
|
Write-Host "이미 junction/symlink. 유지: $memLink"
|
|
}
|
|
} else {
|
|
cmd /c mklink /J "`"$memLink`"" "`"$orgMemoryTarget`"" | Out-Null
|
|
Write-Host "Junction 생성: $memLink -> $orgMemoryTarget"
|
|
}
|
|
}
|
|
|
|
if ($hashDirs.Count -eq 0) {
|
|
Write-Warning "Claude 프로젝트 해시 폴더를 찾지 못했습니다. 수동 연결 필요."
|
|
}
|
|
|
|
# 3.5. Live 증분 동기화 중앙 저장소 + Junction (C34, 2026-04-18 PD님 직접 지시)
|
|
# worktree 격리로 인한 .live/ 물리 분리 문제를 해결하기 위해
|
|
# $HOME\.claude\burningtimes-live\ 중앙 디렉토리로 junction 연결한다.
|
|
# 헌법 제1원칙 ⑤ 세션·PC 연속성의 근원 보장 장치.
|
|
$centralLive = Join-Path $env:USERPROFILE ".claude\burningtimes-live"
|
|
$localLive = Join-Path $BurningTimesRoot ".live"
|
|
$markerName = ".junction-marker"
|
|
$markerText = "burningtimes-live central junction target (C34, 2026-04-18)"
|
|
|
|
if (-not (Test-Path $centralLive)) {
|
|
New-Item -ItemType Directory -Path $centralLive -Force | Out-Null
|
|
Write-Host "Live 중앙 저장소 생성: $centralLive"
|
|
}
|
|
|
|
$centralMarker = Join-Path $centralLive $markerName
|
|
if (-not (Test-Path $centralMarker)) {
|
|
[System.IO.File]::WriteAllText($centralMarker, $markerText, [System.Text.UTF8Encoding]::new($false))
|
|
}
|
|
|
|
if (Test-Path $localLive) {
|
|
$liveItem = Get-Item $localLive -Force
|
|
$isReparse = ($liveItem.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0
|
|
if (-not $isReparse) {
|
|
# 실체 디렉토리 — 백업 후 junction 전환 (C6-1 원본 보호)
|
|
$bak = "$localLive.bak_$(Get-Date -Format yyyyMMdd_HHmm)"
|
|
# 기존 파일 중앙으로 복사 (기존 중앙 파일 덮어쓰기 안 함)
|
|
Get-ChildItem $localLive -File -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$dst = Join-Path $centralLive $_.Name
|
|
if (-not (Test-Path $dst)) { Copy-Item $_.FullName $dst -Force }
|
|
}
|
|
Rename-Item $localLive $bak
|
|
Write-Host "기존 .live/ 백업: $bak"
|
|
New-Item -ItemType Junction -Path $localLive -Target $centralLive -Force | Out-Null
|
|
Write-Host "Live Junction 생성: $localLive -> $centralLive"
|
|
} else {
|
|
Write-Host "Live Junction 이미 존재. 유지: $localLive"
|
|
}
|
|
} else {
|
|
New-Item -ItemType Junction -Path $localLive -Target $centralLive -Force | Out-Null
|
|
Write-Host "Live Junction 생성: $localLive -> $centralLive"
|
|
}
|
|
|
|
# 3.6. memory/org/ 중앙 저장소 + Junction (C34-16, 2026-04-19 신설)
|
|
# Claude user memory junction 대상을 $HOME\.claude\burningtimes-memory\로 변경.
|
|
# 레포 `memory/org/`는 git 추적 SOT로 실체 디렉토리 유지 + sync 스크립트가 양방향 동기화.
|
|
$centralMemory = Join-Path $env:USERPROFILE ".claude\burningtimes-memory"
|
|
$memoryMarkerName = ".memory-junction-marker"
|
|
$memoryMarkerText = "burningtimes-memory central (C34-16, 2026-04-19)"
|
|
|
|
if (-not (Test-Path $centralMemory)) {
|
|
New-Item -ItemType Directory -Path $centralMemory -Force | Out-Null
|
|
Write-Host "memory 중앙 저장소 생성: $centralMemory"
|
|
}
|
|
|
|
$centralMemoryMarker = Join-Path $centralMemory $memoryMarkerName
|
|
if (-not (Test-Path $centralMemoryMarker)) {
|
|
[System.IO.File]::WriteAllText($centralMemoryMarker, $memoryMarkerText, [System.Text.UTF8Encoding]::new($false))
|
|
}
|
|
|
|
# 초기 sync — 레포 memory/org → 중앙 (기존 중앙 파일 덮어쓰기 안 함)
|
|
$repoMemoryOrg = Join-Path $BurningTimesRoot "memory\org"
|
|
if (Test-Path $repoMemoryOrg) {
|
|
Get-ChildItem $repoMemoryOrg -File -ErrorAction SilentlyContinue | Where-Object { $_.Extension -in @('.md','.json') } | ForEach-Object {
|
|
$dst = Join-Path $centralMemory $_.Name
|
|
if (-not (Test-Path $dst)) { Copy-Item $_.FullName $dst -Force }
|
|
}
|
|
Write-Host "memory 초기 sync 레포 → 중앙 완료"
|
|
}
|
|
|
|
# 모든 E--BurningTimesAi* 해시 폴더 순회하여 junction 중앙으로 재연결 (광범위 filter)
|
|
$allHashDirs = Get-ChildItem $claudeMemoryBase -Directory -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.Name -like "E--BurningTimesAi*" -or $_.Name -like "*BurningTimesAi*" }
|
|
|
|
foreach ($d in $allHashDirs) {
|
|
$memLink = Join-Path $d.FullName "memory"
|
|
$markerPath = Join-Path $memLink $memoryMarkerName
|
|
|
|
# 이미 중앙으로 연결된 경우 skip (sentinel 경유)
|
|
if (Test-Path $markerPath) { continue }
|
|
|
|
if (Test-Path $memLink) {
|
|
$item = Get-Item $memLink -Force
|
|
$isReparse = ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0
|
|
if (-not $isReparse) {
|
|
# 실체 디렉토리 — 내용 중앙으로 흡수 후 백업
|
|
Get-ChildItem $memLink -File -ErrorAction SilentlyContinue | Where-Object { $_.Extension -in @('.md','.json') } | ForEach-Object {
|
|
$dst = Join-Path $centralMemory $_.Name
|
|
if (-not (Test-Path $dst)) { Copy-Item $_.FullName $dst -Force }
|
|
}
|
|
Rename-Item $memLink "$memLink.bak_$(Get-Date -Format yyyyMMdd_HHmm)"
|
|
} else {
|
|
Remove-Item $memLink -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
try {
|
|
New-Item -ItemType Junction -Path $memLink -Target $centralMemory -Force | Out-Null
|
|
Write-Host "memory Junction 중앙 연결: $memLink -> $centralMemory"
|
|
} catch {
|
|
Write-Warning "memory Junction 생성 실패: $memLink"
|
|
}
|
|
}
|
|
|
|
# 3.7. Unity MCP 외부 저장소 자동 clone (A안, 2026-04-21 PD님 직접 승인)
|
|
# - CoplayDev/unity-mcp 외부 저장소를 BT 레포 내부에 clone
|
|
# - BT 레포 `.gitignore`로 추적 제외 (외부 저장소 분리 유지)
|
|
# - 업데이트는 `cd 코어코드/unity-mcp && git pull` 수동
|
|
Write-Host "=== Unity MCP 외부 저장소 셋업 ==="
|
|
$unityMcpPath = Join-Path $BurningTimesRoot "코어코드\unity-mcp"
|
|
if (-not (Test-Path $unityMcpPath)) {
|
|
$parent = Split-Path $unityMcpPath -Parent
|
|
if (-not (Test-Path $parent)) {
|
|
New-Item -ItemType Directory -Path $parent -Force | Out-Null
|
|
}
|
|
Write-Host "[setup] unity-mcp clone 시작..."
|
|
git clone https://github.com/CoplayDev/unity-mcp.git $unityMcpPath
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "✅ unity-mcp clone 완료: $unityMcpPath"
|
|
} else {
|
|
Write-Warning "unity-mcp clone 실패 — 네트워크·권한 확인 후 수동 실행 필요: git clone https://github.com/CoplayDev/unity-mcp.git `"$unityMcpPath`""
|
|
}
|
|
} else {
|
|
Write-Host "[setup] unity-mcp 이미 존재: $unityMcpPath"
|
|
Write-Host " (업데이트는 수동: cd '$unityMcpPath'; git pull)"
|
|
}
|
|
|
|
# 4. .claude/settings.json 부서 동기화 (루트 SOT → 개발팀/기획팀 복제)
|
|
# Claude Code는 .claude/ 계층 auto-merge를 지원하지 않으므로 자식 디렉토리에서 세션 시작 시
|
|
# 루트 settings.json을 인식하지 못함. 이를 우회하기 위해 루트 settings.json을 부서 디렉토리로 복제.
|
|
$rootSettings = Join-Path $BurningTimesRoot ".claude\settings.json"
|
|
if (Test-Path $rootSettings) {
|
|
$deptPaths = @("개발팀", "기획팀")
|
|
foreach ($dept in $deptPaths) {
|
|
$deptClaudeDir = Join-Path $BurningTimesRoot "$dept\.claude"
|
|
$deptSettings = Join-Path $deptClaudeDir "settings.json"
|
|
if (-not (Test-Path $deptClaudeDir)) {
|
|
New-Item -ItemType Directory -Path $deptClaudeDir -Force | Out-Null
|
|
}
|
|
Copy-Item -Path $rootSettings -Destination $deptSettings -Force
|
|
Write-Host "settings.json 동기화: $dept/.claude/settings.json"
|
|
}
|
|
} else {
|
|
Write-Warning "루트 .claude/settings.json 미발견. 부서 동기화 생략."
|
|
}
|
|
|
|
# 5. (선택) 부서별 바탕화면 바로가기 3종 생성
|
|
# Claude Code 앱의 "New Session"은 현재 열린 프로젝트 컨텍스트 내에서 새 대화를 만드는 동작이라
|
|
# 루트에서 앱이 시작되면 부서 폴더 진입이 어려움. 각 부서 폴더를 WorkingDirectory로 지정한 바로가기로 우회.
|
|
if ($CreateShortcuts) {
|
|
Write-Host ""
|
|
Write-Host "=== 부서별 바탕화면 바로가기 생성 ==="
|
|
|
|
# 1) MSIX/Store 패키지 우선 탐지 (PD님 환경 표준)
|
|
$msixPkg = $null
|
|
try { $msixPkg = Get-AppxPackage -Name '*Claude*' -ErrorAction SilentlyContinue | Select-Object -First 1 } catch {}
|
|
|
|
$msixLaunchArg = $null
|
|
if ($msixPkg) {
|
|
# AppxManifest에서 AppId 추출
|
|
$manifestPath = Join-Path $msixPkg.InstallLocation 'AppxManifest.xml'
|
|
$appId = 'App'
|
|
if (Test-Path $manifestPath) {
|
|
try {
|
|
[xml]$m = Get-Content $manifestPath
|
|
$appIdNode = $m.Package.Applications.Application | Select-Object -First 1
|
|
if ($appIdNode -and $appIdNode.Id) { $appId = $appIdNode.Id }
|
|
} catch {}
|
|
}
|
|
$msixLaunchArg = "shell:AppsFolder\$($msixPkg.PackageFamilyName)!$appId"
|
|
Write-Host "Claude MSIX 패키지 탐지: $($msixPkg.PackageFamilyName) / AppId=$appId"
|
|
}
|
|
|
|
# 2) MSIX 미탐지 시 일반 claude.exe 탐색 (fallback)
|
|
if (-not $msixLaunchArg -and -not $ClaudeExePath) {
|
|
$candidatePaths = @(
|
|
"$env:LOCALAPPDATA\Programs\claude\claude.exe",
|
|
"$env:LOCALAPPDATA\AnthropicClaude\claude.exe",
|
|
"$env:LOCALAPPDATA\claude\claude.exe",
|
|
"$env:ProgramFiles\claude\claude.exe",
|
|
"${env:ProgramFiles(x86)}\claude\claude.exe",
|
|
"$env:LOCALAPPDATA\Programs\Claude\Claude.exe"
|
|
)
|
|
foreach ($cp in $candidatePaths) {
|
|
if (Test-Path $cp) { $ClaudeExePath = $cp; Write-Host "claude.exe 자동 탐지: $ClaudeExePath"; break }
|
|
}
|
|
if (-not $ClaudeExePath) {
|
|
$where = (Get-Command claude.exe -ErrorAction SilentlyContinue).Source
|
|
if ($where) { $ClaudeExePath = $where; Write-Host "claude.exe PATH에서 탐지: $ClaudeExePath" }
|
|
}
|
|
}
|
|
|
|
if (-not $msixLaunchArg -and (-not $ClaudeExePath -or -not (Test-Path $ClaudeExePath))) {
|
|
Write-Warning "Claude 실행 수단 탐지 실패 (MSIX·exe 모두). 바로가기 생성 생략."
|
|
Write-Warning "수동 지정: .\setup_windows.ps1 -CreateShortcuts -ClaudeExePath '<실제 경로>'"
|
|
} else {
|
|
$WshShell = New-Object -ComObject WScript.Shell
|
|
$desktop = [Environment]::GetFolderPath("Desktop")
|
|
|
|
$targets = @(
|
|
@{ Name = "BurningTimes_총괄PM"; Dir = $BurningTimesRoot; Desc = "BurningTimes 총괄PM 세션 (루트)" },
|
|
@{ Name = "BurningTimes_개발팀"; Dir = (Join-Path $BurningTimesRoot "개발팀"); Desc = "BurningTimes 개발팀 세션" },
|
|
@{ Name = "BurningTimes_기획팀"; Dir = (Join-Path $BurningTimesRoot "기획팀"); Desc = "BurningTimes 기획팀 세션" }
|
|
)
|
|
|
|
foreach ($t in $targets) {
|
|
if (-not (Test-Path $t.Dir)) {
|
|
Write-Warning "대상 디렉토리 없음. 건너뜀: $($t.Dir)"
|
|
continue
|
|
}
|
|
$shortcutPath = Join-Path $desktop "$($t.Name).lnk"
|
|
$sc = $WshShell.CreateShortcut($shortcutPath)
|
|
if ($msixLaunchArg) {
|
|
# MSIX 앱: explorer.exe shell:AppsFolder\... 방식
|
|
$sc.TargetPath = "explorer.exe"
|
|
$sc.Arguments = $msixLaunchArg
|
|
} else {
|
|
# 일반 exe 방식
|
|
$sc.TargetPath = $ClaudeExePath
|
|
$sc.IconLocation = "$ClaudeExePath,0"
|
|
}
|
|
$sc.WorkingDirectory = $t.Dir
|
|
$sc.Description = $t.Desc
|
|
$sc.Save()
|
|
Write-Host "바로가기 생성: $shortcutPath (WD=$($t.Dir))"
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($msixLaunchArg) {
|
|
Write-Host "바로가기 3종 생성 완료 (MSIX 모드)."
|
|
Write-Host "※ MSIX 앱은 WorkingDirectory가 전달되지 않을 수 있음. 바로가기 더블클릭 후 실제 프로젝트 경로 확인 필수."
|
|
} else {
|
|
Write-Host "바로가기 3종 생성 완료."
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "셋업 완료. 'git pull'로 최신 상태 유지 권장."
|
|
Write-Host "※ .claude/settings.json 변경사항은 세션 재시작 후 적용됨."
|
|
if (-not $CreateShortcuts) {
|
|
Write-Host "※ 부서별 바탕화면 바로가기 필요 시: .\setup_windows.ps1 -CreateShortcuts"
|
|
}
|