From 31d1ae265058b791a47422c7022a62301a183aef Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Thu, 21 May 2026 16:10:14 +0300 Subject: [PATCH] =?UTF-8?q?feat(skd-compile):=20sentinel-check=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B8=D0=BD=D1=82=D0=B5=D0=B3=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=D0=BE=20skd-decompile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit При наличии __unsupported__ маркеров в JSON (от skd-decompile, Кольцо 2) compile завершается с exit 4 и понятным сообщением: id/kind/loc каждого sentinel и подсказка про .warnings.md рядом. Рекурсивный walk JSON покрывает hashtable/PSCustomObject/array. Sentinel в любом месте дерева — фейл. Bump skd-compile v1.26 → v1.27. Co-Authored-By: Claude Opus 4.7 --- .../skd-compile/scripts/skd-compile.ps1 | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index 00c37ad9..743addd9 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.26 — Compile 1C DCS from JSON +# skd-compile v1.27 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -36,6 +36,47 @@ if ($DefinitionFile) { $def = $json | ConvertFrom-Json +# --- Sentinel check: refuse to compile if JSON contains skd-decompile sentinels --- +# These mark places the decompiler couldn't reverse cleanly; user must resolve +# them manually before compile (see .warnings.md alongside the JSON). +$script:foundSentinels = @() +function Scan-Sentinels { + param($obj, [string]$path) + if ($null -eq $obj) { return } + if ($obj -is [System.Collections.IDictionary]) { + foreach ($k in @($obj.Keys)) { + if ($k -eq '__unsupported__') { + $u = $obj[$k] + $id = $u.id; $kind = $u.kind; $loc = $u.loc + $script:foundSentinels += " $id [$kind] at $path → $loc" + } else { + Scan-Sentinels -obj $obj[$k] -path "$path/$k" + } + } + } elseif ($obj -is [System.Management.Automation.PSCustomObject]) { + foreach ($p in $obj.PSObject.Properties) { + if ($p.Name -eq '__unsupported__') { + $u = $p.Value + $id = $u.id; $kind = $u.kind; $loc = $u.loc + $script:foundSentinels += " $id [$kind] at $path → $loc" + } else { + Scan-Sentinels -obj $p.Value -path "$path/$($p.Name)" + } + } + } elseif ($obj -is [System.Collections.IEnumerable] -and -not ($obj -is [string])) { + $i = 0 + foreach ($item in $obj) { Scan-Sentinels -obj $item -path "$path[$i]"; $i++ } + } +} +Scan-Sentinels -obj $def -path '' +if ($script:foundSentinels.Count -gt 0) { + [Console]::Error.WriteLine("skd-compile: JSON содержит __unsupported__ маркеры от skd-decompile.") + [Console]::Error.WriteLine("Это конструкции, которые декомпиляция не смогла обратить — нужно разрешить вручную перед компиляцией.") + [Console]::Error.WriteLine("См. .warnings.md рядом с JSON. Найдено:") + foreach ($s in $script:foundSentinels) { [Console]::Error.WriteLine($s) } + exit 4 +} + if (-not $def.dataSets -or $def.dataSets.Count -eq 0) { Write-Error "JSON must have at least one entry in 'dataSets'" exit 1