diff --git a/.claude/skills/skd-info/scripts/skd-info.ps1 b/.claude/skills/skd-info/scripts/skd-info.ps1 index 4dd75dae..9350cca6 100644 --- a/.claude/skills/skd-info/scripts/skd-info.ps1 +++ b/.claude/skills/skd-info/scripts/skd-info.ps1 @@ -1,4 +1,4 @@ -# skd-info v1.0 — Analyze 1C DCS structure +# skd-info v1.1 — Analyze 1C DCS structure # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory=$true)] @@ -17,6 +17,8 @@ $ErrorActionPreference = "Stop" # --- Resolve path --- +$originalPath = $TemplatePath + if (-not $TemplatePath.EndsWith(".xml")) { $candidate = Join-Path (Join-Path $TemplatePath "Ext") "Template.xml" if (Test-Path $candidate) { @@ -24,7 +26,48 @@ if (-not $TemplatePath.EndsWith(".xml")) { } } -if (-not (Test-Path $TemplatePath)) { +# If still not a file, try resolving from object directory (Reports/X, DataProcessors/X) +if (-not (Test-Path $TemplatePath -PathType Leaf)) { + $templatesDir = Join-Path $originalPath "Templates" + if (Test-Path $templatesDir) { + $dcsTemplates = @() + foreach ($metaXml in (Get-ChildItem $templatesDir -Filter "*.xml" -File)) { + [xml]$meta = Get-Content $metaXml.FullName -Encoding UTF8 + $tt = $meta.SelectSingleNode("//*[local-name()='TemplateType']") + if ($tt -and $tt.InnerText -eq "DataCompositionSchema") { + $tplName = [System.IO.Path]::GetFileNameWithoutExtension($metaXml.Name) + $tplPath = Join-Path (Join-Path (Join-Path $templatesDir $tplName) "Ext") "Template.xml" + if (Test-Path $tplPath) { + $dcsTemplates += $tplPath + } + } + } + if ($dcsTemplates.Count -eq 1) { + $TemplatePath = $dcsTemplates[0] + $resolvedMsg = (Resolve-Path $TemplatePath).Path + $cwd = (Get-Location).Path + if ($resolvedMsg.StartsWith($cwd)) { + $resolvedMsg = $resolvedMsg.Substring($cwd.Length + 1) + } + Write-Host "[i] Resolved: $resolvedMsg" + } elseif ($dcsTemplates.Count -gt 1) { + Write-Host "Multiple DCS templates found in: $originalPath" + $cwd = (Get-Location).Path + for ($i = 0; $i -lt $dcsTemplates.Count; $i++) { + $p = (Resolve-Path $dcsTemplates[$i]).Path + if ($p.StartsWith($cwd)) { $p = $p.Substring($cwd.Length + 1) } + Write-Host " $($i+1). $p" + } + Write-Host "Specify the template path." + exit 1 + } else { + Write-Error "No DCS templates found in: $originalPath" + exit 1 + } + } +} + +if (-not (Test-Path $TemplatePath -PathType Leaf)) { Write-Error "File not found: $TemplatePath" exit 1 } diff --git a/.claude/skills/skd-info/scripts/skd-info.py b/.claude/skills/skd-info/scripts/skd-info.py index 300a79cf..9a837ddc 100644 --- a/.claude/skills/skd-info/scripts/skd-info.py +++ b/.claude/skills/skd-info/scripts/skd-info.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-info v1.0 — Analyze 1C DCS structure +# skd-info v1.1 — Analyze 1C DCS structure # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -281,12 +281,48 @@ def main(): args = parser.parse_args() # --- Resolve path --- - template_path = args.TemplatePath + original_path = args.TemplatePath + template_path = original_path if not template_path.endswith(".xml"): candidate = os.path.join(template_path, "Ext", "Template.xml") if os.path.isfile(candidate): template_path = candidate + # If still not found, try resolving from object directory (Reports/X, DataProcessors/X) + if not os.path.isfile(template_path) and not template_path.endswith(".xml"): + templates_dir = os.path.join(original_path, "Templates") + if os.path.isdir(templates_dir): + dcs_templates = [] + for fname in os.listdir(templates_dir): + if not fname.endswith(".xml"): + continue + meta_path = os.path.join(templates_dir, fname) + if not os.path.isfile(meta_path): + continue + try: + meta_tree = etree.parse(meta_path, etree.XMLParser(remove_blank_text=True)) + tt_nodes = meta_tree.xpath("//*[local-name()='TemplateType']") + if tt_nodes and (tt_nodes[0].text or "").strip() == "DataCompositionSchema": + tpl_name = os.path.splitext(fname)[0] + tpl_path = os.path.join(templates_dir, tpl_name, "Ext", "Template.xml") + if os.path.isfile(tpl_path): + dcs_templates.append(tpl_path) + except Exception: + continue + if len(dcs_templates) == 1: + template_path = dcs_templates[0] + resolved_display = os.path.relpath(os.path.abspath(template_path)) + print(f"[i] Resolved: {resolved_display}") + elif len(dcs_templates) > 1: + print(f"Multiple DCS templates found in: {original_path}") + for i, p in enumerate(dcs_templates): + print(f" {i+1}. {os.path.relpath(os.path.abspath(p))}") + print("Specify the template path.") + sys.exit(1) + else: + print(f"No DCS templates found in: {original_path}", file=sys.stderr) + sys.exit(1) + if not os.path.isabs(template_path): template_path = os.path.join(os.getcwd(), template_path)