mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-06 11:40:20 +03:00
fix(subsystem-compile): write stub XML for declared children
When a subsystem definition includes `children: [...]`, the parent XML
was emitted with `<ChildObjects><Subsystem>Name</Subsystem></ChildObjects>`
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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
037062c728
commit
aa93031a3f
@@ -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('<?xml version="1.0" encoding="UTF-8"?>')
|
||||
[void]$sb.AppendLine("<MetaDataObject xmlns=`"http://v8.1c.ru/8.3/MDClasses`" xmlns:app=`"http://v8.1c.ru/8.2/managed-application/core`" xmlns:cfg=`"http://v8.1c.ru/8.1/data/enterprise/current-config`" xmlns:cmi=`"http://v8.1c.ru/8.2/managed-application/cmi`" xmlns:ent=`"http://v8.1c.ru/8.1/data/enterprise`" xmlns:lf=`"http://v8.1c.ru/8.2/managed-application/logform`" xmlns:style=`"http://v8.1c.ru/8.1/data/ui/style`" xmlns:sys=`"http://v8.1c.ru/8.1/data/ui/fonts/system`" xmlns:v8=`"http://v8.1c.ru/8.1/data/core`" xmlns:v8ui=`"http://v8.1c.ru/8.1/data/ui`" 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=`"$formatVersion`">")
|
||||
[void]$sb.AppendLine("`t<Subsystem uuid=`"$childUuid`">")
|
||||
[void]$sb.AppendLine("`t`t<Properties>")
|
||||
[void]$sb.AppendLine("`t`t`t<Name>$(Esc-Xml $childName)</Name>")
|
||||
[void]$sb.AppendLine("`t`t`t<Synonym/>")
|
||||
[void]$sb.AppendLine("`t`t`t<Comment/>")
|
||||
[void]$sb.AppendLine("`t`t`t<IncludeHelpInContents>true</IncludeHelpInContents>")
|
||||
[void]$sb.AppendLine("`t`t`t<IncludeInCommandInterface>true</IncludeInCommandInterface>")
|
||||
[void]$sb.AppendLine("`t`t`t<UseOneCommand>false</UseOneCommand>")
|
||||
[void]$sb.AppendLine("`t`t`t<Explanation/>")
|
||||
[void]$sb.AppendLine("`t`t`t<Picture/>")
|
||||
[void]$sb.AppendLine("`t`t`t<Content/>")
|
||||
[void]$sb.AppendLine("`t`t</Properties>")
|
||||
[void]$sb.AppendLine("`t`t<ChildObjects/>")
|
||||
[void]$sb.AppendLine("`t</Subsystem>")
|
||||
[void]$sb.AppendLine('</MetaDataObject>')
|
||||
[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 ---
|
||||
|
||||
Reference in New Issue
Block a user