diff --git a/.gitignore b/.gitignore index 904350c..d5be867 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ !/.vscode/ !/.vscode/automatizadores/ !/.vscode/automatizadores/bootstrap-workspace.sh +!/.vscode/automatizadores/bootstrap-workspace.ps1 !/.vscode/automatizadores/sync_vitruvio_zip.sh !/.vscode/automatizadores/sync_vitruvio_zip.ps1 !/.vscode/vsix/ diff --git a/.vscode/automatizadores/bootstrap-workspace.ps1 b/.vscode/automatizadores/bootstrap-workspace.ps1 new file mode 100644 index 0000000..3b00a66 --- /dev/null +++ b/.vscode/automatizadores/bootstrap-workspace.ps1 @@ -0,0 +1,115 @@ +$ErrorActionPreference = 'Stop' + +param( + [string]$TargetDir, + [switch]$Force +) + +if ([string]::IsNullOrWhiteSpace($TargetDir)) { + Write-Host "Uso: .vscode/automatizadores/bootstrap-workspace.ps1 [-Force]" + exit 1 +} + +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$sourceDir = [System.IO.Path]::GetFullPath((Join-Path $scriptDir '..\..')) +$targetFullPath = [System.IO.Path]::GetFullPath($TargetDir) + +function Fail { + param([string]$Message) + + Write-Error $Message + exit 1 +} + +function Copy-Entry { + param([string]$RelativePath) + + $sourcePath = Join-Path $sourceDir $RelativePath + $targetPath = Join-Path $targetFullPath $RelativePath + + if (-not (Test-Path -LiteralPath $sourcePath)) { + Fail "Origem nao encontrada: $RelativePath" + } + + $parentDir = Split-Path -Parent $targetPath + New-Item -ItemType Directory -Path $parentDir -Force | Out-Null + + if (Test-Path -LiteralPath $targetPath) { + if (-not $Force.IsPresent) { + Fail "Destino ja existe: $RelativePath. Use -Force para sobrescrever." + } + + Remove-Item -LiteralPath $targetPath -Recurse -Force + } + + Copy-Item -LiteralPath $sourcePath -Destination $targetPath -Recurse -Force + Write-Host "Copiado: $RelativePath" +} + +function Write-PortableClaudeSettings { + $targetPath = Join-Path $targetFullPath '.claude\settings.local.json' + $targetDir = Split-Path -Parent $targetPath + + New-Item -ItemType Directory -Path $targetDir -Force | Out-Null + + if ((Test-Path -LiteralPath $targetPath) -and (-not $Force.IsPresent)) { + Fail 'Destino ja existe: .claude/settings.local.json. Use -Force para sobrescrever.' + } + + @' +{ + "permissions": { + "allow": [ + "mcp__oracle-davinti__run_query" + ] + }, + "enableAllProjectMcpServers": true, + "enabledMcpjsonServers": [ + "oracle-davinti" + ] +} +'@ | Set-Content -LiteralPath $targetPath -Encoding UTF8 + + Write-Host 'Gerado: .claude/settings.local.json' +} + +function Cleanup-VscodeMcpDir { + $mcpDir = Join-Path $targetFullPath '.vscode\mcp-oracle-davinti' + $nodeModulesDir = Join-Path $mcpDir 'node_modules' + $envFile = Join-Path $mcpDir '.env' + + if (Test-Path -LiteralPath $nodeModulesDir) { + Remove-Item -LiteralPath $nodeModulesDir -Recurse -Force + } + + if (Test-Path -LiteralPath $envFile) { + Remove-Item -LiteralPath $envFile -Force + } +} + +function Create-BaseDirectories { + New-Item -ItemType Directory -Path (Join-Path $targetFullPath 'Andamento') -Force | Out-Null + New-Item -ItemType Directory -Path (Join-Path $targetFullPath 'Concluidos') -Force | Out-Null + New-Item -ItemType Directory -Path (Join-Path $targetFullPath 'Vitruvio\Documentação') -Force | Out-Null + New-Item -ItemType Directory -Path (Join-Path $targetFullPath 'Vitruvio\Documentação\Componentes') -Force | Out-Null + + Write-Host 'Criadas pastas base do workspace' +} + +New-Item -ItemType Directory -Path $targetFullPath -Force | Out-Null + +if ($targetFullPath -eq $sourceDir) { + Fail 'O destino deve ser diferente da pasta do template.' +} + +Copy-Entry '.claude\agents' +Write-PortableClaudeSettings +Copy-Entry '.vscode' +Cleanup-VscodeMcpDir +Copy-Entry '.github' +Copy-Entry 'CLAUDE.md' +Copy-Entry '.mcp.json' +Create-BaseDirectories + +Write-Host "Workspace base criado em: $targetFullPath" +Write-Host 'Proximo passo: copie .vscode/mcp-oracle-davinti/.env.example para .env e ajuste as credenciais locais.' \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f0914bc..3d8e59a 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -34,6 +34,18 @@ "${workspaceFolder}/.vscode/automatizadores/bootstrap-workspace.sh", "${input:bootstrapWorkspaceTarget}" ], + "windows": { + "command": "powershell", + "args": [ + "-NoLogo", + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}\\.vscode\\automatizadores\\bootstrap-workspace.ps1", + "${input:bootstrapWorkspaceTarget}" + ] + }, "group": "build", "problemMatcher": [] }, @@ -46,6 +58,19 @@ "${input:bootstrapWorkspaceTarget}", "--force" ], + "windows": { + "command": "powershell", + "args": [ + "-NoLogo", + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}\\.vscode\\automatizadores\\bootstrap-workspace.ps1", + "${input:bootstrapWorkspaceTarget}", + "-Force" + ] + }, "group": "build", "problemMatcher": [] } diff --git a/GUIA_SETUP_OUTRA_MAQUINA.md b/GUIA_SETUP_OUTRA_MAQUINA.md index 9aea438..cb70b9d 100644 --- a/GUIA_SETUP_OUTRA_MAQUINA.md +++ b/GUIA_SETUP_OUTRA_MAQUINA.md @@ -12,6 +12,9 @@ bash bootstrap-workspace.sh /caminho/do/novo-workspace Se preferir rodar pelo VS Code, execute a task `Workspace: Bootstrap Base`. +- No Linux, a task usa `.vscode/automatizadores/bootstrap-workspace.sh`. +- No Windows, a task usa `.vscode/automatizadores/bootstrap-workspace.ps1`. + Esse comando leva para o destino: - .claude/agents - .claude/settings.local.json em versao portavel, sem caminhos absolutos da maquina atual