diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index 93797e0f..b250b641 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.ps1 +++ b/.claude/skills/skd-compile/scripts/skd-compile.ps1 @@ -1,4 +1,4 @@ -# skd-compile v1.85 — Compile 1C DCS from JSON +# skd-compile v1.86 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -2585,26 +2585,51 @@ function Emit-DataParameters { } elseif ($null -ne $dp.value) { $vtype = "$($dp.valueType)" if (($dp.value -is [PSCustomObject] -or $dp.value -is [hashtable]) -and ($dp.value.variant)) { - # StandardPeriod (PSCustomObject from JSON / hashtable from shorthand parser). - # Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom. - $_sd = $null; $_ed = $null + # Standard{Period,BeginningDate} — различаем по форме value: + # {variant, date} → SBD + # {variant, startDate, endDate} → SP с датами + # {variant} only → инференс по имени (BeginningOf* → SBD, иначе SP) + $_hasDate = $false; $_hasSD = $false if ($dp.value -is [PSCustomObject]) { - if ($dp.value.PSObject.Properties['startDate']) { $_sd = "$($dp.value.startDate)" } - if ($dp.value.PSObject.Properties['endDate']) { $_ed = "$($dp.value.endDate)" } + $_hasDate = [bool]$dp.value.PSObject.Properties['date'] + $_hasSD = [bool]$dp.value.PSObject.Properties['startDate'] } else { - if ($dp.value.Contains('startDate')) { $_sd = "$($dp.value['startDate'])" } - if ($dp.value.Contains('endDate')) { $_ed = "$($dp.value['endDate'])" } + $_hasDate = $dp.value.Contains('date') + $_hasSD = $dp.value.Contains('startDate') } $_variantStr = "$($dp.value.variant)" - X "$indent`t`t" - X "$indent`t`t`t$(Esc-Xml $_variantStr)" - if ($_variantStr -eq 'Custom') { - if (-not $_sd) { $_sd = '0001-01-01T00:00:00' } - if (-not $_ed) { $_ed = '0001-01-01T00:00:00' } - X "$indent`t`t`t$(Esc-Xml $_sd)" - X "$indent`t`t`t$(Esc-Xml $_ed)" + $_isSBD = $_hasDate -or (-not $_hasSD -and $_variantStr -like 'BeginningOf*') + if ($_isSBD) { + $_d = $null + if ($dp.value -is [PSCustomObject] -and $dp.value.PSObject.Properties['date']) { $_d = "$($dp.value.date)" } + elseif ($dp.value -is [System.Collections.IDictionary] -and $dp.value.Contains('date')) { $_d = "$($dp.value['date'])" } + X "$indent`t`t" + X "$indent`t`t`t$(Esc-Xml $_variantStr)" + if ($_variantStr -eq 'Custom') { + if (-not $_d) { $_d = '0001-01-01T00:00:00' } + X "$indent`t`t`t$(Esc-Xml $_d)" + } + X "$indent`t`t" + } else { + # StandardPeriod — platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom. + $_sd = $null; $_ed = $null + if ($dp.value -is [PSCustomObject]) { + if ($dp.value.PSObject.Properties['startDate']) { $_sd = "$($dp.value.startDate)" } + if ($dp.value.PSObject.Properties['endDate']) { $_ed = "$($dp.value.endDate)" } + } else { + if ($dp.value.Contains('startDate')) { $_sd = "$($dp.value['startDate'])" } + if ($dp.value.Contains('endDate')) { $_ed = "$($dp.value['endDate'])" } + } + X "$indent`t`t" + X "$indent`t`t`t$(Esc-Xml $_variantStr)" + if ($_variantStr -eq 'Custom') { + if (-not $_sd) { $_sd = '0001-01-01T00:00:00' } + if (-not $_ed) { $_ed = '0001-01-01T00:00:00' } + X "$indent`t`t`t$(Esc-Xml $_sd)" + X "$indent`t`t`t$(Esc-Xml $_ed)" + } + X "$indent`t`t" } - X "$indent`t`t" } elseif ($vtype -match '^[a-zA-Z]+:') { # Полный xsi:type из decompile (например "xs:boolean", "dcscor:DesignTimeValue"). $vStr = if ($dp.value -is [bool]) { "$($dp.value)".ToLower() } else { "$($dp.value)" } diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index e9915ba5..8228d019 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.py +++ b/.claude/skills/skd-compile/scripts/skd-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-compile v1.85 — Compile 1C DCS from JSON +# skd-compile v1.86 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -2100,16 +2100,31 @@ def emit_data_parameters(lines, items, indent): val = dp['value'] vtype = str(dp.get('valueType') or '') if isinstance(val, dict) and val.get('variant'): - # StandardPeriod. Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom. + # Standard{Period,BeginningDate} — различаем по форме value: + # {variant, date} → SBD + # {variant, startDate, endDate} → SP с датами + # {variant} only → инференс по имени (BeginningOf* → SBD, иначе SP) variant_str = str(val['variant']) - lines.append(f'{indent}\t\t') - lines.append(f'{indent}\t\t\t{esc_xml(variant_str)}') - if variant_str == 'Custom': - sd = str(val.get('startDate') or '0001-01-01T00:00:00') - ed = str(val.get('endDate') or '0001-01-01T00:00:00') - lines.append(f'{indent}\t\t\t{esc_xml(sd)}') - lines.append(f'{indent}\t\t\t{esc_xml(ed)}') - lines.append(f'{indent}\t\t') + has_date = 'date' in val + has_sd = 'startDate' in val + is_sbd = has_date or (not has_sd and variant_str.startswith('BeginningOf')) + if is_sbd: + lines.append(f'{indent}\t\t') + lines.append(f'{indent}\t\t\t{esc_xml(variant_str)}') + if variant_str == 'Custom': + d = str(val.get('date') or '0001-01-01T00:00:00') + lines.append(f'{indent}\t\t\t{esc_xml(d)}') + lines.append(f'{indent}\t\t') + else: + # StandardPeriod — platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom. + lines.append(f'{indent}\t\t') + lines.append(f'{indent}\t\t\t{esc_xml(variant_str)}') + if variant_str == 'Custom': + sd = str(val.get('startDate') or '0001-01-01T00:00:00') + ed = str(val.get('endDate') or '0001-01-01T00:00:00') + lines.append(f'{indent}\t\t\t{esc_xml(sd)}') + lines.append(f'{indent}\t\t\t{esc_xml(ed)}') + lines.append(f'{indent}\t\t') elif re.match(r'^[a-zA-Z]+:', vtype): # Полный xsi:type из decompile (например "xs:boolean", "dcscor:DesignTimeValue"). v_str = str(val).lower() if isinstance(val, bool) else str(val) diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index a93b0d09..ddfec202 100644 --- a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 +++ b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 @@ -1,4 +1,4 @@ -# skd-decompile v0.68 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.69 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1807,6 +1807,8 @@ function Build-DataParameters { $vDisplay = $null $stdPeriodObj = $null if ($vt -eq 'StandardPeriod') { + # Shape inference в compile: {variant, startDate, endDate} → SP с датами, + # {variant} only с SP-вариантом (ThisMonth/Custom/etc) → SP без дат. $variant = Get-Text $valNode "v8:variant" $sd = Get-Text $valNode "v8:startDate" $ed = Get-Text $valNode "v8:endDate" @@ -1817,14 +1819,23 @@ function Build-DataParameters { if ($ed) { $stdPeriodObj['endDate'] = $ed } $canAuto = $false } elseif ($variant) { - # Для shorthand эмитим как строку "Period = ThisMonth"; для object form — - # объектом {variant: ThisMonth}, чтобы compile сгенерировал - # вместо плоского ThisMonth. $vDisplay = $variant if ($vmN -or $uspN) { $stdPeriodObj = [ordered]@{ variant = $variant } } } + } elseif ($vt -eq 'StandardBeginningDate') { + # Shape inference в compile: {variant, date} → SBD, либо variant начинается с BeginningOf*. + $variant = Get-Text $valNode "v8:variant" + $d = Get-Text $valNode "v8:date" + $hasExplicitDate = $d -and $d -ne '0001-01-01T00:00:00' + if ($hasExplicitDate) { + $stdPeriodObj = [ordered]@{ variant = $variant; date = $d } + $canAuto = $false + } elseif ($variant) { + $stdPeriodObj = [ordered]@{ variant = $variant } + $canAuto = $false + } } elseif ($vt -eq 'DesignTimeValue') { $vDisplay = $valNode.InnerText } elseif ($vt -eq 'LocalStringType') {