diff --git a/conductor/tracks/consolidate_cruft_and_log_taxonomy_20260228/plan.md b/conductor/tracks/consolidate_cruft_and_log_taxonomy_20260228/plan.md index 1af7fbd..a36ef06 100644 --- a/conductor/tracks/consolidate_cruft_and_log_taxonomy_20260228/plan.md +++ b/conductor/tracks/consolidate_cruft_and_log_taxonomy_20260228/plan.md @@ -13,7 +13,7 @@ - [x] Task: Conductor - User Manual Verification 'Phase 2: App Logic Redirection' (Protocol in workflow.md) (6326546) ## Phase 3: Migration Script -- [ ] Task: Create `scripts/migrate_cruft.ps1` to identify and move existing files (e.g., `temp_*.toml`, `*.log`) from the root to their new locations. +- [~] Task: Create `scripts/migrate_cruft.ps1` to identify and move existing files (e.g., `temp_*.toml`, `*.log`) from the root to their new locations. - [ ] Task: Test the migration script on a few dummy files. - [ ] Task: Execute the migration script and verify the project root is clean. - [ ] Task: Conductor - User Manual Verification 'Phase 3: Migration Script' (Protocol in workflow.md) diff --git a/scripts/migrate_cruft.ps1 b/scripts/migrate_cruft.ps1 new file mode 100644 index 0000000..d9a4259 --- /dev/null +++ b/scripts/migrate_cruft.ps1 @@ -0,0 +1,60 @@ +$projectRoot = Resolve-Path (Join-Path $PSScriptRoot "..") +$logsDir = Join-Path $projectRoot "logs" +$sessionsDir = Join-Path $logsDir "sessions" +$agentsDir = Join-Path $logsDir "agents" +$errorsDir = Join-Path $logsDir "errors" +$testsDir = Join-Path $projectRoot "tests" +$artifactsDir = Join-Path $testsDir "artifacts" + +# Ensure target directories exist +New-Item -ItemType Directory -Force -Path $sessionsDir | Out-Null +New-Item -ItemType Directory -Force -Path $agentsDir | Out-Null +New-Item -ItemType Directory -Force -Path $errorsDir | Out-Null +New-Item -ItemType Directory -Force -Path $artifactsDir | Out-Null + +Write-Host "Migrating logs and temporary files to new taxonomy..." + +# 1. Move temp files +Get-ChildItem -Path $projectRoot -Filter "temp_*" -File | ForEach-Object { + Write-Host "Moving $($_.Name) to tests/artifacts/" + Move-Item -Path $_.FullName -Destination $artifactsDir -Force +} +if (Test-Path $testsDir) { + Get-ChildItem -Path $testsDir -Filter "temp_*" -File | ForEach-Object { + Write-Host "Moving $($_.Name) to tests/artifacts/" + Move-Item -Path $_.FullName -Destination $artifactsDir -Force + } +} + +# 2. Move MMA logs to logs/agents/ +Get-ChildItem -Path $logsDir -Filter "mma_*.log" -File | ForEach-Object { + Write-Host "Moving $($_.Name) to logs/agents/" + Move-Item -Path $_.FullName -Destination $agentsDir -Force +} + +# 3. Move error/test logs to logs/errors/ +Get-ChildItem -Path $logsDir -Filter "*.log" -File | Where-Object { $_.Name -like "*test*" -or $_.Name -like "gui_*.log" } | ForEach-Object { + Write-Host "Moving $($_.Name) to logs/errors/" + Move-Item -Path $_.FullName -Destination $errorsDir -Force +} + +# 4. Move log_registry.toml to logs/sessions/ +if (Test-Path (Join-Path $logsDir "log_registry.toml")) { + Write-Host "Moving log_registry.toml to logs/sessions/" + Move-Item -Path (Join-Path $logsDir "log_registry.toml") -Destination $sessionsDir -Force +} + +# 5. Move session directories to logs/sessions/ +# Pattern: Starts with 202 (year) +Get-ChildItem -Path $logsDir -Directory | Where-Object { $_.Name -match "^202\d" } | ForEach-Object { + Write-Host "Moving session directory $($_.Name) to logs/sessions/" + Move-Item -Path $_.FullName -Destination $sessionsDir -Force +} + +# 6. Move remaining .log files to logs/sessions/ +Get-ChildItem -Path $logsDir -Filter "*.log" -File | ForEach-Object { + Write-Host "Moving session log $($_.Name) to logs/sessions/" + Move-Item -Path $_.FullName -Destination $sessionsDir -Force +} + +Write-Host "Migration complete."