74 lines
2.7 KiB
PowerShell
74 lines
2.7 KiB
PowerShell
param(
|
|
[string]$Phase14Root = "",
|
|
[string]$RemainingReportPath = "",
|
|
[string]$OutputDir = "",
|
|
[string]$ArtifactRoot = "",
|
|
[string[]]$SourceId = @("LAW-COMPANY-2023"),
|
|
[int]$ChunkSize = 40,
|
|
[int]$StartBatchNumber = 0,
|
|
[int]$MaxBatches = 0
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
|
if (-not (Test-Path "$HOME\.Codex\skills\gstack\bin")) {
|
|
throw "GSTACK_MISSING: gstack is required for AI-assisted work in this repo."
|
|
}
|
|
|
|
if ([string]::IsNullOrWhiteSpace($Phase14Root)) {
|
|
$Phase14Root = Join-Path $repoRoot "project-docs\phase14-legal-fulltext-library"
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($RemainingReportPath)) {
|
|
$remainingRoot = Join-Path $repoRoot "project-docs\qa-artifacts\phase14-remaining-articles"
|
|
$latest = Get-ChildItem $remainingRoot -Directory |
|
|
Where-Object { Test-Path (Join-Path $_.FullName "phase14-remaining-articles.json") } |
|
|
Sort-Object Name -Descending |
|
|
Select-Object -First 1
|
|
if ($null -eq $latest) {
|
|
throw "No phase14-remaining-articles.json artifact found under $remainingRoot"
|
|
}
|
|
$RemainingReportPath = Join-Path $latest.FullName "phase14-remaining-articles.json"
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($OutputDir)) {
|
|
$OutputDir = Join-Path $Phase14Root "incremental-batches"
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($ArtifactRoot)) {
|
|
$ArtifactRoot = Join-Path $repoRoot "project-docs\qa-artifacts\phase14-remaining-article-batch-plan"
|
|
}
|
|
|
|
$timestamp = Get-Date -Format "yyyy-MM-ddTHH-mm-ss-fff"
|
|
$artifactDir = Join-Path $ArtifactRoot $timestamp
|
|
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
|
New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
|
|
|
|
$toolPath = Join-Path $repoRoot "backend\tools\plan_phase14_remaining_article_batches.py"
|
|
$toolArgs = @(
|
|
"--phase14-root", $Phase14Root,
|
|
"--remaining-report", $RemainingReportPath,
|
|
"--output-dir", $OutputDir,
|
|
"--artifact-dir", $artifactDir,
|
|
"--chunk-size", $ChunkSize
|
|
)
|
|
foreach ($id in $SourceId) {
|
|
if (-not [string]::IsNullOrWhiteSpace($id)) {
|
|
$toolArgs += @("--source-id", $id)
|
|
}
|
|
}
|
|
if ($StartBatchNumber -gt 0) {
|
|
$toolArgs += @("--start-batch-number", $StartBatchNumber)
|
|
}
|
|
if ($MaxBatches -gt 0) {
|
|
$toolArgs += @("--max-batches", $MaxBatches)
|
|
}
|
|
|
|
$toolOutput = & python $toolPath @toolArgs
|
|
$toolExitCode = if ($LASTEXITCODE -is [int]) { $LASTEXITCODE } else { 0 }
|
|
($toolOutput -join [Environment]::NewLine) | Set-Content -Encoding UTF8 -Path (Join-Path $artifactDir "phase14-remaining-article-batch-plan-tool.log")
|
|
if ($toolExitCode -ne 0) {
|
|
throw "plan_phase14_remaining_article_batches.py failed with exit code $toolExitCode."
|
|
}
|
|
|
|
Write-Host "PHASE14_REMAINING_ARTICLE_BATCH_PLAN_PASS $artifactDir"
|
|
Write-Output ($toolOutput -join [Environment]::NewLine)
|