From aa93031a3f70cff181b047e07980f6245b03c9e9 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 11 Apr 2026 18:38:03 +0300 Subject: [PATCH] fix(subsystem-compile): write stub XML for declared children MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a subsystem definition includes `children: [...]`, the parent XML was emitted with `Name` refs, but the referenced `Subsystems/{Parent}/Subsystems/{Child}.xml` files were never created. Before 96d1dea (-StrictLog) the platform silently dropped the refs on load (exit 0), so verify-snapshots showed these cases green. With the new strict log parsing, `full` and `with-children` started failing on "Файл объекта не существует". Both PS1 and PY ports now emit a minimal valid child subsystem stub (full MetaDataObject, empty Synonym/Content/ChildObjects) via new Write-ChildSubsystemStub / write_child_subsystem_stub helpers. Stub creation is guarded by Test-Path / os.path.exists, so a subsequent compile of the same child via -Parent does not get clobbered, and re-running the parent compile is idempotent. Дубли в children[] дедуплицируются через seen-set. Also removed the "Что генерируется" section from SKILL.md — filesystem layout is covered by the OutputDir param + [OK] stdout lines; the section was noise for model consumers. Bumped subsystem-compile.ps1 v1.4→v1.5 and subsystem-compile.py v1.3→v1.5 (PY caught up with PS1 version pin). Verification: - verify-snapshots --skill subsystem-compile: 5/7 → 7/7 - runner --filter subsystem-compile (PS1): 7/7 - runner --filter subsystem-compile --runtime python: 7/7 (dual-port drift clean) Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/subsystem-compile/SKILL.md | 5 -- .../scripts/subsystem-compile.ps1 | 37 ++++++++++++- .../scripts/subsystem-compile.py | 55 ++++++++++++++++++- .../Продажи/Subsystems/Настройки.xml | 17 ++++++ .../Subsystems/Настройки.xml | 17 ++++++ .../Subsystems/Пользователи.xml | 17 ++++++ 6 files changed, 139 insertions(+), 9 deletions(-) create mode 100644 tests/skills/cases/subsystem-compile/snapshots/full/Subsystems/Продажи/Subsystems/Настройки.xml create mode 100644 tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Настройки.xml create mode 100644 tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Пользователи.xml diff --git a/.claude/skills/subsystem-compile/SKILL.md b/.claude/skills/subsystem-compile/SKILL.md index 3fc1de60..ce9d4af5 100644 --- a/.claude/skills/subsystem-compile/SKILL.md +++ b/.claude/skills/subsystem-compile/SKILL.md @@ -58,8 +58,3 @@ powershell.exe -NoProfile -File '.claude/skills/subsystem-compile/scripts/subsys ... -Value '{"name":"Дочерняя"}' -OutputDir config/ -Parent config/Subsystems/Продажи.xml ``` -## Что генерируется - -- `{OutputDir}/Subsystems/{Name}.xml` — определение подсистемы -- `{OutputDir}/Subsystems/{Name}/` — каталог (если есть children) -- `Configuration.xml` или родительская подсистема — регистрация в `` diff --git a/.claude/skills/subsystem-compile/scripts/subsystem-compile.ps1 b/.claude/skills/subsystem-compile/scripts/subsystem-compile.ps1 index 3036f563..071aacaa 100644 --- a/.claude/skills/subsystem-compile/scripts/subsystem-compile.ps1 +++ b/.claude/skills/subsystem-compile/scripts/subsystem-compile.ps1 @@ -1,4 +1,4 @@ -# subsystem-compile v1.4 — Create 1C subsystem from JSON definition +# subsystem-compile v1.5 — Create 1C subsystem from JSON definition # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -85,6 +85,29 @@ function New-Guid-String { return [System.Guid]::NewGuid().ToString() } +function Write-ChildSubsystemStub([string]$childPath, [string]$childName, [string]$formatVersion, [System.Text.Encoding]$utf8Bom) { + $childUuid = New-Guid-String + $sb = New-Object System.Text.StringBuilder 2048 + [void]$sb.AppendLine('') + [void]$sb.AppendLine("") + [void]$sb.AppendLine("`t") + [void]$sb.AppendLine("`t`t") + [void]$sb.AppendLine("`t`t`t$(Esc-Xml $childName)") + [void]$sb.AppendLine("`t`t`t") + [void]$sb.AppendLine("`t`t`t") + [void]$sb.AppendLine("`t`t`ttrue") + [void]$sb.AppendLine("`t`t`ttrue") + [void]$sb.AppendLine("`t`t`tfalse") + [void]$sb.AppendLine("`t`t`t") + [void]$sb.AppendLine("`t`t`t") + [void]$sb.AppendLine("`t`t`t") + [void]$sb.AppendLine("`t`t") + [void]$sb.AppendLine("`t`t") + [void]$sb.AppendLine("`t") + [void]$sb.AppendLine('') + [System.IO.File]::WriteAllText($childPath, $sb.ToString(), $utf8Bom) +} + # --- 3. Content type normalization (plural→singular, Russian→English) --- $script:contentTypeMap = @{ # Plural English → Singular @@ -385,13 +408,23 @@ $utf8Bom = New-Object System.Text.UTF8Encoding($true) [System.IO.File]::WriteAllText($targetXml, $xmlContent, $utf8Bom) Write-Host "[OK] Created: $targetXml" -# Create subdirectory if children exist +# Create subdirectory and stub files for children if they exist if ($children.Count -gt 0) { $childSubsDir = Join-Path (Join-Path $subsDir $objName) "Subsystems" if (-not (Test-Path $childSubsDir)) { New-Item -ItemType Directory -Path $childSubsDir -Force | Out-Null Write-Host "[OK] Created directory: $childSubsDir" } + $seen = @{} + foreach ($ch in $children) { + if ($seen.ContainsKey($ch)) { continue } + $seen[$ch] = $true + $childXml = Join-Path $childSubsDir "$ch.xml" + if (-not (Test-Path $childXml)) { + Write-ChildSubsystemStub $childXml $ch $formatVersion $utf8Bom + Write-Host "[OK] Created stub: $childXml" + } + } } # --- 6. Register in parent --- diff --git a/.claude/skills/subsystem-compile/scripts/subsystem-compile.py b/.claude/skills/subsystem-compile/scripts/subsystem-compile.py index 311be981..bdabb4e1 100644 --- a/.claude/skills/subsystem-compile/scripts/subsystem-compile.py +++ b/.claude/skills/subsystem-compile/scripts/subsystem-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# subsystem-compile v1.3 — Create 1C subsystem from JSON definition +# subsystem-compile v1.5 — Create 1C subsystem from JSON definition # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -60,6 +60,48 @@ def split_camel_case(name): return result +def write_child_subsystem_stub(child_path, child_name, format_version): + child_uuid = new_uuid() + lines = [] + lines.append('') + lines.append( + '' + ) + lines.append(f'\t') + lines.append('\t\t') + lines.append(f'\t\t\t{esc_xml(child_name)}') + lines.append('\t\t\t') + lines.append('\t\t\t') + lines.append('\t\t\ttrue') + lines.append('\t\t\ttrue') + lines.append('\t\t\tfalse') + lines.append('\t\t\t') + lines.append('\t\t\t') + lines.append('\t\t\t') + lines.append('\t\t') + lines.append('\t\t') + lines.append('\t') + lines.append('') + write_utf8_bom(child_path, '\n'.join(lines) + '\n') + + def main(): sys.stdout.reconfigure(encoding="utf-8") sys.stderr.reconfigure(encoding="utf-8") @@ -305,12 +347,21 @@ def main(): write_utf8_bom(target_xml, xml_content) print(f"[OK] Created: {target_xml}") - # Create subdirectory if children exist + # Create subdirectory and stub files for children if they exist if len(children) > 0: child_subs_dir = os.path.join(subs_dir, obj_name, 'Subsystems') if not os.path.exists(child_subs_dir): os.makedirs(child_subs_dir, exist_ok=True) print(f"[OK] Created directory: {child_subs_dir}") + seen = set() + for ch in children: + if ch in seen: + continue + seen.add(ch) + child_xml = os.path.join(child_subs_dir, f'{ch}.xml') + if not os.path.exists(child_xml): + write_child_subsystem_stub(child_xml, ch, format_version) + print(f"[OK] Created stub: {child_xml}") # --- 5. Register in parent --- parent_xml_path = None diff --git a/tests/skills/cases/subsystem-compile/snapshots/full/Subsystems/Продажи/Subsystems/Настройки.xml b/tests/skills/cases/subsystem-compile/snapshots/full/Subsystems/Продажи/Subsystems/Настройки.xml new file mode 100644 index 00000000..7f218906 --- /dev/null +++ b/tests/skills/cases/subsystem-compile/snapshots/full/Subsystems/Продажи/Subsystems/Настройки.xml @@ -0,0 +1,17 @@ + + + + + Настройки + + + true + true + false + + + + + + + diff --git a/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Настройки.xml b/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Настройки.xml new file mode 100644 index 00000000..7f218906 --- /dev/null +++ b/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Настройки.xml @@ -0,0 +1,17 @@ + + + + + Настройки + + + true + true + false + + + + + + + diff --git a/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Пользователи.xml b/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Пользователи.xml new file mode 100644 index 00000000..cdbce883 --- /dev/null +++ b/tests/skills/cases/subsystem-compile/snapshots/with-children/Subsystems/Администрирование/Subsystems/Пользователи.xml @@ -0,0 +1,17 @@ + + + + + Пользователи + + + true + true + false + + + + + + +