From 7b945e786d9dc06fed511a533e85f68748aac250 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 6 Jun 2026 21:51:26 +0300 Subject: [PATCH] =?UTF-8?q?feat(form-decompile,form-compile):=20=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD-=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20AutoCommand?= =?UTF-8?q?Bar=20=E2=80=94=20=D0=BC=D0=B0=D1=80=D0=BA=D0=B5=D1=80=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=BB=D0=BE=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2?= =?UTF-8?q?=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20ADDED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Хвост кластера командных панелей: компилятор-эвристика додумывает Autofill=false дин-список-таблицам (подавляет панель, чтобы не дублировать КП формы), но ~15% таблиц имеют голый (autofill=true по умолчанию — панель оставлена при таблице). Раньше эвристика их перетирала → ADDED false>. Решение (B): эвристика держит дефолт false (оптимальный — 85% дин-списков; контекст- сигналы проверены по корпусу, ни один не даёт >50% «голых» → улучшать дефолт нечем), а декомпилятор фиксирует ОТКЛОНЕНИЕ маркером commandBar:{ autofill: true }. commandBar имеет приоритет над эвристикой. Компилятор: Emit-CompanionPanel больше не пишет true (платформа его не эмитит — true это дефолт); только false. autofill:true или отсутствие → тег опускается, при пустой панели → self-closing . TOTAL diff lines выборки 2.17: 5293 → 5249 (-44). Table>AutoCommandBar ADDED 22 → 0 (полностью закрыт). Остаток AutoCommandBar 18 — форменная панель (heuristic B3, корень формы) — отдельный пункт. Регресс form-compile 33/33 зелёный на ps + python. decompile v0.30, compile v1.49. Co-Authored-By: Claude Opus 4.8 --- .claude/skills/form-compile/scripts/form-compile.ps1 | 8 +++++--- .claude/skills/form-compile/scripts/form-compile.py | 10 ++++++---- .../skills/form-decompile/scripts/form-decompile.ps1 | 12 ++++++++---- docs/form-dsl-spec.md | 3 ++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.claude/skills/form-compile/scripts/form-compile.ps1 b/.claude/skills/form-compile/scripts/form-compile.ps1 index 3b929986..f2a08427 100644 --- a/.claude/skills/form-compile/scripts/form-compile.ps1 +++ b/.claude/skills/form-compile/scripts/form-compile.ps1 @@ -1,4 +1,4 @@ -# form-compile v1.48 — Compile 1C managed form from JSON or object metadata +# form-compile v1.49 — Compile 1C managed form from JSON or object metadata # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$JsonPath, @@ -2281,13 +2281,15 @@ function Emit-CompanionPanel { $children = $panel.children } $hasChildren = $children -and @($children).Count -gt 0 - if ($null -eq $autofill -and -not $hasChildren -and -not $halign) { + # Платформа пишет только при false; true = дефолт (тег опускается). + $emitAfFalse = ($autofill -eq $false) + if (-not $emitAfFalse -and -not $hasChildren -and -not $halign) { X "$indent<$tag name=`"$name`" id=`"$id`"/>" return } X "$indent<$tag name=`"$name`" id=`"$id`">" if ($halign) { X "$indent`t$halign" } - if ($null -ne $autofill) { X "$indent`t$(if ($autofill){'true'}else{'false'})" } + if ($emitAfFalse) { X "$indent`tfalse" } if ($hasChildren) { X "$indent`t" foreach ($c in @($children)) { Emit-Element -el $c -indent "$indent`t`t" -inCmdBar $true } diff --git a/.claude/skills/form-compile/scripts/form-compile.py b/.claude/skills/form-compile/scripts/form-compile.py index b2870381..99ca2f81 100644 --- a/.claude/skills/form-compile/scripts/form-compile.py +++ b/.claude/skills/form-compile/scripts/form-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# form-compile v1.48 — Compile 1C managed form from JSON or object metadata +# form-compile v1.49 — Compile 1C managed form from JSON or object metadata # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import copy @@ -2084,14 +2084,16 @@ def emit_companion_panel(lines, tag, name, indent, panel): halign = str(panel.get('horizontalAlign')) children = panel.get('children') has_children = bool(children) and len(children) > 0 - if autofill is None and not has_children and not halign: + # Платформа пишет только при false; true = дефолт (тег опускается). + emit_af_false = (autofill is False) + if not emit_af_false and not has_children and not halign: lines.append(f'{indent}<{tag} name="{name}" id="{cid}"/>') return lines.append(f'{indent}<{tag} name="{name}" id="{cid}">') if halign: lines.append(f'{indent}\t{halign}') - if autofill is not None: - lines.append(f'{indent}\t{"true" if autofill else "false"}') + if emit_af_false: + lines.append(f'{indent}\tfalse') if has_children: lines.append(f'{indent}\t') for c in children: diff --git a/.claude/skills/form-decompile/scripts/form-decompile.ps1 b/.claude/skills/form-decompile/scripts/form-decompile.ps1 index 03b3d8b6..c353aa9f 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.29 — Decompile 1C managed Form.xml to JSON DSL (draft) +# form-decompile v0.30 — Decompile 1C managed Form.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью. param( @@ -885,8 +885,9 @@ function Decompile-Children { # Инверсия Emit-CompanionPanel: companion-командная-панель (ContextMenu/AutoCommandBar) с контентом # → { autofill?, horizontalAlign?, children?[] } либо $null, если companion пустой (self-closing). -# $isDynListTable: для дин-список-таблицы пустой AutoCommandBar с autofill=false восстановит -# эвристика компилятора — молчим (как с tableAutofill), чтобы не плодить ключ. +# Дин-список-таблица: компилятор-эвристика додумывает Autofill=false. Выражаем только ОТКЛОНЕНИЕ: +# autofill=false (нет детей) → совпадает с дефолтом → молчим; +# голый (autofill=true по умолчанию) → маркер { autofill: true } (панель не скрыта). function Decompile-CompanionPanel { param($node, [string]$tag, [bool]$isDynListTable = $false) $p = $node.SelectSingleNode("lf:$tag", $ns) @@ -895,8 +896,11 @@ function Decompile-CompanionPanel { $halign = Get-Child $p 'HorizontalAlign' $kids = Decompile-Children $p $hasKids = $kids -and @($kids).Count -gt 0 + if ($isDynListTable -and $tag -eq 'AutoCommandBar' -and -not $hasKids -and -not $halign) { + if ($autofillRaw -eq 'false') { return $null } # = дефолт эвристики → молчим + return [ordered]@{ autofill = $true } # голая панель → отклонение + } if (-not $hasKids -and $null -eq $autofillRaw -and -not $halign) { return $null } - if ($isDynListTable -and $tag -eq 'AutoCommandBar' -and -not $hasKids -and -not $halign -and $autofillRaw -eq 'false') { return $null } $o = [ordered]@{} if ($halign) { $o['horizontalAlign'] = $halign } if ($autofillRaw -eq 'false') { $o['autofill'] = $false } diff --git a/docs/form-dsl-spec.md b/docs/form-dsl-spec.md index d39f5855..07cc3826 100644 --- a/docs/form-dsl-spec.md +++ b/docs/form-dsl-spec.md @@ -179,8 +179,9 @@ companion-панели с собственным контентом. Оба не `children` — обычная грамматика кнопок: `button` (с `command`/`commandName`/`stdCommand`), `buttonGroup`, `popup`. -- `autofill`: отсутствует → дефолт платформы (тег не эмитим); `false` → подавить автозаполнение панели. +- `autofill`: `false` → подавить автозаполнение (тег `false`); `true` или отсутствие → автозаполнение (платформенный дефолт, тег **не пишется**). Платформа `Autofill=true` не эмитит никогда. - Отсутствие свойства целиком → пустой companion (как обычно). +- **Дин-список-таблица**: компилятор по эвристике подавляет её панель (`autofill=false`), чтобы не дублировать командную панель формы. Чтобы оставить панель таблицы (она автозаполняется) — задайте явно `commandBar: { "autofill": true }`. **Разведение тип-элемента и панель-свойства — по типу значения:** `cmdBar: "Имя"` (строка) — это отдельный элемент-панель в дереве (§4.3); `commandBar: { … }` (объект/массив) — companion-панель *данного*