feat(skd-edit): add-selection @group= targets named StructureItemGroup

- add-selection supports @group=Name to add selection items to a named grouping instead of variant level
- Finds StructureItemGroup by dcsset:name, falls back to variant level if not found
- Document @group= in SKILL.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-04-06 19:35:07 +03:00
co-authored by Claude Opus 4.6
parent 17afd807d2
commit 6404016afb
3 changed files with 59 additions and 4 deletions
+26 -2
View File
@@ -1882,8 +1882,31 @@ switch ($Operation) {
foreach ($val in $values) {
$fieldName = $val.Trim()
$groupName = $null
$selection = Ensure-SettingsChild $settings "selection" @()
# Extract @group=Name
if ($fieldName -match '\s*@group=(\S+)') {
$groupName = $Matches[1]
$fieldName = ($fieldName -replace '\s*@group=\S+', '').Trim()
}
if ($groupName) {
# Find named StructureItemGroup
$dcssetNs = "http://v8.1c.ru/8.1/data-composition-system/settings"
$nsMgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable)
$nsMgr.AddNamespace("dcsset", $dcssetNs)
$groupEl = $settings.SelectSingleNode(".//dcsset:item[@xsi:type='dcsset:StructureItemGroup'][dcsset:name='$groupName']", $nsMgr)
if (-not $groupEl) {
Write-Host "[WARN] StructureItemGroup `"$groupName`" not found — adding to variant level"
$targetEl = $settings
} else {
$targetEl = $groupEl
}
} else {
$targetEl = $settings
}
$selection = Ensure-SettingsChild $targetEl "selection" @()
$selIndent = Get-ContainerChildIndent $selection
$selXml = Build-SelectionItemFragment -fieldName $fieldName -indent $selIndent
@@ -1892,7 +1915,8 @@ switch ($Operation) {
Insert-BeforeElement $selection $node $null $selIndent
}
Write-Host "[OK] Selection `"$fieldName`" added to variant `"$varName`""
$target = if ($groupName) { "group `"$groupName`"" } else { "variant `"$varName`"" }
Write-Host "[OK] Selection `"$fieldName`" added to $target"
}
}