From 334241bea4fcfec496a4e14428a72100b5918996 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Thu, 21 May 2026 10:19:20 +0300 Subject: [PATCH] fix(skd-info): handle absolute -OutFile paths correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раньше PS1-порт делал `Join-Path (Get-Location) $OutFile` без проверки, что приводило к невалидным склейкам типа `C:\cwd\C:\abs\path.txt`, и запись падала с «The given path's format is not supported». Теперь: если путь абсолютный — нормализуется через `Path::GetFullPath`, если относительный — резолвится против CWD. Python-порт уже был корректен, только version bump. Дополнительно: `args_extra` в runner.mjs теперь поддерживает подстановку `{workDir}` — нужно для тестов с абсолютными путями внутри workspace. Тесты: `skd-info/outfile-absolute-cyrillic` (PS + Python). Co-Authored-By: Claude Opus 4.7 --- .claude/skills/skd-info/scripts/skd-info.ps1 | 9 +++- .claude/skills/skd-info/scripts/skd-info.py | 2 +- .../skd-info/outfile-absolute-cyrillic.json | 17 +++++++ .../outfile-absolute-cyrillic/Template.xml | 44 +++++++++++++++++++ .../outfile-absolute-cyrillic/выгрузка.txt | 3 ++ tests/skills/runner.mjs | 5 ++- 6 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 tests/skills/cases/skd-info/outfile-absolute-cyrillic.json create mode 100644 tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/Template.xml create mode 100644 tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/выгрузка.txt diff --git a/.claude/skills/skd-info/scripts/skd-info.ps1 b/.claude/skills/skd-info/scripts/skd-info.ps1 index 78a19f98..46bba981 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.4 — Analyze 1C DCS structure +# skd-info v1.5 — Analyze 1C DCS structure # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory=$true)] @@ -1875,7 +1875,12 @@ $totalLines = $result.Count # OutFile if ($OutFile) { $utf8Bom = New-Object System.Text.UTF8Encoding($true) - [System.IO.File]::WriteAllLines((Join-Path (Get-Location) $OutFile), $result, $utf8Bom) + if ([System.IO.Path]::IsPathRooted($OutFile)) { + $outPath = [System.IO.Path]::GetFullPath($OutFile) + } else { + $outPath = [System.IO.Path]::GetFullPath((Join-Path (Get-Location).Path $OutFile)) + } + [System.IO.File]::WriteAllLines($outPath, $result, $utf8Bom) Write-Host "Written $totalLines lines to $OutFile" exit 0 } diff --git a/.claude/skills/skd-info/scripts/skd-info.py b/.claude/skills/skd-info/scripts/skd-info.py index de479054..3303a8fb 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.4 — Analyze 1C DCS structure +# skd-info v1.5 — Analyze 1C DCS structure # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse diff --git a/tests/skills/cases/skd-info/outfile-absolute-cyrillic.json b/tests/skills/cases/skd-info/outfile-absolute-cyrillic.json new file mode 100644 index 00000000..ceff52fc --- /dev/null +++ b/tests/skills/cases/skd-info/outfile-absolute-cyrillic.json @@ -0,0 +1,17 @@ +{ + "name": "OutFile: абсолютный путь с кириллическим именем файла", + "preRun": [ + { + "script": "skd-compile/scripts/skd-compile", + "input": { + "dataSets": [{ + "query": "ВЫБРАТЬ Т.Поле ИЗ Регистр КАК Т", + "fields": ["Поле"] + }] + }, + "args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "{workDir}/Template.xml" } + } + ], + "params": { "templatePath": "Template.xml" }, + "args_extra": ["-Mode", "query", "-OutFile", "{workDir}/выгрузка.txt"] +} diff --git a/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/Template.xml b/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/Template.xml new file mode 100644 index 00000000..94284708 --- /dev/null +++ b/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/Template.xml @@ -0,0 +1,44 @@ + + + + ИсточникДанных1 + Local + + + НаборДанных1 + + Поле + Поле + + ИсточникДанных1 + ВЫБРАТЬ Т.Поле ИЗ Регистр КАК Т + + + Основной + + + ru + Основной + + + + + + + + + + + + + + + + diff --git a/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/выгрузка.txt b/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/выгрузка.txt new file mode 100644 index 00000000..ff03d38d --- /dev/null +++ b/tests/skills/cases/skd-info/snapshots/outfile-absolute-cyrillic/выгрузка.txt @@ -0,0 +1,3 @@ +=== Query: НаборДанных1 (1 lines) === + +ВЫБРАТЬ Т.Поле ИЗ Регистр КАК Т diff --git a/tests/skills/runner.mjs b/tests/skills/runner.mjs index 7a16300e..557e59cd 100644 --- a/tests/skills/runner.mjs +++ b/tests/skills/runner.mjs @@ -279,9 +279,10 @@ function buildArgs(skillConfig, caseData, workDir, inputFilePath, runtime) { } } - // Append extra args from case (for optional params like -Vendor, -Version) + // Append extra args from case (for optional params like -Vendor, -Version). + // Supports {workDir} substitution for tests that need absolute paths inside the workspace. if (caseData.args_extra) { - args.push(...caseData.args_extra); + args.push(...caseData.args_extra.map(a => typeof a === 'string' ? a.replace('{workDir}', workDir) : a)); } return { scriptPath, args };