From 24358f212f01ad94851edce50c5ce8b3c9c56946 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Tue, 10 Feb 2026 18:00:30 +0300 Subject: [PATCH] Split fields mode into fields, links, and totals modes Separate concerns for cleaner output: fields shows only dataset field tables, links shows dataset connections, totals shows calculated fields and resources. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/skd-info/SKILL.md | 41 +++++-- .claude/skills/skd-info/scripts/skd-info.ps1 | 110 ++++++++++++++----- 2 files changed, 113 insertions(+), 38 deletions(-) diff --git a/.claude/skills/skd-info/SKILL.md b/.claude/skills/skd-info/SKILL.md index 6d39d0f8..525420ba 100644 --- a/.claude/skills/skd-info/SKILL.md +++ b/.claude/skills/skd-info/SKILL.md @@ -1,7 +1,7 @@ --- name: skd-info description: Анализ структуры схемы компоновки данных 1С (СКД) — наборы, поля, параметры, варианты -argument-hint: [-Mode overview|query|fields|params|variant] [-Name ] +argument-hint: [-Mode overview|query|fields|links|totals|params|variant] [-Name ] allowed-tools: - Bash - Read @@ -24,7 +24,7 @@ allowed-tools: | Параметр | Обязательный | По умолчанию | Описание | |--------------|:------------:|--------------|---------------------------------------------------| | TemplatePath | да | — | Путь к Template.xml или каталогу макета | -| Mode | нет | `overview` | Режим: `overview`, `query`, `fields`, `params`, `variant` | +| Mode | нет | `overview` | Режим: `overview`, `query`, `fields`, `links`, `totals`, `params`, `variant` | | Name | нет | — | Имя набора (query/fields) или варианта (variant) | | Batch | нет | `0` | Номер пакета запроса (0 = все). Только для query | | Limit | нет | `150` | Макс. строк вывода (защита от переполнения) | @@ -43,6 +43,8 @@ powershell.exe -NoProfile -File .claude\skills\skd-info\scripts\skd-info.ps1 -Te ... -Mode query -Name ДанныеТ13 -Batch 3 ... -Mode fields ... -Mode fields -Name НаборДанных1 +... -Mode links +... -Mode totals ... -Mode params ... -Mode variant -Name Основной ... -Mode variant -Name 1 @@ -78,7 +80,8 @@ Variants: Next: -Mode query query text - -Mode fields field details + calculated + totals + -Mode fields field tables by dataset + -Mode totals calculated fields + resources -Mode variant -Name variant structure (1..2) ``` @@ -115,17 +118,37 @@ Params: 18 (7 visible, 11 hidden): Период, Ответственный, ... Фильтр по номеру батча: `-Batch 3` покажет только 3-й пакет. -### fields — таблица полей +### fields — таблица полей наборов данных ``` -=== Fields: НоменклатураСЦенами (7) === +=== Fields: НоменклатураСЦенами [Query] (7) === dataPath title role restrict format Номенклатура - - - - Номенклатура.Артикул "Артикул" - - - Цена - - - ЧГ=0 ---- calculated --- +``` + +Без `-Name` — поля всех наборов. С `-Name <набор>` — только указанного. + +### links — связи наборов данных + +``` +=== Links (5) === + +РасчетНалогаНаИмущество -> СостояниеОС : + Организация -> Организация + ОсновноеСредство -> ОсновноеСредство +``` + +Группирует по парам наборов. Показывает поля связи и параметры. + +### totals — вычисляемые поля и ресурсы + +``` +=== Calculated fields (3) === УИД = БухгалтерскиеОтчеты.ПолучитьУИДСсылкиСтрокой(Номенклатура) restrict:cond,grp,ord ---- totals --- + +=== Resources (2) === Цена = Максимум(Цена) ПравоИнтерактивное = Максимум(ПравоИнтерактивное) [group:ОбъектМетаданных] ``` @@ -178,7 +201,9 @@ Output: style=ЧерноБелый groups=Separately totalsH=None totalsV=Non - **Перед анализом отчёта**: overview для понимания структуры - **Отладка данных**: query для просмотра текста запроса -- **Модификация полей**: fields для полного списка с ролями +- **Модификация полей**: fields для списка с ролями по наборам +- **Связи между наборами**: links для полей связи и параметров +- **Формулы и ресурсы**: totals для вычисляемых полей и ресурсов - **Программный вызов**: params для списка параметров - **Изменение вывода**: variant для структуры группировок и фильтров diff --git a/.claude/skills/skd-info/scripts/skd-info.ps1 b/.claude/skills/skd-info/scripts/skd-info.ps1 index 85b08791..1836755f 100644 --- a/.claude/skills/skd-info/scripts/skd-info.ps1 +++ b/.claude/skills/skd-info/scripts/skd-info.ps1 @@ -1,7 +1,7 @@ param( [Parameter(Mandatory=$true)] [string]$TemplatePath, - [ValidateSet("overview", "query", "fields", "params", "variant")] + [ValidateSet("overview", "query", "fields", "links", "totals", "params", "variant")] [string]$Mode = "overview", [string]$Name, [int]$Batch = 0, @@ -498,7 +498,16 @@ if ($Mode -eq "overview") { } elseif ($queryDsNames.Count -gt 1) { $hints += "-Mode query -Name query text ($($queryDsNames -join ', '))" } - $hints += "-Mode fields field details + calculated + totals" + $hints += "-Mode fields field tables by dataset" + $linkCount = $root.SelectNodes("s:dataSetLink", $ns).Count + if ($linkCount -gt 0) { + $hints += "-Mode links dataset connections ($linkCount)" + } + $calcCount = $root.SelectNodes("s:calculatedField", $ns).Count + $totalCount = $root.SelectNodes("s:totalField", $ns).Count + if ($calcCount -gt 0 -or $totalCount -gt 0) { + $hints += "-Mode totals calculated fields + resources" + } if ($params.Count -gt 0) { $hints += "-Mode params parameter details" } @@ -646,22 +655,6 @@ elseif ($Mode -eq "query") { # ============================================================ elseif ($Mode -eq "fields") { - # Links (full detail) - $links = $root.SelectNodes("s:dataSetLink", $ns) - if ($links.Count -gt 0) { - $lines.Add("--- links ---") - foreach ($lnk in $links) { - $srcDs = $lnk.SelectSingleNode("s:sourceDataSet", $ns).InnerText - $dstDs = $lnk.SelectSingleNode("s:destinationDataSet", $ns).InnerText - $srcExpr = $lnk.SelectSingleNode("s:sourceExpression", $ns).InnerText - $dstExpr = $lnk.SelectSingleNode("s:destinationExpression", $ns).InnerText - $paramNode = $lnk.SelectSingleNode("s:parameter", $ns) - $paramStr = if ($paramNode) { " param=$($paramNode.InnerText)" } else { "" } - $lines.Add(" $srcDs.$srcExpr -> $dstDs.$dstExpr$paramStr") - } - $lines.Add("") - } - $dataSets = $root.SelectNodes("s:dataSet", $ns) function Show-DataSetFields($dsNode) { @@ -734,14 +727,9 @@ elseif ($Mode -eq "fields") { } if ($Name) { + # Search nested items first (Union child over Union parent) $found = $false foreach ($ds in $dataSets) { - $dsNameNode = $ds.SelectSingleNode("s:name", $ns) - if ($dsNameNode -and $dsNameNode.InnerText -eq $Name) { - Show-DataSetFields $ds - $found = $true - break - } foreach ($subDs in $ds.SelectNodes("s:item", $ns)) { $subNameNode = $subDs.SelectSingleNode("s:name", $ns) if ($subNameNode -and $subNameNode.InnerText -eq $Name) { @@ -752,6 +740,16 @@ elseif ($Mode -eq "fields") { } if ($found) { break } } + if (-not $found) { + foreach ($ds in $dataSets) { + $dsNameNode = $ds.SelectSingleNode("s:name", $ns) + if ($dsNameNode -and $dsNameNode.InnerText -eq $Name) { + Show-DataSetFields $ds + $found = $true + break + } + } + } if (-not $found) { Write-Error "Dataset '$Name' not found" exit 1 @@ -773,15 +771,63 @@ elseif ($Mode -eq "fields") { } } } +} + +# ============================================================ +# MODE: links +# ============================================================ +elseif ($Mode -eq "links") { + + $links = $root.SelectNodes("s:dataSetLink", $ns) + if ($links.Count -eq 0) { + $lines.Add("(no links)") + } else { + $lines.Add("=== Links ($($links.Count)) ===") + $lines.Add("") + # Group by source->dest pair + $currentPair = "" + foreach ($lnk in $links) { + $srcDs = $lnk.SelectSingleNode("s:sourceDataSet", $ns).InnerText + $dstDs = $lnk.SelectSingleNode("s:destinationDataSet", $ns).InnerText + $srcExpr = $lnk.SelectSingleNode("s:sourceExpression", $ns).InnerText + $dstExpr = $lnk.SelectSingleNode("s:destinationExpression", $ns).InnerText + $paramNode = $lnk.SelectSingleNode("s:parameter", $ns) + $paramListNode = $lnk.SelectSingleNode("s:parameterListAllowed", $ns) + + $pair = "$srcDs -> $dstDs" + if ($pair -ne $currentPair) { + if ($currentPair) { $lines.Add("") } + $lines.Add("$pair :") + $currentPair = $pair + } + + $paramStr = "" + if ($paramNode) { $paramStr = " param=$($paramNode.InnerText)" } + + $lines.Add(" $srcExpr -> $dstExpr$paramStr") + } + } +} + +# ============================================================ +# MODE: totals +# ============================================================ +elseif ($Mode -eq "totals") { # Calculated fields $calcFields = $root.SelectNodes("s:calculatedField", $ns) if ($calcFields.Count -gt 0) { - $lines.Add("") - $lines.Add("--- calculated ---") + $lines.Add("=== Calculated fields ($($calcFields.Count)) ===") foreach ($cf in $calcFields) { $cfPath = $cf.SelectSingleNode("s:dataPath", $ns).InnerText $cfExpr = $cf.SelectSingleNode("s:expression", $ns).InnerText + $cfTitle = $cf.SelectSingleNode("s:title", $ns) + $titleStr = "" + if ($cfTitle) { + $t = Get-MLText $cfTitle + if ($t) { $titleStr = " `"$t`"" } + } + $cfRestrict = $cf.SelectSingleNode("s:useRestriction", $ns) $restrictStr = "" if ($cfRestrict) { @@ -793,15 +839,15 @@ elseif ($Mode -eq "fields") { } if ($parts.Count -gt 0) { $restrictStr = " restrict:" + ($parts -join ",") } } - $lines.Add(" $cfPath = $cfExpr$restrictStr") + $lines.Add(" $cfPath = $cfExpr$restrictStr$titleStr") } + $lines.Add("") } - # Total fields + # Total fields (resources) $totalFields = $root.SelectNodes("s:totalField", $ns) if ($totalFields.Count -gt 0) { - $lines.Add("") - $lines.Add("--- totals ---") + $lines.Add("=== Resources ($($totalFields.Count)) ===") foreach ($tf in $totalFields) { $tfPath = $tf.SelectSingleNode("s:dataPath", $ns).InnerText $tfExpr = $tf.SelectSingleNode("s:expression", $ns).InnerText @@ -811,6 +857,10 @@ elseif ($Mode -eq "fields") { $lines.Add(" $tfPath = $tfExpr$groupStr") } } + + if ($calcFields.Count -eq 0 -and $totalFields.Count -eq 0) { + $lines.Add("(no calculated fields or resources)") + } } # ============================================================