260304:1233 20260304:1200 update app to lcbp3
Some checks failed
Build and Deploy / deploy (push) Failing after 1m32s
Some checks failed
Build and Deploy / deploy (push) Failing after 1m32s
This commit is contained in:
157
.agents/scripts/powershell/common.ps1
Normal file
157
.agents/scripts/powershell/common.ps1
Normal file
@@ -0,0 +1,157 @@
|
||||
# PowerShell equivalents for key .agents bash scripts
|
||||
# These provide Windows-native alternatives for the most commonly used functions
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Common utility functions for Spec-Kit PowerShell scripts.
|
||||
.DESCRIPTION
|
||||
PowerShell equivalent of .agents/scripts/bash/common.sh
|
||||
Provides repository root detection, branch identification, and feature path resolution.
|
||||
#>
|
||||
|
||||
function Get-RepoRoot {
|
||||
try {
|
||||
$root = git rev-parse --show-toplevel 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { return $root.Trim() }
|
||||
} catch {}
|
||||
# Fallback: navigate up from script location
|
||||
return (Resolve-Path "$PSScriptRoot\..\..\..").Path
|
||||
}
|
||||
|
||||
function Get-CurrentBranch {
|
||||
# Check environment variable first
|
||||
if ($env:SPECIFY_FEATURE) { return $env:SPECIFY_FEATURE }
|
||||
|
||||
try {
|
||||
$branch = git rev-parse --abbrev-ref HEAD 2>$null
|
||||
if ($LASTEXITCODE -eq 0) { return $branch.Trim() }
|
||||
} catch {}
|
||||
|
||||
# Fallback: find latest feature directory
|
||||
$repoRoot = Get-RepoRoot
|
||||
$specsDir = Join-Path $repoRoot "specs"
|
||||
if (Test-Path $specsDir) {
|
||||
$latest = Get-ChildItem -Path $specsDir -Directory |
|
||||
Where-Object { $_.Name -match '^\d{3}-' } |
|
||||
Sort-Object Name -Descending |
|
||||
Select-Object -First 1
|
||||
if ($latest) { return $latest.Name }
|
||||
}
|
||||
return "main"
|
||||
}
|
||||
|
||||
function Test-HasGit {
|
||||
try {
|
||||
git rev-parse --show-toplevel 2>$null | Out-Null
|
||||
return $LASTEXITCODE -eq 0
|
||||
} catch { return $false }
|
||||
}
|
||||
|
||||
function Test-FeatureBranch {
|
||||
param([string]$Branch, [bool]$HasGit)
|
||||
if (-not $HasGit) {
|
||||
Write-Warning "[specify] Git repository not detected; skipped branch validation"
|
||||
return $true
|
||||
}
|
||||
if ($Branch -notmatch '^\d{3}-') {
|
||||
Write-Error "Not on a feature branch. Current branch: $Branch"
|
||||
Write-Error "Feature branches should be named like: 001-feature-name"
|
||||
return $false
|
||||
}
|
||||
return $true
|
||||
}
|
||||
|
||||
function Find-FeatureDir {
|
||||
param([string]$RepoRoot, [string]$BranchName)
|
||||
$specsDir = Join-Path $RepoRoot "specs"
|
||||
|
||||
if ($BranchName -match '^(\d{3})-') {
|
||||
$prefix = $Matches[1]
|
||||
$matches = Get-ChildItem -Path $specsDir -Directory -Filter "$prefix-*" -ErrorAction SilentlyContinue
|
||||
if ($matches.Count -eq 1) { return $matches[0].FullName }
|
||||
if ($matches.Count -gt 1) {
|
||||
Write-Warning "Multiple spec dirs with prefix '$prefix': $($matches.Name -join ', ')"
|
||||
}
|
||||
}
|
||||
return Join-Path $specsDir $BranchName
|
||||
}
|
||||
|
||||
function Get-FeaturePaths {
|
||||
$repoRoot = Get-RepoRoot
|
||||
$branch = Get-CurrentBranch
|
||||
$hasGit = Test-HasGit
|
||||
$featureDir = Find-FeatureDir -RepoRoot $repoRoot -BranchName $branch
|
||||
|
||||
return [PSCustomObject]@{
|
||||
RepoRoot = $repoRoot
|
||||
Branch = $branch
|
||||
HasGit = $hasGit
|
||||
FeatureDir = $featureDir
|
||||
FeatureSpec = Join-Path $featureDir "spec.md"
|
||||
ImplPlan = Join-Path $featureDir "plan.md"
|
||||
Tasks = Join-Path $featureDir "tasks.md"
|
||||
Research = Join-Path $featureDir "research.md"
|
||||
DataModel = Join-Path $featureDir "data-model.md"
|
||||
Quickstart = Join-Path $featureDir "quickstart.md"
|
||||
ContractsDir = Join-Path $featureDir "contracts"
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Check prerequisites for Spec-Kit workflows.
|
||||
.DESCRIPTION
|
||||
PowerShell equivalent of .agents/scripts/bash/check-prerequisites.sh
|
||||
.PARAMETER RequireTasks
|
||||
Require tasks.md to exist (for implementation phase)
|
||||
.PARAMETER IncludeTasks
|
||||
Include tasks.md in available docs list
|
||||
.PARAMETER PathsOnly
|
||||
Only output paths, no validation
|
||||
.EXAMPLE
|
||||
.\common.ps1
|
||||
$result = Check-Prerequisites -RequireTasks
|
||||
#>
|
||||
function Check-Prerequisites {
|
||||
param(
|
||||
[switch]$RequireTasks,
|
||||
[switch]$IncludeTasks,
|
||||
[switch]$PathsOnly
|
||||
)
|
||||
|
||||
$paths = Get-FeaturePaths
|
||||
$valid = Test-FeatureBranch -Branch $paths.Branch -HasGit $paths.HasGit
|
||||
if (-not $valid) { throw "Not on a feature branch" }
|
||||
|
||||
if ($PathsOnly) { return $paths }
|
||||
|
||||
# Validate required files
|
||||
if (-not (Test-Path $paths.FeatureDir)) {
|
||||
throw "Feature directory not found: $($paths.FeatureDir). Run /speckit.specify first."
|
||||
}
|
||||
if (-not (Test-Path $paths.ImplPlan)) {
|
||||
throw "plan.md not found. Run /speckit.plan first."
|
||||
}
|
||||
if ($RequireTasks -and -not (Test-Path $paths.Tasks)) {
|
||||
throw "tasks.md not found. Run /speckit.tasks first."
|
||||
}
|
||||
|
||||
# Build available docs list
|
||||
$docs = @()
|
||||
if (Test-Path $paths.Research) { $docs += "research.md" }
|
||||
if (Test-Path $paths.DataModel) { $docs += "data-model.md" }
|
||||
if ((Test-Path $paths.ContractsDir) -and (Get-ChildItem $paths.ContractsDir -ErrorAction SilentlyContinue)) {
|
||||
$docs += "contracts/"
|
||||
}
|
||||
if (Test-Path $paths.Quickstart) { $docs += "quickstart.md" }
|
||||
if ($IncludeTasks -and (Test-Path $paths.Tasks)) { $docs += "tasks.md" }
|
||||
|
||||
return [PSCustomObject]@{
|
||||
FeatureDir = $paths.FeatureDir
|
||||
AvailableDocs = $docs
|
||||
Paths = $paths
|
||||
}
|
||||
}
|
||||
|
||||
# Export functions when dot-sourced
|
||||
Export-ModuleMember -Function * -ErrorAction SilentlyContinue 2>$null
|
||||
138
.agents/scripts/powershell/create-new-feature.ps1
Normal file
138
.agents/scripts/powershell/create-new-feature.ps1
Normal file
@@ -0,0 +1,138 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new feature branch and spec directory.
|
||||
.DESCRIPTION
|
||||
PowerShell equivalent of .agents/scripts/bash/create-new-feature.sh
|
||||
Creates a numbered feature branch and initializes the spec directory.
|
||||
.PARAMETER Description
|
||||
Natural language description of the feature.
|
||||
.PARAMETER ShortName
|
||||
Optional custom short name for the branch (2-4 words).
|
||||
.PARAMETER Number
|
||||
Optional manual branch number (overrides auto-detection).
|
||||
.EXAMPLE
|
||||
.\create-new-feature.ps1 -Description "Add user authentication" -ShortName "user-auth"
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0)]
|
||||
[string]$Description,
|
||||
|
||||
[string]$ShortName,
|
||||
[int]$Number = 0
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Load common functions
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$repoRoot = Get-RepoRoot
|
||||
$hasGit = Test-HasGit
|
||||
$specsDir = Join-Path $repoRoot "specs"
|
||||
if (-not (Test-Path $specsDir)) { New-Item -ItemType Directory -Path $specsDir | Out-Null }
|
||||
|
||||
# Stop words for smart branch name generation
|
||||
$stopWords = @('i','a','an','the','to','for','of','in','on','at','by','with','from',
|
||||
'is','are','was','were','be','been','being','have','has','had',
|
||||
'do','does','did','will','would','should','could','can','may','might',
|
||||
'must','shall','this','that','these','those','my','your','our','their',
|
||||
'want','need','add','get','set')
|
||||
|
||||
function ConvertTo-BranchName {
|
||||
param([string]$Text)
|
||||
$Text.ToLower() -replace '[^a-z0-9]', '-' -replace '-+', '-' -replace '^-|-$', ''
|
||||
}
|
||||
|
||||
function Get-SmartBranchName {
|
||||
param([string]$Desc)
|
||||
$words = ($Desc.ToLower() -replace '[^a-z0-9]', ' ').Split(' ', [StringSplitOptions]::RemoveEmptyEntries)
|
||||
$meaningful = $words | Where-Object { $_ -notin $stopWords -and $_.Length -ge 3 } | Select-Object -First 3
|
||||
if ($meaningful.Count -gt 0) { return ($meaningful -join '-') }
|
||||
return ConvertTo-BranchName $Desc
|
||||
}
|
||||
|
||||
function Get-HighestNumber {
|
||||
param([string]$Dir)
|
||||
$highest = 0
|
||||
if (Test-Path $Dir) {
|
||||
Get-ChildItem -Path $Dir -Directory | ForEach-Object {
|
||||
if ($_.Name -match '^(\d+)-') {
|
||||
$num = [int]$Matches[1]
|
||||
if ($num -gt $highest) { $highest = $num }
|
||||
}
|
||||
}
|
||||
}
|
||||
return $highest
|
||||
}
|
||||
|
||||
# Generate branch suffix
|
||||
if ($ShortName) {
|
||||
$branchSuffix = ConvertTo-BranchName $ShortName
|
||||
} else {
|
||||
$branchSuffix = Get-SmartBranchName $Description
|
||||
}
|
||||
|
||||
# Determine branch number
|
||||
if ($Number -gt 0) {
|
||||
$branchNumber = $Number
|
||||
} else {
|
||||
$highestSpec = Get-HighestNumber $specsDir
|
||||
$highestBranch = 0
|
||||
if ($hasGit) {
|
||||
try {
|
||||
git fetch --all --prune 2>$null | Out-Null
|
||||
$branches = git branch -a 2>$null
|
||||
foreach ($b in $branches) {
|
||||
$clean = $b.Trim('* ') -replace '^remotes/[^/]+/', ''
|
||||
if ($clean -match '^(\d{3})-') {
|
||||
$num = [int]$Matches[1]
|
||||
if ($num -gt $highestBranch) { $highestBranch = $num }
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
$branchNumber = [Math]::Max($highestSpec, $highestBranch) + 1
|
||||
}
|
||||
|
||||
$featureNum = "{0:D3}" -f $branchNumber
|
||||
$branchName = "$featureNum-$branchSuffix"
|
||||
|
||||
# Truncate if exceeding GitHub's 244-byte limit
|
||||
if ($branchName.Length -gt 244) {
|
||||
$maxSuffix = 244 - 4 # 3 digits + 1 hyphen
|
||||
$branchSuffix = $branchSuffix.Substring(0, $maxSuffix).TrimEnd('-')
|
||||
Write-Warning "Branch name truncated to 244 bytes"
|
||||
$branchName = "$featureNum-$branchSuffix"
|
||||
}
|
||||
|
||||
# Create git branch
|
||||
if ($hasGit) {
|
||||
git checkout -b $branchName
|
||||
} else {
|
||||
Write-Warning "Git not detected; skipped branch creation for $branchName"
|
||||
}
|
||||
|
||||
# Create feature directory and spec file
|
||||
$featureDir = Join-Path $specsDir $branchName
|
||||
New-Item -ItemType Directory -Path $featureDir -Force | Out-Null
|
||||
|
||||
$templateFile = Join-Path $repoRoot ".specify" "templates" "spec-template.md"
|
||||
$specFile = Join-Path $featureDir "spec.md"
|
||||
if (Test-Path $templateFile) {
|
||||
Copy-Item $templateFile $specFile
|
||||
} else {
|
||||
New-Item -ItemType File -Path $specFile -Force | Out-Null
|
||||
}
|
||||
|
||||
$env:SPECIFY_FEATURE = $branchName
|
||||
|
||||
# Output
|
||||
[PSCustomObject]@{
|
||||
BranchName = $branchName
|
||||
SpecFile = $specFile
|
||||
FeatureNum = $featureNum
|
||||
}
|
||||
|
||||
Write-Host "BRANCH_NAME: $branchName"
|
||||
Write-Host "SPEC_FILE: $specFile"
|
||||
Write-Host "FEATURE_NUM: $featureNum"
|
||||
Reference in New Issue
Block a user