From c998139c89f7e990ba455d8a07db6d9eebb554c9 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 6 Jun 2026 22:08:01 +0300 Subject: [PATCH] =?UTF-8?q?feat(form-decompile):=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20AutoCommandBar=20?= =?UTF-8?q?=E2=80=94=20=D0=BC=D0=B0=D1=80=D0=BA=D0=B5=D1=80=20autofill=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B3=D0=BE=D0=BB=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D0=BD=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Корень формы (id=-1) при голом (autofill=true по умолчанию) терялся: эвристика B3 (Compute-MainAcbAutofill) при наличии cmdBar-элемента в форме додумывает Autofill=false → ADDED. Тот же приём, что у таблицы: декомпилятор зеркалит условие эвристики (Test-AnyCmdBar) и при голом корне + наличии cmdBar пишет отклонение autoCmdBar:{ autofill: true }. Компилятор не менялся (Compute-MainAcbAutofill уже возвращает mainAcbDef.autofill; при true без детей корень эмитится голым). TOTAL diff lines выборки 2.17: 5249 → 5189 (-60). AutoCommandBar ADDED 18 → 0 (голый корень закрыт). Регресс form-compile 33/33 зелёный на ps + python. decompile v0.31. Co-Authored-By: Claude Opus 4.8 --- .../form-decompile/scripts/form-decompile.ps1 | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.claude/skills/form-decompile/scripts/form-decompile.ps1 b/.claude/skills/form-decompile/scripts/form-decompile.ps1 index c353aa9f..2c5255ca 100644 --- a/.claude/skills/form-decompile/scripts/form-decompile.ps1 +++ b/.claude/skills/form-decompile/scripts/form-decompile.ps1 @@ -1,4 +1,4 @@ -# form-decompile v0.30 — Decompile 1C managed Form.xml to JSON DSL (draft) +# form-decompile v0.31 — Decompile 1C managed Form.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью. param( @@ -1213,23 +1213,46 @@ if ($evForm) { if ($evMap.Count -gt 0) { $dsl['events'] = $evMap } } -# elements (+ форменный AutoCommandBar как autoCmdBar-элемент, если у него есть содержимое) +# Зеркало компилятор-эвристики B3 (Compute-MainAcbAutofill): наличие cmdBar-элемента где-либо +# в дереве → форменный AutoCommandBar autofill=false. Нужно, чтобы предсказать вывод и выразить +# отклонение (голый корень при наличии cmdBar). +function Test-AnyCmdBar { + param($list) + if (-not $list) { return $false } + foreach ($e in $list) { + if ($e -is [System.Collections.IDictionary] -and $e.Contains('cmdBar')) { return $true } + if ($e -is [System.Collections.IDictionary]) { + if ($e.Contains('children') -and (Test-AnyCmdBar $e['children'])) { return $true } + if ($e.Contains('columns') -and (Test-AnyCmdBar $e['columns'])) { return $true } + } + } + return $false +} + +# elements (+ форменный AutoCommandBar как autoCmdBar-элемент, если у него есть содержимое/отклонение) $elemList = New-Object System.Collections.ArrayList +$elements = Decompile-Children $root +$formHasCmdBar = Test-AnyCmdBar $elements $acb = $root.SelectSingleNode("lf:AutoCommandBar", $ns) if ($acb) { $haln = Get-Child $acb 'HorizontalAlign' $acbAutofill = Get-Child $acb 'Autofill' $acbKids = Decompile-Children $acb + $acbObj = $null if ($haln -or ($acbAutofill -eq 'false') -or $acbKids) { $acbObj = [ordered]@{} $acbObj['autoCmdBar'] = $acb.GetAttribute("name") if ($haln) { $acbObj['horizontalAlign'] = $haln } if ($acbAutofill -eq 'false') { $acbObj['autofill'] = $false } if ($acbKids) { $acbObj['children'] = $acbKids } - [void]$elemList.Add($acbObj) + } elseif ($formHasCmdBar -and $null -eq $acbAutofill) { + # Корень голый (autofill=true по умолчанию), но эвристика B3 дала бы false (есть cmdBar) → маркер + $acbObj = [ordered]@{} + $acbObj['autoCmdBar'] = $acb.GetAttribute("name") + $acbObj['autofill'] = $true } + if ($acbObj) { [void]$elemList.Add($acbObj) } } -$elements = Decompile-Children $root if ($elements) { foreach ($e in $elements) { [void]$elemList.Add($e) } } if ($elemList.Count -gt 0) { $dsl['elements'] = @($elemList) }