diff --git a/.claude/skills/skd-edit/SKILL.md b/.claude/skills/skd-edit/SKILL.md index 24ffb3ae..d3dcfab9 100644 --- a/.claude/skills/skd-edit/SKILL.md +++ b/.claude/skills/skd-edit/SKILL.md @@ -61,13 +61,16 @@ Shorthand: `"Имя [Заголовок]: тип @роль #ограничени ### add-calculated-field — добавить вычисляемое поле -Shorthand: `"Имя [Заголовок]: тип = Выражение"`. +Shorthand: `"Имя [Заголовок]: тип = Выражение #noFilter #noOrder #noGroup"`. ``` "Маржа = Продажа - Закупка" "Наценка [Наценка, %]: decimal(10,2) = Маржа / Закупка * 100" +"Служебное: string = \"\" #noFilter #noOrder #noGroup" ``` +`#noFilter`, `#noOrder`, `#noGroup`, `#noField` → `` (аналогично add-field). + Также добавляется в selection варианта. ### add-parameter — добавить параметр diff --git a/.claude/skills/skd-edit/scripts/skd-edit.ps1 b/.claude/skills/skd-edit/scripts/skd-edit.ps1 index ba1bd8c6..ce9d3c5c 100644 --- a/.claude/skills/skd-edit/scripts/skd-edit.ps1 +++ b/.claude/skills/skd-edit/scripts/skd-edit.ps1 @@ -1,4 +1,4 @@ -# skd-edit v1.6 — Atomic 1C DCS editor +# skd-edit v1.7 — Atomic 1C DCS editor # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -257,6 +257,14 @@ function Parse-CalcShorthand { $s = $s -replace '\s*\[[^\]]+\]', '' } + # Extract #restrictions + $restrict = @() + $restrictMatches = [regex]::Matches($s, '#(\w+)') + foreach ($m in $restrictMatches) { + $restrict += $m.Groups[1].Value + } + $s = [regex]::Replace($s, '\s*#\w+', '') + # Support "Name: Type = Expression" and "Name = Expression" $eqIdx = $s.IndexOf('=') if ($eqIdx -gt 0) { @@ -267,11 +275,11 @@ function Parse-CalcShorthand { $colonIdx = $left.IndexOf(':') $dataPath = $left.Substring(0, $colonIdx).Trim() $type = Resolve-TypeStr ($left.Substring($colonIdx + 1).Trim()) - return @{ dataPath = $dataPath; expression = $expression; type = $type; title = $title } + return @{ dataPath = $dataPath; expression = $expression; type = $type; title = $title; restrict = $restrict } } - return @{ dataPath = $left; expression = $expression; type = ""; title = $title } + return @{ dataPath = $left; expression = $expression; type = ""; title = $title; restrict = $restrict } } - return @{ dataPath = $s.Trim(); expression = ""; type = ""; title = $title } + return @{ dataPath = $s.Trim(); expression = ""; type = ""; title = $title; restrict = $restrict } } function Parse-ParamShorthand { @@ -752,6 +760,10 @@ function Build-CalcFieldFragment { $lines += (Build-MLTextXml -tag "title" -text $parsed.title -indent "$i`t") } + if ($parsed.restrict -and $parsed.restrict.Count -gt 0) { + $lines += (Build-RestrictionXml -restrict $parsed.restrict -indent "$i`t") + } + if ($parsed.type) { $lines += "$i`t" $lines += (Build-ValueTypeXml -typeStr $parsed.type -indent "$i`t`t") diff --git a/.claude/skills/skd-edit/scripts/skd-edit.py b/.claude/skills/skd-edit/scripts/skd-edit.py index b833b7ba..3622eba8 100644 --- a/.claude/skills/skd-edit/scripts/skd-edit.py +++ b/.claude/skills/skd-edit/scripts/skd-edit.py @@ -1,4 +1,4 @@ -# skd-edit v1.6 — Atomic 1C DCS editor (Python port) +# skd-edit v1.7 — Atomic 1C DCS editor (Python port) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import os @@ -265,6 +265,9 @@ def parse_calc_shorthand(s): title = m.group(1) s = re.sub(r'\s*\[[^\]]+\]', '', s) + restrict_matches = re.findall(r'#(\w+)', s) + s = re.sub(r'\s*#\w+', '', s) + eq_idx = s.find("=") if eq_idx > 0: left = s[:eq_idx].strip() @@ -273,9 +276,9 @@ def parse_calc_shorthand(s): colon_idx = left.index(":") data_path = left[:colon_idx].strip() type_str = resolve_type_str(left[colon_idx + 1:].strip()) - return {"dataPath": data_path, "expression": expression, "type": type_str, "title": title} - return {"dataPath": left, "expression": expression, "type": "", "title": title} - return {"dataPath": s.strip(), "expression": "", "type": "", "title": title} + return {"dataPath": data_path, "expression": expression, "type": type_str, "title": title, "restrict": restrict_matches} + return {"dataPath": left, "expression": expression, "type": "", "title": title, "restrict": restrict_matches} + return {"dataPath": s.strip(), "expression": "", "type": "", "title": title, "restrict": restrict_matches} def parse_param_shorthand(s): @@ -678,6 +681,8 @@ def build_calc_field_fragment(parsed, indent): ] if parsed.get("title"): lines.append(build_mltext_xml("title", parsed["title"], f"{i}\t")) + if parsed.get("restrict"): + lines.append(build_restriction_xml(parsed["restrict"], f"{i}\t")) if parsed.get("type"): lines.append(f"{i}\t") lines.append(build_value_type_xml(parsed["type"], f"{i}\t\t")) diff --git a/tests/skills/cases/skd-edit/add-calculated-field-restrict.json b/tests/skills/cases/skd-edit/add-calculated-field-restrict.json new file mode 100644 index 00000000..f7ca8be6 --- /dev/null +++ b/tests/skills/cases/skd-edit/add-calculated-field-restrict.json @@ -0,0 +1,21 @@ +{ + "name": "Вычисляемое поле с useRestriction", + "preRun": [ + { + "script": "skd-compile/scripts/skd-compile", + "input": { + "dataSets": [{ + "name": "Основной", + "query": "ВЫБРАТЬ Т.Цена, Т.Закупка ИЗ Регистр КАК Т", + "fields": ["Цена: decimal(15,2)", "Закупка: decimal(15,2)"] + }] + }, + "args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "{workDir}/Template.xml" } + } + ], + "params": { + "templatePath": "Template.xml", + "operation": "add-calculated-field", + "value": "Служебное: string = \"\" #noFilter #noOrder #noGroup" + } +} diff --git a/tests/skills/cases/skd-edit/snapshots/add-calculated-field-restrict/Template.xml b/tests/skills/cases/skd-edit/snapshots/add-calculated-field-restrict/Template.xml new file mode 100644 index 00000000..01696c5d --- /dev/null +++ b/tests/skills/cases/skd-edit/snapshots/add-calculated-field-restrict/Template.xml @@ -0,0 +1,76 @@ + + + + ИсточникДанных1 + Local + + + Основной + + Цена + Цена + + xs:decimal + + 15 + 2 + Any + + + + + Закупка + Закупка + + xs:decimal + + 15 + 2 + Any + + + + ИсточникДанных1 + ВЫБРАТЬ Т.Цена, Т.Закупка ИЗ Регистр КАК Т + + + Служебное + "" + + true + true + true + + + xs:string + + 0 + Variable + + + + + Основной + + + ru + Основной + + + + + + Служебное + + + + + + + + + + + + +