diff --git a/.claude/skills/xdto-compile/scripts/xdto-compile.ps1 b/.claude/skills/xdto-compile/scripts/xdto-compile.ps1 index 69225b1f..1df055d0 100644 --- a/.claude/skills/xdto-compile/scripts/xdto-compile.ps1 +++ b/.claude/skills/xdto-compile/scripts/xdto-compile.ps1 @@ -1,4 +1,4 @@ -# xdto-compile v1.1 — Build a 1C XDTO package from an XML Schema (XSD) +# xdto-compile v1.2 — Build a 1C XDTO package from an XML Schema (XSD) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory=$true, ParameterSetName='File')] @@ -41,6 +41,27 @@ $V8_NS = "http://v8.1c.ru/8.1/data/core" # read-only configs unless allowed. Trigger = bin present; reaction from # .v8-project.json editingAllowedCheck (deny|warn|off, default deny). Never # throws — guard errors degrade to allow. +# Версия формата выгрузки — из Configuration.xml проекта (климб вверх от каталога исходников). +# Её задаёт платформа выгрузки: 8.3.20-8.3.24 → 2.17, 8.3.25 → 2.18, 8.3.26 → 2.19, 8.3.27 → 2.20. +# Раньше здесь стоял хардкод 2.17, и на проекте 2.20 пакет расходился с выгрузкой платформы. +function Detect-FormatVersion([string]$dir) { + $d = $dir + while ($d) { + $cfgPath = Join-Path $d "Configuration.xml" + if (Test-Path $cfgPath) { + $cfgText = [System.IO.File]::ReadAllText($cfgPath, [System.Text.Encoding]::UTF8) + # Длину среза берём по СТРОКЕ, а не по размеру файла: размер в БАЙТАХ, Substring считает + # СИМВОЛЫ, и на кириллице байт больше — короткий Configuration.xml ронял навык исключением. + $head = $cfgText.Substring(0, [Math]::Min(2000, $cfgText.Length)) + if ($head -match ']+version="(\d+\.\d+)"') { return $Matches[1] } + } + $parent = Split-Path $d -Parent + if ($parent -eq $d) { break } + $d = $parent + } + return "2.17" +} + function Get-RootUuid([string]$xmlPath) { if (-not (Test-Path $xmlPath)) { return $null } try { @@ -811,6 +832,8 @@ if ($Name -match '^\d') { $Name = "_$Name" } Assert-EditAllowed $OutputDir +$script:formatVersion = Detect-FormatVersion $OutputDir + $pkgRoot = Join-Path $OutputDir "XDTOPackages" $pkgDir = Join-Path $pkgRoot $Name $extDir = Join-Path $pkgDir "Ext" @@ -843,7 +866,7 @@ $uuid = [guid]::NewGuid().ToString() $md = New-Object System.Text.StringBuilder function M([string]$s) { [void]$md.Append($s); [void]$md.Append("`r`n") } M '' -M '' +M ("") M "`t" M "`t`t" M "`t`t`t$(EscText $Name)" diff --git a/.claude/skills/xdto-compile/scripts/xdto-compile.py b/.claude/skills/xdto-compile/scripts/xdto-compile.py index cb2c1e77..788127fb 100644 --- a/.claude/skills/xdto-compile/scripts/xdto-compile.py +++ b/.claude/skills/xdto-compile/scripts/xdto-compile.py @@ -1,4 +1,4 @@ -# xdto-compile v1.1 — Build a 1C XDTO package from an XML Schema (XSD) (Python port) +# xdto-compile v1.2 — Build a 1C XDTO package from an XML Schema (XSD) (Python port) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -98,6 +98,28 @@ def is_external_object_root(xml_path): return False +def detect_format_version(d): + """Версия формата выгрузки — из Configuration.xml проекта (климб вверх от каталога исходников). + + Её задаёт платформа выгрузки: 8.3.20-8.3.24 -> 2.17, 8.3.25 -> 2.18, 8.3.26 -> 2.19, + 8.3.27 -> 2.20. Раньше здесь стоял хардкод 2.17, и на проекте 2.20 пакет расходился с выгрузкой. + Тело — точная копия из остальных навыков (разрешение пути делает вызывающая сторона). + """ + while d: + cfg_path = os.path.join(d, "Configuration.xml") + if os.path.isfile(cfg_path): + with open(cfg_path, "r", encoding="utf-8-sig") as f: + head = f.read(2000) + m = re.search(r']+version="(\d+\.\d+)"', head) + if m: + return m.group(1) + parent = os.path.dirname(d) + if parent == d: + break + d = parent + return "2.17" + + def assert_edit_allowed(target_path): d = os.path.abspath(target_path) for _ in range(20): @@ -837,6 +859,8 @@ if re.match(r"^\d", name): assert_edit_allowed(args.OutputDir) +format_version = detect_format_version(os.path.abspath(args.OutputDir)) + pkg_root = os.path.join(args.OutputDir, "XDTOPackages") pkg_dir = os.path.join(pkg_root, name) ext_dir = os.path.join(pkg_dir, "Ext") @@ -871,7 +895,7 @@ md_lines = [ 'xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows" ' 'xmlns:xen="http://v8.1c.ru/8.3/xcf/enums" xmlns:xpr="http://v8.1c.ru/8.3/xcf/predef" ' 'xmlns:xr="http://v8.1c.ru/8.3/xcf/readable" xmlns:xs="http://www.w3.org/2001/XMLSchema" ' - 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.17">', + f'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="{format_version}">', f'\t', "\t\t", f"\t\t\t{esc_text(name)}",