diff --git a/.claude/skills/meta-compile/SKILL.md b/.claude/skills/meta-compile/SKILL.md index 9af0db6b..3594e7f5 100644 --- a/.claude/skills/meta-compile/SKILL.md +++ b/.claude/skills/meta-compile/SKILL.md @@ -17,7 +17,7 @@ allowed-tools: | Параметр | Описание | |----------|----------| -| `JsonPath` | Путь к JSON-определению объекта | +| `JsonPath` | Путь к JSON-определению объекта (один объект `{...}` или массив `[{...}, ...]`) | | `OutputDir` | Корневая директория выгрузки конфигурации (где `Catalogs/`, `Documents/` и т.д.) | ```powershell @@ -169,6 +169,18 @@ Constant (Константа), DefinedType (ОпределяемыйТип), Com { "type": "BusinessProcess", "name": "Задание", "attributes": ["Описание: String(200)"] } ``` +### Batch — массив объектов в одном файле + +```json +[ + { "type": "Enum", "name": "Статусы", "values": ["Новый", "Закрыт"] }, + { "type": "Catalog", "name": "Валюты" }, + { "type": "Constant", "name": "ОсновнаяВалюта", "valueType": "CatalogRef.Валюты" } +] +``` + +Каждый элемент массива компилируется отдельно. Итоговый вывод: `=== Batch: 3 objects, 3 compiled, 0 failed ===`. + ## Что генерируется - `{OutputDir}/{TypePlural}/{Name}.xml` — метаданные объекта diff --git a/.claude/skills/meta-compile/scripts/meta-compile.ps1 b/.claude/skills/meta-compile/scripts/meta-compile.ps1 index c0359019..5ab0b515 100644 --- a/.claude/skills/meta-compile/scripts/meta-compile.ps1 +++ b/.claude/skills/meta-compile/scripts/meta-compile.ps1 @@ -1,4 +1,4 @@ -# meta-compile v1.0 — Compile 1C metadata object from JSON +# meta-compile v1.1 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -21,6 +21,28 @@ if (-not (Test-Path $JsonPath)) { $json = Get-Content -Raw -Encoding UTF8 $JsonPath $def = $json | ConvertFrom-Json +# --- Batch mode: JSON array of objects --- +if ($def -is [array] -or ($null -ne $def -and $def.GetType().BaseType.Name -eq 'Array')) { + $batchOk = 0 + $batchFail = 0 + $idx = 0 + foreach ($item in $def) { + $idx++ + $tmpJson = Join-Path ([System.IO.Path]::GetTempPath()) "meta-compile-batch-$idx.json" + try { + $item | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 $tmpJson + $proc = Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -File `"$PSCommandPath`" -JsonPath `"$tmpJson`" -OutputDir `"$OutputDir`"" -NoNewWindow -Wait -PassThru + if ($proc.ExitCode -eq 0) { $batchOk++ } else { $batchFail++ } + } finally { + Remove-Item $tmpJson -Force -ErrorAction SilentlyContinue + } + } + Write-Host "" + Write-Host "=== Batch: $idx objects, $batchOk compiled, $batchFail failed ===" + if ($batchFail -gt 0) { exit 1 } + exit 0 +} + # Normalize field synonyms: accept "objectType" as alias for "type" if (-not $def.type -and $def.objectType) { $def | Add-Member -NotePropertyName "type" -NotePropertyValue $def.objectType diff --git a/.claude/skills/meta-compile/scripts/meta-compile.py b/.claude/skills/meta-compile/scripts/meta-compile.py index 6d629b0b..ad87f460 100644 --- a/.claude/skills/meta-compile/scripts/meta-compile.py +++ b/.claude/skills/meta-compile/scripts/meta-compile.py @@ -1,12 +1,14 @@ #!/usr/bin/env python3 -# meta-compile v1.0 — Compile 1C metadata object from JSON +# meta-compile v1.1 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json import os import re +import subprocess import sys +import tempfile import uuid import xml.etree.ElementTree as ET @@ -81,6 +83,27 @@ with open(json_path, 'r', encoding='utf-8-sig') as f: defn = json.loads(json_text) +# --- Batch mode: JSON array of objects --- +if isinstance(defn, list): + batch_ok = 0 + batch_fail = 0 + for idx, item in enumerate(defn, 1): + tmp_fd, tmp_path = tempfile.mkstemp(suffix='.json', prefix=f'meta-compile-batch-{idx}-') + try: + with os.fdopen(tmp_fd, 'w', encoding='utf-8') as f: + json.dump(item, f, ensure_ascii=False, indent=2) + rc = subprocess.call([sys.executable, __file__, '-JsonPath', tmp_path, '-OutputDir', output_dir]) + if rc == 0: + batch_ok += 1 + else: + batch_fail += 1 + finally: + if os.path.exists(tmp_path): + os.unlink(tmp_path) + print() + print(f"=== Batch: {len(defn)} objects, {batch_ok} compiled, {batch_fail} failed ===") + sys.exit(1 if batch_fail > 0 else 0) + # Normalize field synonyms: accept "objectType" as alias for "type" if not defn.get('type') and defn.get('objectType'): defn['type'] = defn['objectType']