Loading...
Loading...
Used when the current Spec Pack needs to be discarded/revoked due to major requirement issues, and the corresponding `.aisdlc/specs/{branch}` directory as well as local and remote branches must be deleted. Meanwhile, you need to output the deletion list and ask the user for double confirmation before performing the deletion.
npx skill4agent add zixun-github/aisdlc spec-pack-abandonspec-context{FEATURE_DIR}.aisdlc/specs/{CURRENT_BRANCH}/{CURRENT_BRANCH}{num}-{short-name}spec-contextFEATURE_DIR=...(reuse)CURRENT_BRANCHFEATURE_DIRGet-SpecContextgit clean -fdThis section is only used for generating list and risk prompts, no deletion is performed.
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host ("FEATURE_DIR={0}" -f $FEATURE_DIR)
Write-Host ("CURRENT_BRANCH={0}" -f $context.CURRENT_BRANCH)
$repoRoot = $context.REPO_ROOT
$branch = $context.CURRENT_BRANCH
$featureDir = $context.FEATURE_DIR
$demoDir = Join-Path $repoRoot ("demo\prototypes\{0}" -f $branch)
$hasRemote = $false
git ls-remote --exit-code --heads origin $branch *> $null
if ($LASTEXITCODE -eq 0) { $hasRemote = $true }
$dirty = git status --porcelain
$aheadBehind = git rev-list --left-right --count ("origin/{0}...{0}" -f $branch) 2>$null
Write-Host "=== Deletion List (Pending Confirmation) ==="
Write-Host ("REPO_ROOT: {0}" -f $repoRoot)
Write-Host ("CURRENT_BRANCH (to be deleted): {0}" -f $branch)
Write-Host ("FEATURE_DIR (to be deleted/cleaned): {0}" -f $featureDir)
Write-Host ("demo/prototypes (to be deleted/cleaned if exists): {0}" -f $demoDir)
Write-Host ("Whether remote branch origin/{0} exists: {1}" -f $branch, $hasRemote)
Write-Host ""
Write-Host "=== Workspace Risk Prompt ==="
if ($dirty) {
Write-Host "Uncommitted changes detected (will be lost when the branch is deleted). git status --porcelain:"
$dirty | ForEach-Object { Write-Host (" {0}" -f $_) }
} else {
Write-Host "No uncommitted changes detected."
}
if ($aheadBehind) {
Write-Host ("Ahead/behind count with origin/{0} (may be empty/error if the branch is not pushed): {1}" -f $branch, $aheadBehind)
}确认删除清单This section still does not perform deletion; only lists the "commands to be executed" in full as the object of the second confirmation.
. (Join-Path (git rev-parse --show-toplevel) "skills\spec-context\scripts\spec-common.ps1")
$context = Get-SpecContext
$branch = $context.CURRENT_BRANCH
$featureDir = $context.FEATURE_DIR
$repoRoot = $context.REPO_ROOT
$demoDir = Join-Path $repoRoot ("demo\prototypes\{0}" -f $branch)
$hasRemote = $false
git ls-remote --exit-code --heads origin $branch *> $null
if ($LASTEXITCODE -eq 0) { $hasRemote = $true }
@"
【Deletion commands to be executed (pending final confirmation)】
1) Switch to main (avoid deleting while on the branch to be deleted)
git switch main
git pull
2) Clean up local residual directories (if exist)
if (Test-Path -LiteralPath `"$featureDir`") { Remove-Item -LiteralPath `"$featureDir`" -Recurse -Force }
if (Test-Path -LiteralPath `"$demoDir`") { Remove-Item -LiteralPath `"$demoDir`" -Recurse -Force }
3) Delete local branch
git branch -D $branch
4) Delete remote branch (if exists)
"@ | Write-Host
if ($hasRemote) {
Write-Host ("git push origin --delete {0}" -f $branch)
} else {
Write-Host ("(Skip remote deletion: origin/{0} not detected)" -f $branch)
}
最终确认执行删除git branch --list $branch
git branch -r | Select-String ("origin/{0}" -f $branch)
Test-Path -LiteralPath $featureDirgit branch --list $branchTest-Path $featureDirFalsespec-contextgit branch -Dgit push --deleteRemove-Itemgit clean -fdGet-SpecContext.CURRENT_BRANCH