@@ -147,64 +147,41 @@ $result.needsTriage = $triageLabels.Count -gt 0
147147
148148# Calculate area suggestion confidence if no area label
149149if (-not $result.hasAreaLabel ) {
150- # Fetch available area labels from the repository using Get-RepositoryLabels.ps1
150+ # Load area keywords from area-keywords.json
151151 $scriptDir = Split-Path - Parent $MyInvocation.MyCommand.Path
152- $getLabelsScript = Join-Path $scriptDir " Get-RepositoryLabels.ps1"
153-
154- $availableAreaLabels = @ ()
155- if (Test-Path $getLabelsScript ) {
156- try {
157- $rawLabels = & $getLabelsScript - Repository $Repository - Filter " area-*" - OutputFormat json 2> $null
158- if ($LASTEXITCODE -eq 0 -and $rawLabels ) {
159- $labelData = $rawLabels | ConvertFrom-Json
160- $availableAreaLabels = @ ($labelData | ForEach-Object { $_.name })
161- Write-Verbose " Fetched $ ( $availableAreaLabels.Count ) area labels from repository"
162- }
163- }
164- catch {
165- Write-Verbose " Could not fetch area labels: $_ "
166- }
152+ $skillDir = Split-Path - Parent $scriptDir
153+ $keywordsFile = Join-Path $skillDir " area-keywords.json"
154+
155+ if (-not (Test-Path $keywordsFile )) {
156+ Write-Error " Area keywords file not found: $keywordsFile "
157+ exit 1
167158 }
168-
169- # Build keyword map - use fetched labels or fall back to common ones
170- # Keywords are derived from label names (strip 'area-' prefix and expand)
171- $areaKeywords = @ {}
172-
173- # Default keywords for common areas (fallback and enhancement)
174- # area-Notifications covers all notification types (toast, badge, push, app notifications)
175- $defaultKeywords = @ {
176- ' area-Notifications' = @ (' notification' , ' toast' , ' badge' , ' push' , ' appnotification' , ' pushnotification' , ' wns' )
177- ' area-Packaging' = @ (' msix' , ' package' , ' deploy' , ' install' , ' appx' , ' deployment' )
178- ' area-Windowing' = @ (' window' , ' appwindow' , ' titlebar' , ' backdrop' , ' presenter' )
179- ' area-Widgets' = @ (' widget' , ' dashboard' )
180- ' area-AppLifecycle' = @ (' lifecycle' , ' activation' , ' restart' , ' single instance' , ' appinstance' )
181- ' area-PowerManagement' = @ (' power' , ' battery' , ' suspend' , ' resume' , ' powermanager' )
182- ' area-MRTCore' = @ (' resource' , ' mrt' , ' localization' , ' pri' , ' resourcemanager' )
183- ' area-DWriteCore' = @ (' font' , ' dwrite' , ' text' , ' typography' )
184- ' area-AccessControl' = @ (' access' , ' security' , ' token' , ' permission' )
185- ' area-Environment' = @ (' environment' , ' variable' , ' env' )
159+
160+ $keywordsJson = Get-Content - Path $keywordsFile - Raw - ErrorAction Stop
161+ try {
162+ $keywordsData = $keywordsJson | ConvertFrom-Json - ErrorAction Stop
186163 }
187-
188- # Use fetched labels if available, otherwise use default set
189- $labelsToUse = if ($availableAreaLabels.Count -gt 0 ) { $availableAreaLabels } else { $defaultKeywords.Keys }
190-
191- foreach ($areaLabel in $labelsToUse ) {
192- # Start with default keywords if we have them
193- if ($defaultKeywords.ContainsKey ($areaLabel )) {
194- $areaKeywords [$areaLabel ] = $defaultKeywords [$areaLabel ]
195- }
196- else {
197- # Generate keywords from label name (e.g., area-SomeFeature -> @('some', 'feature', 'somefeature'))
198- $labelBase = $areaLabel -replace ' ^area-' , ' '
199- $keywords = @ ($labelBase.ToLower ())
200- # Split PascalCase into words
201- $words = [regex ]::Matches($labelBase , ' [A-Z][a-z]+' ) | ForEach-Object { $_.Value.ToLower () }
202- if ($words ) {
203- $keywords += $words
204- }
205- $areaKeywords [$areaLabel ] = $keywords
164+ catch {
165+ Write-Error " Failed to parse area keywords file '$keywordsFile ': $_ "
166+ exit 1
167+ }
168+
169+ if ($null -eq $keywordsData -or ($keywordsData | Get-Member - MemberType NoteProperty).Count -eq 0 ) {
170+ Write-Error " Area keywords file '$keywordsFile ' is empty or contains no label entries."
171+ exit 1
172+ }
173+
174+ # Convert parsed JSON object to hashtable
175+ $areaKeywords = @ {}
176+ foreach ($prop in $keywordsData.PSObject.Properties ) {
177+ if ($null -eq $prop.Value -or @ ($prop.Value ).Count -eq 0 ) {
178+ Write-Error " Area keywords file '$keywordsFile ' has no keywords for label '$ ( $prop.Name ) '."
179+ exit 1
206180 }
181+ $areaKeywords [$prop.Name ] = @ ($prop.Value )
207182 }
183+
184+ Write-Verbose " Loaded $ ( $areaKeywords.Count ) area keyword entries from $keywordsFile "
208185
209186 # Extract text to search for keywords
210187 $text = " $ ( $issue.title ) $ ( $issue.body ) "
0 commit comments