feat(migration): Add script to consolidate legacy logs and artifacts

This commit is contained in:
2026-03-01 09:06:07 -05:00
parent 32f7a13fa8
commit 61d513ad08
2 changed files with 61 additions and 1 deletions

View File

@@ -13,7 +13,7 @@
- [x] Task: Conductor - User Manual Verification 'Phase 2: App Logic Redirection' (Protocol in workflow.md) (6326546) - [x] Task: Conductor - User Manual Verification 'Phase 2: App Logic Redirection' (Protocol in workflow.md) (6326546)
## Phase 3: Migration Script ## 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: Test the migration script on a few dummy files.
- [ ] Task: Execute the migration script and verify the project root is clean. - [ ] 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) - [ ] Task: Conductor - User Manual Verification 'Phase 3: Migration Script' (Protocol in workflow.md)

60
scripts/migrate_cruft.ps1 Normal file
View File

@@ -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."